Merge pull request #5001 from Citadel-Station-13/upstream-merge-34633

[MIRROR] Refactor weather to use Z traits, assorted related cleanup
This commit is contained in:
deathride58
2018-01-21 22:42:53 +00:00
committed by GitHub
26 changed files with 114 additions and 122 deletions
+19 -26
View File
@@ -1,10 +1,5 @@
//The effects of weather occur across an entire z-level. For instance, lavaland has periodic ash storms that scorch most unprotected creatures.
#define STARTUP_STAGE 1
#define MAIN_STAGE 2
#define WIND_DOWN_STAGE 3
#define END_STAGE 4
/datum/weather
var/name = "space wind"
var/desc = "Heavy gusts of wind blanket the area, periodically knocking down anyone caught in the open."
@@ -30,7 +25,7 @@
var/area_type = /area/space //Types of area to affect
var/list/impacted_areas = list() //Areas to be affected by the weather, calculated when the weather begins
var/list/protected_areas = list()//Areas that are protected and excluded from the affected areas.
var/target_z = ZLEVEL_STATION_PRIMARY //The z-level to affect
var/impacted_z_levels // The list of z-levels that this weather is actively affecting
var/overlay_layer = AREA_LAYER //Since it's above everything else, this is the layer used by default. TURF_LAYER is below mobs and walls if you need to use that.
var/aesthetic = FALSE //If the weather has no purpose other than looks
@@ -38,15 +33,13 @@
var/stage = END_STAGE //The stage of the weather, from 1-4
var/probability = FALSE //Percent chance to happen if there are other possible weathers on the z-level
// These are read by the weather subsystem and used to determine when and where to run the weather.
var/probability = 0 // Weight amongst other eligible weather. If zero, will never happen randomly.
var/target_trait = ZTRAIT_STATION // The z-level trait to affect when run randomly or when not overridden.
/datum/weather/New()
..()
SSweather.existing_weather += src
/datum/weather/Destroy()
SSweather.existing_weather -= src
/datum/weather/New(z_levels)
..()
impacted_z_levels = z_levels
/datum/weather/proc/telegraph()
if(stage == STARTUP_STAGE)
@@ -59,13 +52,14 @@
affectareas -= get_areas(V)
for(var/V in affectareas)
var/area/A = V
if(A.z == target_z)
if(A.z in impacted_z_levels)
impacted_areas |= A
weather_duration = rand(weather_duration_lower, weather_duration_upper)
START_PROCESSING(SSweather, src)
update_areas()
for(var/V in GLOB.player_list)
var/mob/M = V
if(M.z == target_z)
for(var/M in GLOB.player_list)
var/turf/mob_turf = get_turf(M)
if(mob_turf && (mob_turf.z in impacted_z_levels))
if(telegraph_message)
to_chat(M, telegraph_message)
if(telegraph_sound)
@@ -77,14 +71,13 @@
return
stage = MAIN_STAGE
update_areas()
for(var/V in GLOB.player_list)
var/mob/M = V
if(M.z == target_z)
for(var/M in GLOB.player_list)
var/turf/mob_turf = get_turf(M)
if(mob_turf && (mob_turf.z in impacted_z_levels))
if(weather_message)
to_chat(M, weather_message)
if(weather_sound)
SEND_SOUND(M, sound(weather_sound))
START_PROCESSING(SSweather, src)
addtimer(CALLBACK(src, .proc/wind_down), weather_duration)
/datum/weather/proc/wind_down()
@@ -92,25 +85,25 @@
return
stage = WIND_DOWN_STAGE
update_areas()
for(var/V in GLOB.player_list)
var/mob/M = V
if(M.z == target_z)
for(var/M in GLOB.player_list)
var/turf/mob_turf = get_turf(M)
if(mob_turf && (mob_turf.z in impacted_z_levels))
if(end_message)
to_chat(M, end_message)
if(end_sound)
SEND_SOUND(M, sound(end_sound))
STOP_PROCESSING(SSweather, src)
addtimer(CALLBACK(src, .proc/end), end_duration)
/datum/weather/proc/end()
if(stage == END_STAGE)
return 1
stage = END_STAGE
STOP_PROCESSING(SSweather, src)
update_areas()
/datum/weather/proc/can_weather_act(mob/living/L) //Can this weather impact a mob?
var/turf/mob_turf = get_turf(L)
if(mob_turf && (mob_turf.z != target_z))
if(mob_turf && !(mob_turf.z in impacted_z_levels))
return
if(immunity_type in L.weather_immunities)
return
@@ -18,7 +18,7 @@
end_sound = 'sound/ambience/acidrain_end.ogg'
area_type = /area/lavaland/surface/outdoors
target_z = ZLEVEL_LAVALAND
target_trait = ZTRAIT_MINING
immunity_type = "acid" // temp
@@ -14,7 +14,7 @@
end_duration = 0
area_type = /area
target_z = ZLEVEL_STATION_PRIMARY
target_trait = ZTRAIT_STATION
/datum/weather/advanced_darkness/update_areas()
for(var/V in impacted_areas)
@@ -17,7 +17,7 @@
end_overlay = "light_ash"
area_type = /area/lavaland/surface/outdoors
target_z = ZLEVEL_LAVALAND
target_trait = ZTRAIT_MINING
immunity_type = "ash"
@@ -32,7 +32,9 @@
. = ..()
var/list/inside_areas = list()
var/list/outside_areas = list()
var/list/eligible_areas = SSmapping.areas_in_z["[target_z]"]
var/list/eligible_areas = list()
for (var/z in impacted_z_levels)
eligible_areas += SSmapping.areas_in_z["[z]"]
for(var/i in 1 to eligible_areas.len)
var/area/place = eligible_areas[i]
if(place.outdoors)
@@ -16,14 +16,14 @@
area_type = /area
protected_areas = list(/area/space)
target_z = ZLEVEL_STATION_PRIMARY
target_trait = ZTRAIT_STATION
overlay_layer = ABOVE_OPEN_TURF_LAYER //Covers floors only
immunity_type = "lava"
/datum/weather/floor_is_lava/weather_act(mob/living/L)
for(var/obj/structure/O in L.loc)
for(var/obj/structure/O in L.loc)
if(O.density || (L in O.buckled_mobs && istype(O, /obj/structure/bed)))
return
if(L.loc.density)
@@ -19,7 +19,7 @@
area_type = /area
protected_areas = list(/area/maintenance, /area/ai_monitored/turret_protected/ai_upload, /area/ai_monitored/turret_protected/ai_upload_foyer,
/area/ai_monitored/turret_protected/ai, /area/storage/emergency/starboard, /area/storage/emergency/port, /area/shuttle)
target_z = ZLEVEL_STATION_PRIMARY
target_trait = ZTRAIT_STATION
immunity_type = "rad"