mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
Alarm centralization completion
Fire alarms now handled centrally.
This commit is contained in:
@@ -110,7 +110,10 @@ var/list/ghostteleportlocs = list()
|
||||
power_environ = 0
|
||||
ambience = list('sound/ambience/ambispace.ogg','sound/music/title2.ogg','sound/music/space.ogg','sound/music/main.ogg','sound/music/traitor.ogg')
|
||||
|
||||
/area/space/firealert()
|
||||
/area/space/fire_alert()
|
||||
return
|
||||
|
||||
/area/space/fire_reset()
|
||||
return
|
||||
|
||||
/area/space/readyalert()
|
||||
|
||||
@@ -87,9 +87,9 @@
|
||||
if(!src.master.air_doors_activated)
|
||||
src.master.air_doors_activated = 1
|
||||
for(var/obj/machinery/door/firedoor/E in src.master.all_doors)
|
||||
if(!E:blocked)
|
||||
if(!E.blocked)
|
||||
if(E.operating)
|
||||
E:nextstate = CLOSED
|
||||
E.nextstate = CLOSED
|
||||
else if(!E.density)
|
||||
spawn(0)
|
||||
E.close()
|
||||
@@ -98,21 +98,21 @@
|
||||
if(src.master.air_doors_activated)
|
||||
src.master.air_doors_activated = 0
|
||||
for(var/obj/machinery/door/firedoor/E in src.master.all_doors)
|
||||
if(!E:blocked)
|
||||
if(!E.blocked)
|
||||
if(E.operating)
|
||||
E:nextstate = OPEN
|
||||
E.nextstate = OPEN
|
||||
else if(E.density)
|
||||
spawn(0)
|
||||
E.open()
|
||||
|
||||
|
||||
/area/proc/firealert()
|
||||
if(name == "Space") //no fire alarms in space
|
||||
return
|
||||
/area/proc/fire_alert()
|
||||
if(!fire)
|
||||
fire = 1
|
||||
master.fire = 1 //used for firedoor checks
|
||||
updateicon()
|
||||
master.updateicon()
|
||||
for(var/area/A in related)
|
||||
A.fire = 1
|
||||
A.updateicon()
|
||||
mouse_opacity = 0
|
||||
for(var/obj/machinery/door/firedoor/D in all_doors)
|
||||
if(!D.blocked)
|
||||
@@ -122,12 +122,14 @@
|
||||
spawn()
|
||||
D.close()
|
||||
|
||||
/area/proc/firereset()
|
||||
/area/proc/fire_reset()
|
||||
if (fire)
|
||||
fire = 0
|
||||
master.fire = 0 //used for firedoor checks
|
||||
master.updateicon()
|
||||
for(var/area/A in related)
|
||||
A.fire = 0
|
||||
A.updateicon()
|
||||
mouse_opacity = 0
|
||||
updateicon()
|
||||
for(var/obj/machinery/door/firedoor/D in all_doors)
|
||||
if(!D.blocked)
|
||||
if(D.operating)
|
||||
@@ -135,13 +137,6 @@
|
||||
else if(D.density)
|
||||
spawn(0)
|
||||
D.open()
|
||||
/*for(var/area/RA in related)
|
||||
for (var/obj/machinery/camera/C in RA)
|
||||
C.network.Remove("Fire Alarms")
|
||||
for (var/mob/living/silicon/ai/aiPlayer in player_list)
|
||||
aiPlayer.cancelAlarm("Fire", src, src)
|
||||
for (var/obj/machinery/computer/station_alert/a in machines)
|
||||
a.cancelAlarm("Fire", src, src)*/
|
||||
|
||||
/area/proc/readyalert()
|
||||
if(!eject)
|
||||
|
||||
@@ -117,11 +117,6 @@
|
||||
|
||||
first_run()
|
||||
|
||||
/obj/machinery/alarm/Del()
|
||||
//If there's an active alarm, clear it after minute so that alarms don't keep going forver
|
||||
delayed_reset()
|
||||
..()
|
||||
|
||||
//needed to cancel the alarm after it is deleted
|
||||
/obj/machinery/alarm/proc/delayed_reset()
|
||||
var/area/A = alarm_area
|
||||
@@ -949,7 +944,6 @@ FIRE ALARM
|
||||
var/buildstage = 2 // 2 = complete, 1 = no wires, 0 = circuit gone
|
||||
|
||||
/obj/machinery/firealarm/update_icon()
|
||||
|
||||
if(wiresexposed)
|
||||
switch(buildstage)
|
||||
if(2)
|
||||
@@ -983,7 +977,8 @@ FIRE ALARM
|
||||
return src.alarm()
|
||||
|
||||
/obj/machinery/firealarm/emp_act(severity)
|
||||
if(prob(50/severity)) alarm()
|
||||
if(prob(50/severity))
|
||||
alarm(rand(30/severity, 60/severity))
|
||||
..()
|
||||
|
||||
/obj/machinery/firealarm/attackby(obj/item/W as obj, mob/user as mob)
|
||||
@@ -1082,6 +1077,7 @@ FIRE ALARM
|
||||
var/d2
|
||||
if (istype(user, /mob/living/carbon/human) || istype(user, /mob/living/silicon))
|
||||
A = A.loc
|
||||
A = A.master
|
||||
|
||||
if (A.fire)
|
||||
d1 = text("<A href='?src=\ref[];reset=1'>Reset - Lockdown</A>", src)
|
||||
@@ -1147,26 +1143,26 @@ FIRE ALARM
|
||||
/obj/machinery/firealarm/proc/reset()
|
||||
if (!( src.working ))
|
||||
return
|
||||
var/area/A = src.loc
|
||||
A = A.loc
|
||||
if (!( istype(A, /area) ))
|
||||
return
|
||||
A.firereset()
|
||||
var/area/area = get_area(src)
|
||||
for(var/area/A in area.related)
|
||||
for(var/obj/machinery/firealarm/FA in A)
|
||||
fire_alarm.clearAlarm(loc, FA)
|
||||
update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/firealarm/proc/alarm()
|
||||
/obj/machinery/firealarm/proc/alarm(var/duration = 0)
|
||||
if (!( src.working))
|
||||
return
|
||||
var/area/A = src.loc
|
||||
A = A.loc
|
||||
if (!( istype(A, /area) ))
|
||||
return
|
||||
A.firealert()
|
||||
var/area/area = get_area(src)
|
||||
for(var/area/A in area.related)
|
||||
for(var/obj/machinery/firealarm/FA in A)
|
||||
fire_alarm.triggerAlarm(loc, FA, duration)
|
||||
update_icon()
|
||||
//playsound(src.loc, 'sound/ambience/signal.ogg', 75, 0)
|
||||
return
|
||||
|
||||
|
||||
|
||||
/obj/machinery/firealarm/New(loc, dir, building)
|
||||
..()
|
||||
|
||||
@@ -1182,20 +1178,6 @@ FIRE ALARM
|
||||
pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24)
|
||||
pixel_y = (dir & 3)? (dir ==1 ? -24 : 24) : 0
|
||||
|
||||
/obj/machinery/firealarm/Del()
|
||||
//so fire alarms don't keep going forever
|
||||
delayed_reset()
|
||||
..()
|
||||
|
||||
//needed to cancel the alarm after it is deleted
|
||||
/obj/machinery/firealarm/proc/delayed_reset()
|
||||
var/area/A = get_area(src)
|
||||
if (!A) return
|
||||
|
||||
src = null
|
||||
spawn(600)
|
||||
A.firereset()
|
||||
|
||||
/obj/machinery/firealarm/initialize()
|
||||
if(z in config.contact_levels)
|
||||
if(security_level)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
var/source = null // The source trigger
|
||||
var/source_name = "" // The name of the source should it be lost (for example a destroyed camera)
|
||||
var/duration = 0 // How long this source will be alarming, 0 for indefinetely.
|
||||
var/severity = 1 // How severe the alarm from this source is.
|
||||
var/start_time = 0 // When this source began alarming.
|
||||
var/end_time = 0 // Use to set when this trigger should clear, in case the source is lost.
|
||||
|
||||
@@ -22,11 +23,11 @@
|
||||
var/area/last_camera_area //The last area in which cameras where fetched, used to see if the camera list should be updated.
|
||||
var/end_time //Used to set when this alarm should clear, in case the origin is lost.
|
||||
|
||||
/datum/alarm/New(var/atom/origin, var/atom/source, var/duration)
|
||||
/datum/alarm/New(var/atom/origin, var/atom/source, var/duration, var/severity)
|
||||
src.origin = origin
|
||||
|
||||
cameras() // Sets up both cameras and last alarm area.
|
||||
set_duration(source, duration)
|
||||
set_source_data(source, duration, severity)
|
||||
|
||||
/datum/alarm/proc/process()
|
||||
// Has origin gone missing?
|
||||
@@ -41,7 +42,7 @@
|
||||
AS.duration = 0
|
||||
AS.end_time = world.time + ALARM_RESET_DELAY
|
||||
|
||||
/datum/alarm/proc/set_duration(var/atom/source, var/duration)
|
||||
/datum/alarm/proc/set_source_data(var/atom/source, var/duration, var/severity)
|
||||
var/datum/alarm_source/AS = sources_assoc[source]
|
||||
if(!AS)
|
||||
AS = new/datum/alarm_source(source)
|
||||
@@ -51,6 +52,7 @@
|
||||
if(AS.duration)
|
||||
duration = SecondsToTicks(duration)
|
||||
AS.duration = duration
|
||||
AS.severity = severity
|
||||
|
||||
/datum/alarm/proc/clear(var/source)
|
||||
var/datum/alarm_source/AS = sources_assoc[source]
|
||||
@@ -83,22 +85,29 @@
|
||||
last_camera_area = last_area
|
||||
return cameras
|
||||
|
||||
/datum/alarm/proc/max_severity()
|
||||
var/max_severity = 0
|
||||
for(var/datum/alarm_source/AS in sources)
|
||||
max_severity = max(AS.severity, max_severity)
|
||||
|
||||
return max_severity
|
||||
|
||||
/******************
|
||||
* Assisting procs *
|
||||
******************/
|
||||
/atom/proc/get_alarm_area()
|
||||
return get_area(src)
|
||||
var/area/A = get_area(src)
|
||||
return A.master
|
||||
|
||||
/area/get_alarm_area()
|
||||
return src
|
||||
return src.master
|
||||
|
||||
/atom/proc/get_alarm_name()
|
||||
var/area/A = get_area(src)
|
||||
return A.master.name
|
||||
|
||||
/area/get_alarm_name()
|
||||
return name
|
||||
return master.name
|
||||
|
||||
/mob/get_alarm_name()
|
||||
return name
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
A.process()
|
||||
check_alarm_cleared(A)
|
||||
|
||||
/datum/alarm_handler/proc/triggerAlarm(var/atom/origin, var/atom/source, var/duration = 0)
|
||||
/datum/alarm_handler/proc/triggerAlarm(var/atom/origin, var/atom/source, var/duration = 0, var/severity = 1)
|
||||
var/new_alarm
|
||||
//Proper origin and source mandatory
|
||||
if(!(origin && source))
|
||||
@@ -23,16 +23,16 @@
|
||||
//see if there is already an alarm of this origin
|
||||
var/datum/alarm/existing = alarms_assoc[origin]
|
||||
if(existing)
|
||||
existing.set_duration(source, duration)
|
||||
existing.set_source_data(source, duration, severity)
|
||||
else
|
||||
existing = new/datum/alarm(origin, source, duration)
|
||||
existing = new/datum/alarm(origin, source, duration, severity)
|
||||
new_alarm = 1
|
||||
|
||||
alarms |= existing
|
||||
alarms_assoc[origin] = existing
|
||||
if(new_alarm)
|
||||
alarms = dd_sortedObjectList(alarms)
|
||||
notify_listeners(existing, ALARM_RAISED)
|
||||
on_alarm_change(existing, ALARM_RAISED)
|
||||
|
||||
return new_alarm
|
||||
|
||||
@@ -51,10 +51,30 @@
|
||||
if ((alarm.end_time && world.time > alarm.end_time) || !alarm.sources.len)
|
||||
alarms -= alarm
|
||||
alarms_assoc -= alarm.origin
|
||||
notify_listeners(alarm, ALARM_CLEARED)
|
||||
on_alarm_change(alarm, ALARM_CLEARED)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/alarm_handler/proc/on_alarm_change(var/datum/alarm/alarm, var/was_raised)
|
||||
for(var/obj/machinery/camera/C in alarm.cameras())
|
||||
if(was_raised)
|
||||
C.network.Add(category)
|
||||
invalidateCameraCache()
|
||||
else
|
||||
C.network.Remove(category)
|
||||
notify_listeners(alarm, was_raised)
|
||||
|
||||
/datum/alarm_handler/proc/get_alarm_severity_for_origin(var/atom/origin)
|
||||
if(!origin)
|
||||
return
|
||||
|
||||
origin = origin.get_alarm_origin()
|
||||
var/datum/alarm/existing = alarms_assoc[origin]
|
||||
if(!existing)
|
||||
return
|
||||
|
||||
return existing.max_severity()
|
||||
|
||||
/atom/proc/get_alarm_origin()
|
||||
return src
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/datum/alarm_handler/atmosphere
|
||||
category = "Atmosphere"
|
||||
category = "Atmosphere Alarms"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/datum/alarm_handler/camera
|
||||
category = "Camera"
|
||||
category = "Camera Alarms"
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
/datum/alarm_handler/fire
|
||||
category = "Fire"
|
||||
category = "Fire Alarms"
|
||||
|
||||
/datum/alarm_handler/fire/on_alarm_change(var/datum/alarm/alarm, var/was_raised)
|
||||
var/area/A = alarm.origin
|
||||
if(istype(A))
|
||||
if(was_raised)
|
||||
A.fire_alert()
|
||||
else
|
||||
A.fire_reset()
|
||||
..()
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/datum/alarm_handler/motion
|
||||
category = "Motion"
|
||||
category = "Motion Alarms"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/datum/alarm_handler/power
|
||||
category = "Power"
|
||||
category = "Power Alarms"
|
||||
|
||||
/datum/alarm_handler/power/notify_listeners(var/datum/alarm/alarm, var/was_raised)
|
||||
..()
|
||||
/datum/alarm_handler/power/on_alarm_change(var/datum/alarm/alarm, var/was_raised)
|
||||
var/area/A = alarm.origin
|
||||
if(istype(A))
|
||||
A.power_alert(was_raised)
|
||||
..()
|
||||
|
||||
/area/proc/power_alert(var/alarming)
|
||||
|
||||
Reference in New Issue
Block a user