Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Sechailer dispatch #807

Merged
merged 6 commits into from
Dec 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
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)
Legendaxe marked this conversation as resolved.
Show resolved Hide resolved

/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
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
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
dj-34 marked this conversation as resolved.
Show resolved Hide resolved

radio.autosay("Центр, Код [message], офицер [user] запрашивает помощь в [A].", "Система Оповещения", "Security", list(z))
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
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))
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
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("Обнаружен электромагнитный импульс, система оповещения отключена для сохранения работоспособности..."))