diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index cf8a9df119..54dd2a982c 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -488,6 +488,11 @@ for(var/key in key_list) . |= key_list[key] +/proc/make_associative(list/flat_list) + . = list() + for(var/thing in flat_list) + .[thing] = TRUE + //Picks from the list, with some safeties, and returns the "default" arg if it fails #define DEFAULTPICK(L, default) ((islist(L) && length(L)) ? pick(L) : default) diff --git a/code/controllers/subsystem/events.dm b/code/controllers/subsystem/events.dm index e70fd1cd7d..ffc934c061 100644 --- a/code/controllers/subsystem/events.dm +++ b/code/controllers/subsystem/events.dm @@ -93,25 +93,6 @@ SUBSYSTEM_DEF(events) else if(. == EVENT_READY) E.runEvent(TRUE) -/datum/round_event/proc/findEventArea() //Here's a nice proc to use to find an area for your event to land in! - var/list/safe_areas = list( - /area/ai_monitored/turret_protected/ai, - /area/ai_monitored/turret_protected/ai_upload, - /area/engine, - /area/solar, - /area/holodeck, - /area/shuttle - ) - - //These are needed because /area/engine has to be removed from the list, but we still want these areas to get fucked up. - var/list/danger_areas = list( - /area/engine/break_room, - /area/crew_quarters/heads/chief) - - //Need to locate() as it's just a list of paths. - return locate(pick((GLOB.the_station_areas - safe_areas) + danger_areas)) in GLOB.sortedAreas - - //allows a client to trigger an event //aka Badmin Central // > Not in modules/admin diff --git a/code/modules/events/anomaly.dm b/code/modules/events/anomaly.dm index c866dcca0f..bb1df49ca5 100644 --- a/code/modules/events/anomaly.dm +++ b/code/modules/events/anomaly.dm @@ -12,17 +12,33 @@ announceWhen = 1 -/datum/round_event/anomaly/setup(loop=0) - var/safety_loop = loop + 1 - if(safety_loop > 50) - kill() - end() +/datum/round_event/anomaly/proc/findEventArea() + var/static/list/allowed_areas + if(!allowed_areas) + //Places that shouldn't explode + var/list/safe_area_types = typecacheof(list( + /area/ai_monitored/turret_protected/ai, + /area/ai_monitored/turret_protected/ai_upload, + /area/engine, + /area/solar, + /area/holodeck, + /area/shuttle) + ) + + //Subtypes from the above that actually should explode. + var/list/unsafe_area_subtypes = typecacheof(list(/area/engine/break_room)) + + allowed_areas = make_associative(GLOB.the_station_areas) - safe_area_types + unsafe_area_subtypes + + return safepick(typecache_filter_list(GLOB.sortedAreas,allowed_areas)) + +/datum/round_event/anomaly/setup() impact_area = findEventArea() if(!impact_area) - setup(safety_loop) + CRASH("No valid areas for anomaly found.") var/list/turf_test = get_area_turfs(impact_area) if(!turf_test.len) - setup(safety_loop) + CRASH("Anomaly : No valid turfs found for [impact_area] - [impact_area.type]") /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") @@ -30,4 +46,4 @@ /datum/round_event/anomaly/start() var/turf/T = safepick(get_area_turfs(impact_area)) if(T) - newAnomaly = new /obj/effect/anomaly/flux(T) + newAnomaly = new /obj/effect/anomaly/flux(T) \ No newline at end of file