From 37dcd2ca5760bf9beb9502cb37986c923342d422 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 15:28:57 -0500 Subject: [PATCH 1/7] Rename code files with spaces in their name --- .../uplink/{devices and tools.dm => devices_and_tools.dm} | 0 .../ZAS/{Variable Settings.dm => VariableSettings.dm} | 0 .../keycard_authentication.dm | 0 nebula.dme | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename code/datums/uplink/{devices and tools.dm => devices_and_tools.dm} (100%) rename code/modules/ZAS/{Variable Settings.dm => VariableSettings.dm} (100%) rename code/modules/{security levels => security_levels}/keycard_authentication.dm (100%) diff --git a/code/datums/uplink/devices and tools.dm b/code/datums/uplink/devices_and_tools.dm similarity index 100% rename from code/datums/uplink/devices and tools.dm rename to code/datums/uplink/devices_and_tools.dm diff --git a/code/modules/ZAS/Variable Settings.dm b/code/modules/ZAS/VariableSettings.dm similarity index 100% rename from code/modules/ZAS/Variable Settings.dm rename to code/modules/ZAS/VariableSettings.dm diff --git a/code/modules/security levels/keycard_authentication.dm b/code/modules/security_levels/keycard_authentication.dm similarity index 100% rename from code/modules/security levels/keycard_authentication.dm rename to code/modules/security_levels/keycard_authentication.dm diff --git a/nebula.dme b/nebula.dme index c08cae0b5a9..2c7c6835f1d 100644 --- a/nebula.dme +++ b/nebula.dme @@ -693,7 +693,7 @@ #include "code\datums\underwear\underwear.dm" #include "code\datums\uplink\ammunition.dm" #include "code\datums\uplink\badassery.dm" -#include "code\datums\uplink\devices and tools.dm" +#include "code\datums\uplink\devices_and_tools.dm" #include "code\datums\uplink\grenades.dm" #include "code\datums\uplink\hardsuit_modules.dm" #include "code\datums\uplink\highly_visible_and_dangerous_weapons.dm" @@ -3738,7 +3738,7 @@ #include "code\modules\sealant_gun\sealant_injector.dm" #include "code\modules\sealant_gun\sealant_rack.dm" #include "code\modules\sealant_gun\sealant_tank.dm" -#include "code\modules\security levels\keycard_authentication.dm" +#include "code\modules\security_levels\keycard_authentication.dm" #include "code\modules\shield_generators\floor_diffuser.dm" #include "code\modules\shield_generators\handheld_diffuser.dm" #include "code\modules\shield_generators\modes.dm" @@ -4002,7 +4002,7 @@ #include "code\modules\ZAS\Diagnostic.dm" #include "code\modules\ZAS\Fire.dm" #include "code\modules\ZAS\Turf.dm" -#include "code\modules\ZAS\Variable Settings.dm" +#include "code\modules\ZAS\VariableSettings.dm" #include "code\modules\ZAS\Zone.dm" #include "code\procs\announce.dm" #include "code\procs\dbcore.dm" From 75945001df749d15895e349117e5269a09f477e6 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 15:31:08 -0500 Subject: [PATCH 2/7] Rename asset files with spaces in their path --- code/datums/music_tracks/europa.dm | 2 +- .../{Martian Cowboy.ogg => MartianCowboy.ogg} | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename sound/music/europa/{Martian Cowboy.ogg => MartianCowboy.ogg} (100%) diff --git a/code/datums/music_tracks/europa.dm b/code/datums/music_tracks/europa.dm index ccbc948eda0..b1b050118ba 100644 --- a/code/datums/music_tracks/europa.dm +++ b/code/datums/music_tracks/europa.dm @@ -8,7 +8,7 @@ /decl/music_track/martiancowboy artist = "Kevin MacLeod" title = "Martian Cowboy" - song = 'sound/music/europa/Martian Cowboy.ogg' + song = 'sound/music/europa/MartianCowboy.ogg' license = /decl/license/cc_by_3_0 url = "https://incompetech.com/music/royalty-free/index.html?isrc=usuan1100349" diff --git a/sound/music/europa/Martian Cowboy.ogg b/sound/music/europa/MartianCowboy.ogg similarity index 100% rename from sound/music/europa/Martian Cowboy.ogg rename to sound/music/europa/MartianCowboy.ogg From 570908975268471779955f45a8d8df346af19042 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 15:32:26 -0500 Subject: [PATCH 3/7] Move security levels into security levels module folder --- code/datums/security_state.dm | 335 ------------------ .../security_levels/_security_level.dm | 48 +++ .../security_levels/alarm_appearance.dm | 61 ++++ .../security_levels/security_levels.dm | 93 +++++ .../modules/security_levels/security_state.dm | 134 +++++++ nebula.dme | 5 +- 6 files changed, 340 insertions(+), 336 deletions(-) delete mode 100644 code/datums/security_state.dm create mode 100644 code/modules/security_levels/_security_level.dm create mode 100644 code/modules/security_levels/alarm_appearance.dm create mode 100644 code/modules/security_levels/security_levels.dm create mode 100644 code/modules/security_levels/security_state.dm diff --git a/code/datums/security_state.dm b/code/datums/security_state.dm deleted file mode 100644 index 1863d4ae860..00000000000 --- a/code/datums/security_state.dm +++ /dev/null @@ -1,335 +0,0 @@ -/decl/security_state - abstract_type = /decl/security_state - // When defining any of these values type paths should be used, not instances. Instances will be acquired in /New() - - var/decl/security_level/severe_security_level // At which security level (and higher) the use of nuclear fission devices and other extreme measures are allowed. Defaults to the last entry in all_security_levels if unset. - var/decl/security_level/high_security_level // At which security level (and higher) transfer votes are disabled, ERT may be requested, and other similar high alert implications. Defaults to the second to last entry in all_security_levels if unset. - // All security levels within the above convention: Low, Guarded, Elevated, High, Severe - - - // Under normal conditions the crew may not raise the current security level higher than the highest_standard_security_level - // The crew may also not adjust the security level once it is above the highest_standard_security_level. - // Defaults to the second to last entry in all_security_levels if unset/null. - // Set to FALSE/0 if there should be no restrictions. - var/decl/security_level/highest_standard_security_level - - var/decl/security_level/current_security_level // The current security level. Defaults to the first entry in all_security_levels if unset. - var/decl/security_level/stored_security_level // The security level that we are escalating to high security from - we will return to this level once we choose to revert. - var/list/all_security_levels // List of all available security levels - var/list/standard_security_levels // List of all normally selectable security levels - var/list/comm_console_security_levels // List of all selectable security levels for the command and communication console - basically standard_security_levels - 1 - -/decl/security_state/Initialize() - - . = ..() - - // Setup the severe security level - if(!(severe_security_level in all_security_levels)) - severe_security_level = all_security_levels[all_security_levels.len] - severe_security_level = GET_DECL(severe_security_level) - - // Setup the high security level - if(!(high_security_level in all_security_levels)) - high_security_level = all_security_levels[all_security_levels.len - 1] - high_security_level = GET_DECL(high_security_level) - - // Setup the highest standard security level - if(highest_standard_security_level || isnull(highest_standard_security_level)) - if(!(highest_standard_security_level in all_security_levels)) - highest_standard_security_level = all_security_levels[all_security_levels.len - 1] - highest_standard_security_level = GET_DECL(highest_standard_security_level) - else - highest_standard_security_level = null - - // Setup the current security level - if(current_security_level in all_security_levels) - current_security_level = GET_DECL(current_security_level) - else - current_security_level = GET_DECL(all_security_levels[1]) - - // Setup the full list of available security levels now that we no longer need to use "x in all_security_levels" - var/list/security_level_instances = list() - for(var/security_level_type in all_security_levels) - security_level_instances += GET_DECL(security_level_type) - all_security_levels = security_level_instances - - standard_security_levels = list() - // Setup the list of normally selectable security levels - for(var/security_level in all_security_levels) - standard_security_levels += security_level - if(security_level == highest_standard_security_level) - break - - comm_console_security_levels = list() - // Setup the list of selectable security levels available in the comm. console - for(var/security_level in all_security_levels) - if(security_level == highest_standard_security_level) - break - comm_console_security_levels += security_level - - // Now we ensure the high security level is not above the severe one (but we allow them to be equal) - var/severe_index = all_security_levels.Find(severe_security_level) - var/high_index = all_security_levels.Find(high_security_level) - if(high_index > severe_index) - high_security_level = severe_security_level - - // Finally switch up to the default starting security level. - current_security_level.switching_up_to() - -/decl/security_state/proc/can_change_security_level() - return current_security_level in standard_security_levels - -/decl/security_state/proc/can_switch_to(var/given_security_level) - if(!can_change_security_level()) - return FALSE - return given_security_level in standard_security_levels - -/decl/security_state/proc/current_security_level_is_lower_than(var/given_security_level) - var/current_index = all_security_levels.Find(current_security_level) - var/given_index = all_security_levels.Find(given_security_level) - - return given_index && current_index < given_index - -/decl/security_state/proc/current_security_level_is_same_or_higher_than(var/given_security_level) - var/current_index = all_security_levels.Find(current_security_level) - var/given_index = all_security_levels.Find(given_security_level) - - return given_index && current_index >= given_index - -/decl/security_state/proc/current_security_level_is_higher_than(var/given_security_level) - var/current_index = all_security_levels.Find(current_security_level) - var/given_index = all_security_levels.Find(given_security_level) - - return given_index && current_index > given_index - -/decl/security_state/proc/set_security_level(var/decl/security_level/new_security_level, var/force_change = FALSE) - if(new_security_level == current_security_level) - return FALSE - if(!(new_security_level in all_security_levels)) - return FALSE - if(!force_change && !can_switch_to(new_security_level)) - return FALSE - - var/decl/security_level/previous_security_level = current_security_level - current_security_level = new_security_level - - var/previous_index = all_security_levels.Find(previous_security_level) - var/new_index = all_security_levels.Find(new_security_level) - - if(new_index > previous_index) - previous_security_level.switching_up_from() - new_security_level.switching_up_to() - else - previous_security_level.switching_down_from() - new_security_level.switching_down_to() - - log_and_message_admins("has changed the security level from [previous_security_level.name] to [new_security_level.name].") - return TRUE - -// This proc decreases the current security level, if possible -/decl/security_state/proc/decrease_security_level(var/force_change = FALSE) - var/current_index = all_security_levels.Find(current_security_level) - if(current_index == 1) - return FALSE - return set_security_level(all_security_levels[current_index - 1], force_change) - -/decl/security_level - var/icon - var/name - - // These values are primarily for station alarms and status displays, and which light colors and overlays to use - var/light_range - var/light_power - var/light_color_alarm - var/light_color_class - var/light_color_status_display - - var/up_description - var/down_description - - var/datum/alarm_appearance/alarm_appearance - - abstract_type = /decl/security_level - -/decl/security_level/Initialize() - . = ..() - if(ispath(alarm_appearance, /datum/alarm_appearance)) - alarm_appearance = new alarm_appearance - -/decl/security_level/validate() - . = ..() - var/initial_appearance = initial(alarm_appearance) - if(!initial_appearance) - . += "alarm_appearance was not set" - else if(!ispath(initial_appearance)) - . += "alarm_appearance was not set to a /datum/alarm_appearance subpath" - else if(!istype(alarm_appearance, /datum/alarm_appearance)) - . += "alarm_appearance creation failed (check runtimes?)" - -// Called when we're switching from a lower security level to this one. -/decl/security_level/proc/switching_up_to() - return - -// Called when we're switching from a higher security level to this one. -/decl/security_level/proc/switching_down_to() - return - -// Called when we're switching from this security level to a higher one. -/decl/security_level/proc/switching_up_from() - return - -// Called when we're switching from this security level to a lower one. -/decl/security_level/proc/switching_down_from() - return - -/* -* The default security state and levels setup -*/ -/decl/security_state/default - all_security_levels = list(/decl/security_level/default/code_green, /decl/security_level/default/code_blue, /decl/security_level/default/code_red, /decl/security_level/default/code_delta) - -/decl/security_level/default - abstract_type = /decl/security_level/default - icon = 'icons/misc/security_state.dmi' - - var/static/datum/announcement/priority/security/security_announcement_up = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) - var/static/datum/announcement/priority/security/security_announcement_down = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) - -/decl/security_level/default/switching_up_to() - if(up_description) - security_announcement_up.Announce(up_description, "Attention! Alert level elevated to [name]!") - notify_station() - -/decl/security_level/default/switching_down_to() - if(down_description) - security_announcement_down.Announce(down_description, "Attention! Alert level changed to [name]!") - notify_station() - -/decl/security_level/default/proc/notify_station() - for(var/obj/machinery/firealarm/FA in SSmachines.machinery) - if(isContactLevel(FA.z)) - FA.update_icon() - post_status("alert") - -/decl/security_level/default/code_green - name = "code green" - - light_range = 2 - light_power = 1 - - light_color_alarm = COLOR_GREEN - light_color_class = "font_green" - light_color_status_display = COLOR_GREEN - - - alarm_appearance = /datum/alarm_appearance/green - - down_description = "All threats to the station have passed. Security may not have weapons visible, privacy laws are once again fully enforced." - -/decl/security_level/default/code_blue - name = "code blue" - - light_range = 2 - light_power = 1 - light_color_alarm = COLOR_BLUE - light_color_class = "font_blue" - light_color_status_display = COLOR_BLUE - - alarm_appearance = /datum/alarm_appearance/blue - - up_description = "The station has received reliable information about possible hostile activity on the station. Security staff may have weapons visible, random searches are permitted." - down_description = "The immediate threat has passed. Security may no longer have weapons drawn at all times, but may continue to have them visible. Random searches are still allowed." - -/decl/security_level/default/code_red - name = "code red" - - light_range = 4 - light_power = 2 - light_color_alarm = COLOR_RED - light_color_class = "font_red" - light_color_status_display = COLOR_RED - - alarm_appearance = /datum/alarm_appearance/red - - up_description = "There is an immediate serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised." - down_description = "The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised." - -/decl/security_level/default/code_delta - name = "code delta" - - light_range = 4 - light_power = 2 - light_color_alarm = COLOR_RED - light_color_class = "font_red" - light_color_status_display = COLOR_RED - - alarm_appearance = /datum/alarm_appearance/delta - - - var/static/datum/announcement/priority/security/security_announcement_delta = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/effects/siren.ogg')) - -/decl/security_level/default/code_delta/switching_up_to() - security_announcement_delta.Announce("The self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.", "Attention! Delta security level reached!") - notify_station() - -/datum/alarm_appearance - var/display_icon //The icon_state for the displays. Normally only one is used, unless uses_twotone_displays is TRUE. - var/display_icon_color //The color for the display icon. - - var/display_icon_twotone //Used for two-tone displays. - var/display_icon_twotone_color //The color for the display icon. - - var/display_emblem //The icon_state for the emblem, i.e for delta, a radstorm, alerts. - var/display_emblem_color //The color for the emblem. - - var/alarm_icon //The icon_state for the alarms - var/alarm_icon_color //the color for the icon_state - - var/alarm_icon_twotone //Used for two-tone alarms (i.e delta). - var/alarm_icon_twotone_color //The color for the secondary tone icon. - -/datum/alarm_appearance/green - display_icon = "status_display_lines" - display_icon_color = PIPE_COLOR_GREEN - - display_emblem = "status_display_alert" - display_emblem_color = COLOR_WHITE - - alarm_icon = "alarm_normal" - alarm_icon_color = PIPE_COLOR_GREEN - -/datum/alarm_appearance/blue - display_icon = "status_display_lines" - display_icon_color = COLOR_BLUE - - display_emblem = "status_display_alert" - display_emblem_color = COLOR_WHITE - - alarm_icon = "alarm_normal" - alarm_icon_color = COLOR_BLUE - -/datum/alarm_appearance/red - display_icon = "status_display_lines" - display_icon_color = COLOR_RED - - display_emblem = "status_display_alert" - display_emblem_color = COLOR_WHITE - - alarm_icon = "alarm_blinking" - alarm_icon_color = COLOR_RED - -/datum/alarm_appearance/delta - display_icon = "status_display_twotone1" - display_icon_color = COLOR_RED - - display_icon_twotone = "status_display_twotone2" - display_icon_twotone_color = COLOR_YELLOW - - display_emblem = "delta" - display_emblem_color = COLOR_WHITE - - alarm_icon = "alarm_blinking_twotone1" - alarm_icon_color = COLOR_RED - - alarm_icon_twotone = "alarm_blinking_twotone2" - alarm_icon_twotone_color = PIPE_COLOR_YELLOW \ No newline at end of file diff --git a/code/modules/security_levels/_security_level.dm b/code/modules/security_levels/_security_level.dm new file mode 100644 index 00000000000..ea9d88b442a --- /dev/null +++ b/code/modules/security_levels/_security_level.dm @@ -0,0 +1,48 @@ +/decl/security_level + var/icon + var/name + + // These values are primarily for station alarms and status displays, and which light colors and overlays to use + var/light_range + var/light_power + var/light_color_alarm + var/light_color_class + var/light_color_status_display + + var/up_description + var/down_description + + var/datum/alarm_appearance/alarm_appearance + + abstract_type = /decl/security_level + +/decl/security_level/Initialize() + . = ..() + if(ispath(alarm_appearance, /datum/alarm_appearance)) + alarm_appearance = new alarm_appearance + +/decl/security_level/validate() + . = ..() + var/initial_appearance = initial(alarm_appearance) + if(!initial_appearance) + . += "alarm_appearance was not set" + else if(!ispath(initial_appearance)) + . += "alarm_appearance was not set to a /datum/alarm_appearance subpath" + else if(!istype(alarm_appearance, /datum/alarm_appearance)) + . += "alarm_appearance creation failed (check runtimes?)" + +// Called when we're switching from a lower security level to this one. +/decl/security_level/proc/switching_up_to() + return + +// Called when we're switching from a higher security level to this one. +/decl/security_level/proc/switching_down_to() + return + +// Called when we're switching from this security level to a higher one. +/decl/security_level/proc/switching_up_from() + return + +// Called when we're switching from this security level to a lower one. +/decl/security_level/proc/switching_down_from() + return \ No newline at end of file diff --git a/code/modules/security_levels/alarm_appearance.dm b/code/modules/security_levels/alarm_appearance.dm new file mode 100644 index 00000000000..494158a6039 --- /dev/null +++ b/code/modules/security_levels/alarm_appearance.dm @@ -0,0 +1,61 @@ +/datum/alarm_appearance + var/display_icon //The icon_state for the displays. Normally only one is used, unless uses_twotone_displays is TRUE. + var/display_icon_color //The color for the display icon. + + var/display_icon_twotone //Used for two-tone displays. + var/display_icon_twotone_color //The color for the display icon. + + var/display_emblem //The icon_state for the emblem, i.e for delta, a radstorm, alerts. + var/display_emblem_color //The color for the emblem. + + var/alarm_icon //The icon_state for the alarms + var/alarm_icon_color //the color for the icon_state + + var/alarm_icon_twotone //Used for two-tone alarms (i.e delta). + var/alarm_icon_twotone_color //The color for the secondary tone icon. + +/datum/alarm_appearance/green + display_icon = "status_display_lines" + display_icon_color = PIPE_COLOR_GREEN + + display_emblem = "status_display_alert" + display_emblem_color = COLOR_WHITE + + alarm_icon = "alarm_normal" + alarm_icon_color = PIPE_COLOR_GREEN + +/datum/alarm_appearance/blue + display_icon = "status_display_lines" + display_icon_color = COLOR_BLUE + + display_emblem = "status_display_alert" + display_emblem_color = COLOR_WHITE + + alarm_icon = "alarm_normal" + alarm_icon_color = COLOR_BLUE + +/datum/alarm_appearance/red + display_icon = "status_display_lines" + display_icon_color = COLOR_RED + + display_emblem = "status_display_alert" + display_emblem_color = COLOR_WHITE + + alarm_icon = "alarm_blinking" + alarm_icon_color = COLOR_RED + +/datum/alarm_appearance/delta + display_icon = "status_display_twotone1" + display_icon_color = COLOR_RED + + display_icon_twotone = "status_display_twotone2" + display_icon_twotone_color = COLOR_YELLOW + + display_emblem = "delta" + display_emblem_color = COLOR_WHITE + + alarm_icon = "alarm_blinking_twotone1" + alarm_icon_color = COLOR_RED + + alarm_icon_twotone = "alarm_blinking_twotone2" + alarm_icon_twotone_color = PIPE_COLOR_YELLOW \ No newline at end of file diff --git a/code/modules/security_levels/security_levels.dm b/code/modules/security_levels/security_levels.dm new file mode 100644 index 00000000000..a1825bd9be8 --- /dev/null +++ b/code/modules/security_levels/security_levels.dm @@ -0,0 +1,93 @@ +/// The default security state used on most space maps. +/decl/security_state/default + all_security_levels = list( + /decl/security_level/default/code_green, + /decl/security_level/default/code_blue, + /decl/security_level/default/code_red, + /decl/security_level/default/code_delta + ) + +/// An abstract security level type that supports announcements on level change. +/decl/security_level/default + abstract_type = /decl/security_level/default + icon = 'icons/misc/security_state.dmi' + + var/static/datum/announcement/priority/security/security_announcement_up = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) + var/static/datum/announcement/priority/security/security_announcement_down = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) + +/decl/security_level/default/switching_up_to() + if(up_description) + security_announcement_up.Announce(up_description, "Attention! Alert level elevated to [name]!") + notify_station() + +/decl/security_level/default/switching_down_to() + if(down_description) + security_announcement_down.Announce(down_description, "Attention! Alert level changed to [name]!") + notify_station() + +/decl/security_level/default/proc/notify_station() + for(var/obj/machinery/firealarm/FA in SSmachines.machinery) + if(isContactLevel(FA.z)) + FA.update_icon() + post_status("alert") + +/decl/security_level/default/code_green + name = "code green" + + light_range = 2 + light_power = 1 + + light_color_alarm = COLOR_GREEN + light_color_class = "font_green" + light_color_status_display = COLOR_GREEN + + + alarm_appearance = /datum/alarm_appearance/green + + down_description = "All threats to the station have passed. Security may not have weapons visible, privacy laws are once again fully enforced." + +/decl/security_level/default/code_blue + name = "code blue" + + light_range = 2 + light_power = 1 + light_color_alarm = COLOR_BLUE + light_color_class = "font_blue" + light_color_status_display = COLOR_BLUE + + alarm_appearance = /datum/alarm_appearance/blue + + up_description = "The station has received reliable information about possible hostile activity on the station. Security staff may have weapons visible, random searches are permitted." + down_description = "The immediate threat has passed. Security may no longer have weapons drawn at all times, but may continue to have them visible. Random searches are still allowed." + +/decl/security_level/default/code_red + name = "code red" + + light_range = 4 + light_power = 2 + light_color_alarm = COLOR_RED + light_color_class = "font_red" + light_color_status_display = COLOR_RED + + alarm_appearance = /datum/alarm_appearance/red + + up_description = "There is an immediate serious threat to the station. Security may have weapons unholstered at all times. Random searches are allowed and advised." + down_description = "The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised." + +/decl/security_level/default/code_delta + name = "code delta" + + light_range = 4 + light_power = 2 + light_color_alarm = COLOR_RED + light_color_class = "font_red" + light_color_status_display = COLOR_RED + + alarm_appearance = /datum/alarm_appearance/delta + + + var/static/datum/announcement/priority/security/security_announcement_delta = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/effects/siren.ogg')) + +/decl/security_level/default/code_delta/switching_up_to() + security_announcement_delta.Announce("The self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.", "Attention! Delta security level reached!") + notify_station() \ No newline at end of file diff --git a/code/modules/security_levels/security_state.dm b/code/modules/security_levels/security_state.dm new file mode 100644 index 00000000000..0f115f8c57b --- /dev/null +++ b/code/modules/security_levels/security_state.dm @@ -0,0 +1,134 @@ +/decl/security_state + abstract_type = /decl/security_state + // When defining any of these values type paths should be used, not instances. Instances will be acquired in /New() + + var/decl/security_level/severe_security_level // At which security level (and higher) the use of nuclear fission devices and other extreme measures are allowed. Defaults to the last entry in all_security_levels if unset. + var/decl/security_level/high_security_level // At which security level (and higher) transfer votes are disabled, ERT may be requested, and other similar high alert implications. Defaults to the second to last entry in all_security_levels if unset. + // All security levels within the above convention: Low, Guarded, Elevated, High, Severe + + + // Under normal conditions the crew may not raise the current security level higher than the highest_standard_security_level + // The crew may also not adjust the security level once it is above the highest_standard_security_level. + // Defaults to the second to last entry in all_security_levels if unset/null. + // Set to FALSE/0 if there should be no restrictions. + var/decl/security_level/highest_standard_security_level + + var/decl/security_level/current_security_level // The current security level. Defaults to the first entry in all_security_levels if unset. + var/decl/security_level/stored_security_level // The security level that we are escalating to high security from - we will return to this level once we choose to revert. + var/list/all_security_levels // List of all available security levels + var/list/standard_security_levels // List of all normally selectable security levels + var/list/comm_console_security_levels // List of all selectable security levels for the command and communication console - basically standard_security_levels - 1 + +/decl/security_state/Initialize() + + . = ..() + + // Setup the severe security level + if(!(severe_security_level in all_security_levels)) + severe_security_level = all_security_levels[all_security_levels.len] + severe_security_level = GET_DECL(severe_security_level) + + // Setup the high security level + if(!(high_security_level in all_security_levels)) + high_security_level = all_security_levels[all_security_levels.len - 1] + high_security_level = GET_DECL(high_security_level) + + // Setup the highest standard security level + if(highest_standard_security_level || isnull(highest_standard_security_level)) + if(!(highest_standard_security_level in all_security_levels)) + highest_standard_security_level = all_security_levels[all_security_levels.len - 1] + highest_standard_security_level = GET_DECL(highest_standard_security_level) + else + highest_standard_security_level = null + + // Setup the current security level + if(current_security_level in all_security_levels) + current_security_level = GET_DECL(current_security_level) + else + current_security_level = GET_DECL(all_security_levels[1]) + + // Setup the full list of available security levels now that we no longer need to use "x in all_security_levels" + var/list/security_level_instances = list() + for(var/security_level_type in all_security_levels) + security_level_instances += GET_DECL(security_level_type) + all_security_levels = security_level_instances + + standard_security_levels = list() + // Setup the list of normally selectable security levels + for(var/security_level in all_security_levels) + standard_security_levels += security_level + if(security_level == highest_standard_security_level) + break + + comm_console_security_levels = list() + // Setup the list of selectable security levels available in the comm. console + for(var/security_level in all_security_levels) + if(security_level == highest_standard_security_level) + break + comm_console_security_levels += security_level + + // Now we ensure the high security level is not above the severe one (but we allow them to be equal) + var/severe_index = all_security_levels.Find(severe_security_level) + var/high_index = all_security_levels.Find(high_security_level) + if(high_index > severe_index) + high_security_level = severe_security_level + + // Finally switch up to the default starting security level. + current_security_level.switching_up_to() + +/decl/security_state/proc/can_change_security_level() + return current_security_level in standard_security_levels + +/decl/security_state/proc/can_switch_to(var/given_security_level) + if(!can_change_security_level()) + return FALSE + return given_security_level in standard_security_levels + +/decl/security_state/proc/current_security_level_is_lower_than(var/given_security_level) + var/current_index = all_security_levels.Find(current_security_level) + var/given_index = all_security_levels.Find(given_security_level) + + return given_index && current_index < given_index + +/decl/security_state/proc/current_security_level_is_same_or_higher_than(var/given_security_level) + var/current_index = all_security_levels.Find(current_security_level) + var/given_index = all_security_levels.Find(given_security_level) + + return given_index && current_index >= given_index + +/decl/security_state/proc/current_security_level_is_higher_than(var/given_security_level) + var/current_index = all_security_levels.Find(current_security_level) + var/given_index = all_security_levels.Find(given_security_level) + + return given_index && current_index > given_index + +/decl/security_state/proc/set_security_level(var/decl/security_level/new_security_level, var/force_change = FALSE) + if(new_security_level == current_security_level) + return FALSE + if(!(new_security_level in all_security_levels)) + return FALSE + if(!force_change && !can_switch_to(new_security_level)) + return FALSE + + var/decl/security_level/previous_security_level = current_security_level + current_security_level = new_security_level + + var/previous_index = all_security_levels.Find(previous_security_level) + var/new_index = all_security_levels.Find(new_security_level) + + if(new_index > previous_index) + previous_security_level.switching_up_from() + new_security_level.switching_up_to() + else + previous_security_level.switching_down_from() + new_security_level.switching_down_to() + + log_and_message_admins("has changed the security level from [previous_security_level.name] to [new_security_level.name].") + return TRUE + +// This proc decreases the current security level, if possible +/decl/security_state/proc/decrease_security_level(var/force_change = FALSE) + var/current_index = all_security_levels.Find(current_security_level) + if(current_index == 1) + return FALSE + return set_security_level(all_security_levels[current_index - 1], force_change) diff --git a/nebula.dme b/nebula.dme index 2c7c6835f1d..324850fd28f 100644 --- a/nebula.dme +++ b/nebula.dme @@ -349,7 +349,6 @@ #include "code\datums\mutable_appearance.dm" #include "code\datums\position_point_vector.dm" #include "code\datums\progressbar.dm" -#include "code\datums\security_state.dm" #include "code\datums\sound_player.dm" #include "code\datums\suit_sensor_jammer_method.dm" #include "code\datums\sun.dm" @@ -3738,7 +3737,11 @@ #include "code\modules\sealant_gun\sealant_injector.dm" #include "code\modules\sealant_gun\sealant_rack.dm" #include "code\modules\sealant_gun\sealant_tank.dm" +#include "code\modules\security_levels\_security_level.dm" +#include "code\modules\security_levels\alarm_appearance.dm" #include "code\modules\security_levels\keycard_authentication.dm" +#include "code\modules\security_levels\security_levels.dm" +#include "code\modules\security_levels\security_state.dm" #include "code\modules\shield_generators\floor_diffuser.dm" #include "code\modules\shield_generators\handheld_diffuser.dm" #include "code\modules\shield_generators\modes.dm" From 62365c50efa42f0ea827451b37984ca6ac6228de Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 19:22:27 -0500 Subject: [PATCH 4/7] Disable security state on Shaded Hills --- code/modules/mob/new_player/login.dm | 11 +++++------ code/modules/security_levels/_security_level.dm | 2 +- code/modules/security_levels/security_levels.dm | 16 ++++++++++++++-- code/modules/security_levels/security_state.dm | 2 ++ maps/shaded_hills/shaded_hills_define.dm | 1 + 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/code/modules/mob/new_player/login.dm b/code/modules/mob/new_player/login.dm index 6951ec383e3..6c3a0d04ada 100644 --- a/code/modules/mob/new_player/login.dm +++ b/code/modules/mob/new_player/login.dm @@ -36,12 +36,11 @@ show_lobby_menu(TRUE) var/decl/security_state/security_state = GET_DECL(global.using_map.security_state) - var/decl/security_level/SL = security_state.current_security_level - var/alert_desc = "" - if(SL.up_description) - alert_desc = SL.up_description - - to_chat(src, SPAN_NOTICE("The alert level on the [station_name()] is currently: [SL.name]. [alert_desc]")) + if(security_state?.show_on_login) + var/decl/security_level/SL = security_state.current_security_level + // todo: allow maps to oevrride this string for things like the fantasy map being on high alert? + // eg "The alert level *in* Karzerfeste Keep is currently high alert." or "Karzerfeste Keep is currently on high alert." + to_chat(src, SPAN_NOTICE("The alert level on the [station_name()] is currently: [SL.name]. [SL?.up_description]")) // bolds the changelog button on the interface so we know there are updates. if(client.prefs?.lastchangelog != global.changelog_hash) diff --git a/code/modules/security_levels/_security_level.dm b/code/modules/security_levels/_security_level.dm index ea9d88b442a..ca4ba811c82 100644 --- a/code/modules/security_levels/_security_level.dm +++ b/code/modules/security_levels/_security_level.dm @@ -1,5 +1,5 @@ /decl/security_level - var/icon + var/icon = 'icons/misc/security_state.dmi' var/name // These values are primarily for station alarms and status displays, and which light colors and overlays to use diff --git a/code/modules/security_levels/security_levels.dm b/code/modules/security_levels/security_levels.dm index a1825bd9be8..186fd37fbbe 100644 --- a/code/modules/security_levels/security_levels.dm +++ b/code/modules/security_levels/security_levels.dm @@ -10,7 +10,6 @@ /// An abstract security level type that supports announcements on level change. /decl/security_level/default abstract_type = /decl/security_level/default - icon = 'icons/misc/security_state.dmi' var/static/datum/announcement/priority/security/security_announcement_up = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) var/static/datum/announcement/priority/security/security_announcement_down = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/misc/notice1.ogg')) @@ -90,4 +89,17 @@ /decl/security_level/default/code_delta/switching_up_to() security_announcement_delta.Announce("The self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.", "Attention! Delta security level reached!") - notify_station() \ No newline at end of file + notify_station() + +// The following are dummy states and levels to soft-disable security levels on some maps. +/// A security state used for maps that don't have security levels exposed to players. +/decl/security_state/none + all_security_levels = list( + /decl/security_level/none + ) + +/// A dummy security level with no effects. +/decl/security_level/none + name = "none" + // Since currently we're required to have an alarm_appearance, we just use a blank one. + alarm_appearance = /datum/alarm_appearance \ No newline at end of file diff --git a/code/modules/security_levels/security_state.dm b/code/modules/security_levels/security_state.dm index 0f115f8c57b..dfc0c78a94c 100644 --- a/code/modules/security_levels/security_state.dm +++ b/code/modules/security_levels/security_state.dm @@ -1,5 +1,7 @@ /decl/security_state abstract_type = /decl/security_state + /// Whether or not security level information should be shown to new players on login. + var/show_on_login = TRUE // When defining any of these values type paths should be used, not instances. Instances will be acquired in /New() var/decl/security_level/severe_security_level // At which security level (and higher) the use of nuclear fission devices and other extreme measures are allowed. Defaults to the last entry in all_security_levels if unset. diff --git a/maps/shaded_hills/shaded_hills_define.dm b/maps/shaded_hills/shaded_hills_define.dm index 757f9948826..6266ab2a09e 100644 --- a/maps/shaded_hills/shaded_hills_define.dm +++ b/maps/shaded_hills/shaded_hills_define.dm @@ -31,6 +31,7 @@ 'sound/music/Miris-Magic-Dance.ogg' ) game_year = -914 // in 2024, the year should be 1110, roughly a century after the fall of the Imperial Aegis + security_state = /decl/security_state/none char_preview_bgstate_options = list( "000", From 8be56cccfa49f3810e4571435ccd64ddeeea0d49 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 19:44:04 -0500 Subject: [PATCH 5/7] Move inertial dampener into a modpack --- code/datums/supplypacks/engineering.dm | 7 --- code/modules/events/event_container.dm | 1 - .../imprinter/designs_misc_circuits.dm | 3 -- .../overmap/ships/computers/engine_control.dm | 23 ++++++--- code/modules/overmap/ships/ship.dm | 19 -------- maps/modpack_testing/modpack_testing.dm | 1 + mods/content/inertia/_inertia.dm | 3 ++ mods/content/inertia/_inertia.dme | 13 ++++++ .../content/inertia/fabrication.dm | 5 +- .../inertia/icons}/inertial_damper.dmi | Bin mods/content/inertia/inertia_controller.dm | 24 ++++++++++ .../content/inertia/inertia_failure.dm | 11 +++++ .../content/inertia}/inertial_damper.dm | 35 ++++---------- mods/content/inertia/ship_inertia.dm | 44 ++++++++++++++++++ mods/content/inertia/supplies.dm | 6 +++ .../content/inertia/wires.dm | 9 ++-- nebula.dme | 4 -- 17 files changed, 135 insertions(+), 73 deletions(-) create mode 100644 mods/content/inertia/_inertia.dm create mode 100644 mods/content/inertia/_inertia.dme rename code/game/objects/items/weapons/circuitboards/machinery/inertial_damper.dm => mods/content/inertia/fabrication.dm (80%) rename {icons/obj/machines => mods/content/inertia/icons}/inertial_damper.dmi (100%) create mode 100644 mods/content/inertia/inertia_controller.dm rename code/modules/events/inertial_damper.dm => mods/content/inertia/inertia_failure.dm (78%) rename {code/modules/inertial_damper => mods/content/inertia}/inertial_damper.dm (88%) create mode 100644 mods/content/inertia/ship_inertia.dm create mode 100644 mods/content/inertia/supplies.dm rename code/datums/wires/inertial_damper.dm => mods/content/inertia/wires.dm (71%) diff --git a/code/datums/supplypacks/engineering.dm b/code/datums/supplypacks/engineering.dm index 91b8006a194..3c771acd1e4 100644 --- a/code/datums/supplypacks/engineering.dm +++ b/code/datums/supplypacks/engineering.dm @@ -155,13 +155,6 @@ containername = "shield generator construction kit crate" access = access_engine -/decl/hierarchy/supply_pack/engineering/inertial_damper - name = "Equipment - inertial damper construction kit" - contains = list(/obj/item/stock_parts/circuitboard/inertial_damper, /obj/item/stock_parts/capacitor, /obj/item/stock_parts/micro_laser, /obj/item/stock_parts/console_screen) - containertype = /obj/structure/closet/crate/secure - containername = "inertial damper construction kit crate" - access = access_engine - /decl/hierarchy/supply_pack/engineering/smbig name = "Power - Supermatter core" contains = list(/obj/machinery/power/supermatter) diff --git a/code/modules/events/event_container.dm b/code/modules/events/event_container.dm index 97dc8f97f3f..2e0256a4706 100644 --- a/code/modules/events/event_container.dm +++ b/code/modules/events/event_container.dm @@ -157,7 +157,6 @@ var/global/list/severity_to_string = list(EVENT_LEVEL_MUNDANE = "Mundane", EVENT new /datum/event_meta/no_overmap(EVENT_LEVEL_MODERATE, "Electrical Storm", /datum/event/electrical_storm, 10, list(ASSIGNMENT_ENGINEER = 15, ASSIGNMENT_JANITOR = 10)), new /datum/event_meta(EVENT_LEVEL_MODERATE, "Gravity Failure", /datum/event/gravity, 75, list(ASSIGNMENT_ENGINEER = 25)), new /datum/event_meta(EVENT_LEVEL_MODERATE, "Grid Check", /datum/event/grid_check, 200, list(ASSIGNMENT_ENGINEER = 10)), - new /datum/event_meta(EVENT_LEVEL_MODERATE, "Inertial Damper Recalibration", /datum/event/inertial_damper, 75, list(ASSIGNMENT_ENGINEER = 25)), new /datum/event_meta/no_overmap(EVENT_LEVEL_MODERATE, "Ion Storm", /datum/event/ionstorm, 0, list(ASSIGNMENT_COMPUTER = 50, ASSIGNMENT_ROBOT = 50, ASSIGNMENT_ENGINEER = 15, ASSIGNMENT_SCIENTIST = 5)), new /datum/event_meta/no_overmap(EVENT_LEVEL_MODERATE, "Meteor Shower", /datum/event/meteor_wave, 0, list(ASSIGNMENT_ENGINEER = 20)), new /datum/event_meta(EVENT_LEVEL_MODERATE, "Prison Break", /datum/event/prison_break, 0, list(ASSIGNMENT_SECURITY = 100)), diff --git a/code/modules/fabrication/designs/imprinter/designs_misc_circuits.dm b/code/modules/fabrication/designs/imprinter/designs_misc_circuits.dm index c817352197f..44f481a550c 100644 --- a/code/modules/fabrication/designs/imprinter/designs_misc_circuits.dm +++ b/code/modules/fabrication/designs/imprinter/designs_misc_circuits.dm @@ -467,9 +467,6 @@ /datum/fabricator_recipe/imprinter/circuit/long_range_relay path = /obj/item/stock_parts/circuitboard/relay/long_range -/datum/fabricator_recipe/imprinter/circuit/inertial_damper - path = /obj/item/stock_parts/circuitboard/inertial_damper - /datum/fabricator_recipe/imprinter/circuit/docking_beacon path = /obj/item/stock_parts/circuitboard/docking_beacon diff --git a/code/modules/overmap/ships/computers/engine_control.dm b/code/modules/overmap/ships/computers/engine_control.dm index a62b7258705..f7f37fcb346 100644 --- a/code/modules/overmap/ships/computers/engine_control.dm +++ b/code/modules/overmap/ships/computers/engine_control.dm @@ -6,6 +6,21 @@ icon_screen = "engines" var/display_state = "status" +/// A stub used for modpacks to modify per-ship readout information. +/// This mutates the UI data list, so it can be used to mask or remove features +/// as well as to add entirely new ones. +/// It does not return a value. +/// While it can access per-engine data, it should be dispreferred for that compared to modify_engine_ui_data(). +/obj/machinery/computer/ship/engines/proc/modify_ship_ui_data(list/ui_data) + return + +/// A stub used for modpacks to modify per-engine readout information. +/// This mutates the engine's data list, so it can be used to mask or remove features +/// as well as to add entirely new ones. +/// It does not return a value. +/obj/machinery/computer/ship/engines/proc/modify_engine_ui_data(datum/extension/ship_engine/engine, list/engine_data) + return + /obj/machinery/computer/ship/engines/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) if(!linked) display_reconnect_dialog(user, "ship control systems") @@ -29,17 +44,13 @@ var/thrust = E.get_exhaust_velocity() total_thrust += thrust rdata["eng_thrust"] = "[thrust] m/s" + modify_engine_ui_data(E, rdata) enginfo.Add(list(rdata)) data["engines_info"] = enginfo data["total_thrust"] = "[total_thrust] m/s" - var/damping_strength = 0 - for(var/datum/ship_inertial_damper/I in linked.inertial_dampers) - var/obj/machinery/inertial_damper/ID = I.holder - damping_strength += ID.get_damping_strength(FALSE) - data["damping_strength"] = damping_strength - data["needs_dampers"] = linked.needs_dampers + modify_ship_ui_data(data) ui = SSnano.try_update_ui(user, src, ui_key, ui, data, force_open) if (!ui) diff --git a/code/modules/overmap/ships/ship.dm b/code/modules/overmap/ships/ship.dm index f4f1a734c88..133c506ffa6 100644 --- a/code/modules/overmap/ships/ship.dm +++ b/code/modules/overmap/ships/ship.dm @@ -19,9 +19,6 @@ var/global/const/OVERMAP_SPEED_CONSTANT = (1 SECOND) var/skill_needed = SKILL_ADEPT //piloting skill needed to steer it without going in random dir var/operator_skill - var/needs_dampers = FALSE - var/list/inertial_dampers = list() - var/damping_strength = null var/vessel_size = SHIP_SIZE_LARGE // arbitrary number, affects how likely are we to evade meteors var/list/navigation_viewers // list of weakrefs to people viewing the overmap via this ship @@ -85,15 +82,6 @@ var/global/const/OVERMAP_SPEED_CONSTANT = (1 SECOND) /obj/effect/overmap/visitable/ship/adjust_speed(n_x, n_y) . = ..() - var/magnitude = norm(n_x, n_y) - var/inertia_dir = magnitude >= 0 ? turn(fore_dir, 180) : fore_dir - var/inertia_strength = magnitude * 1e3 - if(needs_dampers && damping_strength < inertia_strength) - var/list/areas_by_name = area_repository.get_areas_by_z_level() - for(var/area_name in areas_by_name) - var/area/A = areas_by_name[area_name] - if(area_belongs_to_zlevels(A, map_z)) - A.throw_unbuckled_occupants(inertia_strength+2, inertia_strength, inertia_dir) for(var/zz in map_z) if(is_still()) toggle_move_stars(zz) @@ -119,10 +107,6 @@ var/global/const/OVERMAP_SPEED_CONSTANT = (1 SECOND) return round(num_burns / burns_per_grid) /obj/effect/overmap/visitable/ship/Process(wait, tick) - damping_strength = 0 - for(var/datum/ship_inertial_damper/I in inertial_dampers) - var/obj/machinery/inertial_damper/ID = I.holder - damping_strength += ID.get_damping_strength(TRUE) sensor_visibility = min(round(base_sensor_visibility + get_speed_sensor_increase(), 1), 100) /obj/effect/overmap/visitable/ship/on_update_icon() @@ -181,9 +165,6 @@ var/global/const/OVERMAP_SPEED_CONSTANT = (1 SECOND) for(var/datum/extension/ship_engine/E in global.ship_engines) if(check_ownership(E.holder)) engines |= E - for(var/datum/ship_inertial_damper/I in global.ship_inertial_dampers) - if(check_ownership(I.holder)) - inertial_dampers |= I var/v_mass = recalculate_vessel_mass() if(v_mass) vessel_mass = v_mass diff --git a/maps/modpack_testing/modpack_testing.dm b/maps/modpack_testing/modpack_testing.dm index de68e49bc7b..f94fbbc844c 100644 --- a/maps/modpack_testing/modpack_testing.dm +++ b/maps/modpack_testing/modpack_testing.dm @@ -29,6 +29,7 @@ #include "../../mods/content/pheromones/_pheromones.dme" #include "../../mods/species/drakes/_drakes.dme" // include before _fantasy.dme so overrides work #include "../../mods/content/fantasy/_fantasy.dme" + #include "../../mods/content/inertia/_inertia.dme" #include "../../mods/mobs/dionaea/_dionaea.dme" #include "../../mods/mobs/borers/_borers.dme" diff --git a/mods/content/inertia/_inertia.dm b/mods/content/inertia/_inertia.dm new file mode 100644 index 00000000000..97bee4de9a0 --- /dev/null +++ b/mods/content/inertia/_inertia.dm @@ -0,0 +1,3 @@ +/decl/modpack/inertia + name = "Ship Inertia Content" + desc = "This modpack adds support for inertia (throwing unsecured mobs) when ship thrusters fire, and adds an inertial dampener machine to counteract this." \ No newline at end of file diff --git a/mods/content/inertia/_inertia.dme b/mods/content/inertia/_inertia.dme new file mode 100644 index 00000000000..2407851eca3 --- /dev/null +++ b/mods/content/inertia/_inertia.dme @@ -0,0 +1,13 @@ +#ifndef MODPACK_SHIP_INERTIA +#define MODPACK_SHIP_INERTIA +// BEGIN_INCLUDE +#include "_inertia.dm" +#include "fabrication.dm" +#include "inertia_controller.dm" +#include "inertia_failure.dm" +#include "inertial_damper.dm" +#include "ship_inertia.dm" +#include "supplies.dm" +#include "wires.dm" +// END_INCLUDE +#endif diff --git a/code/game/objects/items/weapons/circuitboards/machinery/inertial_damper.dm b/mods/content/inertia/fabrication.dm similarity index 80% rename from code/game/objects/items/weapons/circuitboards/machinery/inertial_damper.dm rename to mods/content/inertia/fabrication.dm index 3bf3f65219e..72a1837b513 100644 --- a/code/game/objects/items/weapons/circuitboards/machinery/inertial_damper.dm +++ b/mods/content/inertia/fabrication.dm @@ -10,4 +10,7 @@ /obj/item/stock_parts/console_screen = 1, /obj/item/stock_parts/keyboard = 1, /obj/item/stock_parts/power/apc/buildable = 1 - ) \ No newline at end of file + ) + +/datum/fabricator_recipe/imprinter/circuit/inertial_damper + path = /obj/item/stock_parts/circuitboard/inertial_damper diff --git a/icons/obj/machines/inertial_damper.dmi b/mods/content/inertia/icons/inertial_damper.dmi similarity index 100% rename from icons/obj/machines/inertial_damper.dmi rename to mods/content/inertia/icons/inertial_damper.dmi diff --git a/mods/content/inertia/inertia_controller.dm b/mods/content/inertia/inertia_controller.dm new file mode 100644 index 00000000000..6b020a67b60 --- /dev/null +++ b/mods/content/inertia/inertia_controller.dm @@ -0,0 +1,24 @@ +/// A list of all inertial dampers in existence. This is only used for assigning them to ships at roundstart. +var/global/list/ship_inertial_dampers = list() + +/datum/ship_inertial_damper + var/name = "ship inertial damper" + var/obj/machinery/holder + +/datum/ship_inertial_damper/proc/get_damping_strength(var/reliable) + return 0 + +/datum/ship_inertial_damper/New(var/obj/machinery/_holder) + ..() + holder = _holder + global.ship_inertial_dampers += src + +/datum/ship_inertial_damper/Destroy() + global.ship_inertial_dampers -= src + // This may need some future optimization for servers with lots of ships. + // Just track what ship we're assigned to somehow, and then use that here. + // You'd also have to register it to clear that ref if/when the ship object is destroyed. + for(var/obj/effect/overmap/visitable/ship/S in SSshuttle.ships) + S.inertial_dampers -= src + holder = null + . = ..() \ No newline at end of file diff --git a/code/modules/events/inertial_damper.dm b/mods/content/inertia/inertia_failure.dm similarity index 78% rename from code/modules/events/inertial_damper.dm rename to mods/content/inertia/inertia_failure.dm index e8d14585967..ce7d147f770 100644 --- a/code/modules/events/inertial_damper.dm +++ b/mods/content/inertia/inertia_failure.dm @@ -1,7 +1,18 @@ +// TODO: This should either be removed, or reworked to announce to specifically only the affected ship or its associated map. /datum/event/inertial_damper announceWhen = 5 check_proc = /proc/inertial_dampener_event_can_fire +/datum/event_container/moderate/New() + ..() + available_events += new /datum/event_meta( + EVENT_LEVEL_MODERATE, + "Inertial Damper Recalibration", + /datum/event/inertial_damper, + 75, + list(ASSIGNMENT_ENGINEER = 25) + ) + /datum/event/inertial_damper/setup() endWhen = rand(45, 120) diff --git a/code/modules/inertial_damper/inertial_damper.dm b/mods/content/inertia/inertial_damper.dm similarity index 88% rename from code/modules/inertial_damper/inertial_damper.dm rename to mods/content/inertia/inertial_damper.dm index 60eea516044..4cb9905a95c 100644 --- a/code/modules/inertial_damper/inertial_damper.dm +++ b/mods/content/inertia/inertial_damper.dm @@ -1,28 +1,6 @@ -#define WARNING_DELAY 80 //seconds between warnings. -var/global/list/ship_inertial_dampers = list() - -/datum/ship_inertial_damper - var/name = "ship inertial damper" - var/obj/machinery/holder - -/datum/ship_inertial_damper/proc/get_damping_strength(var/reliable) - return 0 - -/datum/ship_inertial_damper/New(var/obj/machinery/_holder) - ..() - holder = _holder - global.ship_inertial_dampers += src - -/datum/ship_inertial_damper/Destroy() - global.ship_inertial_dampers -= src - for(var/obj/effect/overmap/visitable/ship/S in SSshuttle.ships) - S.inertial_dampers -= src - holder = null - . = ..() - /obj/machinery/inertial_damper name = "inertial damper" - icon = 'icons/obj/machines/inertial_damper.dmi' + icon = 'mods/content/inertia/icons/inertial_damper.dmi' desc = "An inertial damper, a very large machine that balances against engine thrust to prevent harm to the crew." density = TRUE icon_state = "damper_on" @@ -67,6 +45,9 @@ var/global/list/ship_inertial_dampers = list() var/width = 3 var/height = 2 + /// The cooldown between announcements that the inertial damping system is off. + var/const/WARNING_DELAY = 8 SECONDS + /obj/machinery/inertial_damper/Initialize() . = ..() SetBounds() @@ -117,8 +98,10 @@ var/global/list/ship_inertial_dampers = list() /obj/machinery/inertial_damper/proc/is_on() return active -/obj/machinery/inertial_damper/proc/get_damping_strength(var/reliable) - if(hacked && !reliable) +/// Returns either the true damping strength including modifiers (include_modifiers == TRUE), +/// or just the value the damper is set to (include_modifiers == FALSE). +/obj/machinery/inertial_damper/proc/get_damping_strength(var/include_modifiers) + if(hacked && !include_modifiers) return initial(damping_strength) return damping_strength + damping_modifier @@ -203,5 +186,3 @@ var/global/list/ship_inertial_dampers = list() /obj/machinery/inertial_damper/dismantle() if((. = ..())) update_nearby_tiles(locs) - -#undef WARNING_DELAY \ No newline at end of file diff --git a/mods/content/inertia/ship_inertia.dm b/mods/content/inertia/ship_inertia.dm new file mode 100644 index 00000000000..d903ef02aa1 --- /dev/null +++ b/mods/content/inertia/ship_inertia.dm @@ -0,0 +1,44 @@ +/obj/effect/overmap/visitable/ship + /// Whether or not this ship throws mobs on acceleration if dampers are inactive. + var/needs_dampers = FALSE + /// A list of inertial damping controller datums associated with this ship. + var/list/datum/ship_inertial_damper/inertial_dampers = list() + /// The current damping strength from all inertial dampers, recalculated every tick in the ship's Process(). + var/tmp/damping_strength = null + +/obj/effect/overmap/visitable/ship/populate_sector_objects() + ..() + for(var/datum/ship_inertial_damper/I in global.ship_inertial_dampers) + if(check_ownership(I.holder)) + inertial_dampers |= I + +// Theoretically there's no need to recalculate this every tick, +// instead it should be recalculated any time damping strength changes +// based only on the damper that changed. +/obj/effect/overmap/visitable/ship/Process(wait, tick) + . = ..() + damping_strength = 0 + for(var/datum/ship_inertial_damper/I in inertial_dampers) + var/obj/machinery/inertial_damper/ID = I.holder + damping_strength += ID.get_damping_strength(TRUE) + +/obj/effect/overmap/visitable/ship/adjust_speed(n_x, n_y) + . = ..() + var/magnitude = norm(n_x, n_y) + var/inertia_dir = magnitude >= 0 ? turn(fore_dir, 180) : fore_dir + var/inertia_strength = magnitude * 1e3 + if(needs_dampers && damping_strength < inertia_strength) + var/list/areas_by_name = area_repository.get_areas_by_z_level() + for(var/area_name in areas_by_name) + var/area/A = areas_by_name[area_name] + if(area_belongs_to_zlevels(A, map_z)) + A.throw_unbuckled_occupants(inertia_strength+2, inertia_strength, inertia_dir) + +// Add additional data to the engine console. +/obj/machinery/computer/ship/engines/modify_ship_ui_data(list/ui_data) + var/damping_strength = 0 + for(var/datum/ship_inertial_damper/inertia_controller in linked.inertial_dampers) + var/obj/machinery/inertial_damper/damper = inertia_controller.holder + damping_strength += damper.get_damping_strength(FALSE) // get only the level it's set to, not the actual level + ui_data["damping_strength"] = damping_strength + ui_data["needs_dampers"] = linked.needs_dampers \ No newline at end of file diff --git a/mods/content/inertia/supplies.dm b/mods/content/inertia/supplies.dm new file mode 100644 index 00000000000..fbe975ab7cb --- /dev/null +++ b/mods/content/inertia/supplies.dm @@ -0,0 +1,6 @@ +/decl/hierarchy/supply_pack/engineering/inertial_damper + name = "Equipment - inertial damper construction kit" + contains = list(/obj/item/stock_parts/circuitboard/inertial_damper, /obj/item/stock_parts/capacitor, /obj/item/stock_parts/micro_laser, /obj/item/stock_parts/console_screen) + containertype = /obj/structure/closet/crate/secure + containername = "inertial damper construction kit crate" + access = access_engine \ No newline at end of file diff --git a/code/datums/wires/inertial_damper.dm b/mods/content/inertia/wires.dm similarity index 71% rename from code/datums/wires/inertial_damper.dm rename to mods/content/inertia/wires.dm index 4ea708f73be..4cc74f8bc94 100644 --- a/code/datums/wires/inertial_damper.dm +++ b/mods/content/inertia/wires.dm @@ -7,11 +7,10 @@ new /datum/wire_description(DAMPER_WIRE_CONTROL, "This wire connects to the main control panel."), new /datum/wire_description(DAMPER_WIRE_AICONTROL, "This wire connects to automated control systems.") ) - -var/global/const/DAMPER_WIRE_POWER = 1 // Cut to disable power input into the generator. Pulse does nothing. Mend to restore. -var/global/const/DAMPER_WIRE_HACK = 2 // Pulse to hack the dampener, causing false display on engine consoles. Cut to unhack. Mend does nothing. -var/global/const/DAMPER_WIRE_CONTROL = 4 // Cut to lock controls. Mend to unlock them. Pulse does nothing. -var/global/const/DAMPER_WIRE_AICONTROL = 8 // Cut to disable AI control. Mend to restore. + var/const/DAMPER_WIRE_POWER = 1 // Cut to disable power input into the generator. Pulse does nothing. Mend to restore. + var/const/DAMPER_WIRE_HACK = 2 // Pulse to hack the dampener, causing false display on engine consoles. Cut to unhack. Mend does nothing. + var/const/DAMPER_WIRE_CONTROL = 4 // Cut to lock controls. Mend to unlock them. Pulse does nothing. + var/const/DAMPER_WIRE_AICONTROL = 8 // Cut to disable AI control. Mend to restore. /datum/wires/inertial_damper/CanUse() var/obj/machinery/inertial_damper/I = holder diff --git a/nebula.dme b/nebula.dme index 324850fd28f..5272f7674a0 100644 --- a/nebula.dme +++ b/nebula.dme @@ -720,7 +720,6 @@ #include "code\datums\wires\camera.dm" #include "code\datums\wires\explosive.dm" #include "code\datums\wires\fabricator.dm" -#include "code\datums\wires\inertial_damper.dm" #include "code\datums\wires\nuclearbomb.dm" #include "code\datums\wires\particle_accelerator.dm" #include "code\datums\wires\radio.dm" @@ -1286,7 +1285,6 @@ #include "code\game\objects\items\weapons\circuitboards\machinery\forensic.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\holomap.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\household.dm" -#include "code\game\objects\items\weapons\circuitboards\machinery\inertial_damper.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\mech_recharger.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\medical.dm" #include "code\game\objects\items\weapons\circuitboards\machinery\mining.dm" @@ -2336,7 +2334,6 @@ #include "code\modules\events\event_dynamic.dm" #include "code\modules\events\gravity.dm" #include "code\modules\events\grid_check.dm" -#include "code\modules\events\inertial_damper.dm" #include "code\modules\events\infestation.dm" #include "code\modules\events\ion_storm.dm" #include "code\modules\events\location_event.dm" @@ -2599,7 +2596,6 @@ #include "code\modules\hydroponics\trays\tray_soil.dm" #include "code\modules\hydroponics\trays\tray_tools.dm" #include "code\modules\hydroponics\trays\tray_update_icons.dm" -#include "code\modules\inertial_damper\inertial_damper.dm" #include "code\modules\integrated_electronics\_defines.dm" #include "code\modules\integrated_electronics\core\_electronics.dm" #include "code\modules\integrated_electronics\core\analyzer.dm" From 20f95d633b5bd10464bbff91b270828746d79395 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 31 Dec 2024 19:46:00 -0500 Subject: [PATCH 6/7] Allow modpacks to include NanoUI template folders --- .../subsystems/initialization/modpacks.dm | 1 + code/modules/client/asset_cache.dm | 41 +++++++++++++------ mods/_modpack.dm | 11 +++++ mods/content/inertia/_inertia.dm | 3 +- .../nano_templates}/inertial_damper.tmpl | 0 nano/templates/engines_control.tmpl | 2 + scripts/server.sh | 2 +- 7 files changed, 46 insertions(+), 14 deletions(-) rename {nano/templates => mods/content/inertia/nano_templates}/inertial_damper.tmpl (100%) diff --git a/code/controllers/subsystems/initialization/modpacks.dm b/code/controllers/subsystems/initialization/modpacks.dm index 5fad4ec549c..f2f6c65a2e6 100644 --- a/code/controllers/subsystems/initialization/modpacks.dm +++ b/code/controllers/subsystems/initialization/modpacks.dm @@ -7,6 +7,7 @@ SUBSYSTEM_DEF(modpacks) // Compiled modpack information. var/list/default_submap_whitelisted_species = list() var/list/default_submap_blacklisted_species = list(SPECIES_ALIEN, SPECIES_GOLEM) + var/list/modpack_nanoui_directories = list() /datum/controller/subsystem/modpacks/Initialize() var/list/all_modpacks = decls_repository.get_decls_of_subtype(/decl/modpack) diff --git a/code/modules/client/asset_cache.dm b/code/modules/client/asset_cache.dm index 8e8c90860c4..d582783e091 100644 --- a/code/modules/client/asset_cache.dm +++ b/code/modules/client/asset_cache.dm @@ -185,7 +185,7 @@ var/global/template_file_name = "all_templates.json" if(fexists(path + filename)) register_asset(filename, fcopy_rsc(path + filename)) - merge_and_register_templates() + merge_and_register_all_templates() var/list/mapnames = list() for(var/z in SSmapping.map_levels) @@ -199,13 +199,18 @@ var/global/template_file_name = "all_templates.json" common[filename] = fcopy_rsc(file_path) register_asset(filename, common[filename]) -/datum/asset/nanoui/proc/merge_and_register_templates() - var/list/templates = flist(template_dir) - for(var/filename in templates) - if(copytext(filename, length(filename)) != "/") - templates[filename] = replacetext(replacetext(file2text(template_dir + filename), "\n", ""), "\t", "") - else - templates -= filename +/datum/asset/nanoui/proc/merge_and_register_all_templates() + . = merge_templates(template_dir) + . += merge_modpack_templates() + register_templates(.) + +/datum/asset/nanoui/proc/merge_modpack_templates() + PRIVATE_PROC(TRUE) + . = list() + for(var/mod_template_dir in SSmodpacks.modpack_nanoui_directories) + . += merge_templates(mod_template_dir) + +/datum/asset/nanoui/proc/register_templates(templates) var/full_file_name = template_temp_dir + global.template_file_name if(fexists(full_file_name)) fdel(file(full_file_name)) @@ -213,6 +218,17 @@ var/global/template_file_name = "all_templates.json" to_file(template_file, json_encode(templates)) register_asset(global.template_file_name, fcopy_rsc(template_file)) +/// Handles adding a directory's templates to the compiled templates list. +/datum/asset/nanoui/proc/merge_templates(use_dir) + PRIVATE_PROC(TRUE) + var/list/templates = flist(use_dir) + for(var/filename in templates) + if(copytext(filename, length(filename)) != "/") + templates[filename] = replacetext(replacetext(file2text(use_dir + filename), "\n", ""), "\t", "") + else + templates -= filename + return templates + /datum/asset/nanoui/send(client, uncommon) if(!islist(uncommon)) uncommon = list(uncommon) @@ -223,11 +239,12 @@ var/global/template_file_name = "all_templates.json" // Note: this is intended for dev work, and is unsafe. Do not use outside of that. /datum/asset/nanoui/proc/recompute_and_resend_templates() - merge_and_register_templates() + merge_and_register_all_templates() for(var/client/C in clients) - if(C) // there are sleeps here, potentially - send_asset(C, global.template_file_name, FALSE, FALSE) - to_chat(C, SPAN_WARNING("Nanoui templates have been updated. Please close and reopen any browser windows.")) + spawn() // there are sleeps here, potentially + if(C) + send_asset(C, global.template_file_name, FALSE, FALSE) + to_chat(C, SPAN_WARNING("Nanoui templates have been updated. Please close and reopen any browser windows.")) /client/proc/resend_nanoui_templates() set category = "Debug" diff --git a/mods/_modpack.dm b/mods/_modpack.dm index 1e8accdf306..81c16e69f7a 100644 --- a/mods/_modpack.dm +++ b/mods/_modpack.dm @@ -6,6 +6,8 @@ /// A string with authors of this modpack. var/author var/secrets_directory + /// The folder to load additional NanoUI templates from. Must be relative to the DME's location (root game folder). + var/nanoui_directory var/list/dreams //! A list of strings to be added to the random dream proc. var/list/credits_other //! A list of strings that are used by the end of round credits roll. @@ -32,6 +34,15 @@ if(!fexists(secrets_directory)) return "Modpack secrets_directory does not exist." SSsecrets.load_directories |= secrets_directory + if(nanoui_directory) + nanoui_directory = trim(lowertext(nanoui_directory)) + if(!length(nanoui_directory)) + return "Modpack nanoui_directory is zero length after trim." + if(copytext(nanoui_directory, -1) != "/") + nanoui_directory = "[nanoui_directory]/" + if(!fexists(nanoui_directory)) + return "Modpack nanoui_directory does not exist." + SSmodpacks.modpack_nanoui_directories |= nanoui_directory /decl/modpack/proc/initialize() return diff --git a/mods/content/inertia/_inertia.dm b/mods/content/inertia/_inertia.dm index 97bee4de9a0..585525241f1 100644 --- a/mods/content/inertia/_inertia.dm +++ b/mods/content/inertia/_inertia.dm @@ -1,3 +1,4 @@ /decl/modpack/inertia name = "Ship Inertia Content" - desc = "This modpack adds support for inertia (throwing unsecured mobs) when ship thrusters fire, and adds an inertial dampener machine to counteract this." \ No newline at end of file + desc = "This modpack adds support for inertia (throwing unsecured mobs) when ship thrusters fire, and adds an inertial dampener machine to counteract this." + nanoui_directory = "mods/content/inertia/nano_templates/" \ No newline at end of file diff --git a/nano/templates/inertial_damper.tmpl b/mods/content/inertia/nano_templates/inertial_damper.tmpl similarity index 100% rename from nano/templates/inertial_damper.tmpl rename to mods/content/inertia/nano_templates/inertial_damper.tmpl diff --git a/nano/templates/engines_control.tmpl b/nano/templates/engines_control.tmpl index 4df88e86014..c9ec27c77c7 100644 --- a/nano/templates/engines_control.tmpl +++ b/nano/templates/engines_control.tmpl @@ -29,6 +29,8 @@ {{:data.total_thrust}} + + {{if data.needs_dampers}}
diff --git a/scripts/server.sh b/scripts/server.sh index b65b6b33d16..bc89d45b7c4 100755 --- a/scripts/server.sh +++ b/scripts/server.sh @@ -63,7 +63,7 @@ while [[ ! -e stopserver ]]; do cp "$GITDIR/$DME.rsc" . cp -r "$GITDIR/nano" . # Necessary for NanoUI cp -r "$GITDIR/maps" . # Necessary for runtime submap loading - cp -r "$GITDIR/mods" . # Also necessary for runtime submap loading. TODO: a better solution + cp -r "$GITDIR/mods" . # Also necessary for runtime submap and NanoUI loading. TODO: a better solution? [[ ! -e btime.so && -e "$GITDIR/btime.so" ]] && cp "$GITDIR/btime.so" . [[ ! -e .git/logs ]] && mkdir -p .git/logs cp "$GITDIR/.git/HEAD" ./.git/HEAD From ae35726b6f8356bffad45908c7026bdccbc0466b Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Wed, 1 Jan 2025 00:51:08 -0500 Subject: [PATCH 7/7] Fix runtime from security states with fewer than two levels --- code/modules/security_levels/security_state.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/security_levels/security_state.dm b/code/modules/security_levels/security_state.dm index dfc0c78a94c..2e997845d41 100644 --- a/code/modules/security_levels/security_state.dm +++ b/code/modules/security_levels/security_state.dm @@ -32,13 +32,13 @@ // Setup the high security level if(!(high_security_level in all_security_levels)) - high_security_level = all_security_levels[all_security_levels.len - 1] + high_security_level = all_security_levels[max(1, all_security_levels.len - 1)] high_security_level = GET_DECL(high_security_level) // Setup the highest standard security level if(highest_standard_security_level || isnull(highest_standard_security_level)) if(!(highest_standard_security_level in all_security_levels)) - highest_standard_security_level = all_security_levels[all_security_levels.len - 1] + highest_standard_security_level = all_security_levels[max(1, all_security_levels.len - 1)] highest_standard_security_level = GET_DECL(highest_standard_security_level) else highest_standard_security_level = null