Refactor weather to use Z traits, assorted related cleanup (#34633)

* Add a proc for getting the station center

* Add a couple of comments to ZTRAIT defines

* Remove unused global_map list

* Refactor weather to use the trait system

* Un-hardcode the transit z-level

* Use Z traits to determine Portal Storm event areas

* Fix loading away missions containing anything that reads traits
This commit is contained in:
Tad Hardesty
2018-01-21 11:33:11 -08:00
committed by CitadelStationBot
parent f692ffaa0c
commit 4451aca2e8
26 changed files with 114 additions and 122 deletions
+1 -1
View File
@@ -422,7 +422,7 @@
L.fix()
if("floorlava")
SSweather.run_weather("the floor is lava")
SSweather.run_weather(/datum/weather/floor_is_lava)
if("virus")
if(!check_rights(R_FUN))
+1 -1
View File
@@ -8,7 +8,7 @@ GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "config/away
if(GLOB.potentialRandomZlevels && GLOB.potentialRandomZlevels.len)
to_chat(world, "<span class='boldannounce'>Loading away mission...</span>")
var/map = pick(GLOB.potentialRandomZlevels)
load_new_z_level(map)
load_new_z_level(map, "Away Mission")
to_chat(world, "<span class='boldannounce'>Away mission loaded.</span>")
/proc/reset_gateway_spawns(reset = FALSE)
+4 -2
View File
@@ -33,14 +33,16 @@
var/list/hostiles_spawn = list()
var/list/hostile_types = list()
var/number_of_hostiles
var/list/station_areas = list()
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 = get_areas_in_z(ZLEVEL_STATION_PRIMARY)
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)
+1 -1
View File
@@ -16,4 +16,4 @@
//sound not longer matches the text, but an audible warning is probably good
/datum/round_event/radiation_storm/start()
SSweather.run_weather("radiation storm",ZLEVEL_STATION_PRIMARY)
SSweather.run_weather(/datum/weather/rad_storm)
@@ -13,4 +13,4 @@
/datum/round_event/wizard/darkness/start()
if(!started)
started = TRUE
SSweather.run_weather("advanced darkness", ZLEVEL_STATION_PRIMARY)
SSweather.run_weather(/datum/weather/advanced_darkness)
+1 -1
View File
@@ -12,4 +12,4 @@
/datum/round_event/wizard/lava/start()
if(!started)
started = TRUE
SSweather.run_weather("the floor is lava", ZLEVEL_STATION_PRIMARY)
SSweather.run_weather(/datum/weather/floor_is_lava)
+2 -1
View File
@@ -52,7 +52,8 @@
var/x = round((world.maxx - width)/2)
var/y = round((world.maxy - height)/2)
var/list/bounds = maploader.load_map(file(mappath), x, y)
var/datum/space_level/level = SSmapping.add_new_zlevel(name, UNAFFECTED, list(ZTRAIT_AWAY = TRUE))
var/list/bounds = maploader.load_map(file(mappath), x, y, level.z_value, no_changeturf=(SSatoms.initialized == INITIALIZATION_INSSATOMS))
if(!bounds)
return FALSE
@@ -44,3 +44,8 @@
if (S.traits[trait])
. += S.z_value
break
// Prefer not to use this one too often
/datum/controller/subsystem/mapping/proc/get_station_center()
var/station_z = levels_by_trait(ZTRAIT_STATION)[1]
return locate(round(world.maxx * 0.5, 1), round(world.maxy * 0.5, 1), station_z)
@@ -24,7 +24,7 @@
// TODO: sleep here if the Z level needs to be cleared
var/datum/space_level/S = new z_type(new_z, name, linkage, traits)
z_list += S
return new_z
return S
/datum/controller/subsystem/mapping/proc/get_level(z)
. = z_list[z]
+1 -1
View File
@@ -107,7 +107,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(turfs.len)
T = pick(turfs)
else
T = locate(round(world.maxx/2), round(world.maxy/2), ZLEVEL_STATION_PRIMARY) //middle of the station
T = SSmapping.get_station_center()
forceMove(T)
@@ -170,17 +170,18 @@ Difficulty: Medium
return
var/area/user_area = get_area(user)
if(user_area.type in excluded_areas)
var/turf/user_turf = get_turf(user)
if(!user_area || !user_turf || (user_area.type in excluded_areas))
to_chat(user, "<span class='warning'>Something is preventing you from using the staff here.</span>")
return
var/datum/weather/A
for(var/V in SSweather.existing_weather)
for(var/V in SSweather.processing)
var/datum/weather/W = V
if(W.target_z == user.z && W.area_type == user_area.type)
if((user_turf.z in W.impacted_z_levels) && W.area_type == user_area.type)
A = W
break
if(A)
if(A)
if(A.stage != END_STAGE)
if(A.stage == WIND_DOWN_STAGE)
to_chat(user, "<span class='warning'>The storm is already ending! It would be a waste to use the staff now.</span>")
@@ -191,10 +192,9 @@ Difficulty: Medium
A.wind_down()
return
else
A = new storm_type
A = new storm_type(list(user_turf.z))
A.name = "staff storm"
A.area_type = user_area.type
A.target_z = user.z
A.telegraph_duration = 100
A.end_duration = 100