From 6b0adb782fc407fca009b3338436068fbbb97b93 Mon Sep 17 00:00:00 2001 From: Runa Dacino Date: Sat, 29 Jul 2023 14:05:59 +0200 Subject: [PATCH] tweak(Event Triggers): Implements requested changes - Merges Personal, Vis and Aud checks into a single var - Removes excessive isObserver check - Permits removing other staff's stuff with an explicit confirmation and request to ask them first - Removes Invisibility = 100 setting from new() - Adds check for potential null responses - Clarifies comment in type definition. --- code/game/objects/effects/landmarks_events.dm | 42 +++++++++---------- code/modules/admin/verbs/event_triggers.dm | 29 ++++++++----- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/code/game/objects/effects/landmarks_events.dm b/code/game/objects/effects/landmarks_events.dm index 86c97c464ce..d95832ee160 100644 --- a/code/game/objects/effects/landmarks_events.dm +++ b/code/game/objects/effects/landmarks_events.dm @@ -11,7 +11,7 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm var/isTeamwork = FALSE //Whether to notify creator or whole team. var/isRepeating = FALSE var/coordinates = "" - var/cooldown = 0 //in seconds + var/cooldown = 0 //Given in seconds in set_vars() but stored in ticks var/last_trigger = 0 var/isLoud = FALSE var/isNarrate = FALSE @@ -19,10 +19,12 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm /obj/effect/landmark/event_trigger/New() ..() coordinates = "(X:[loc.x];Y:[loc.y];Z:[loc.z])" - invisibility = 100 /obj/effect/landmark/event_trigger/proc/set_vars(mob/M) - name = sanitize(tgui_input_text(M, "Input Name for the trigger", "Naming", "Event Trigger")) + var/new_name = sanitize(tgui_input_text(M, "Input Name for the trigger", "Naming", "Event Trigger")) + if(!new_name) + return + name = new_name creator_ckey = M.ckey if(!event_triggers[creator_ckey]) event_triggers[creator_ckey] = list() @@ -44,7 +46,7 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm ..() /obj/effect/landmark/event_trigger/Crossed(var/atom/movable/AM) - if(isobserver(AM) || !isliving(AM)) + if(!isliving(AM)) return FALSE var/mob/living/L = AM if(!L.ckey) return FALSE @@ -82,9 +84,8 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm /obj/effect/landmark/event_trigger/auto_narrate var/message - var/isVis_or_isAud = 0 //0 for vis, 1 for aud + var/isPersonal_orVis_orAud = 0 //0 for personal, 1 for vis, 2 for aud var/message_range //Leave at 0 for world.view - var/isPersonal = FALSE //Overrides isVis/isAud, to_chats the player var/isWarning = FALSE //For personal messages isNarrate = TRUE @@ -95,11 +96,11 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm /obj/effect/landmark/event_trigger/auto_narrate/set_vars(mob/M) ..() message = encode_html_emphasis(sanitize(tgui_input_text(M, "What should the automatic narration say?", "Message"), encode = FALSE)) - isPersonal = (tgui_alert(M, "Should it send directly to the player, or send to the turf?", "Target", list("Player", "Turf")) == "Player" ? TRUE : FALSE) - if(isPersonal) + isPersonal_orVis_orAud = (tgui_alert(M, "Should it send directly to the player, or send to the turf?", "Target", list("Player", "Turf")) == "Player" ? 0 : 1) + if(isPersonal_orVis_orAud == 0) isWarning = (tgui_alert(M, "Should it be a normal message or a big scary red text?", "Scary Red", list("Big Red", "Normal")) == "Big Red" ? TRUE : FALSE) else - isVis_or_isAud = (tgui_alert(M, "Should it be visible or audible?", "Mode", list("Visible", "Audible")) == "Audible" ? 1 : 0) + isPersonal_orVis_orAud = (tgui_alert(M, "Should it be visible or audible?", "Mode", list("Visible", "Audible")) == "Audible" ? 2 : 1) var/range = tgui_input_number(M, "Give narration range! Input value over 10 to use world.view", "Range",default = 11, min_value = 0) if(range <= 10) message_range = range @@ -113,17 +114,16 @@ Admin verb is called by code\modules\admin\verbs\event_triggers.dm if(!.) return var/mob/living/L = . - if(isPersonal) - if(isWarning) - to_chat(L, SPAN_DANGER(message)) - else - to_chat(L, message) - else - var/turf/T = get_turf(src) - switch(isVis_or_isAud) - if(0) - T.visible_message(message, range = message_range, runemessage = message) - if(1) - T.audible_message(message, hearing_distance = message_range, runemessage= message) + var/turf/T = get_turf(src) + switch(isPersonal_orVis_orAud) + if(0) + if(isWarning) + to_chat(L, SPAN_DANGER(message)) + else + to_chat(L, message) + if(1) + T.visible_message(message, range = message_range, runemessage = message) + if(2) + T.audible_message(message, hearing_distance = message_range, runemessage= message) if(!isRepeating) qdel(src) diff --git a/code/modules/admin/verbs/event_triggers.dm b/code/modules/admin/verbs/event_triggers.dm index 26221f8ac21..332e6a7d625 100644 --- a/code/modules/admin/verbs/event_triggers.dm +++ b/code/modules/admin/verbs/event_triggers.dm @@ -18,7 +18,7 @@ Eventkit verb to be used to spawn the obj/effect/landmarks defined under code\ga "Manage Other's Triggers", "Cancel" ), "Cancel" ) - if(mode == "Cancel") return + if(!mode || mode == "Cancel") return feedback_add_details("admin_verb","EventTriggerManage") switch(mode) @@ -40,7 +40,7 @@ Eventkit verb to be used to spawn the obj/effect/landmarks defined under code\ga personal_list |= list("Cancel", "Delete All") var/choice = tgui_input_list(src, "Select a landmark to choose between teleporting to it or deleting it, select delete all to clear them.", \ "Manage Personal Triggers", personal_list) - if(choice == "Cancel") + if(!choice || choice == "Cancel") return if(choice == "Delete All") var/confirm = tgui_alert(src, "ARE YOU SURE? THERE IS NO GOING BACK", "CONFIRM", list("Go Back", "Delete all my event triggers"), autofocus = FALSE) @@ -75,17 +75,21 @@ Eventkit verb to be used to spawn the obj/effect/landmarks defined under code\ga others_list |= list("Cancel", "Delete All") var/choice = tgui_input_list(src, "Select a landmark to choose between teleporting to it or deleting it, select delete all to clear them.", \ "Manage Personal Triggers", others_list) - if(choice == "Cancel") + if(!choice || choice == "Cancel") return if(choice == "Delete All") if(other_ckey && GLOB.directory[other_ckey]) var/client/C = GLOB.directory[other_ckey] var/mob/M = C.statobj if(M.client && M.client.inactivity < 30 MINUTES) - to_chat(src, SPAN_WARNING("[M] has only been inactive for [M.client.inactivity / (1 MINUTE)] minutes.\n \ - If you want to delete their event triggers, ask them in asay or discord to do it themselves or wait 30 minutes")) - log_and_message_admins("[src.ckey] tried to delete all of [other_ckey]'s event triggers, but [other_ckey] is active.") - return + if(tgui_alert(src, "[M] has only been inactive for [M.client.inactivity / (1 MINUTE)] minutes.\n \ + If you want to delete their event triggers, ask them in asay or discord to do it themselves or wait 30 minutes. \n \ + Only proceed if you are absolutely certain.", "Force Delete", list("Confirm", "Cancel")) == "Confirm") + for(var/obj/effect/landmark/event_trigger/ET in others_list) + ET.delete_me = TRUE + qdel(ET) + log_and_message_admins("[src.ckey] deleted all of [other_ckey]'s event triggers while [other_ckey] was active") + return var/confirm = tgui_alert(src, "ARE YOU SURE? THERE IS NO GOING BACK", "CONFIRM", list("Go Back", "Delete all my event triggers"), autofocus = FALSE) if(confirm == "Go Back") return @@ -109,10 +113,13 @@ Eventkit verb to be used to spawn the obj/effect/landmarks defined under code\ga var/client/C = GLOB.directory[other_ckey] var/mob/M = C.statobj if(M.client && M.client.inactivity < 30 MINUTES) - to_chat(src, SPAN_WARNING("[M] has only been inactive for [M.client.inactivity / (1 MINUTE)] minutes.\n \ - If you want to delete their event triggers, ask them in asay or discord to do it themselves or wait 30 minutes")) - log_and_message_admins("[src.ckey] tried to delete event trigger [ET.name], but [other_ckey] is active.") - return + if(tgui_alert(src, "[M] has only been inactive for [M.client.inactivity / (1 MINUTE)] minutes.\n \ + If you want to delete their event triggers, ask them in asay or discord to do it themselves or wait 30 minutes. \n \ + Only proceed if you are absolutely certain.", "Force Delete", list("Confirm", "Cancel")) == "Confirm") + ET.delete_me = TRUE + qdel(ET) + log_and_message_admins("[src.ckey] tried to delete event trigger [ET.name] while [other_ckey] is active.") + return var/confirm = tgui_alert(src, "ARE YOU SURE? THERE IS NO GOING BACK FROM DELETING [ET.name]", "CONFIRM", list("Go Back", "Delete it!"), autofocus = FALSE) if(confirm == "Go Back") return