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
Show file tree
Hide file tree
Changes from 3 commits
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
87 changes: 65 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 dispatch to work
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,70 @@ 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 (never will be updated, lol)
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)
var/cooldown_info = "Ожидайте. Система оповещения "
if(is_emped)
cooldown_info += "в защитном режиме, "
else
cooldown_info += "перезаряжается, "
// Cooldown not updating realtime, and i don't want to rewrite it just for the sake of it
cooldown_info += "примерное время восстановления: [dispatch_cooldown / 10] секунд."
to_chat(user, span_notice(cooldown_info))
return

is_on_cooldown = TRUE
addtimer(CALLBACK(src, PROC_REF(reboot)), dispatch_cooldown)
// This code if fucking hell, but it works as intended
for(var/atom/movable/hailer in GLOB.sechailers)
var/security_channel_found = FALSE
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)
// Check if mob has a radio, then check if the radio has the right channels
for(var/obj/item/radio/my_radio in user.contents)
for(var/chan in 1 to length(my_radio.channels))
var/channel_name = my_radio.channels[chan]
if(channel_name == DEPARTMENT_SECURITY)
security_channel_found = TRUE
break
dj-34 marked this conversation as resolved.
Show resolved Hide resolved

if(security_channel_found)
dj-34 marked this conversation as resolved.
Show resolved Hide resolved
radio.autosay("Центр, Код [message], офицер [user] запрашивает помощь в [A].", "Система Оповещения", DEPARTMENT_SECURITY, list(z))
playsound(hailer.loc, 'modular_ss220/sechailer/sound/dispatch_please_respond.ogg', 55, FALSE)
break
else
to_chat(user, span_warning("Внимание: Невозможно установить соединение с каналом службы безопасности, требуется подключение!"))
playsound(hailer.loc, 'modular_ss220/sechailer/sound/radio_static.ogg', 30, TRUE)

/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("Обнаружен электромагнитный импульс, система оповещения отключена для сохранения работоспособности..."))
Binary file added modular_ss220/sechailer/sound/radio_static.ogg
Binary file not shown.