Skip to content

Commit

Permalink
lets do this
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Feb 24, 2024
1 parent 92c1eb9 commit d7b3336
Show file tree
Hide file tree
Showing 21 changed files with 132 additions and 57 deletions.
11 changes: 3 additions & 8 deletions code/__HELPERS/lazy_templates.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
GLOBAL_LIST_INIT(lazy_templates, generate_lazy_template_map())

/**
* Iterates through all lazy template datums that exist and returns a list of them as an associative list of map_name -> instance.
*
* Screams if more than one key exists, loudly.
*/
* Iterates through all lazy template datums that exist and returns a list of them as an associative list of type -> instance.
* */
/proc/generate_lazy_template_map()
. = list()
for(var/datum/lazy_template/template as anything in subtypesof(/datum/lazy_template))
var/map_name = initial(template.map_name)
if(map_name in .)
stack_trace("Found multiple lazy templates with the same map name! '[map_name]'")
.[map_name] = new template
.[template] = new template
return .
9 changes: 0 additions & 9 deletions code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,3 @@ GLOBAL_PROTECT(topic_tokens)

GLOBAL_LIST_EMPTY(topic_commands)
GLOBAL_PROTECT(topic_commands)

GLOBAL_LIST_INIT(distress_beacon_hubs, setup_distress_hubs())

/proc/setup_distress_hubs()
var/all_hubs = list()
for(var/path in subtypesof(/datum/ert_home))
all_hubs[path] = new path()
return all_hubs

1 change: 1 addition & 0 deletions code/datums/emergency_calls/cbrn.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "CBRN (Squad)"
arrival_message = "A CBRN squad has been dispatched to your ship. Stand by."
objectives = "Handle the chemical, biological, radiological, or nuclear threat. Further orders may be provided."
home_base = /datum/lazy_template/ert/weyland_station
mob_min = 3
mob_max = 5
max_heavies = 0
Expand Down
3 changes: 2 additions & 1 deletion code/datums/emergency_calls/clf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/datum/emergency_call/clf
name = "Colonial Liberation Front (Squad)"
mob_max = 10
mob_min = 1
arrival_message = "'Attention, you are tresspassing on our soverign territory. Expect no forgiveness.'"
objectives = "Assault the USCM, and sabotage as much as you can. Ensure any survivors escape in your custody."
probability = 20
hostility = TRUE
home_base = /datum/ert_home/clf
home_base = /datum/lazy_template/ert/clf_station
var/max_synths = 1
var/synths = 0

Expand Down
1 change: 1 addition & 0 deletions code/datums/emergency_calls/cmb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name = "CMB - Colonial Marshals Patrol Team (Friendly)"
mob_max = 5
probability = 10
home_base = /datum/lazy_template/ert/weyland_station

var/max_synths = 1
var/synths = 0
Expand Down
3 changes: 3 additions & 0 deletions code/datums/emergency_calls/deathsquad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
objectives = "Whiteout protocol is in effect for the target. Ensure there are no traces of the infestation or any witnesses."
probability = 0
shuttle_id = MOBILE_SHUTTLE_ID_ERT2
home_base = /datum/lazy_template/ert/weyland_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_pmc
item_spawn = /obj/effect/landmark/ert_spawns/distress_pmc/item
max_medics = 1
Expand Down Expand Up @@ -92,6 +93,7 @@
mob_min = 5
probability = 0
shuttle_id = MOBILE_SHUTTLE_ID_ERT2
home_base = /datum/lazy_template/ert/weyland_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_pmc

/datum/emergency_call/marsoc/create_member(datum/mind/M, turf/override_spawn_loc)
Expand Down Expand Up @@ -122,6 +124,7 @@
probability = 0
shuttle_id = MOBILE_SHUTTLE_ID_ERT2
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_pmc
home_base = /datum/lazy_template/ert/weyland_station

/datum/emergency_call/marsoc_covert/create_member(datum/mind/M)

Expand Down
35 changes: 22 additions & 13 deletions code/datums/emergency_calls/emergency_call.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,11 @@

var/time_required_for_job = 5 HOURS

/// the [/datum/ert_home] we should attempt to spawn in for the return journey
var/home_base
/// the shuttle being used by this distress call
var/obj/docking_port/mobile/emergency_response/shuttle

/datum/ert_home
/// the lazy template we should spawn in that contains the home base
var/base_template

/// the dock ID we should attempt to dock home with
var/home_dock

/datum/ert_home/clf
base_template = /datum/lazy_template/clf_ert_station
home_dock = ADMIN_LANDING_PAD_1
/// the [/datum/lazy_template] we should attempt to spawn in for the return journey
var/home_base = /datum/lazy_template/ert/freelancer_station

/datum/game_mode/proc/initialize_emergency_calls()
if(all_calls.len) //It's already been set up.
Expand Down Expand Up @@ -283,14 +275,14 @@
if(M.client)
to_chat(M, SPAN_NOTICE("Distress beacon: [src.name] finalized."))

var/obj/docking_port/mobile/shuttle
if(shuttle_id)
if(!SSmapping.shuttle_templates[shuttle_id])
message_admins("Distress beacon: [name] does not have a valid shuttle_id: [shuttle_id]")
CRASH("ert called with invalid shuttle_id")

var/datum/map_template/shuttle/new_shuttle = SSmapping.shuttle_templates[shuttle_id]
shuttle = SSshuttle.load_template_to_transit(new_shuttle)
shuttle.home_base = home_base

if(shuttle && auto_shuttle_launch)
var/obj/structure/machinery/computer/shuttle/ert/comp = shuttle.getControlConsole()
Expand Down Expand Up @@ -351,6 +343,23 @@

/datum/emergency_call/proc/get_spawn_point(is_for_items)
var/landmark

if(shuttle)
if(is_for_items)
landmark = SAFEPICK(shuttle.local_landmarks[item_spawn])
else
landmark = SAFEPICK(shuttle.local_landmarks[name_of_spawn])

if(landmark)
return get_turf(landmark)

var/list/valid_turfs = list()
for(var/turf/open/floor/valid_turf in shuttle.return_turfs())
valid_turfs += valid_turf

if(length(valid_turfs))
return pick(valid_turfs)

if(is_for_items)
landmark = SAFEPICK(GLOB.ert_spawns[item_spawn])
else
Expand Down
10 changes: 5 additions & 5 deletions code/datums/emergency_calls/ert_stations.dm
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/datum/lazy_template/clf_ert_station
/datum/lazy_template/ert/clf_station
map_name = "clf_ert_station"

/datum/lazy_template/freelancer_ert_station
/datum/lazy_template/ert/freelancer_station
map_name = "freelancer_ert_station"

/datum/lazy_template/twe_ert_station
/datum/lazy_template/ert/twe_station
map_name = "twe_ert_station"

/datum/lazy_template/upp_ert_station
/datum/lazy_template/ert/upp_station
map_name = "upp_ert_station"

/datum/lazy_template/weyland_ert_station
/datum/lazy_template/ert/weyland_station
map_name = "weyland_ert_station"
1 change: 1 addition & 0 deletions code/datums/emergency_calls/goons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "Weyland-Yutani Corporate Security (Squad)"
mob_max = 6
probability = 0
home_base = /datum/lazy_template/ert/weyland_station

/datum/emergency_call/goon/New()
..()
Expand Down
2 changes: 2 additions & 0 deletions code/datums/emergency_calls/inspection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
name = "Inspection - Corporate"
mob_max = 2
mob_min = 1
home_base = /datum/lazy_template/ert/weyland_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_pmc
item_spawn = /obj/effect/landmark/ert_spawns/distress_pmc/item
probability = 0
Expand Down Expand Up @@ -207,6 +208,7 @@
mob_max = 4
mob_min = 1
probability = 0
home_base = /datum/lazy_template/ert/weyland_station

var/max_synths = 1
var/synths = 0
Expand Down
1 change: 1 addition & 0 deletions code/datums/emergency_calls/pmc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
mob_max = 6
probability = 20
shuttle_id = MOBILE_SHUTTLE_ID_ERT2
home_base = /datum/lazy_template/ert/weyland_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_pmc
item_spawn = /obj/effect/landmark/ert_spawns/distress_pmc/item

Expand Down
1 change: 1 addition & 0 deletions code/datums/emergency_calls/royal_marines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "Royal Marines Commando (Squad) (Friendly)"
mob_max = 7
probability = 15
home_base = /datum/lazy_template/ert/twe_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_twe
item_spawn = /obj/effect/landmark/ert_spawns/distress_twe/item
max_engineers = 0
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emergency_calls/upp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
mob_max = 9
probability = 20
shuttle_id = MOBILE_SHUTTLE_ID_ERT3

home_base = /datum/lazy_template/ert/upp_station
name_of_spawn = /obj/effect/landmark/ert_spawns/distress_upp
item_spawn = /obj/effect/landmark/ert_spawns/distress_upp/item
//1 leader, 1 engineer, 2 medics, 1 specialist, 5 soldiers
Expand Down
13 changes: 5 additions & 8 deletions code/datums/lazy_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
/// If this is true each load will increment an index keyed to the type and it will load [map_name]_[index]
var/uses_multiple_allocations = FALSE

/// Key to identify this template - used in caching
var/key

/// Directory of maps to prefix to the filename
var/map_dir = "maps/templates/lazy_templates"

Expand All @@ -28,7 +25,7 @@
return QDEL_HINT_LETMELIVE

QDEL_LIST(reservations)
GLOB.lazy_templates -= key
GLOB.lazy_templates -= type
return ..()

/**
Expand All @@ -43,9 +40,9 @@

var/load_path = "[map_dir]/[map_name].dmm"
if(uses_multiple_allocations)
var/times = multiple_allocation_hash[key] || 0
var/times = multiple_allocation_hash[type] || 0
times += 1
multiple_allocation_hash[key] = times
multiple_allocation_hash[type] = times
load_path = "[map_dir]/[map_name]_[times].dmm"

if(!load_path || !fexists(load_path))
Expand All @@ -56,7 +53,7 @@
measure_only = TRUE,
)
if(isnull(parsed_template.parsed_bounds))
CRASH("Failed to cache lazy template for loading: '[key]'")
CRASH("Failed to cache lazy template for loading: '[type]'")

var/width = parsed_template.parsed_bounds[MAP_MAXX] - parsed_template.parsed_bounds[MAP_MINX] + 1
var/height = parsed_template.parsed_bounds[MAP_MAXY] - parsed_template.parsed_bounds[MAP_MINY] + 1
Expand All @@ -66,7 +63,7 @@
parsed_template.parsed_bounds[MAP_MAXZ],
)
if(!reservation)
CRASH("Failed to reserve a block for lazy template: '[key]'")
CRASH("Failed to reserve a block for lazy template: '[type]'")

// lists kept for overall loading
var/list/loaded_atom_movables = list()
Expand Down
6 changes: 0 additions & 6 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@
if(is_mainship_level(z))
GLOB.ship_areas += src

if(base_lighting_alpha)
return INITIALIZE_HINT_ROUNDSTART

/area/LateInitialize()
. = ..()

update_base_lighting()

/area/proc/initialize_power(override_power)
Expand Down
4 changes: 4 additions & 0 deletions code/game/turfs/open.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
edge_overlay.SwapColor(rgb(255, 0, 255, 255), rgb(0, 0, 0, 0))
overlays += edge_overlay

var/area/my_area = loc
if(my_area.lighting_effect)
overlays += my_area.lighting_effect

/turf/open/proc/scorch(heat_level)
// All scorched icons should be in the dmi that their unscorched bases are
// "name_scorched#" where # is the scorchedness level 0 - 1 - 2 - 3
Expand Down
5 changes: 0 additions & 5 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@
if(opacity)
directional_opacity = ALL_CARDINALS

//Get area light
var/area/A = loc
if(A?.lighting_effect)
overlays += A.lighting_effect

return INITIALIZE_HINT_NORMAL

/turf/Destroy(force)
Expand Down
4 changes: 4 additions & 0 deletions code/game/turfs/walls/wall_icon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
bullet_overlay = image('icons/effects/bulletholes.dmi', src, "bhole_[bullethole_state]_2")
overlays += bullet_overlay

var/area/my_area = loc
if(my_area.lighting_effect)
overlays += my_area.lighting_effect

#undef BULLETHOLE_STATES
#undef cur_increment

Expand Down
30 changes: 30 additions & 0 deletions code/modules/shuttle/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
unslashable = TRUE
unacidable = TRUE
var/disabled = FALSE
var/must_launch_home = TRUE
var/compatible_landing_zones = list()

/obj/structure/machinery/computer/shuttle/ert/broken
Expand Down Expand Up @@ -154,6 +155,7 @@
.["shuttle_mode"] = ert.mode
.["flight_time"] = ert.timeLeft(0)
.["is_disabled"] = disabled
.["must_launch_home"] = must_launch_home

var/door_count = length(ert.external_doors)
var/locked_count = 0
Expand Down Expand Up @@ -188,6 +190,34 @@
return

var/obj/docking_port/mobile/emergency_response/ert = SSshuttle.getShuttle(shuttleId)

if(must_launch_home)
if(action == "launch_home")
var/datum/turf_reservation/loaded = SSmapping.lazy_load_template(ert.home_base)
var/turf/bottom_left = loaded.bottom_left_turfs[1]
var/turf/top_right = loaded.top_right_turfs[1]

var/obj/docking_port/stationary/emergency_response/target
for(var/obj/docking_port/stationary/emergency_response/shuttle in SSshuttle.stationary)
if(shuttle.z != bottom_left.z)
continue
if(shuttle.x >= top_right.x || shuttle.y >= top_right.y)
continue
if(shuttle.x <= bottom_left.x || shuttle.y <= bottom_left.y)
continue

target = shuttle
break

if(!target)
return

SSshuttle.moveShuttleToDock(ert, target, TRUE)
target.lockdown_on_land = TRUE
must_launch_home = FALSE

return

switch(action)
if("move")
if(ert.mode != SHUTTLE_IDLE)
Expand Down
Loading

0 comments on commit d7b3336

Please sign in to comment.