Skip to content

Commit

Permalink
Merge pull request #4198 from MistakeNot4892/map/shaded_hills
Browse files Browse the repository at this point in the history
Fixes several Shaded Hills map issues
  • Loading branch information
out-of-phaze authored Jul 16, 2024
2 parents 808b3b8 + 85e5f7e commit 28e2947
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 44 deletions.
2 changes: 2 additions & 0 deletions code/controllers/subsystems/mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ SUBSYSTEM_DEF(mapping)
for(var/obj/abstract/turbolift_spawner/turbolift as anything in turbolifts_to_initialize)
turbolift.build_turbolift()

global.using_map.finalize_map_generation()

. = ..()

/datum/controller/subsystem/mapping/Recover()
Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystems/weather.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SUBSYSTEM_DEF(weather)
return

///Sets a weather state to use for a given z level/z level stack. topmost_level may be a level_id or a level_data instance.
/datum/controller/subsystem/weather/proc/setup_weather_system(var/datum/level_data/topmost_level, var/decl/state/weather/initial_state)
/datum/controller/subsystem/weather/proc/setup_weather_system(var/datum/level_data/topmost_level, var/decl/state/weather/initial_state, list/banned_states)
if(istext(topmost_level))
topmost_level = SSmapping.levels_by_id[topmost_level]

Expand All @@ -41,7 +41,7 @@ SUBSYSTEM_DEF(weather)
unregister_weather_system(WS)
qdel(WS)
//Create the new weather system and let it register itself
new /obj/abstract/weather_system(locate(1, 1, topmost_level.level_z), topmost_level.level_z, initial_state)
new /obj/abstract/weather_system(locate(1, 1, topmost_level.level_z), topmost_level.level_z, initial_state, banned_states)

///Registers a given weather system obj for getting updates by SSweather.
/datum/controller/subsystem/weather/proc/register_weather_system(var/obj/abstract/weather_system/WS)
Expand Down
26 changes: 13 additions & 13 deletions code/datums/daycycle/daycycle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
/// Unique string ID used to register a level with a daycycle.
var/daycycle_id
/// How long is a full day and night cycle?
var/day_duration = 30 MINUTES
var/cycle_duration = 1 HOUR
/// How far are we into the current cycle?
var/time_of_day = 0
var/time_in_cycle = 0
/// What world.time did we last update? Used to calculate time progression between ticks.
var/last_update = 0
/// What z-levels are affected by this daycycle? Used for mass updating ambience.
var/list/levels_affected = list()
/// What period of day are we sitting in as of our last update?
var/datum/time_of_day/current_period
var/datum/daycycle_period/current_period
/// Mappings of colour and power to % progression points throughout the cycle.
/// Each entry must be arranged in order of earliest to latest.
/// Null values on periods use the general level ambience instead.
var/list/cycle_periods = list(
new /datum/time_of_day/sunrise,
new /datum/time_of_day/daytime,
new /datum/time_of_day/sunset,
new /datum/time_of_day/night
new /datum/daycycle_period/sunrise,
new /datum/daycycle_period/daytime,
new /datum/daycycle_period/sunset,
new /datum/daycycle_period/night
)

/datum/daycycle/New(_cycle_id)
Expand All @@ -45,12 +45,12 @@

/datum/daycycle/proc/transition_daylight()

time_of_day = (time_of_day + (world.time - last_update)) % day_duration
time_in_cycle = (time_in_cycle + (world.time - last_update)) % cycle_duration
last_update = world.time

var/datum/time_of_day/last_period = current_period
var/progression_percentage = time_of_day / day_duration
for(var/datum/time_of_day/period in cycle_periods)
var/datum/daycycle_period/last_period = current_period
var/progression_percentage = time_in_cycle / cycle_duration
for(var/datum/daycycle_period/period in cycle_periods)
if(progression_percentage <= period.period)
current_period = period
break
Expand All @@ -74,11 +74,11 @@
level.update_turf_ambience()

/datum/daycycle/exoplanet/New()
day_duration = rand(get_config_value(/decl/config/num/exoplanet_min_day_duration), get_config_value(/decl/config/num/exoplanet_max_day_duration)) MINUTES
cycle_duration = rand(get_config_value(/decl/config/num/exoplanet_min_day_duration), get_config_value(/decl/config/num/exoplanet_max_day_duration)) MINUTES
..()

// Dummy daycycle used solely so the sun datum has a chance to tick.
/datum/daycycle/solars
cycle_periods = list(
new /datum/time_of_day/permanent_daytime
new /datum/daycycle_period/permanent_daytime
)
14 changes: 7 additions & 7 deletions code/datums/daycycle/time_of_day.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/datum/time_of_day
abstract_type = /datum/time_of_day
/datum/daycycle_period
abstract_type = /datum/daycycle_period
/// In-character descriptor (ie. 'sunrise')
var/name
/// Message shown to outdoors players when the daycycle moves to this period.
Expand All @@ -13,36 +13,36 @@
/// Ambient temperature modifier during this time of day.
var/temperature

/datum/time_of_day/sunrise
/datum/daycycle_period/sunrise
name = "sunrise"
announcement = "The sun peeks over the horizon, bathing the world in rosy light."
period = 0.1
color = COLOR_RED_LIGHT
power = 0.5

/datum/time_of_day/daytime
/datum/daycycle_period/daytime
name = "daytime"
announcement = "The sun rises over the horizon, beginning another day."
period = 0.4
power = 1
color = COLOR_DAYLIGHT

/datum/time_of_day/sunset
/datum/daycycle_period/sunset
name = "sunset"
announcement = "The sun begins to dip below the horizon, and the daylight fades."
period = 0.6
color = COLOR_ORANGE
power = 0.5

/datum/time_of_day/night
/datum/daycycle_period/night
name = "night"
announcement = "Night falls, blanketing the world in darkness."
period = 1
color = COLOR_CYAN_BLUE
power = 0.3

// Dummy period used by solars.
/datum/time_of_day/permanent_daytime
/datum/daycycle_period/permanent_daytime
name = null
announcement = null
color = null
Expand Down
19 changes: 12 additions & 7 deletions code/modules/weather/_weather.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
appearance_flags = (RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM)
is_spawnable_type = FALSE

// List of /decl/state types that are forbidden.
var/list/banned_weather_conditions

var/water_material = /decl/material/liquid/water // Material to use for the properties of rain.
var/ice_material = /decl/material/solid/ice // Material to use for the properties of snow and hail.

Expand Down Expand Up @@ -82,13 +85,15 @@
// Exoplanet stuff for the future:
// - TODO: track and check exoplanet temperature.
// - TODO: compare to a list of 'acceptable' states
if(istype(next_state))
if(next_state.is_liquid)
return !!water_material
if(next_state.is_ice)
return !!ice_material
return TRUE
return FALSE
if(!istype(next_state))
return FALSE
if(next_state.is_liquid && isnull(water_material))
return FALSE
if(next_state.is_ice && isnull(ice_material))
return FALSE
if(length(banned_weather_conditions) && (next_state.type in banned_weather_conditions))
return FALSE
return TRUE

// Dummy object for lightning flash animation.
/obj/abstract/lightning_overlay
Expand Down
2 changes: 1 addition & 1 deletion code/modules/weather/weather_fsm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
for(var/decl/state_transition/weather/state_transition in valid_transitions)
transitions[state_transition] = state_transition.likelihood_weighting
if(length(transitions))
return pick(transitions) //pickweight(transitions)
return pickweight(transitions)
return ..()
8 changes: 6 additions & 2 deletions code/modules/weather/weather_fsm_state_transitions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@

/decl/state_transition/weather/calm
target = /decl/state/weather/calm
likelihood_weighting = 50

/decl/state_transition/weather/cold
target = /decl/state/weather/cold
likelihood_weighting = 50

/decl/state_transition/weather/snow
target = /decl/state/weather/snow
likelihood_weighting = 30

/decl/state_transition/weather/rain
target = /decl/state/weather/rain
likelihood_weighting = 30

/decl/state_transition/weather/snow_medium
target = /decl/state/weather/snow/medium
likelihood_weighting = 20

/decl/state_transition/weather/snow_heavy
target = /decl/state/weather/snow/heavy
likelihood_weighting = 20
likelihood_weighting = 10

/decl/state_transition/weather/storm
target = /decl/state/weather/rain/storm
likelihood_weighting = 20

/decl/state_transition/weather/hail
target = /decl/state/weather/rain/hail
Expand Down
4 changes: 3 additions & 1 deletion code/modules/weather/weather_init.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
INITIALIZE_IMMEDIATE(/obj/abstract/weather_system)
/obj/abstract/weather_system/Initialize(var/ml, var/target_z, var/initial_weather)
/obj/abstract/weather_system/Initialize(var/ml, var/target_z, var/initial_weather, var/list/banned)
SSweather.register_weather_system(src)

. = ..()

set_invisibility(INVISIBILITY_NONE)

banned_weather_conditions = banned

// Bookkeeping/rightclick guards.
verbs.Cut()
forceMove(null)
Expand Down
2 changes: 1 addition & 1 deletion maps/planets/test_planet/test_planet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
fauna = /datum/fauna_generator/neutralia

/datum/daycycle/exoplanet/neutralia
day_duration = 12 MINUTES
cycle_duration = 12 MINUTES

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Neutralia Template
Expand Down
14 changes: 4 additions & 10 deletions maps/shaded_hills/levels/_levels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
var/submap_area
var/list/mobs_to_spawn = list()

/datum/daycycle/shaded_hills
cycle_duration = 2 HOURS // 1 hour of daylight, 1 hour of night

// Randomized time of day to start at.
/datum/daycycle/shaded_hills/New()
time_of_day = rand(day_duration)
time_in_cycle = rand(cycle_duration)
..()

/datum/level_data/player_level/shaded_hills/get_subtemplate_areas(template_category, blacklist, whitelist)
Expand Down Expand Up @@ -83,10 +86,6 @@
)
)

/datum/level_data/player_level/shaded_hills/grassland/after_generate_level()
. = ..()
// Neither of these procs handle laterally linked levels yet.
SSweather.setup_weather_system(src)

/datum/level_data/player_level/shaded_hills/swamp
name = "Shaded Hills - Swamp"
Expand Down Expand Up @@ -178,11 +177,6 @@
submap_category = MAP_TEMPLATE_CATEGORY_SH_DOWNLANDS
submap_area = /area/shaded_hills/outside/downlands/poi

/datum/level_data/player_level/shaded_hills/downlands/after_generate_level()
. = ..()
// Neither of these procs handle laterally linked levels yet.
SSweather.setup_weather_system(src)

/datum/level_data/player_level/shaded_hills/caverns
name = "Shaded Hills - Caverns"
level_id = "shaded_hills_caverns"
Expand Down
8 changes: 8 additions & 0 deletions maps/shaded_hills/shaded_hills-inn.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"bW" = (
/obj/structure/table/woodentable/ebony,
/obj/item/chems/cooking_vessel/skillet,
/obj/item/chems/glass/pottery/bowl,
/obj/item/chems/glass/pottery/bowl,
/obj/item/chems/glass/pottery/bowl,
/obj/item/chems/glass/pottery/cup,
/obj/item/chems/glass/pottery/cup,
/obj/item/chems/glass/pottery/cup,
/turf/floor/wood/walnut,
/area/shaded_hills/shrine)
"cl" = (
Expand Down Expand Up @@ -1080,6 +1086,8 @@
/obj/item/chems/food/grown/carrot,
/obj/item/chems/food/grown/carrot,
/obj/item/chems/food/grown/cabbage,
/obj/item/chems/condiment/flour,
/obj/item/chems/condiment/large/salt,
/turf/floor/wood/walnut,
/area/shaded_hills/shrine)
"TR" = (
Expand Down
11 changes: 11 additions & 0 deletions maps/shaded_hills/shaded_hills_map.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
/decl/loadout_category/fantasy/utility
)

/datum/map/shaded_hills/finalize_map_generation()
. = ..()
var/static/list/banned_weather = list(
/decl/state/weather/snow/medium,
/decl/state/weather/snow/heavy,
/decl/state/weather/snow
)
var/datum/level_data/shadyhills = SSmapping.levels_by_id["shaded_hills_grassland"]
if(istype(shadyhills)) // if this is false, something has badly exploded
SSweather.setup_weather_system(shadyhills, banned_states = banned_weather)

/decl/spawnpoint/arrivals
name = "Queens' Road"
spawn_announcement = null
3 changes: 3 additions & 0 deletions maps/~mapsystem/maps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,6 @@ var/global/const/MAP_HAS_RANK = 2 //Rank system, also togglable
/datum/map/proc/populate_overmap_events()
for(var/overmap_id in global.overmaps_by_name)
SSmapping.overmap_event_handler.create_events(global.overmaps_by_name[overmap_id])

/datum/map/proc/finalize_map_generation()
return
1 change: 1 addition & 0 deletions mods/species/drakes/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
base_external_prosthetics_model = null // no robolimbs for dogs
preview_outfit = null // no pants for dogs
snow_slowdown_mod = -0.5
gluttonous = GLUT_TINY
available_pronouns = list(
/decl/pronouns,
/decl/pronouns/neuter,
Expand Down

0 comments on commit 28e2947

Please sign in to comment.