Skip to content

Commit

Permalink
Flashbangs now inform user if the security level is green, and during…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
vinylspiders authored and StealsThePRs committed Jul 7, 2024
1 parent 518a485 commit b20b5d7
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 3 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/~nova_defines/keybindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions code/modules/jobs/job_types/detective.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion config/nova/config_nova.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions modular_nova/modules/goofsec/code/department_guards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
106 changes: 106 additions & 0 deletions modular_nova/modules/sec_haul/code/misc/grenades.dm
Original file line number Diff line number Diff line change
@@ -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 = "<span class='doyourjobidiot'><b>\n\nWARNING: Breach of company policy detected!:</b></span>\n\n[user], \
<b>[user.mind?.assigned_role.title]</b> 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
3 changes: 3 additions & 0 deletions modular_nova/modules/sec_haul/code/sec_haul_config.dm
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b20b5d7

Please sign in to comment.