Files
Batrachophreno 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
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.
2026-05-26 19:35:48 +00:00

41 lines
1.2 KiB
Plaintext

/datum/event/camera_damage/start()
..()
var/obj/structure/machinery/camera/C = acquire_random_camera()
if(!C)
return
var/severity_range = 0
switch(severity)
if(EVENT_LEVEL_MUNDANE)
severity_range = 0
if(EVENT_LEVEL_MODERATE)
severity_range = 7
if(EVENT_LEVEL_MAJOR)
severity_range = 15
for(var/obj/structure/machinery/camera/cam in range(severity_range,C))
if(is_valid_camera(cam))
if(prob(2*severity))
cam.destroy()
else
cam.wires.cut(WIRE_POWER, src)
if(prob(5*severity))
cam.wires.cut(WIRE_ALARM, src)
/datum/event/camera_damage/proc/acquire_random_camera(var/remaining_attempts = 5)
if(!GLOB.cameranet.cameras.len)
return
if(!remaining_attempts)
return
var/obj/structure/machinery/camera/C = pick(GLOB.cameranet.cameras)
if(is_valid_camera(C))
return C
return acquire_random_camera(remaining_attempts-1)
/datum/event/camera_damage/proc/is_valid_camera(var/obj/structure/machinery/camera/C)
// Only return a functional camera, not installed in a silicon, and that exists somewhere players have access
var/turf/T = get_turf(C)
return T && C.can_use() && !istype(C.loc, /mob/living/silicon) && is_station_level(T.z)