Files
CHOMPStation2/code/modules/events/camera_damage.dm
Neerti 12abb2d6f2 Ports a large chunk of the map datum system that europa/bay uses.
Links many map-specific details such as the station name, z-level information, and allowed jobs from global vars to map datum vars, which should help us maintain multiple maps at once in the future, which will be needed for the future Southern Cross.
Note that a config change will be needed to change GENERATE_ASTEROID to GENERATE_MAP, otherwise no changes should be required to continue normal map usage.
To change to a different map, it's suggested to tick the file that ticks all the other needed files, which for the Northern Star is called northern_star.dm.
2017-02-27 07:36:41 -05:00

39 lines
1.2 KiB
Plaintext

/datum/event/camera_damage/start()
var/obj/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/machinery/camera/cam in range(severity_range,C))
if(is_valid_camera(cam))
if(prob(2*severity))
cam.destroy()
else
cam.wires.UpdateCut(CAMERA_WIRE_POWER, 0)
if(prob(5*severity))
cam.wires.UpdateCut(CAMERA_WIRE_ALARM, 0)
/datum/event/camera_damage/proc/acquire_random_camera(var/remaining_attempts = 5)
if(!cameranet.cameras.len)
return
if(!remaining_attempts)
return
var/obj/machinery/camera/C = pick(cameranet.cameras)
if(is_valid_camera(C))
return C
return acquire_random_camera(remaining_attempts--)
/datum/event/camera_damage/proc/is_valid_camera(var/obj/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) && (T.z in using_map.player_levels)