From b20b5d7896c2bfeadd92d1786ffa0761d13c6b9f Mon Sep 17 00:00:00 2001
From: Bloop <13398309+vinylspiders@users.noreply.github.com>
Date: Sat, 6 Jul 2024 20:02:56 -0400
Subject: [PATCH] Flashbangs now inform user if the security level is green,
and during green alerts they must be ctrl+clicked to arm (only affects
security) (#2553)
* Grenades now give a warning before triggering them during green alert, alerts when (mis)used, fixes some pdas not imprinting
* Fix linters
* Update grenades.dm
* Adds keybind + context, makes PDA message bolder
* Formatting
* Formatting 2
* Updates silent alert message
* Updates with ctrlclick refactor
* Update grenades.dm
* Update grenades.dm
---
code/__DEFINES/~nova_defines/keybindings.dm | 1 +
code/modules/jobs/job_types/detective.dm | 4 +-
config/nova/config_nova.txt | 5 +-
.../code/modules/jobs/job_types/detective.dm | 5 +
.../modules/goofsec/code/department_guards.dm | 5 +
.../modules/sec_haul/code/misc/grenades.dm | 106 ++++++++++++++++++
.../modules/sec_haul/code/sec_haul_config.dm | 3 +
tgstation.dme | 2 +
8 files changed, 128 insertions(+), 3 deletions(-)
create mode 100644 modular_nova/master_files/code/modules/jobs/job_types/detective.dm
create mode 100644 modular_nova/modules/sec_haul/code/misc/grenades.dm
diff --git a/code/__DEFINES/~nova_defines/keybindings.dm b/code/__DEFINES/~nova_defines/keybindings.dm
index 8d99a7a0278..04d588724e8 100644
--- a/code/__DEFINES/~nova_defines/keybindings.dm
+++ b/code/__DEFINES/~nova_defines/keybindings.dm
@@ -6,3 +6,4 @@
#define COMSIG_KB_CARBON_TOGGLE_SAFETY "keybinding_carbon_toggle_safety"
#define COMSIG_KB_CLIENT_DO_DOWN "keybinding_client_do_down"
#define COMSIG_KB_CLIENT_DO_LONGER_DOWN "keybinding_client_do_longer_down"
+#define COMSIG_KB_MOB_CTRL_ACTIVATEINHAND_DOWN "keybinding_mob_ctrl_activateinhand_down"
diff --git a/code/modules/jobs/job_types/detective.dm b/code/modules/jobs/job_types/detective.dm
index 904bbb8549a..00bd8790d9b 100644
--- a/code/modules/jobs/job_types/detective.dm
+++ b/code/modules/jobs/job_types/detective.dm
@@ -57,14 +57,14 @@
/obj/item/melee/baton = 1,
/obj/item/storage/box/evidence = 1,
)
- belt = /obj/item/storage/belt/holster/detective/full // NOVA EDIT CHANGE - ORIGINAL: /obj/item/modular_computer/pda/detective
+ belt = /obj/item/modular_computer/pda/detective
ears = /obj/item/radio/headset/headset_sec/alt
gloves = /obj/item/clothing/gloves/color/black
head = /obj/item/clothing/head/fedora/det_hat
mask = /obj/item/cigarette
neck = /obj/item/clothing/neck/tie/detective
shoes = /obj/item/clothing/shoes/sneakers/brown
- l_pocket = /obj/item/modular_computer/pda/detective // NOVA EDIT CHANGE - ORIGINAL: /obj/item/toy/crayon/white
+ l_pocket = /obj/item/toy/crayon/white
r_pocket = /obj/item/lighter
chameleon_extras = list(
diff --git a/config/nova/config_nova.txt b/config/nova/config_nova.txt
index e0e4667b175..af44fea6ed8 100644
--- a/config/nova/config_nova.txt
+++ b/config/nova/config_nova.txt
@@ -163,4 +163,7 @@ ARRIVALS_WAIT 150
REPLACE_SECBELT_FLASHBANGS_WITH_BOLA
## Uncomment to block borgs/silicons from going through gateways
-BORG_GATEWAY_BLACKLIST
+#BORG_GATEWAY_BLACKLIST
+
+## Uncomment to make flashbangs forbidden during green alerts
+FLASHBANGS_FORBIDDEN_DURING_GREEN
diff --git a/modular_nova/master_files/code/modules/jobs/job_types/detective.dm b/modular_nova/master_files/code/modules/jobs/job_types/detective.dm
new file mode 100644
index 00000000000..a2a4a6c6a8c
--- /dev/null
+++ b/modular_nova/master_files/code/modules/jobs/job_types/detective.dm
@@ -0,0 +1,5 @@
+// Moves PDA to left pocket, gives them a holster in their belt slot
+/datum/outfit/job/detective
+ belt = /obj/item/storage/belt/holster/detective/full
+ l_pocket = /obj/item/modular_computer/pda/detective
+ pda_slot = ITEM_SLOT_LPOCKET
diff --git a/modular_nova/modules/goofsec/code/department_guards.dm b/modular_nova/modules/goofsec/code/department_guards.dm
index 47256b70c95..31170531e14 100644
--- a/modular_nova/modules/goofsec/code/department_guards.dm
+++ b/modular_nova/modules/goofsec/code/department_guards.dm
@@ -275,6 +275,7 @@
messenger = /obj/item/storage/backpack/messenger/science
id_trim = /datum/id_trim/job/science_guard
+ pda_slot = ITEM_SLOT_LPOCKET
/datum/id_trim/job/science_guard
assignment = "Science Guard"
@@ -376,6 +377,7 @@
box = /obj/item/storage/box/survival/medical
id_trim = /datum/id_trim/job/orderly
+ pda_slot = ITEM_SLOT_LPOCKET
/datum/id_trim/job/orderly
assignment = "Orderly"
@@ -470,6 +472,7 @@
box = /obj/item/storage/box/survival/engineer
id_trim = /datum/id_trim/job/engineering_guard
+ pda_slot = ITEM_SLOT_LPOCKET
/datum/id_trim/job/engineering_guard
assignment = "Engineering Guard"
@@ -570,6 +573,7 @@
messenger = /obj/item/storage/backpack/messenger
id_trim = /datum/id_trim/job/customs_agent
+ pda_slot = ITEM_SLOT_LPOCKET
/datum/id_trim/job/customs_agent
assignment = "Customs Agent"
@@ -664,6 +668,7 @@
messenger = /obj/item/storage/backpack/messenger
id_trim = /datum/id_trim/job/bouncer
+ pda_slot = ITEM_SLOT_LPOCKET
/datum/id_trim/job/bouncer
assignment = "Bouncer"
diff --git a/modular_nova/modules/sec_haul/code/misc/grenades.dm b/modular_nova/modules/sec_haul/code/misc/grenades.dm
new file mode 100644
index 00000000000..bf819d31655
--- /dev/null
+++ b/modular_nova/modules/sec_haul/code/misc/grenades.dm
@@ -0,0 +1,106 @@
+/obj/item/grenade/flashbang/Initialize(mapload)
+ . = ..()
+ register_context()
+
+/obj/item/grenade/flashbang/add_context(atom/source, list/context, obj/item/held_item, mob/user)
+ . = ..()
+ if(!is_currently_forbidden(user))
+ return
+
+ context[SCREENTIP_CONTEXT_CTRL_LMB] = "Break Company Policy! There will be consequences..."
+ return CONTEXTUAL_SCREENTIP_SET
+
+/// If the company policy currently forbids flashbangs during green alert
+/obj/item/grenade/flashbang/proc/is_currently_forbidden(mob/user)
+ if(!CONFIG_GET(flag/flashbangs_forbidden_during_green) || SSsecurity_level.get_current_level_as_number() != SEC_LEVEL_GREEN)
+ return FALSE
+
+ if(!(user.mind?.assigned_role.departments_bitflags & (DEPARTMENT_BITFLAG_SECURITY|DEPARTMENT_BITFLAG_COMMAND)))
+ return FALSE
+
+ return TRUE
+
+// Security members are not supposed to use flashbangs during green alert, as per company policy.
+// Disobeying this policy will result in IC consequences.
+/obj/item/grenade/flashbang/attack_self(mob/user, modifiers, breaking_policy = FALSE)
+ if(active || HAS_TRAIT(src, TRAIT_NODROP) || !is_currently_forbidden(user))
+ return ..()
+
+ if(breaking_policy)
+ var/crew_to_alert = list(
+ JOB_CAPTAIN,
+ JOB_WARDEN,
+ JOB_DETECTIVE,
+ JOB_HEAD_OF_SECURITY,
+ )
+ var/message = "\n\nWARNING: Breach of company policy detected!:\n\n[user], \
+ [user.mind?.assigned_role.title] has armed a flashbang during security level green! \
+ This is a violation of corporate regulations, and should be investigated immediately."
+ silent_alert(user, src, crew_to_alert, message)
+ return ..()
+ else
+ to_chat(user, span_doyourjobidiot("The use of flashbangs when the security level is green is a violation of company policy!\nTo \
+ bypass this restriction and arm the flashbang anyway, CTRL + Click it (be prepared to have a good reason for doing this!)."))
+ return
+
+// CTRL + Click to willingly bypass the green alert restriction
+/obj/item/grenade/flashbang/item_ctrl_click(mob/user)
+ attack_self(user, breaking_policy = TRUE)
+ return CLICK_ACTION_SUCCESS
+
+/// Sends a silent alert message to certain crew members' PDAs
+/proc/silent_alert(mob/sender, atom/source, crew_to_alert, message)
+ // build list of alt titles + base titles. We have to do this because the pda's saved_job uses the alt_title string instead of the job datum.
+ var/list/base_title_by_alt_title = list()
+ for(var/job_title in crew_to_alert)
+ var/datum/job/job_datum = SSjob.GetJob(job_title)
+ for(var/alt_job_title in job_datum.alt_titles)
+ base_title_by_alt_title[alt_job_title] = job_title
+
+ for(var/messenger_ref in GLOB.pda_messengers)
+ var/datum/computer_file/program/messenger/messenger = GLOB.pda_messengers[messenger_ref]
+ if(!length(crew_to_alert))
+ break
+ if(sender.name == messenger.computer.saved_identification) // don't alert yourself
+ continue
+ // Alt titles exist, so we need to check all of the possible titles
+ if(!(base_title_by_alt_title[messenger.computer.saved_job] in crew_to_alert))
+ continue
+
+ var/datum/signal/subspace/messaging/tablet_message/signal = new(source, list(
+ "fakename" = "NanoTrasen Corp Alerts",
+ "fakejob" = "Flashbang Watchdog",
+ "message" = message,
+ "targets" = list(messenger),
+ "automated" = TRUE
+ ))
+ signal.send_to_receivers()
+ sender.log_message("(PDA: Flashbang Alerts) sent \"[message]\" to [signal.format_target()]", LOG_PDA)
+
+ return TRUE
+
+// Keybindings
+/datum/keybinding/mob/ctrl_activate_inhand
+ hotkey_keys = list("CtrlZ")
+ name = "ctrl-activate_inhand"
+ full_name = "CTRL-Activate in-hand"
+ description = "Uses whatever item you have inhand"
+ keybind_signal = COMSIG_KB_MOB_CTRL_ACTIVATEINHAND_DOWN
+
+/datum/keybinding/mob/ctrl_activate_inhand/down(client/user)
+ . = ..()
+ if(.)
+ return
+ var/mob/user_mob = user.mob
+ if(ismecha(user_mob.loc))
+ return
+
+ if(user_mob.incapacitated())
+ return
+
+ var/obj/item/held_item = user_mob.get_active_held_item()
+ if(held_item)
+ user_mob.CtrlClickOn(held_item)
+ user_mob.update_held_items()
+
+ return TRUE
diff --git a/modular_nova/modules/sec_haul/code/sec_haul_config.dm b/modular_nova/modules/sec_haul/code/sec_haul_config.dm
index 3096b840de4..40ed05b3fac 100644
--- a/modular_nova/modules/sec_haul/code/sec_haul_config.dm
+++ b/modular_nova/modules/sec_haul/code/sec_haul_config.dm
@@ -1,2 +1,5 @@
/datum/config_entry/flag/replace_secbelt_flashbangs_with_bola
default = TRUE
+
+/datum/config_entry/flag/flashbangs_forbidden_during_green
+ default = TRUE
diff --git a/tgstation.dme b/tgstation.dme
index 78b4856d3c1..40fa0e9c2c6 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -6667,6 +6667,7 @@
#include "modular_nova\master_files\code\modules\jobs\job_types\coroner.dm"
#include "modular_nova\master_files\code\modules\jobs\job_types\curator.dm"
#include "modular_nova\master_files\code\modules\jobs\job_types\cyborg.dm"
+#include "modular_nova\master_files\code\modules\jobs\job_types\detective.dm"
#include "modular_nova\master_files\code\modules\jobs\job_types\geneticist.dm"
#include "modular_nova\master_files\code\modules\jobs\job_types\head_of_personnel.dm"
#include "modular_nova\master_files\code\modules\jobs\job_types\head_of_security.dm"
@@ -8270,6 +8271,7 @@
#include "modular_nova\modules\sec_haul\code\misc\ai_module.dm"
#include "modular_nova\modules\sec_haul\code\misc\bullet_drive.dm"
#include "modular_nova\modules\sec_haul\code\misc\decals.dm"
+#include "modular_nova\modules\sec_haul\code\misc\grenades.dm"
#include "modular_nova\modules\sec_haul\code\misc\packs.dm"
#include "modular_nova\modules\sec_haul\code\misc\vending.dm"
#include "modular_nova\modules\sec_haul\code\peacekeeper\armadyne_clothing.dm"