mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
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.
39 lines
1.2 KiB
Plaintext
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)
|