From dfdf01e79ee017b7b025ecbad7281ed80e8dfac2 Mon Sep 17 00:00:00 2001 From: ShizCalev Date: Mon, 22 Jan 2018 17:24:38 -0500 Subject: [PATCH] Fixes portal storm event (#34725) --- code/__HELPERS/unsorted.dm | 3 +++ code/modules/events/portal_storm.dm | 35 ++++++++--------------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index ad52e5b340..d33525e012 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1199,6 +1199,9 @@ B --><-- A sleep(duration) A.cut_overlay(O) +/proc/get_random_station_turf() + return safepick(get_area_turfs(pick(GLOB.the_station_areas))) + /proc/get_closest_atom(type, list, source) var/closest_atom var/closest_distance diff --git a/code/modules/events/portal_storm.dm b/code/modules/events/portal_storm.dm index 054441405f..aa91497b0a 100644 --- a/code/modules/events/portal_storm.dm +++ b/code/modules/events/portal_storm.dm @@ -33,17 +33,12 @@ var/list/hostiles_spawn = list() var/list/hostile_types = list() var/number_of_hostiles - var/list/station_areas var/mutable_appearance/storm /datum/round_event/portal_storm/setup() storm = mutable_appearance('icons/obj/tesla_engine/energy_ball.dmi', "energy_ball_fast", FLY_LAYER) storm.color = "#00FF00" - station_areas = list() - for (var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) - station_areas |= SSmapping.areas_in_z["[z]"] - number_of_bosses = 0 for(var/boss in boss_types) number_of_bosses += boss_types[boss] @@ -52,19 +47,11 @@ for(var/hostile in hostile_types) number_of_hostiles += hostile_types[hostile] - var/list/b_spawns = GLOB.generic_event_spawns.Copy() while(number_of_bosses > boss_spawn.len) - var/turf/F = get_turf(pick_n_take(b_spawns)) - if(!F) - F = safepick(get_area_turfs(pick(station_areas))) - boss_spawn += F + boss_spawn += get_random_station_turf() - var/list/h_spawns = GLOB.generic_event_spawns.Copy() while(number_of_hostiles > hostiles_spawn.len) - var/turf/T = get_turf(pick_n_take(h_spawns)) - if(!T) - T = safepick(get_area_turfs(pick(station_areas))) - hostiles_spawn += T + hostiles_spawn += get_random_station_turf() next_boss_spawn = startWhen + CEILING(2 * number_of_hostiles / number_of_bosses, 1) @@ -77,7 +64,7 @@ sound_to_playing_players('sound/magic/lightningbolt.ogg') /datum/round_event/portal_storm/tick() - spawn_effects() + spawn_effects(get_random_station_turf()) if(spawn_hostile()) var/type = safepick(hostile_types) @@ -105,16 +92,12 @@ spawn_effects(T) /datum/round_event/portal_storm/proc/spawn_effects(turf/T) - if(T) - T = get_step(T, SOUTHWEST) //align center of image with turf - flick_overlay_static(storm, T, 15) - playsound(T, 'sound/magic/lightningbolt.ogg', 100, 1) - else - for(var/V in station_areas) - var/area/A = V - var/turf/F = get_turf(pick(A.contents)) - flick_overlay_static(storm, F, 15) - playsound(F, 'sound/magic/lightningbolt.ogg', 80, 1) + if(!T) + log_game("Portal Storm failed to spawn effect due to an invalid location.") + return + T = get_step(T, SOUTHWEST) //align center of image with turf + flick_overlay_static(storm, T, 15) + playsound(T, 'sound/magic/lightningbolt.ogg', rand(80, 100), 1) /datum/round_event/portal_storm/proc/spawn_hostile() if(!hostile_types || !hostile_types.len)