Merge pull request #7248 from Citadel-Station-13/upstream-merge-38683

[MIRROR] Fixes anomaly area selection.
This commit is contained in:
LetterJay
2018-07-01 09:26:38 -05:00
committed by GitHub
3 changed files with 29 additions and 27 deletions
+5
View File
@@ -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)
-19
View File
@@ -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
+24 -8
View File
@@ -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)