mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-13 17:07:53 +01:00
4ecb0bc21c
Repaths obj/machinery to obj/structure/machinery. **Note for reviewers:** the only meaningful changed code exists within **code/game/objects/structures.dm** and **code/game/objects/structures/_machinery.dm**, largely concerning damage procs. With the exception of moving airlock defines to their own file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES. Objects, _categorically_, are largely divided between those you can hold in your hand/inventory and those you can't. Machinery objects are already subtypes of Structures behaviorally, this PR just makes their pathing reflect that, and allows for future work (tool actions, more health/destruction functionality) to be developed without unnecessary code duplication. I have tested this PR by loading up the Horizon and dismantling various machines and structures with tools, shooting guns of various types throughout the ship, and detonating a bunch of explosions throughout the ship.
68 lines
1.6 KiB
Plaintext
68 lines
1.6 KiB
Plaintext
/datum/event/apc_damage
|
|
no_fake = 1
|
|
|
|
/datum/event/apc_damage/start()
|
|
..()
|
|
|
|
var/obj/structure/machinery/power/apc/victim_apc = acquire_random_apc()
|
|
if(QDELETED(victim_apc))
|
|
return
|
|
|
|
switch(severity)
|
|
if(EVENT_LEVEL_MAJOR)
|
|
victim_apc.overload_lighting(100, TRUE)
|
|
victim_apc.set_broken()
|
|
if(!QDELETED(victim_apc.cell))
|
|
victim_apc.cell.corrupt()
|
|
|
|
if(EVENT_LEVEL_MODERATE)
|
|
victim_apc.overload_lighting(85, TRUE)
|
|
victim_apc.set_broken()
|
|
if(!QDELETED(victim_apc.cell))
|
|
victim_apc.cell.corrupt()
|
|
|
|
//EVENT_LEVEL_MUNDANE and if someone fucked up the config
|
|
else
|
|
victim_apc.overload_lighting(60, TRUE)
|
|
victim_apc.emagged = TRUE
|
|
victim_apc.flicker_lights()
|
|
|
|
victim_apc.update_icon()
|
|
victim_apc.update()
|
|
|
|
/**
|
|
* Returns a random, valid APC from a station area
|
|
*/
|
|
/datum/event/apc_damage/proc/acquire_random_apc()
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
SHOULD_BE_PURE(TRUE)
|
|
RETURN_TYPE(/obj/structure/machinery/power/apc)
|
|
|
|
var/list/possible_valid_apcs = list()
|
|
|
|
for(var/area/candidate_area in GLOB.the_station_areas)
|
|
var/obj/structure/machinery/power/apc/candidate_apc = candidate_area.apc
|
|
if(QDELETED(candidate_apc))
|
|
continue
|
|
|
|
if(!is_valid_apc(candidate_apc))
|
|
continue
|
|
|
|
possible_valid_apcs += candidate_area.apc
|
|
|
|
|
|
if(!length(possible_valid_apcs))
|
|
return
|
|
|
|
return pick(possible_valid_apcs)
|
|
|
|
/**
|
|
* Returns whether the given APC is valid for this event
|
|
*/
|
|
/datum/event/apc_damage/proc/is_valid_apc(obj/structure/machinery/power/apc/apc)
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
SHOULD_BE_PURE(TRUE)
|
|
|
|
var/turf/T = get_turf(apc)
|
|
return !apc.is_critical && !apc.emagged && T && is_station_level(T.z)
|