mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-24 13:38:41 +01:00
Security Level subsystem (#58248)
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
///from SSsun when the sun changes position : (azimuth)
|
||||
#define COMSIG_SUN_MOVED "sun_moved"
|
||||
|
||||
///from SSsecurity_level when the security level changes : (new_level)
|
||||
#define COMSIG_SECURITY_LEVEL_CHANGED "security_level_changed"
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
// /datum signals
|
||||
|
||||
@@ -27,7 +27,7 @@ SUBSYSTEM_DEF(nightshift)
|
||||
priority_announce(message, sound='sound/misc/notice2.ogg', sender_override="Automated Lighting System Announcement")
|
||||
|
||||
/datum/controller/subsystem/nightshift/proc/check_nightshift()
|
||||
var/emergency = GLOB.security_level >= SEC_LEVEL_RED
|
||||
var/emergency = SSsecurity_level.current_level >= SEC_LEVEL_RED
|
||||
var/announcing = TRUE
|
||||
var/time = station_time()
|
||||
var/night_time = (time < nightshift_end_time) || (time > nightshift_start_time)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
SUBSYSTEM_DEF(security_level)
|
||||
name = "Security Level"
|
||||
flags = SS_NO_FIRE
|
||||
/// Currently set security level
|
||||
var/current_level = SEC_LEVEL_GREEN
|
||||
|
||||
/**
|
||||
* Sets a new security level as our current level
|
||||
*
|
||||
* Arguments:
|
||||
* * new_level The new security level that will become our current level
|
||||
*/
|
||||
/datum/controller/subsystem/security_level/proc/set_level(new_level)
|
||||
SSsecurity_level.current_level = new_level
|
||||
SEND_SIGNAL(src, COMSIG_SECURITY_LEVEL_CHANGED, new_level)
|
||||
SSnightshift.check_nightshift()
|
||||
SSblackbox.record_feedback("tally", "security_level_changes", 1, get_security_level())
|
||||
@@ -291,7 +291,7 @@ GLOBAL_VAR_INIT(dynamic_forced_threat_level, -1)
|
||||
|
||||
print_command_report(., "Central Command Status Summary", announce=FALSE)
|
||||
priority_announce("A summary has been copied and printed to all communications consoles.", "Security level elevated.", ANNOUNCER_INTERCEPT)
|
||||
if(GLOB.security_level < SEC_LEVEL_BLUE)
|
||||
if(SSsecurity_level.current_level < SEC_LEVEL_BLUE)
|
||||
set_security_level(SEC_LEVEL_BLUE)
|
||||
|
||||
// Yes, this is copy pasted from game_mode
|
||||
|
||||
@@ -327,7 +327,7 @@
|
||||
|
||||
print_command_report(intercepttext, "Central Command Status Summary", announce=FALSE)
|
||||
priority_announce("A summary has been copied and printed to all communications consoles.", "Enemy communication intercepted. Security level elevated.", ANNOUNCER_INTERCEPT)
|
||||
if(GLOB.security_level < SEC_LEVEL_BLUE)
|
||||
if(SSsecurity_level.current_level < SEC_LEVEL_BLUE)
|
||||
set_security_level(SEC_LEVEL_BLUE)
|
||||
|
||||
/*
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
var/new_sec_level = seclevel2num(params["newSecurityLevel"])
|
||||
if (new_sec_level != SEC_LEVEL_GREEN && new_sec_level != SEC_LEVEL_BLUE)
|
||||
return
|
||||
if (GLOB.security_level == new_sec_level)
|
||||
if (SSsecurity_level.current_level == new_sec_level)
|
||||
return
|
||||
|
||||
set_security_level(new_sec_level)
|
||||
@@ -529,9 +529,9 @@
|
||||
/**
|
||||
* Call an emergency meeting
|
||||
*
|
||||
* Comm Console wrapper for the Communications subsystem wrapper for the call_emergency_meeting world proc.
|
||||
* Checks to make sure the proc can be called, and handles relevant feedback, logging and timing.
|
||||
* See the SScommunications proc definition for more detail, in short, teleports the entire crew to
|
||||
* Comm Console wrapper for the Communications subsystem wrapper for the call_emergency_meeting world proc.
|
||||
* Checks to make sure the proc can be called, and handles relevant feedback, logging and timing.
|
||||
* See the SScommunications proc definition for more detail, in short, teleports the entire crew to
|
||||
* the bridge for a meetup. Should only really happen during april fools.
|
||||
* Arguments:
|
||||
* * user - Mob who called the meeting
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
. = ..()
|
||||
if(defib)
|
||||
. += "<span class='notice'>There is a defib unit hooked up. Alt-click to remove it.</span>"
|
||||
if(GLOB.security_level >= SEC_LEVEL_RED)
|
||||
if(SSsecurity_level.current_level >= SEC_LEVEL_RED)
|
||||
. += "<span class='notice'>Due to a security situation, its locking clamps can be toggled by swiping any ID.</span>"
|
||||
else
|
||||
. += "<span class='notice'>Its locking clamps can be [clamps_locked ? "dis" : ""]engaged by swiping an ID with access.</span>"
|
||||
@@ -102,7 +102,7 @@
|
||||
return
|
||||
var/obj/item/card/id = I.GetID()
|
||||
if(id)
|
||||
if(check_access(id) || GLOB.security_level >= SEC_LEVEL_RED) //anyone can toggle the clamps in red alert!
|
||||
if(check_access(id) || SSsecurity_level.current_level >= SEC_LEVEL_RED) //anyone can toggle the clamps in red alert!
|
||||
if(!defib)
|
||||
to_chat(user, "<span class='warning'>You can't engage the clamps on a defibrillator that isn't there.</span>")
|
||||
return
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
/obj/machinery/door/examine(mob/user)
|
||||
. = ..()
|
||||
if(red_alert_access)
|
||||
if(GLOB.security_level >= SEC_LEVEL_RED)
|
||||
if(SSsecurity_level.current_level >= SEC_LEVEL_RED)
|
||||
. += "<span class='notice'>Due to a security threat, its access requirements have been lifted!</span>"
|
||||
else
|
||||
. += "<span class='notice'>In the event of a red alert, its access requirements will automatically lift.</span>"
|
||||
@@ -57,7 +57,7 @@
|
||||
. += "<span class='notice'>It has labels indicating that it has an emergency mechanism to open it with <b>just your hands</b> if there's no power.</span>"
|
||||
|
||||
/obj/machinery/door/check_access_list(list/access_list)
|
||||
if(red_alert_access && GLOB.security_level >= SEC_LEVEL_RED)
|
||||
if(red_alert_access && SSsecurity_level.current_level >= SEC_LEVEL_RED)
|
||||
return TRUE
|
||||
return ..()
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
//doors only block while dense though so we have to use the proc
|
||||
real_explosion_block = explosion_block
|
||||
explosion_block = EXPLOSION_BLOCK_PROC
|
||||
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_security_level)
|
||||
|
||||
/obj/machinery/door/proc/set_init_door_layer()
|
||||
if(density)
|
||||
@@ -93,6 +94,23 @@
|
||||
air_update_turf(TRUE, FALSE)
|
||||
return ..()
|
||||
|
||||
/**
|
||||
* Signal handler for checking if we notify our surrounding that access requirements are lifted accordingly to a newly set security level
|
||||
*
|
||||
* Arguments:
|
||||
* * source The datum source of the signal
|
||||
* * new_level The new security level that is in effect
|
||||
*/
|
||||
/obj/machinery/door/proc/check_security_level(datum/source, new_level)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(new_level <= SEC_LEVEL_BLUE)
|
||||
return
|
||||
if(!red_alert_access)
|
||||
return
|
||||
audible_message("<span class='notice'>[src] whirr[p_s()] as [p_they()] automatically lift[p_s()] access requirements!</span>")
|
||||
playsound(src, 'sound/machines/boltsup.ogg', 50, TRUE)
|
||||
|
||||
/obj/machinery/door/proc/try_safety_unlock(mob/user)
|
||||
if(safety_mode && !hasPower() && density)
|
||||
to_chat(user, "<span class='notice'>You begin unlocking the airlock safety mechanism...</span>")
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
update_appearance()
|
||||
myarea = get_area(src)
|
||||
LAZYADD(myarea.firealarms, src)
|
||||
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_security_level)
|
||||
|
||||
/obj/machinery/firealarm/ComponentInitialize()
|
||||
. = ..()
|
||||
@@ -78,9 +79,9 @@
|
||||
|
||||
. += "fire_overlay"
|
||||
if(is_station_level(z))
|
||||
. += "fire_[GLOB.security_level]"
|
||||
. += mutable_appearance(icon, "fire_[GLOB.security_level]", layer, plane)
|
||||
. += mutable_appearance(icon, "fire_[GLOB.security_level]", layer, EMISSIVE_PLANE)
|
||||
. += "fire_[SSsecurity_level.current_level]"
|
||||
. += mutable_appearance(icon, "fire_[SSsecurity_level.current_level]", layer, plane)
|
||||
. += mutable_appearance(icon, "fire_[SSsecurity_level.current_level]", layer, EMISSIVE_PLANE)
|
||||
else
|
||||
. += "fire_[SEC_LEVEL_GREEN]"
|
||||
. += mutable_appearance(icon, "fire_[SEC_LEVEL_GREEN]", layer, plane)
|
||||
@@ -145,6 +146,19 @@
|
||||
myarea.triggered_firealarms -= 1
|
||||
update_appearance()
|
||||
|
||||
/**
|
||||
* Signal handler for checking if we should update fire alarm appearance accordingly to a newly set security level
|
||||
*
|
||||
* Arguments:
|
||||
* * source The datum source of the signal
|
||||
* * new_level The new security level that is in effect
|
||||
*/
|
||||
/obj/machinery/firealarm/proc/check_security_level(datum/source, new_level)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(is_station_level(z))
|
||||
update_appearance()
|
||||
|
||||
/obj/machinery/firealarm/proc/alarm(mob/user)
|
||||
if(!is_operational || !COOLDOWN_FINISHED(src, last_alarm))
|
||||
return
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN)
|
||||
//SEC_LEVEL_GREEN = code green
|
||||
//SEC_LEVEL_BLUE = code blue
|
||||
//SEC_LEVEL_RED = code red
|
||||
@@ -18,21 +17,17 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN)
|
||||
level = SEC_LEVEL_DELTA
|
||||
|
||||
//Will not be announced if you try to set to the same level as it already is
|
||||
if(level >= SEC_LEVEL_GREEN && level <= SEC_LEVEL_DELTA && level != GLOB.security_level)
|
||||
if(level >= SEC_LEVEL_GREEN && level <= SEC_LEVEL_DELTA && level != SSsecurity_level.current_level)
|
||||
switch(level)
|
||||
if(SEC_LEVEL_GREEN)
|
||||
minor_announce(CONFIG_GET(string/alert_green), "Attention! Security level lowered to green:")
|
||||
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
|
||||
if(GLOB.security_level >= SEC_LEVEL_RED)
|
||||
if(SSsecurity_level.current_level >= SEC_LEVEL_RED)
|
||||
SSshuttle.emergency.modTimer(4)
|
||||
else
|
||||
SSshuttle.emergency.modTimer(2)
|
||||
GLOB.security_level = SEC_LEVEL_GREEN
|
||||
for(var/obj/machinery/firealarm/FA in GLOB.machines)
|
||||
if(is_station_level(FA.z))
|
||||
FA.update_appearance()
|
||||
if(SEC_LEVEL_BLUE)
|
||||
if(GLOB.security_level < SEC_LEVEL_BLUE)
|
||||
if(SSsecurity_level.current_level < SEC_LEVEL_BLUE)
|
||||
minor_announce(CONFIG_GET(string/alert_blue_upto), "Attention! Security level elevated to blue:",1)
|
||||
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
|
||||
SSshuttle.emergency.modTimer(0.5)
|
||||
@@ -40,52 +35,28 @@ GLOBAL_VAR_INIT(security_level, SEC_LEVEL_GREEN)
|
||||
minor_announce(CONFIG_GET(string/alert_blue_downto), "Attention! Security level lowered to blue:")
|
||||
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
|
||||
SSshuttle.emergency.modTimer(2)
|
||||
GLOB.security_level = SEC_LEVEL_BLUE
|
||||
for(var/obj/machinery/firealarm/FA in GLOB.machines)
|
||||
if(is_station_level(FA.z))
|
||||
FA.update_appearance()
|
||||
if(SEC_LEVEL_RED)
|
||||
if(GLOB.security_level < SEC_LEVEL_RED)
|
||||
if(SSsecurity_level.current_level < SEC_LEVEL_RED)
|
||||
minor_announce(CONFIG_GET(string/alert_red_upto), "Attention! Code red!",1)
|
||||
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
|
||||
if(GLOB.security_level == SEC_LEVEL_GREEN)
|
||||
if(SSsecurity_level.current_level == SEC_LEVEL_GREEN)
|
||||
SSshuttle.emergency.modTimer(0.25)
|
||||
else
|
||||
SSshuttle.emergency.modTimer(0.5)
|
||||
else
|
||||
minor_announce(CONFIG_GET(string/alert_red_downto), "Attention! Code red!")
|
||||
GLOB.security_level = SEC_LEVEL_RED
|
||||
|
||||
for(var/obj/machinery/firealarm/FA in GLOB.machines)
|
||||
if(is_station_level(FA.z))
|
||||
FA.update_appearance()
|
||||
for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines)
|
||||
pod.locked = FALSE
|
||||
if(SEC_LEVEL_DELTA)
|
||||
minor_announce(CONFIG_GET(string/alert_delta), "Attention! Delta security level reached!",1)
|
||||
if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL)
|
||||
if(GLOB.security_level == SEC_LEVEL_GREEN)
|
||||
if(SSsecurity_level.current_level == SEC_LEVEL_GREEN)
|
||||
SSshuttle.emergency.modTimer(0.25)
|
||||
else if(GLOB.security_level == SEC_LEVEL_BLUE)
|
||||
else if(SSsecurity_level.current_level == SEC_LEVEL_BLUE)
|
||||
SSshuttle.emergency.modTimer(0.5)
|
||||
GLOB.security_level = SEC_LEVEL_DELTA
|
||||
for(var/obj/machinery/firealarm/FA in GLOB.machines)
|
||||
if(is_station_level(FA.z))
|
||||
FA.update_appearance()
|
||||
for(var/obj/machinery/computer/shuttle/pod/pod in GLOB.machines)
|
||||
pod.locked = FALSE
|
||||
if(level >= SEC_LEVEL_RED)
|
||||
for(var/obj/machinery/door/D in GLOB.machines)
|
||||
if(D.red_alert_access)
|
||||
D.visible_message("<span class='notice'>[D] whirrs as it automatically lifts access requirements!</span>")
|
||||
playsound(D, 'sound/machines/boltsup.ogg', 50, TRUE)
|
||||
SSblackbox.record_feedback("tally", "security_level_changes", 1, get_security_level())
|
||||
SSnightshift.check_nightshift()
|
||||
else
|
||||
return
|
||||
|
||||
SSsecurity_level.set_level(level)
|
||||
|
||||
/proc/get_security_level()
|
||||
switch(GLOB.security_level)
|
||||
switch(SSsecurity_level.current_level)
|
||||
if(SEC_LEVEL_GREEN)
|
||||
return "green"
|
||||
if(SEC_LEVEL_BLUE)
|
||||
|
||||
@@ -568,7 +568,7 @@
|
||||
var/obj/machinery/computer/shuttle/C = getControlConsole()
|
||||
if(!istype(C, /obj/machinery/computer/shuttle/pod))
|
||||
return ..()
|
||||
if(GLOB.security_level >= SEC_LEVEL_RED || (C && (C.obj_flags & EMAGGED)))
|
||||
if(SSsecurity_level.current_level >= SEC_LEVEL_RED || (C && (C.obj_flags & EMAGGED)))
|
||||
if(launch_status == UNLAUNCHED)
|
||||
launch_status = EARLY_LAUNCHED
|
||||
return ..()
|
||||
@@ -588,6 +588,10 @@
|
||||
light_color = LIGHT_COLOR_BLUE
|
||||
density = FALSE
|
||||
|
||||
/obj/machinery/computer/shuttle/pod/Initialize(mapload)
|
||||
. = ..()
|
||||
RegisterSignal(SSsecurity_level, COMSIG_SECURITY_LEVEL_CHANGED, .proc/check_lock)
|
||||
|
||||
/obj/machinery/computer/shuttle/pod/ComponentInitialize()
|
||||
. = ..()
|
||||
AddElement(/datum/element/update_icon_blocker)
|
||||
@@ -603,6 +607,20 @@
|
||||
. = ..()
|
||||
possible_destinations += ";[port.id]_lavaland"
|
||||
|
||||
/**
|
||||
* Signal handler for checking if we should lock or unlock escape pods accordingly to a newly set security level
|
||||
*
|
||||
* Arguments:
|
||||
* * source The datum source of the signal
|
||||
* * new_level The new security level that is in effect
|
||||
*/
|
||||
/obj/machinery/computer/shuttle/pod/proc/check_lock(datum/source, new_level)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(obj_flags & EMAGGED)
|
||||
return
|
||||
locked = new_level < SEC_LEVEL_RED
|
||||
|
||||
/obj/docking_port/stationary/random
|
||||
name = "escape pod"
|
||||
id = "pod"
|
||||
@@ -698,7 +716,7 @@
|
||||
/obj/item/storage/pod/can_interact(mob/user)
|
||||
if(!..())
|
||||
return FALSE
|
||||
if(GLOB.security_level >= SEC_LEVEL_RED || unlocked)
|
||||
if(SSsecurity_level.current_level >= SEC_LEVEL_RED || unlocked)
|
||||
return TRUE
|
||||
to_chat(user, "The storage unit will only unlock during a Red or Delta security alert.")
|
||||
|
||||
|
||||
@@ -336,6 +336,7 @@
|
||||
#include "code\controllers\subsystem\research.dm"
|
||||
#include "code\controllers\subsystem\restaurant.dm"
|
||||
#include "code\controllers\subsystem\runechat.dm"
|
||||
#include "code\controllers\subsystem\security_level.dm"
|
||||
#include "code\controllers\subsystem\server_maint.dm"
|
||||
#include "code\controllers\subsystem\shuttle.dm"
|
||||
#include "code\controllers\subsystem\skills.dm"
|
||||
|
||||
Reference in New Issue
Block a user