From 9e83e30c023991539bcfb4cee7933635e70513d2 Mon Sep 17 00:00:00 2001 From: dj-34 Date: Sat, 2 Dec 2023 05:41:17 +0500 Subject: [PATCH] Refactor: Sechailer dispatch --- modular_ss220/sechailer/code/sechailer.dm | 68 +++++++++++++++-------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/modular_ss220/sechailer/code/sechailer.dm b/modular_ss220/sechailer/code/sechailer.dm index 217f009b64aa..87465ead33f3 100644 --- a/modular_ss220/sechailer/code/sechailer.dm +++ b/modular_ss220/sechailer/code/sechailer.dm @@ -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) @@ -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, "Dispatch radio broadcasting systems are recharging.") - 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("Обнаружен электромагнитный импульс, система оповещения отключена для сохранения работоспособности..."))