Skip to content

Commit

Permalink
adds (partially broken) sunsets
Browse files Browse the repository at this point in the history
  • Loading branch information
GrrrKitten committed Jun 8, 2024
1 parent d362cf3 commit 3f3e6f0
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 1 deletion.
4 changes: 4 additions & 0 deletions code/__DEFINES/mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#define MODE_RANDOM_HIVE (1<<12)// Makes Join-as-Xeno choose a hive to join as burrowed larva at random rather than at user's input..
#define MODE_THUNDERSTORM (1<<13)// Enables thunderstorm effects on maps that are compatible with it. (Lit exterior tiles, rain effects)
#define MODE_FACTION_CLASH (1<<14)// Disables scopes, sniper sentries, OBs, shooting corpses, dragging enemy corpses, stripping enemy corpses
#define MODE_SUNSET (1<<15) // Has a sunset on the ground Z at the start of the round

// Gamemode Toggleable Flags
#define MODE_NO_SNIPER_SENTRY (1<<0) /// Upgrade kits will no longer allow you to select long-range upgrades
Expand Down Expand Up @@ -315,3 +316,6 @@ DEFINE_BITFIELD(whitelist_status, list(
GLOBAL_VAR(last_ares_callout)

GLOBAL_VAR(last_qm_callout)

/// Registered a single time, used to determine sunrise stuff
GLOBAL_VAR(sunrise_starting_time)
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ DEFINE_BITFIELD(flags_round_type, list(
"MODE_RANDOM_HIVE" = MODE_RANDOM_HIVE,
"MODE_THUNDERSTORM" = MODE_THUNDERSTORM,
"MODE_FACTION_CLASH" = MODE_FACTION_CLASH,
"MODE_SUNSET" = MODE_SUNSET,
))

DEFINE_BITFIELD(toggleable_flags, list(
Expand Down
222 changes: 222 additions & 0 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/mob
var/list/fullscreens = list()

///If a type of special lighting such as a sunset or lightning is currently active, dont have more than one of these without a special fullscreen framework
var/special_lighting = null

/mob/proc/overlay_fullscreen(category, type, severity)
var/atom/movable/screen/fullscreen/screen = fullscreens[category]
if (!screen || screen.type != type)
Expand Down Expand Up @@ -61,6 +64,21 @@
else
client.remove_from_screen(screen)

/mob/proc/initialize_special_lighting() //initialized on hud.dm when a new mob is spawned so you can't dodge this unless you dont have a client somehow
if(!SSticker.mode)
if(special_lighting)
return
SSticker.OnRoundstart(CALLBACK(src, PROC_REF(initialize_special_lighting)))
debug_msg("sunset call has been called on [src] but delayed to roundstart")
special_lighting = "sunset" // technically setting it early, but it shouldnt effect anything
return
if(SSticker.mode.flags_round_type & MODE_SUNSET)
if(fullscreens.len == 0)
return
addtimer(CALLBACK(src, PROC_REF(sunset)), 3 SECONDS) // 3 seconds for them to spawn in and other lighting stuff to load
special_lighting = "sunset"
debug_msg("sunset proc will be called on [src] in 3 seconds")


/atom/movable/screen/fullscreen
icon = 'icons/mob/hud/screen1_full.dmi'
Expand Down Expand Up @@ -227,6 +245,210 @@
color = "#000"
blend_mode = BLEND_ADD


/mob/proc/sunset(special_stage_time = null, special_call = FALSE)

var/atom/movable/screen/fullscreen/screen = fullscreens["lighting_backdrop"]
var/mob/lighting_mob = src
var/area/lighting_mob_area = get_area(lighting_mob)

if(!lighting_mob.client)
return

var/sun_color = "#000" /// used in the animation, set by sun stage and maptype
var/stage_time = 30 SECONDS /// how long each stage lasts, don't edit this if you want smooth movement, use special_stage_time instead
var/max_stages = 9 /// how many stages of sunset there are, starts at 0

var/startup_delay = 10 SECONDS /// how long the initial stage lasts for, doesn't factor in round start stuff

var/sun_stage = clamp((floor((ROUND_TIME + stage_time - startup_delay)/stage_time)), 0, max_stages) /// the current stage of the sun, ticks up by 1 every stagetime after startup_delay
//uses formula (x + y - z)/(y) with x = round_time, y = stage_time, and z being startup_delay

var/time_til_next_suncall = (sun_stage * stage_time) + startup_delay - ROUND_TIME /// how long until the next sunstage occurs

if(special_call)
sun_stage = clamp((sun_stage + 1), 0, max_stages) //you gotta start at the next stage if you come in during the duration of one in order to prevent advantages, more stages make this look better

if(SSmapping.configs[GROUND_MAP].environment_traits[MAP_COLD || ZTRAIT_IN_SPACE] || SSmapping.configs[GROUND_MAP].map_name == MAP_LV522_CHANCES_CLAIM) //if its cold or in space (or chances claim)
switch(sun_stage) //for sun stages, the more you have the better it looks when special called, I recommend choosing cinematic 4 colors then using a gradient tool to pick out the rest
if(0)
sun_color = "#a8c3cf"
special_stage_time = 0.5 SECONDS
time_til_next_suncall = startup_delay
if(1)
sun_color = "#718faf"
if(2)
sun_color = "#5e71a0"
if(3)
sun_color = "#414b70"
if(4)
sun_color = "#303e61"
if(5)
sun_color = "#292b48"
if(6)
sun_color = "#211b36"
if(7)
sun_color = "#1f1b33"
if(8)
sun_color = "#0c0a1b"
if(9)
sun_color = "#000"
else //a warm sunset for anywhere else
switch(sun_stage)
if(0)
sun_color = "#e3a979"
special_stage_time = 0.5 SECONDS
time_til_next_suncall = startup_delay
if(1)
sun_color = "#e29658"
if(2)
sun_color = "#da8b4a"
if(3)
sun_color = "#a9633c"
if(4)
sun_color = "#90422d"
if(5)
sun_color = "#68333a"
if(6)
sun_color = "#4d2b35"
if(7)
sun_color = "#231935"
if(8)
sun_color = "#050c27"
if(9)
sun_color = "#000"

debug_msg("sunset has been called")


debug_msg("(sun_stage * stage_time) + startup_delay - ROUND_TIME = ([(sun_stage * stage_time)/10]) + [startup_delay/10] - [ROUND_TIME/10]")
debug_msg("*------*")

debug_msg("roundtime = [ROUND_TIME/10] seconds, sun_stage = [sun_stage], ")

if(sun_stage < max_stages) // calls for the next sunset
debug_msg("next suncall in [time_til_next_suncall/10] seconds")
addtimer(CALLBACK(lighting_mob, PROC_REF(sunset)), time_til_next_suncall, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_DELETE_ME)
if(sun_stage == max_stages) // deactives special lighting when the sun hits #000
addtimer(VARSET_CALLBACK(lighting_mob, special_lighting, null), time_til_next_suncall)

if(CEILING_IS_PROTECTED(lighting_mob_area.ceiling, CEILING_PROTECTION_TIER_2)) //if underground, don't animate
return
if(!is_ground_level(lighting_mob.z)) // dont animate if not groundlevel
return

if(special_stage_time)
stage_time = special_stage_time

animate(screen, color = sun_color, time = stage_time)


/mob/proc/sunrise(special_stage_time = null, special_call = FALSE)

var/atom/movable/screen/fullscreen/screen = fullscreens["lighting_backdrop"]
var/mob/lighting_mob = src
var/area/lighting_mob_area = get_area(lighting_mob)

if(!lighting_mob.client || lighting_mob.special_lighting == "sunset")
return //failsafes

if(!GLOB.sunrise_starting_time) //failsafe incase sunrise gets called without a sunrise time set
(GLOB.sunrise_starting_time = ROUND_TIME)

var/sun_color = "#000" //saftey
var/stage_time = 60 SECONDS
var/max_stages = 3

var/current_time = ROUND_TIME

var/sun_stage = clamp((floor((GLOB.sunrise_starting_time - current_time)/stage_time)), 0, max_stages)

if(special_call)
sun_stage = clamp((sun_stage - 1), 0, max_stages) //you gotta start at the next stage if you come in during the duration of one in order to prevent advantages

switch(sun_stage)
if(0)
special_stage_time = 0.5 SECONDS //DONT FORGET TO ADD MORE STAGES, 4 IS NOT ENOUGH
sun_color = "#000" //a special confirmation to make sure that sunrise starts on full black
if(1)
sun_color = "#111322"
if(2)
sun_color = "#4e333d"
if(3)
sun_color = "#bb542b" //it ends on very orange for cinematics

lighting_mob.special_lighting = "sunrise" //sunrise is called a few different places instead of a single place so its easier to set it internally

if(sun_stage == 0) //get ddone with the first one fast then instantly call back
addtimer(CALLBACK(lighting_mob, PROC_REF(sunset)), special_stage_time, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_DELETE_ME)
else if(sun_stage < max_stages)
addtimer(CALLBACK(lighting_mob, PROC_REF(sunrise)), (((stage_time * sun_stage)) - GLOB.sunrise_starting_time), TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_DELETE_ME)
if(sun_stage == max_stages) // deactives special lighting when the sun hits #bb542b
addtimer(VARSET_CALLBACK(lighting_mob, special_lighting, null), stage_time)

if(CEILING_IS_PROTECTED(lighting_mob_area?.ceiling, CEILING_PROTECTION_TIER_2)) //if underground, don't animate
return
if(!is_ground_level(lighting_mob.z)) // dont animate if not groundlevel
return

if(special_stage_time)
stage_time = special_stage_time

animate(screen, color = sun_color, time = stage_time)


/mob/proc/special_lighting_listeners()
SIGNAL_HANDLER

var/mob/signaling_mob = src
if(signaling_mob.special_lighting && signaling_mob.client)
RegisterSignal(signaling_mob, COMSIG_MOVABLE_MOVED, PROC_REF(special_lighting_change))




/mob/proc/special_lighting_change()

var/atom/movable/screen/fullscreen/screen = fullscreens["lighting_backdrop"]
var/mob/lighting_mob = src

var/oldloc_z = oldloc.z

Check failure on line 415 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oldloc"

Check warning on line 415 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "z"
var/newloc_z = lighting_mob.z

if(!oldloc_z == newloc_z)
if(!is_ground_level(newloc_z))
animate(screen, color = "#000", time = 0.2 SECONDS, easing = QUAD_EASING | EASE_OUT) //its gotta be fast but not sudden
else if(is_ground_level(newloc_z))
switch(lighting_mob.special_lighting)
if("sunset")
lighting_mob.sunset(0.2 SECONDS, TRUE)
if("sunrise")
lighting_mob.sunrise(0.2 SECONDS, TRUE)

var/oldloc_area = get_area(oldloc)

Check failure on line 428 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oldloc"

Check failure on line 428 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oldloc"

Check failure on line 428 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "oldloc"
var/newloc_area = get_area(lighting_mob)

if(!oldloc_area == newloc_area) //dont gotta continue if its the same area

var/oldloc_incave
var/newloc_incave

if(CEILING_IS_PROTECTED(oldloc_area?.ceiling, CEILING_PROTECTION_TIER_2))

Check warning on line 436 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "ceiling"
oldloc_incave = TRUE
if(CEILING_IS_PROTECTED(newloc_area?.ceiling, CEILING_PROTECTION_TIER_2))

Check warning on line 438 in code/_onclick/hud/fullscreen.dm

View workflow job for this annotation

GitHub Actions / Run Linters

field access requires static type: "ceiling"
newloc_incave = TRUE

if(newloc_incave && !oldloc_incave)
animate(screen, color = "#000", time = 5 SECONDS, easing = QUAD_EASING | EASE_OUT) // 6 seconds no matter sunrise or sunset
else if(oldloc_incave && !newloc_incave)
switch(lighting_mob.special_lighting)
if("sunset")
lighting_mob.sunset(6 SECONDS, TRUE)
if("sunrise")
lighting_mob.sunrise(6 SECONDS, TRUE)



/atom/movable/screen/fullscreen/see_through_darkness
icon_state = "nightvision"
plane = LIGHTING_PLANE
Expand Down
1 change: 1 addition & 0 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
plane_masters["[instance.plane]"] = instance
if(owner.client)
instance.backdrop(mymob)
mymob.initialize_special_lighting()

for(var/mytype in subtypesof(/atom/movable/plane_master_controller))
var/atom/movable/plane_master_controller/controller_instance = new mytype(null,src)
Expand Down
10 changes: 9 additions & 1 deletion code/game/gamemodes/colonialmarines/colonialmarines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xeno_required_num = 1 //Need at least one xeno.
monkey_amount = 5
corpses_to_spawn = 0
flags_round_type = MODE_INFESTATION|MODE_FOG_ACTIVATED|MODE_NEW_SPAWN
flags_round_type = MODE_INFESTATION|MODE_FOG_ACTIVATED|MODE_NEW_SPAWN|MODE_SUNSET
static_comms_amount = 1
var/round_status_flags

Expand Down Expand Up @@ -312,6 +312,10 @@
else
SSticker.roundend_check_paused = TRUE
round_finished = MODE_INFESTATION_M_MAJOR //Humans destroyed the xenomorphs.
if(!GLOB.sunrise_starting_time)
(GLOB.sunrise_starting_time = ROUND_TIME)
for(var/mob/lighting_mob as anything in GLOB.player_list)
lighting_mob.sunrise()
ares_conclude()
addtimer(VARSET_CALLBACK(SSticker, roundend_check_paused, FALSE), MARINE_MAJOR_ROUND_END_DELAY)
else if(!num_humans && !num_xenos)
Expand All @@ -336,6 +340,10 @@
round_finished = MODE_INFESTATION_M_MAJOR
else
round_finished = MODE_INFESTATION_M_MINOR
if(!GLOB.sunrise_starting_time)
(GLOB.sunrise_starting_time = ROUND_TIME)
for(var/mob/lighting_mob as anything in GLOB.player_list)
lighting_mob.sunrise()

///////////////////////////////
//Checks if the round is over//
Expand Down

0 comments on commit 3f3e6f0

Please sign in to comment.