Files
Citadel-Station-13-RP/code/modules/planet/classp.dm
2022-03-13 23:09:54 -07:00

197 lines
5.4 KiB
Plaintext

var/datum/planet/classp/planet_classp = null
/datum/time/classp
seconds_in_day = 2 HOURS
/datum/planet/classp
name = "Class-P Frozen Planet"
desc = "A frosted world that seems stuck in time."
current_time = new /datum/time/classp()
expected_z_levels = list(15) // Debug testing.
/datum/planet/classp/New()
..()
planet_classp = src
weather_holder = new /datum/weather_holder/classp(src)
/datum/planet/classp/update_sun()
..()
var/datum/time/time = current_time
var/length_of_day = time.seconds_in_day / 10 / 60 / 60
var/noon = length_of_day / 2
var/distance_from_noon = abs(text2num(time.show_time("hh")) - noon)
sun_position = distance_from_noon / noon
sun_position = abs(sun_position - 1)
var/low_brightness = null
var/high_brightness = null
var/low_color = null
var/high_color = null
var/min = 0
switch(sun_position)
if(0 to 0.40) // Night
low_brightness = 0.2
low_color = "#110077"
high_brightness = 0.5
high_color = "#66004D"
min = 0
if(0.40 to 0.50) // Twilight
low_brightness = 0.6
low_color = "#66004D"
high_brightness = 0.8
high_color = "#CC3300"
min = 0.40
if(0.50 to 0.70) // Sunrise/set
low_brightness = 0.8
low_color = "#CC3300"
high_brightness = 0.9
high_color = "#FF9933"
min = 0.50
if(0.70 to 1.00) // Noon
low_brightness = 0.9
low_color = "#DDDDDD"
high_brightness = 1.0
high_color = "#FFFFFF"
min = 0.70
var/interpolate_weight = (abs(min - sun_position)) * 4
var/weather_light_modifier = 1
if(weather_holder && weather_holder.current_weather)
weather_light_modifier = weather_holder.current_weather.light_modifier
var/new_brightness = (LERP(low_brightness, high_brightness, interpolate_weight) ) * weather_light_modifier
var/new_color = null
if(weather_holder && weather_holder.current_weather && weather_holder.current_weather.light_color)
new_color = weather_holder.current_weather.light_color
else
var/list/low_color_list = hex2rgb(low_color)
var/low_r = low_color_list[1]
var/low_g = low_color_list[2]
var/low_b = low_color_list[3]
var/list/high_color_list = hex2rgb(high_color)
var/high_r = high_color_list[1]
var/high_g = high_color_list[2]
var/high_b = high_color_list[3]
var/new_r = LERP(low_r, high_r, interpolate_weight)
var/new_g = LERP(low_g, high_g, interpolate_weight)
var/new_b = LERP(low_b, high_b, interpolate_weight)
new_color = rgb(new_r, new_g, new_b)
spawn(1)
update_sun_deferred(2, new_brightness, new_color)
/datum/weather_holder/classp
temperature = T0C
allowed_weather_types = list(
WEATHER_LIGHT_SNOW = new /datum/weather/classp/light_snow(),
WEATHER_SNOW = new /datum/weather/classp/snow(),
WEATHER_BLIZZARD = new /datum/weather/classp/blizzard()
)
roundstart_weather_chances = list(
WEATHER_LIGHT_SNOW = 50,
WEATHER_SNOW = 25,
WEATHER_BLIZZARD = 25
)
/datum/weather/classp
name = "classp base"
temp_high = 260.15 // -19c
temp_low = 269.15 // -10c
/datum/weather/classp/light_snow
name = "light snow"
icon_state = "snowfall_light"
temp_high = 235.15
temp_low = 225.15
light_modifier = 0.7
transition_chances = list(
WEATHER_OVERCAST = 25,
WEATHER_LIGHT_SNOW = 50,
WEATHER_SNOW = 25,
)
observed_message = "It is snowing lightly."
transition_messages = list(
"Small snowflakes begin to fall from above.",
"It begins to snow lightly.",
)
/datum/weather/classp/snow
name = "moderate snow"
icon_state = "snowfall_med"
temp_high = 230.15
temp_low = 220.15
wind_high = 2
wind_low = 0
light_modifier = 0.5
flight_failure_modifier = 5
transition_chances = list(
WEATHER_LIGHT_SNOW = 20,
WEATHER_SNOW = 50,
WEATHER_BLIZZARD = 20,
WEATHER_HAIL = 5,
WEATHER_OVERCAST = 5
)
observed_message = "It is snowing."
transition_messages = list(
"It's starting to snow.",
"The air feels much colder as snowflakes fall from above."
)
outdoor_sounds_type = /datum/looping_sound/weather/outside_snow
indoor_sounds_type = /datum/looping_sound/weather/inside_snow
/datum/weather/classp/snow/process_effects()
..()
for(var/turf/simulated/floor/outdoors/snow/S in SSplanets.new_outdoor_turfs) //This didn't make any sense before SSplanets, either
if(S.z in holder.our_planet.expected_z_levels)
for(var/dir_checked in GLOB.cardinal)
var/turf/simulated/floor/T = get_step(S, dir_checked)
if(istype(T))
if(istype(T, /turf/simulated/floor/outdoors) && prob(33))
T.chill()
/datum/weather/classp/blizzard
name = "blizzard"
icon_state = "snowfall_heavy"
temp_high = 215.15
temp_low = 200.15
wind_high = 4
wind_low = 2
light_modifier = 0.3
flight_failure_modifier = 10
transition_chances = list(
WEATHER_SNOW = 45,
WEATHER_BLIZZARD = 50,
WEATHER_OVERCAST = 5
)
observed_message = "A blizzard blows snow everywhere."
transition_messages = list(
"Strong winds howl around you as a blizzard appears.",
"It starts snowing heavily, and it feels extremly cold now."
)
outdoor_sounds_type = /datum/looping_sound/weather/outside_blizzard
indoor_sounds_type = /datum/looping_sound/weather/inside_blizzard
/datum/weather/classp/blizzard/process_effects()
..()
for(var/turf/simulated/floor/outdoors/snow/S in SSplanets.new_outdoor_turfs) //This didn't make any sense before SSplanets, either
if(S.z in holder.our_planet.expected_z_levels)
for(var/dir_checked in GLOB.cardinal)
var/turf/simulated/floor/T = get_step(S, dir_checked)
if(istype(T))
if(istype(T, /turf/simulated/floor/outdoors) && prob(50))
T.chill()