Skip to content

Commit

Permalink
Refactor: Sechailer dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-34 committed Dec 2, 2023
1 parent 368729b commit 9e83e30
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions modular_ss220/sechailer/code/sechailer.dm
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
GLOBAL_LIST_EMPTY(sechailers)

/datum/action/item_action/dispatch
name = "Signal dispatch"
desc = "Opens up a quick select wheel for reporting crimes, including your current location, to your fellow security officers."
name = "Signal Dispatch"
desc = "Открывает колесо быстрого выбора для сообщения о преступлениях, включая ваше текущее местоположение."
button_icon_state = "dispatch"
icon_icon = 'modular_ss220/sechailer/icons/sechailer.dmi'
use_itemicon = FALSE

/obj/item/clothing/mask/gas/sechailer
name = "\improper security gas mask"
var/obj/item/radio/radio //For engineering alerts.
var/dispatch_cooldown = 250
var/last_dispatch = 0
var/obj/item/radio/radio // For engineering alerts.
var/dispatch_cooldown = 25 SECONDS
var/is_on_cooldown = FALSE
var/is_emped = FALSE
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/adjust, /datum/action/item_action/selectphrase)

/obj/item/clothing/mask/gas/sechailer/hos
name = "\improper head of security's SWAT mask"
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/adjust, /datum/action/item_action/selectphrase)
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/selectphrase)

/obj/item/clothing/mask/gas/sechailer/warden
name = "\improper warden's SWAT mask"
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/adjust, /datum/action/item_action/selectphrase)
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/selectphrase)

/obj/item/clothing/mask/gas/sechailer/swat
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/adjust, /datum/action/item_action/selectphrase)
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/selectphrase)

/obj/item/clothing/mask/gas/sechailer/blue
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/adjust, /datum/action/item_action/selectphrase)
actions_types = list(/datum/action/item_action/dispatch, /datum/action/item_action/halt, /datum/action/item_action/selectphrase)

/obj/item/clothing/mask/gas/sechailer/Destroy()
qdel(radio)
Expand All @@ -41,25 +39,51 @@ GLOBAL_LIST_EMPTY(sechailers)
radio.config(list("Security" = 0))
radio.follow_target = src


/obj/item/clothing/mask/gas/sechailer/proc/dispatch(mob/user)
var/area/A = get_area(src)
if(world.time < last_dispatch + dispatch_cooldown)
to_chat(user, "<span class='notice'>Dispatch radio broadcasting systems are recharging.</span>")
return FALSE
var/area/A = get_location_name(src, TRUE) // get_location_name works better as affected says
var/list/options = list()
for(var/option in list("502 (Убийство)", "101 (Сопротивление Аресту)", "308 (Вторжение)", "305 (Мятеж)", "402 (Нападение на Офицера)")) //Just hardcoded for now!
// Just hardcoded for now!
for(var/option in list(
"502 (Убийство)",
"101 (Сопротивление Аресту)",
"308 (Вторжение)",
"305 (Мятеж)",
"402 (Нападение на Офицера)"
))
options[option] = image(icon = 'modular_ss220/sechailer/icons/menu.dmi', icon_state = option)
var/message = show_radial_menu(user, src, options)

if(!message)
return FALSE
radio.autosay("Диспетчер, [user], код [message] в [A], запрашивается помощь.", src, "Security", list(z))
last_dispatch = world.time
return
if(is_on_cooldown == TRUE && is_emped == FALSE) // If on cooldown
to_chat(user, span_notice("Ожидайте. Система оповещения перезаряжается, примерное время восстановления: [dispatch_cooldown / 10] секунд."))
return
if(is_on_cooldown == TRUE && is_emped == TRUE) // If emped
to_chat(user, span_notice("Ожидайте. Система оповещения в защитном режиме, примерное время восстановления: [dispatch_cooldown / 10] секунд."))
return

radio.autosay("Центр, Код [message], офицер [user] запрашивает помощь в [A].", "Система Оповещения", "Security", list(z))
is_on_cooldown = TRUE
addtimer(CALLBACK(src, PROC_REF(reboot)), dispatch_cooldown)
for(var/atom/movable/hailer in GLOB.sechailers)
if(hailer.loc && ismob(hailer.loc))
playsound(hailer.loc, "modular_ss220/sechailer/sound/dispatch_please_respond.ogg", 55, FALSE)
playsound(hailer.loc, 'modular_ss220/sechailer/sound/dispatch_please_respond.ogg', 55, FALSE)

/obj/item/clothing/mask/gas/sechailer/proc/reboot()
is_on_cooldown = FALSE
is_emped = FALSE

/obj/item/clothing/mask/gas/sechailer/ui_action_click(mob/user, actiontype)
. = ..()
if(actiontype == /datum/action/item_action/dispatch)
dispatch(user)

/obj/item/clothing/mask/gas/sechailer/emp_act(severity)
if(is_on_cooldown)
return
is_on_cooldown = TRUE
is_emped = TRUE
addtimer(CALLBACK(src, PROC_REF(reboot)), dispatch_cooldown)
if(ishuman(loc))
var/mob/living/carbon/human/user = loc
to_chat(user, span_userdanger("Обнаружен электромагнитный импульс, система оповещения отключена для сохранения работоспособности..."))

0 comments on commit 9e83e30

Please sign in to comment.