From e5d7c8d09e4b07a36104a97d072bc7d81c0457bf Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 25 Dec 2022 06:24:30 +0100 Subject: [PATCH] [MIRROR] Anomalies can now be triggered at your location with admin_setup. Also sets control on setup() for events [MDB IGNORE] (#18304) * Anomalies can now be triggered at your location with admin_setup. Also sets control on setup() for events (#72065) ## About The Pull Request Anomaly random events will now ask if you want their anomaly to spawn at your location if triggered via admin setup. This PR also makes a small but useful change to the logic for new round_event objects. round_events now have their control (their associated round_event_controller) set on New, rather than after setup is called. Previously, round_events could not access control in their setup proc (as it was not set at the time), meaning transferring admin-chosen variables had to be done later in start/announce (depending on which comes sooner). While this has just been worked around in the past, the change needed to be made here, as some anomaly event types announce first, and some start first. The admin variables needed to be passed in earlier than start/announce (in setup). Short version: you can access control in round_event setup() now :D ## Why It's Good For The Game MORE adminbus, MORE anomaly shenanigans (they're one of my favorite event types). Also resolves a quirk in event code that bothered me in other PRs I've made. ## Changelog :cl: Rhials admin: anomaly events now give the option to occur at your current location when triggered with the Trigger Event admin verb /:cl: * Anomalies can now be triggered at your location with admin_setup. Also sets control on setup() for events Co-authored-by: Rhials --- code/modules/events/_event.dm | 6 ++--- code/modules/events/anomaly/_anomaly.dm | 33 +++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/code/modules/events/_event.dm b/code/modules/events/_event.dm index bfb6d62bf8f..767986c3e2c 100644 --- a/code/modules/events/_event.dm +++ b/code/modules/events/_event.dm @@ -122,9 +122,8 @@ Runs the event * * In the worst case scenario we can still recall a event which we cancelled by accident, which is much better then to have a unwanted event */ UnregisterSignal(SSdcs, COMSIG_GLOB_RANDOM_EVENT) - var/datum/round_event/E = new typepath() + var/datum/round_event/E = new typepath(TRUE, src) E.current_players = get_active_player_count(alive_check = 1, afk_check = 1, human_check = 1) - E.control = src occurrences++ SSevents.previously_run += src //SKYRAT EDIT ADDITION @@ -280,7 +279,8 @@ Runs the event //Sets up the event then adds the event to the the list of running events -/datum/round_event/New(my_processing = TRUE) +/datum/round_event/New(my_processing = TRUE, datum/round_event_control/event_controller) + control = event_controller setup() processing = my_processing SSevents.running += src diff --git a/code/modules/events/anomaly/_anomaly.dm b/code/modules/events/anomaly/_anomaly.dm index e17ecfb59e3..0e3cb80bcc9 100644 --- a/code/modules/events/anomaly/_anomaly.dm +++ b/code/modules/events/anomaly/_anomaly.dm @@ -7,6 +7,17 @@ weight = 15 category = EVENT_CATEGORY_ANOMALIES description = "This anomaly shocks and explodes. This is the base type." + ///The admin-chosen spawn location. + var/turf/spawn_location + +/datum/round_event_control/anomaly/admin_setup(mob/admin) + . = ..() + + if(!check_rights(R_FUN)) + return ADMIN_CANCEL_EVENT + + if(tgui_alert(usr, "Spawn anomaly at your current location?", "Anomaly Alert", list("Yes", "No")) == "Yes") + spawn_location = get_turf(usr) /datum/round_event/anomaly var/area/impact_area @@ -15,15 +26,33 @@ announce_when = 1 /datum/round_event/anomaly/setup() - impact_area = placer.findValidArea() + + end_when = start_when + 1 //Admin vars are cleared on end(), so we make sure the anomaly spawns before then. + + var/datum/round_event_control/anomaly/anomaly_event = control + if(anomaly_event.spawn_location) + impact_area = get_area(anomaly_event.spawn_location) + else + impact_area = placer.findValidArea() /datum/round_event/anomaly/announce(fake) priority_announce("Localized energetic flux wave detected on long range scanners. Expected location of impact: [impact_area.name].", "Anomaly Alert") /datum/round_event/anomaly/start() - var/turf/anomaly_turf = placer.findValidTurf(impact_area) + var/turf/anomaly_turf + + var/datum/round_event_control/anomaly/anomaly_event = control + if(anomaly_event.spawn_location) + anomaly_turf = anomaly_event.spawn_location + else + anomaly_turf = placer.findValidTurf(impact_area) + var/newAnomaly if(anomaly_turf) newAnomaly = new anomaly_path(anomaly_turf) if (newAnomaly) announce_to_ghosts(newAnomaly) + +/datum/round_event/anomaly/end() + var/datum/round_event_control/anomaly/anomaly_event = control + anomaly_event.spawn_location = null