From 142e96a2dd889160e9f44e098d66741530d3f065 Mon Sep 17 00:00:00 2001 From: deathride58 Date: Mon, 5 Feb 2018 03:28:41 +0000 Subject: [PATCH] [READY] Adds night shifts (#4281) * initial commit - adds night shifts * fixes lighting not updating when nightshift is triggered and fixes compiling issues * makes red alert override nightshift * Update lighting.dm * adds announcements for nightshift changes * fixes nightshift flip-flopping during the night, adjusts night message a little, moves from minor_announce to priority_announce * Update cit_nightshift.dm * fixes compiling errors --- .../configuration/entries/game_options.dm | 9 ++++ code/modules/power/lighting.dm | 5 +- .../security_levels/security_levels.dm | 11 ++++ config/game_options.txt | 16 ++++-- .../controllers/subsystem/cit_nightshift.dm | 52 +++++++++++++++++++ tgstation.dme | 1 + 6 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 modular_citadel/code/controllers/subsystem/cit_nightshift.dm diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index f91d775fba..cc8f832229 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -249,6 +249,15 @@ /datum/config_entry/flag/allow_miscreants /datum/config_entry/flag/allow_extended_miscreants + + +/datum/config_entry/flag/nightshift_enabled + +/datum/config_entry/number/nightshift_start + config_entry_value = 20 + +/datum/config_entry/number/nightshift_finish + config_entry_value = 6 //End of Cit changes /datum/config_entry/number/bombcap/ValidateAndSet(str_val) diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index b86ac56478..cf00f911d8 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -311,8 +311,9 @@ on = FALSE emergency_mode = FALSE if(on) - if(!light || light.light_range != brightness) + if(!light || light.light_range != brightness || SSnightshift.nightshift != nightshift) //Cit change - makes lights update when nightshift triggers switchcount++ + nightshift = SSnightshift.nightshift // Cit change - makes lights update when nightshift triggers if(rigged) if(status == LIGHT_OK && trigger) explode() @@ -321,7 +322,7 @@ burn_out() else use_power = ACTIVE_POWER_USE - set_light(brightness, bulb_power, bulb_colour) + set_light(brightness, ((SSnightshift.nightshift && obeysnightshift) ? SSnightshift.nightshift_light_power : bulb_power), ((SSnightshift.nightshift && obeysnightshift) ? SSnightshift.nightshift_light_color : bulb_colour)) // Citadel change. Allows nightshift and admins to modify station light power and color else if(has_emergency_power(LIGHT_EMERGENCY_POWER_USE) && !turned_off()) use_power = IDLE_POWER_USE emergency_mode = TRUE diff --git a/code/modules/security_levels/security_levels.dm b/code/modules/security_levels/security_levels.dm index 0da7227d3a..d4e21edb32 100644 --- a/code/modules/security_levels/security_levels.dm +++ b/code/modules/security_levels/security_levels.dm @@ -41,6 +41,8 @@ GLOBAL_VAR_INIT(security_level, 0) if(SSshuttle.emergency.mode == SHUTTLE_CALL || SSshuttle.emergency.mode == SHUTTLE_RECALL) SSshuttle.emergency.modTimer(2) GLOB.security_level = SEC_LEVEL_BLUE + sound_to_playing_players('sound/misc/voybluealert.ogg') // Citadel change - Makes alerts play a sound + for(var/obj/machinery/firealarm/FA in GLOB.machines) if(is_station_level(FA.z)) FA.update_icon() @@ -55,6 +57,7 @@ GLOBAL_VAR_INIT(security_level, 0) else minor_announce(CONFIG_GET(string/alert_red_downto), "Attention! Code red!") GLOB.security_level = SEC_LEVEL_RED + sound_to_playing_players('sound/misc/voyalert.ogg') // Citadel change - Makes alerts play a sound for(var/obj/machinery/firealarm/FA in GLOB.machines) if(is_station_level(FA.z)) @@ -69,6 +72,8 @@ GLOBAL_VAR_INIT(security_level, 0) else if(GLOB.security_level == SEC_LEVEL_BLUE) SSshuttle.emergency.modTimer(0.5) GLOB.security_level = SEC_LEVEL_DELTA + sound_to_playing_players('sound/misc/deltakalaxon.ogg') // Citadel change - Makes alerts play a sound + for(var/obj/machinery/firealarm/FA in GLOB.machines) if(is_station_level(FA.z)) FA.update_icon() @@ -79,6 +84,12 @@ GLOBAL_VAR_INIT(security_level, 0) if(D.red_alert_access) D.visible_message("[D] whirrs as it automatically lifts access requirements!") playsound(D, 'sound/machines/boltsup.ogg', 50, TRUE) + //Citadel change, makes red and delta alerts override nightshift lights + SSnightshift.nightshift_override = TRUE + if(SSnightshift.nightshift) + SSnightshift.nightshift = FALSE + SSnightshift.updatenightlights() + //End of citadel changes SSblackbox.record_feedback("tally", "security_level_changes", 1, get_security_level()) else return diff --git a/config/game_options.txt b/config/game_options.txt index 90fe706371..a3c6399013 100644 --- a/config/game_options.txt +++ b/config/game_options.txt @@ -136,10 +136,10 @@ MIDROUND_ANTAG CHANGELING MIDROUND_ANTAG WIZARD #MIDROUND_ANTAG MONKEY -## Uncomment these for overrides of the minimum / maximum number of players in a round type. +## Uncomment these for overrides of the minimum / maximum number of players in a round type. ## If you set any of these occasionally check to see if you still need them as the modes ## will still be actively rebalanced around the SUGGESTED populations, not your overrides. -## Notes: For maximum number of players a value of -1 means no maximum. Setting minimums to +## Notes: For maximum number of players a value of -1 means no maximum. Setting minimums to ## VERY low numbers (< 5) can lead to errors if the roundtypes were not designed for that. #MIN_POP TRAITOR 0 @@ -508,5 +508,13 @@ ALLOW_MISCREANTS ## Uncomment to let miscreants spawn during Extended. I hold no responsibility for fun that may occur while this is enabled. #ALLOW_EXTENDED_MISCREANTS -## Uncomment to give players the choice of their species before they join the game -JOIN_WITH_MUTANT_RACE \ No newline at end of file +## Determines if players are allowed to print integrated circuits, uncomment to allow. +#IC_PRINTING + +## NIGHT SHIFT ## +## Comment to disable nightshift +NIGHTSHIFT_ENABLED + +## These values determine the start and end of night shift. By default, night shift starts at 8 PM, and ends at 6 AM. +NIGHTSHIFT_START 20 +NIGHTSHIFT_FINISH 6 diff --git a/modular_citadel/code/controllers/subsystem/cit_nightshift.dm b/modular_citadel/code/controllers/subsystem/cit_nightshift.dm new file mode 100644 index 0000000000..8f5fbeea62 --- /dev/null +++ b/modular_citadel/code/controllers/subsystem/cit_nightshift.dm @@ -0,0 +1,52 @@ +/obj/machinery/light + var/obeysnightshift = FALSE + var/nightshift = FALSE + +/obj/machinery/light/Initialize() + . = ..() + var/area/a = get_area(src) + if(a.type in GLOB.the_station_areas) + obeysnightshift = TRUE + SSnightshift.nightlights += src + +/obj/machinery/light/Destroy() + if(obeysnightshift && src in SSnightshift.nightlights) + SSnightshift.nightlights -= src + . = ..() + +SUBSYSTEM_DEF(nightshift) + name = "Night shift" + wait = 3000 + flags = SS_BACKGROUND + + var/nightshift = FALSE + var/nightshift_light_power = 0.45 + var/nightshift_light_color = "#FFDDCC" + var/nightshift_override = FALSE + + var/list/nightlights = list() + +/datum/controller/subsystem/nightshift/Initialize() + if(CONFIG_GET(flag/nightshift_enabled) && !nightshift_override) + var/nighttime = text2num(time2text(world.timeofday,"hh")) + if(!nightshift && ((nighttime >= CONFIG_GET(number/nightshift_start)) || (nighttime <= CONFIG_GET(number/nightshift_finish)))) + nightshift = TRUE + . = ..() + +/datum/controller/subsystem/nightshift/fire(resumed = 0) + if(CONFIG_GET(flag/nightshift_enabled) && !nightshift_override) + var/nighttime = text2num(time2text(world.timeofday,"hh")) + if(GLOB.security_level < SEC_LEVEL_RED && ((nighttime >= CONFIG_GET(number/nightshift_start)) || (nighttime <= CONFIG_GET(number/nightshift_finish)))) + if(!nightshift) + nightshift = TRUE + updatenightlights() + priority_announce("Good afternoon, crew. To reduce power consumption and stimulate the circadian rhythms of some species, all of the lights aboard the station have been dimmed for the night.", sound='sound/misc/notice2.ogg', sender_override="Automated Lighting System Announcement") + else if(nightshift) + nightshift = FALSE + updatenightlights() + priority_announce("Good morning, crew. As it is now day time, all of the lights aboard the station have been restored to their former brightness.", sound='sound/misc/notice2.ogg', sender_override="Automated Lighting System Announcement") + +/datum/controller/subsystem/nightshift/proc/updatenightlights() + for(var/obj/machinery/light/nightlight in nightlights) + if(nightlight) + nightlight.update(FALSE) diff --git a/tgstation.dme b/tgstation.dme index 0731d28fa0..cebe192cc2 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -2503,6 +2503,7 @@ #include "modular_citadel\code\init.dm" #include "modular_citadel\code\__HELPERS\lists.dm" #include "modular_citadel\code\__HELPERS\mobs.dm" +#include "modular_citadel\code\controllers\subsystem\cit_nightshift.dm" #include "modular_citadel\code\controllers\subsystem\job.dm" #include "modular_citadel\code\controllers\subsystem\shuttle.dm" #include "modular_citadel\code\datums\uplink_items_cit.dm"