From 4f08c6e4a09c59addccd85d36cc76b0c9bc9d0fe Mon Sep 17 00:00:00 2001 From: Lucy Date: Tue, 26 Mar 2024 16:36:06 -0400 Subject: [PATCH] antag token notification improvements (#1476) * antag token improv * remove old define --- .../~monkestation-helpers/announcements.dm | 15 ++++++++ monkestation/code/datums/meta_tokens.dm | 38 +++++++++++++++++++ monkestation/code/modules/client/verbs.dm | 18 ++++++--- tgstation.dme | 1 + 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 code/__HELPERS/~monkestation-helpers/announcements.dm diff --git a/code/__HELPERS/~monkestation-helpers/announcements.dm b/code/__HELPERS/~monkestation-helpers/announcements.dm new file mode 100644 index 000000000000..2298bfe448f1 --- /dev/null +++ b/code/__HELPERS/~monkestation-helpers/announcements.dm @@ -0,0 +1,15 @@ +/proc/send_formatted_admin_message( + text, + title = "Admin Alert", + sound_override = 'sound/effects/adminhelp.ogg', + color_override = "red" +) + if(isnull(text)) + return + var/list/announcement_strings = list() + announcement_strings += SUBHEADER_ANNOUNCEMENT_TITLE(title) + announcement_strings += span_major_announcement_text(text) + var/finalized_announcement = create_announcement_div(jointext(announcement_strings, ""), color_override) + SEND_ADMINCHAT_MESSAGE(finalized_announcement) + if(sound_override) + SEND_ADMINS_NOTFICATION_SOUND(sound_override) diff --git a/monkestation/code/datums/meta_tokens.dm b/monkestation/code/datums/meta_tokens.dm index 751dd4a01af7..454e5eb8fcd5 100644 --- a/monkestation/code/datums/meta_tokens.dm +++ b/monkestation/code/datums/meta_tokens.dm @@ -37,6 +37,10 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list( var/event_token_month = 0 ///what token event do we currently have queued var/datum/twitch_event/queued_token_event + /// The timer for the antag token timeout + var/antag_timeout + /// The timer for the event token timeout + var/event_timeout /datum/meta_token_holder/New(client/creator) . = ..() @@ -128,6 +132,9 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list( in_queue = null in_queued_tier = null queued_donor = FALSE + if(antag_timeout) + deltimer(antag_timeout) + antag_timeout = null /datum/meta_token_holder/proc/reject_antag_token() if(!in_queue) @@ -135,9 +142,24 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list( to_chat(owner, span_boldwarning("Your request to play as [in_queue] has been denied.")) logger.Log(LOG_CATEGORY_META, "[owner]'s antag token for [in_queue] has been denied.") + SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50)) in_queue = null in_queued_tier = null queued_donor = FALSE + if(antag_timeout) + deltimer(antag_timeout) + antag_timeout = null + +/datum/meta_token_holder/proc/timeout_antag_token() + if(!in_queue) + return + to_chat(owner, span_boldwarning("Your request to play as [in_queue] wasn't answered within 5 minutes. Better luck next time!")) + logger.Log(LOG_CATEGORY_META, "[owner]'s antag token for [in_queue] has timed out.") + SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50)) + in_queue = null + in_queued_tier = null + queued_donor = FALSE + antag_timeout = null /datum/meta_token_holder/proc/adjust_event_tokens(amount) check_event_tokens(owner) @@ -162,6 +184,9 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list( adjust_event_tokens(-queued_token_event.token_cost) SStwitch.add_to_queue(initial(queued_token_event.id_tag)) queued_token_event = null + if(event_timeout) + deltimer(event_timeout) + event_timeout = null /datum/meta_token_holder/proc/reject_token_event() if(!queued_token_event) @@ -169,4 +194,17 @@ GLOBAL_LIST_INIT(patreon_etoken_values, list( to_chat(owner, span_boldwarning("Your request to trigger [queued_token_event] has been denied.")) logger.Log(LOG_CATEGORY_META, "[owner]'s event token for [queued_token_event] has been denied.") + SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50)) + queued_token_event = null + if(event_timeout) + deltimer(event_timeout) + event_timeout = null + +/datum/meta_token_holder/proc/timeout_event_token() + if(!queued_token_event) + return + logger.Log(LOG_CATEGORY_META, "[owner]'s event token for [queued_token_event] has timed out.") + to_chat(owner, span_boldwarning("Your request to trigger [queued_token_event] wasn't answered within 5 minutes. Better luck next time!")) + SEND_SOUND(owner, sound('sound/misc/compiler-failure.ogg', volume = 50)) queued_token_event = null + event_timeout = null diff --git a/monkestation/code/modules/client/verbs.dm b/monkestation/code/modules/client/verbs.dm index 505627ebbf73..663221f424bf 100644 --- a/monkestation/code/modules/client/verbs.dm +++ b/monkestation/code/modules/client/verbs.dm @@ -57,9 +57,12 @@ GLOBAL_LIST_INIT(antag_token_config, load_antag_token_config()) client_token_holder.in_queue = new chosen_antagonist to_chat(src, span_boldnotice("Your request has been sent to the admins.")) - SEND_NOTFIED_ADMIN_MESSAGE('sound/items/bikehorn.ogg', "[span_admin("[span_prefix("ANTAG TOKEN:")] [key_name(src)] \ - [ADMIN_APPROVE_ANTAG_TOKEN(src)] [ADMIN_REJECT_ANTAG_TOKEN(src)] | \ - [src] has requested to use their antag token to be a [chosen_antagonist::name].")]") + send_formatted_admin_message( \ + "[ADMIN_LOOKUPFLW(src)] has requested to use their antag token to be a [chosen_antagonist::name].\n\n[ADMIN_APPROVE_ANTAG_TOKEN(src)] | [ADMIN_REJECT_ANTAG_TOKEN(src)]", \ + title = "Antag Token Request", \ + color_override = "orange" \ + ) + client_token_holder.antag_timeout = addtimer(CALLBACK(client_token_holder, TYPE_PROC_REF(/datum/meta_token_holder, timeout_antag_token)), 5 MINUTES, TIMER_STOPPABLE | TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) /client/verb/trigger_token_event() set category = "IC" @@ -92,9 +95,12 @@ GLOBAL_LIST_INIT(antag_token_config, load_antag_token_config()) client_token_holder.queued_token_event = selected_event to_chat(src, span_boldnotice("Your request has been sent.")) logger.Log(LOG_CATEGORY_META, "[usr] has requested to use their event tokens to trigger [selected_event.event_name]([selected_event]).") - SEND_NOTFIED_ADMIN_MESSAGE('sound/items/bikehorn.ogg', "[span_admin("[span_prefix("TOKEN EVENT:")] [key_name(src)] \ - [ADMIN_APPROVE_TOKEN_EVENT(src)] [ADMIN_REJECT_TOKEN_EVENT(src)] | \ - [src] has requested use their event tokens to trigger [selected_event.event_name]([selected_event]).")]") + send_formatted_admin_message( \ + "[ADMIN_LOOKUPFLW(src)] has requested use their event tokens to trigger [selected_event.event_name]([selected_event]).\n\n[ADMIN_APPROVE_TOKEN_EVENT(src)] | [ADMIN_REJECT_TOKEN_EVENT(src)]", \ + title = "Event Token Request", \ + color_override = "orange" \ + ) + client_token_holder.event_timeout = addtimer(CALLBACK(client_token_holder, TYPE_PROC_REF(/datum/meta_token_holder, timeout_event_token)), 5 MINUTES, TIMER_STOPPABLE | TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) return to_chat(src, "You dont have enough tokens to trigger this event.") diff --git a/tgstation.dme b/tgstation.dme index 19cc79335a85..4b219b9193c8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -537,6 +537,7 @@ #include "code\__HELPERS\sorts\InsertSort.dm" #include "code\__HELPERS\sorts\MergeSort.dm" #include "code\__HELPERS\sorts\TimSort.dm" +#include "code\__HELPERS\~monkestation-helpers\announcements.dm" #include "code\__HELPERS\~monkestation-helpers\icon_smoothing.dm" #include "code\__HELPERS\~monkestation-helpers\time.dm" #include "code\__HELPERS\~monkestation-helpers\virology.dm"