[MIRROR] Up ports the dynamic light system (#10149)

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-02-13 06:49:16 -07:00
committed by GitHub
parent fe69ddd909
commit 7e2fd538ac
26 changed files with 99 additions and 677 deletions

View File

@@ -6,4 +6,4 @@
#define DEFAULT_ICON_SCALE_Y 1
#define DEFAULT_ICON_ROTATION 0
#define MOVE_GLIDE_CALC(glide_size, moving_diagonally) ( (TICKS2DS(WORLD_ICON_SIZE/glide_size)) * (moving_diagonally ? (ONE_OVER_SQRT_2) : 1) ) //ChompEDIT - move calc
#define MOVE_GLIDE_CALC(glide_size, moving_diagonally) ( (TICKS2DS(WORLD_ICON_SIZE/glide_size)) * (moving_diagonally ? (ONE_OVER_SQRT_2) : 1) ) // - move calc

View File

@@ -202,10 +202,10 @@
//Lighting values used by the station lights
#define LIGHT_COLOR_FLUORESCENT_TUBE "#E0EFFF"
#define LIGHT_COLOR_FLUORESCENT_FLASHLIGHT "#CDDDFF"
#define LIGHT_COLOR_INCANDESCENT_TUBE "#fffed9"
#define LIGHT_COLOR_INCANDESCENT_BULB "#ffe7ce"
#define LIGHT_COLOR_INCANDESCENT_TUBE "#E0EFF0"
#define LIGHT_COLOR_INCANDESCENT_BULB "#FFFEB8"
#define LIGHT_COLOR_INCANDESCENT_FLASHLIGHT "#FFCC66"
#define LIGHT_COLOR_NIGHTSHIFT "#EFCC86"
//Fake ambient occlusion filter
#define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-2, size=4, offset=3, color="#04080F80")
#define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-1, size=2, offset=2, color="#04080F55")

View File

@@ -117,3 +117,34 @@ do { \
source.lum_b = 1; \
}; \
} while (FALSE)
//Fake ambient occlusion filter
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3
#define SUNLIGHT_RADIUS 9 //Tiles that sunlight penetrates into shade
#define SUNLIGHT_NONE 0
#define SUNLIGHT_POSSIBLE 1
#define SUNLIGHT_CURRENT 2
#define SUNLIGHT_OVERHEAD 3
#define SUNLIGHT_ONLY 4
#define SUNLIGHT_ONLY_SHADE 5
// Keep in mind. Lighting corners accept the bottom left (northwest) set of cords to them as input
// Handles dynamic light
#define GENERATE_MISSING_CORNERS(gen_for) \
if (!gen_for.lighting_corner_NE) { \
gen_for.lighting_corner_NE = new /datum/lighting_corner(gen_for.x, gen_for.y, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_SE) { \
gen_for.lighting_corner_SE = new /datum/lighting_corner(gen_for.x, gen_for.y - 1, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_SW) { \
gen_for.lighting_corner_SW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y - 1, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_NW) { \
gen_for.lighting_corner_NW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
gen_for.lighting_corners_initialised = TRUE;

View File

@@ -1,7 +0,0 @@
#define SUNLIGHT_RADIUS 9 //Tiles that sunlight penetrates into shade
#define SUNLIGHT_NONE 0
#define SUNLIGHT_POSSIBLE 1
#define SUNLIGHT_CURRENT 2
#define SUNLIGHT_OVERHEAD 3
#define SUNLIGHT_ONLY 4
#define SUNLIGHT_ONLY_SHADE 5

View File

@@ -1,16 +0,0 @@
// Keep in mind. Lighting corners accept the bottom left (northwest) set of cords to them as input
// Handles dynamic light
#define GENERATE_MISSING_CORNERS(gen_for) \
if (!gen_for.lighting_corner_NE) { \
gen_for.lighting_corner_NE = new /datum/lighting_corner(gen_for.x, gen_for.y, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_SE) { \
gen_for.lighting_corner_SE = new /datum/lighting_corner(gen_for.x, gen_for.y - 1, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_SW) { \
gen_for.lighting_corner_SW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y - 1, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
if (!gen_for.lighting_corner_NW) { \
gen_for.lighting_corner_NW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y, gen_for.z, gen_for.has_dynamic_lighting()); \
} \
gen_for.lighting_corners_initialised = TRUE;

View File

@@ -1,13 +0,0 @@
#undef LIGHT_COLOR_INCANDESCENT_TUBE
#define LIGHT_COLOR_INCANDESCENT_TUBE "#E0EFF0"
#undef LIGHT_COLOR_INCANDESCENT_BULB
#define LIGHT_COLOR_INCANDESCENT_BULB "#FFFEB8"
//Fake ambient occlusion filter
#undef AMBIENT_OCCLUSION
#define AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-1, size=2, offset=2, color="#04080F55") //VOREStation Edit for prettier visuals.
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3

View File

@@ -4,8 +4,8 @@
#define NUM_E 2.71828183
#define SQRT_2 (1.41421356237) //CHOMPEDIT
#define ONE_OVER_SQRT_2 (0.707106781188095) //CHOMPEDIT ADDITION - not 1/sqrt(2), instead it is 1/SQRT_2 (1/1.41421356237)
#define SQRT_2 (1.41421356237)
#define ONE_OVER_SQRT_2 (0.707106781188095) // not 1/sqrt(2), instead it is 1/SQRT_2 (1/1.41421356237)
#define M_PI (3.14159265)
#define INFINITY (1.#INF) //closer then enough

View File

@@ -1,17 +1,17 @@
SUBSYSTEM_DEF(lighting)
name = "Lighting"
wait = 1 // CHOMPEdit
wait = 1
init_order = INIT_ORDER_LIGHTING
flags = SS_TICKER
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY //CHOMPEdit Do some work during lobby waiting period. May as well.
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY // Do some work during lobby waiting period. May as well.
var/sun_mult = 1.0
var/static/list/sources_queue = list() // List of lighting sources queued for update.
var/static/list/corners_queue = list() // List of lighting corners queued for update.
var/static/list/objects_queue = list() // List of lighting objects queued for update.
var/static/list/sunlight_queue = list() //CHOMPEdit // List of turfs that are affected by sunlight
var/static/list/sunlight_queue_active = list() //CHOMPEdit // List of turfs that need to have their sunlight updated
var/list/planet_shandlers = list() //CHOMPEdit //Precomputed lighting values for tiles only affected by the sun
var/list/z_to_pshandler = list() //CHOMPEdit
var/static/list/sunlight_queue = list() // List of turfs that are affected by sunlight
var/static/list/sunlight_queue_active = list() // List of turfs that need to have their sunlight updated
var/list/planet_shandlers = list() // Precomputed lighting values for tiles only affected by the sun
var/list/z_to_pshandler = list()
/datum/controller/subsystem/lighting/stat_entry(msg)
msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]"
@@ -28,14 +28,12 @@ SUBSYSTEM_DEF(lighting)
subsystem_initialized = TRUE
create_all_lighting_objects()
//CHOMPEdit Begin
for(var/datum/planet/planet in SSplanets.planets)
if(!planet_shandlers[planet])
planet_shandlers[planet] = new /datum/planet_sunlight_handler(planet)
//CHOMPEdit End
fire(FALSE, TRUE)
sunlight_queue_active += sunlight_queue + sunlight_queue //CHOMPEdit Run through shandler's twice during lobby wait to get some initial computation out of the way. After these two, the sunlight system will run MUCH faster.
sunlight_queue_active += sunlight_queue + sunlight_queue // Run through shandler's twice during lobby wait to get some initial computation out of the way. After these two, the sunlight system will run MUCH faster.
return SS_INIT_SUCCESS
@@ -123,7 +121,6 @@ SUBSYSTEM_DEF(lighting)
break
if (i)
queue.Cut(1, i + 1)
//CHOMPEdit Begin
i = 0
@@ -183,7 +180,6 @@ SUBSYSTEM_DEF(lighting)
return pshandler
/datum/controller/subsystem/lighting
//CHOMPEdit End
/datum/controller/subsystem/lighting/Recover()
subsystem_initialized = SSlighting.subsystem_initialized

View File

@@ -45,7 +45,6 @@ SUBSYSTEM_DEF(planets)
else if(istype(T, /turf/simulated) && T.is_outdoors())
P.planet_floors += T
P.weather_holder.apply_to_turf(T)
//P.sun_holder.apply_to_turf(T) CHOMPEdit replaced planetary lighting
/datum/controller/subsystem/planets/proc/removeTurf(var/turf/T,var/is_edge)
if(z_to_planet.len >= T.z)
@@ -108,7 +107,7 @@ SUBSYSTEM_DEF(planets)
var/new_color = P.sun["color"]
P.sun_holder.update_color(new_color)
SSlighting.update_sunlight(SSlighting.get_pshandler_planet(P)) //CHOMPEdit
SSlighting.update_sunlight(SSlighting.get_pshandler_planet(P))
/datum/controller/subsystem/planets/proc/updateTemp(var/datum/planet/P)
//Set new temperatures

View File

@@ -44,7 +44,7 @@ GLOBAL_DATUM_INIT(moved_event, /decl/observ/moved, new)
if(. && !loc)
SEND_SIGNAL(src,COMSIG_OBSERVER_MOVED, old_loc, null)
/atom/movable/forceMove(atom/destination, direction, movetime) //ChompEDIT - pass movetime through
/atom/movable/forceMove(atom/destination, direction, movetime) // pass movetime through
var/old_loc = loc
. = ..()
if(. && !loc)

View File

@@ -225,7 +225,7 @@
// If we moved, call Moved() on ourselves
if(.)
Moved(oldloc, direct, FALSE, movetime ? movetime : MOVE_GLIDE_CALC(glide_size, moving_diagonally) ) //CHOMPEDIT - proper diagonal movement
Moved(oldloc, direct, FALSE, movetime ? movetime : MOVE_GLIDE_CALC(glide_size, moving_diagonally) )
// Update timers/cooldown stuff
move_speed = world.time - l_move_time

View File

@@ -49,15 +49,13 @@
var/old_outdoors = outdoors
var/old_dangerous_objects = dangerous_objects
var/old_dynamic_lumcount = dynamic_lumcount
var/oldtype = src.type //CHOMPEdit
var/old_density = src.density //CHOMPEdit
var/was_open = istype(src,/turf/simulated/open) //CHOMPEdit
//CHOMPEdit Begin
var/oldtype = src.type
var/old_density = src.density
var/was_open = istype(src,/turf/simulated/open)
var/datum/sunlight_handler/old_shandler
var/turf/simulated/simself = src
if(istype(simself) && simself.shandler)
old_shandler = simself.shandler
//CHOMPEdit End
var/turf/Ab = GetAbove(src)
if(Ab)
@@ -85,7 +83,6 @@
if(old_fire)
W.fire = old_fire
W.RemoveLattice()
//CHOMPEdit Begin
W.lighting_corners_initialised = old_lighting_corners_initialized
var/turf/simulated/W_sim = W
if(istype(W_sim) && old_shandler)
@@ -94,7 +91,6 @@
else if(istype(W_sim) && (SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) && has_dynamic_lighting())
W_sim.shandler = new(src)
W_sim.shandler.manualInit()
//CHOMPEdit End
if(old_fire)
old_fire.RemoveFire()
@@ -137,7 +133,6 @@
for(var/turf/space/space_tile in RANGE_TURFS(1, src))
space_tile.update_starlight()
//CHOMPEdit begin
var/turf/simulated/sim_self = src
if(lighting_object && istype(sim_self) && sim_self.shandler) //sanity check, but this should never be null for either of the switch cases (lighting_object will be null during initializations sometimes)
switch(lighting_object.sunlight_only)
@@ -161,13 +156,11 @@
cur_turf.propogate_sunlight_changes(oldtype, old_density, W, above = TRUE)
while(istype(cur_turf,/turf/simulated/open) && HasBelow(cur_turf.z))
//CHOMPEdit End
if(old_shandler) old_shandler.holder_change() //CHOMPEdit
if(old_shandler) old_shandler.holder_change()
if(preserve_outdoors)
outdoors = old_outdoors
//CHOMPEdit begin
/turf/proc/propogate_sunlight_changes(oldtype, old_density, new_turf, var/above = FALSE)
//SEND_SIGNAL(src, COMSIG_TURF_UPDATE, oldtype, old_density, W)
//Sends signals in a cross pattern to all tiles that may have their sunlight var affected including this tile.
@@ -196,4 +189,3 @@
T.shandler.turf_update(old_density, new_turf, above)
steps += 1
cur_turf = get_step(cur_turf,dir)
//CHOMPEdit end

View File

@@ -5,7 +5,7 @@
/datum/lighting_corner
var/list/datum/light_source/affecting // Light sources affecting us.
var/sunlight = SUNLIGHT_NONE // CHOMPEdit
var/sunlight = SUNLIGHT_NONE
var/x = 0
var/y = 0
@@ -30,7 +30,7 @@
///whether we are to be added to SSlighting's corners_queue list for an update
var/needs_update = FALSE
/datum/lighting_corner/New(x, y, z, dynamic) // CHOMPEdit
/datum/lighting_corner/New(x, y, z, dynamic)
. = ..()
src.x = x + 0.5
@@ -72,7 +72,7 @@
master_SE = process_next
process_next.lighting_corner_NW = src
if(((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) || SSlighting.get_pshandler_z(z)) && dynamic) sunlight = SUNLIGHT_POSSIBLE //CHOMPEdit
if(((SSplanets && SSplanets.z_to_planet.len >= z && SSplanets.z_to_planet[z]) || SSlighting.get_pshandler_z(z)) && dynamic) sunlight = SUNLIGHT_POSSIBLE
/datum/lighting_corner/proc/save_master(turf/master, dir)
switch (dir)
@@ -90,7 +90,7 @@
master.lighting_corner_SE = src
/datum/lighting_corner/proc/self_destruct_if_idle()
if (!LAZYLEN(affecting) && !sunlight) //CHOMPEdit
if (!LAZYLEN(affecting) && !sunlight)
qdel(src, force = TRUE)
/datum/lighting_corner/proc/vis_update()
@@ -102,27 +102,23 @@
light_source.recalc_corner(src)
// God that was a mess, now to do the rest of the corner code! Hooray!
/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b, var/from_sholder = FALSE) //CHOMPEdit
/datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b, var/from_sholder = FALSE)
if (!(delta_r || delta_g || delta_b)) // 0 is falsey ok
return
//CHOMPEdit Begin
if((sunlight == SUNLIGHT_ONLY || sunlight == SUNLIGHT_ONLY_SHADE) && LAZYLEN(affecting))
change_sun()
if(sunlight == SUNLIGHT_ONLY || sunlight == SUNLIGHT_ONLY_SHADE)
//Okay fuck. If we're here some doodoo kaka bullshit happened (probably thanks to in-round map loading) and now the sunlight handler that owned us previously is fucking gone (real cool dude) so like try to get a new one ig
//Is this optimal? No. Is there a better way? Maybe. God knows I tried, but whatever fucking black magic is going on behind the scenes seems to defy all attempts at logic. So, if this works, it stays.
sunlight = SUNLIGHT_POSSIBLE
//CHOMPEdit End
lum_r += delta_r
lum_g += delta_g
lum_b += delta_b
//CHOMPEdit Begin
if(sunlight == SUNLIGHT_CURRENT && !LAZYLEN(affecting) && !from_sholder)
update_sunlight_handlers()
update_sunlight_handlers()
//CHOMPEdit End
if (!needs_update)
needs_update = TRUE
@@ -204,7 +200,6 @@
return ..()
//CHOMPEdit Begin
/datum/lighting_corner/proc/update_sun(var/datum/planet_sunlight_handler/pshandler)
if(!pshandler)
return
@@ -311,5 +306,3 @@
master_SW_sim.shandler.sunlight_update()
if(istype(master_NW_sim) && master_NW_sim.shandler && master_NW_sim.shandler.sleeping)
master_NW_sim.shandler.sunlight_update()
//CHOMPEdit End

View File

@@ -5,7 +5,7 @@
///whether we are already in the SSlighting.objects_queue list
var/needs_update = FALSE
var/sunlight_only = FALSE //CHOMPEdit
var/sunlight_only = FALSE
///the turf that our light is applied to
var/turf/affected_turf
@@ -50,7 +50,7 @@
/datum/lighting_object/proc/update()
if(sunlight_only) return //CHOMPEdit
if(sunlight_only) return
// To the future coder who sees this and thinks
// "Why didn't he just use a loop?"
// Well my man, it's because the loop performed like shit.
@@ -90,7 +90,7 @@
current_underlay.color = null
else
current_underlay.icon_state = "gradient"
current_underlay.color = null //CHOMPEdit
current_underlay.color = null
current_underlay.color = list(
red_corner.cache_r, red_corner.cache_g, red_corner.cache_b, 00,
green_corner.cache_r, green_corner.cache_g, green_corner.cache_b, 00,
@@ -110,7 +110,6 @@
/datum/lighting_object/proc/addtoturf()
affected_turf.underlays |= current_underlay
//CHOMPEdit Begin
/datum/lighting_object/proc/update_sun()
if(QDELETED(src))
return
@@ -137,6 +136,3 @@
affected_turf.vis_contents += pshandler.vis_shade
if(FALSE)
affected_turf.underlays |= current_underlay
//CHOMPEdit End

View File

@@ -145,7 +145,6 @@
(. * _lum_b) - (OLD * _applied_lum_b) \
); \
//CHOMPEdit Begin
#define APPLY_CORNER_NEW(C) \
. = LUM_FALLOFF(C); \
. *= _light_power; \
@@ -160,7 +159,7 @@
(. * _lum_g) - (OLD * _applied_lum_g), \
(. * _lum_b) - (OLD * _applied_lum_b) \
); \
//CHOMPEdit End
#define REMOVE_CORNER(C) \
. = -effect_str[C]; \
C.update_lumcount \
@@ -174,8 +173,8 @@
SETUP_CORNERS_REMOVAL_CACHE(src)
applied = FALSE
for (var/datum/lighting_corner/corner as anything in effect_str)
LAZYREMOVE(corner.affecting, src) //CHOMPEdit
REMOVE_CORNER(corner) //CHOMPEdit
LAZYREMOVE(corner.affecting, src)
REMOVE_CORNER(corner)
effect_str = null
@@ -192,24 +191,6 @@
/datum/light_source/proc/get_turfs_in_range()
return view(CEILING(light_range, 1), source_turf)
// Keep in mind. Lighting corners accept the bottom left (northwest) set of cords to them as input
/* CHOMPRemove Start, we use our own in _defines
# define GENERATE_MISSING_CORNERS(gen_for) \
if (!gen_for.lighting_corner_NE) { \
gen_for.lighting_corner_NE = new /datum/lighting_corner(gen_for.x, gen_for.y, gen_for.z); \
} \
if (!gen_for.lighting_corner_SE) { \
gen_for.lighting_corner_SE = new /datum/lighting_corner(gen_for.x, gen_for.y - 1, gen_for.z); \
} \
if (!gen_for.lighting_corner_SW) { \
gen_for.lighting_corner_SW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y - 1, gen_for.z); \
} \
if (!gen_for.lighting_corner_NW) { \
gen_for.lighting_corner_NW = new /datum/lighting_corner(gen_for.x - 1, gen_for.y, gen_for.z); \
} \
gen_for.lighting_corners_initialised = TRUE;
*/// CHOMPRemove End
/datum/light_source/proc/update_corners()
var/update = FALSE
var/atom/source_atom = src.source_atom
@@ -294,18 +275,13 @@
LAZYINITLIST(src.effect_str)
var/list/effect_str = src.effect_str
if (needs_update == LIGHTING_VIS_UPDATE)
for (var/datum/lighting_corner/corner in new_corners) //CHOMPEdit
//CHOMPEdit Begin
for (var/datum/lighting_corner/corner in new_corners)
APPLY_CORNER_NEW(corner)
//CHOMPEdit End
else
for (var/datum/lighting_corner/corner in new_corners) //CHOMPEdit
//CHOMPEdit Begin
for (var/datum/lighting_corner/corner in new_corners)
APPLY_CORNER_NEW(corner)
//CHOMPEdit End
for (var/datum/lighting_corner/corner in corners - new_corners) // Existing corners //CHOMPEdit
//CHOMPEdit Begin
for (var/datum/lighting_corner/corner in corners - new_corners) // Existing corners
. = LUM_FALLOFF(corner);
. *= _light_power;
var/OLD = effect_str[corner];
@@ -321,12 +297,11 @@
(. * _lum_b) - (OLD * _applied_lum_b) \
);
#undef APPLY_CORNER_NEW
//CHOMPEdit End
var/list/datum/lighting_corner/gone_corners = effect_str - corners
for (var/datum/lighting_corner/corner as anything in gone_corners)
LAZYREMOVE(corner.affecting, src) //CHOMPEdit
REMOVE_CORNER(corner) //CHOMPEdit
LAZYREMOVE(corner.affecting, src)
REMOVE_CORNER(corner)
effect_str -= gone_corners
applied_lum_r = lum_r

View File

@@ -96,11 +96,6 @@
///Setter for the byond luminosity var
/turf/proc/set_luminosity(new_luminosity, force)
/*CHOMP Removal Begin
if((is_outdoors() && !force) || outdoors_adjacent)
if(check_for_sun()) //If another system handles our lighting, don't interfere
return
*/ //CHOMP Removal End
if(((is_outdoors() && !force) || outdoors_adjacent) && (z in fake_sunlight_zs)) //Special exception for fakesun lit tiles
return

View File

@@ -458,7 +458,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
ManualFollow(M || jumpable_mobs()[mobname])
/mob/observer/dead/forceMove(atom/destination, direction, movetime, just_spawned = FALSE) //ChompEDIT - pass movetime through
/mob/observer/dead/forceMove(atom/destination, direction, movetime, just_spawned = FALSE) // pass movetime through
if(client?.holder)
return ..()
@@ -578,7 +578,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
following_mobs -= M
else
if(M.loc != .)
M.forceMove(., movetime = MOVE_GLIDE_CALC(glide_size, moving_diagonally)) //ChompEDIT - pass movespeed
M.forceMove(., movetime = MOVE_GLIDE_CALC(glide_size, moving_diagonally)) // pass movespeed
/mob
var/list/following_mobs = list()

View File

@@ -63,7 +63,8 @@
weather_holder.process()
/datum/planet/proc/update_sun_deferred(var/new_brightness, var/new_color)
if(new_brightness < 0 || new_brightness > 1)
CRASH("Planetary sun brightness was outside of sane bounds. Expected 0.00 to 1.00, got [new_brightness].")
sun["brightness"] = new_brightness
sun["color"] = new_color
needs_work |= PLANET_PROCESS_SUN

View File

@@ -36,8 +36,8 @@ var/datum/planet/sif/planet_sif = null
switch(sun_position)
if(0 to 0.40) // Night
low_brightness = 0.15 //CHOMPedit
low_color = "#19195c" //CHOMPedit
low_brightness = 0.15
low_color = "#19195c"
high_brightness = 0.3
high_color = "#66004D"

View File

@@ -43,7 +43,7 @@
/datum/sun_holder/proc/remove_from_turf(turf/T)
if(!(sun in T.vis_contents))
//warning("Was asked to remove fake sun from [T.x], [T.y], [T.z] despite it not having us in it's vis contents") SHUT YOUR FUCKING MOUTH I DON'T CARE (CHOMP removal)
// warning("Was asked to remove fake sun from [T.x], [T.y], [T.z] despite it not having us in it's vis contents") // Disable the warning
return
sun.remove_from_turf(T)

View File

@@ -26,7 +26,7 @@ var/datum/planet/virgo3c/planet_virgo3c = null
seconds_in_day = 6 HOURS
/datum/planet/virgo3c
name = "Virgo-3c"
name = "Virgo-3C"
desc = "A habitable moon of the gas giant Virgo 3. The volcanic activity of this moon keeps its atmosphere warm enough for life to flourish."
current_time = new /datum/time/virgo3c()
planetary_wall_type = /turf/unsimulated/wall/planetary/virgo3c
@@ -53,15 +53,15 @@ var/datum/planet/virgo3c/planet_virgo3c = null
var/min = 0
switch(sun_position)
if(0 to 0.45) // Night
low_brightness = 0.1
if(0 to 0.3) // Night
low_brightness = 0.3
low_color = "#000066"
high_brightness = 0.2
high_brightness = 0.4
high_color = "#66004D"
min = 0
if(0.45 to 0.50) // Twilight
if(0.3 to 0.35) // Twilight
low_brightness = 0.5
low_color = "#66004D"
@@ -69,19 +69,19 @@ var/datum/planet/virgo3c/planet_virgo3c = null
high_color = "#CC3300"
min = 0.40
if(0.50 to 0.55) // Sunrise/set
if(0.35 to 0.45) // Sunrise/set
low_brightness = 0.9
low_color = "#CC3300"
high_brightness = 3.0
high_brightness = 1.0
high_color = "#FF9933"
min = 0.50
if(0.55 to 1.00) // Noon
low_brightness = 3.0
if(0.45 to 1.00) // Noon
low_brightness = 1.0
low_color = "#DDDDDD"
high_brightness = 10.0
high_brightness = 1.0
high_color = "#FFFFFF"
min = 0.70
@@ -638,7 +638,6 @@ var/datum/planet/virgo3c/planet_virgo3c = null
alpha = 0xFF
VIRGO3C_SET_ATMOS
VIRGO3C_TURF_CREATE(/turf/simulated/mineral/cave)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/outdoors/newdirt)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/outdoors/newdirt_nograss)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/outdoors/sidewalk)
@@ -649,7 +648,6 @@ VIRGO3C_TURF_CREATE(/turf/simulated/floor/water/deep)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/tiled)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/reinforced)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/glass/reinforced)
VIRGO3C_TURF_CREATE(/turf/simulated/open)
VIRGO3C_TURF_CREATE(/turf/simulated/floor/tiled/dark)
VIRGO3C_TURF_CREATE(/turf/simulated/mineral)
VIRGO3C_TURF_CREATE(/turf/simulated/mineral/ignore_cavegen)
@@ -700,17 +698,16 @@ VIRGO3C_TURF_CREATE(/turf/simulated/floor/tiled/asteroid_steel/outdoors)
var/animal_chance = 0.5
var/animal_types = list(
/mob/living/simple_mob/vore/alienanimals/teppi = 5,
/mob/living/simple_mob/vore/redpanda = 20,
/mob/living/simple_mob/vore/redpanda/fae = 1,
/mob/living/simple_mob/vore/sheep = 10,
/mob/living/simple_mob/vore/rabbit/black = 10,
/mob/living/simple_mob/vore/rabbit/white = 10,
/mob/living/simple_mob/vore/rabbit/brown = 10,
/mob/living/simple_mob/vore/leopardmander = 1,
/mob/living/simple_mob/vore/horse/big = 5,
/mob/living/simple_mob/vore/bigdragon/friendly = 0.5,
/mob/living/simple_mob/vore/alienanimals/dustjumper = 10
/mob/living/simple_mob/vore/redpanda = 40,
/mob/living/simple_mob/vore/redpanda/fae = 2,
/mob/living/simple_mob/vore/sheep = 20,
/mob/living/simple_mob/vore/rabbit/black = 20,
/mob/living/simple_mob/vore/rabbit/white = 20,
/mob/living/simple_mob/vore/rabbit/brown = 20,
/mob/living/simple_mob/vore/leopardmander = 2,
/mob/living/simple_mob/vore/horse/big = 10,
/mob/living/simple_mob/vore/bigdragon/friendly = 1,
/mob/living/simple_mob/vore/alienanimals/dustjumper = 20
)

View File

@@ -1,514 +0,0 @@
var/datum/planet/virgo4/planet_virgo4 = null
/datum/time/virgo4
seconds_in_day = 24 HOURS
/datum/planet/virgo4
name = "Virgo-4"
desc = "Zorren homeworld. Mostly dry and desolate, but ocean and fresh water are present, with scattered vegitation." //rewrite me
current_time = new /datum/time/virgo4()
// expected_z_levels = list(1) // This is defined elsewhere.
planetary_wall_type = /turf/unsimulated/wall/planetary/normal/virgo4
/datum/planet/virgo4/New()
..()
planet_virgo4 = src
weather_holder = new /datum/weather_holder/virgo4(src)
/datum/planet/virgo4/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.20) // Night
low_brightness = 0.3
low_color = "#000066"
high_brightness = 0.5
high_color = "#66004D"
min = 0
if(0.20 to 0.30) // Twilight
low_brightness = 0.5
low_color = "#66004D"
high_brightness = 0.9
high_color = "#CC3300"
min = 0.40
if(0.30 to 0.40) // Sunrise/set
low_brightness = 0.9
low_color = "#CC3300"
high_brightness = 3.0
high_color = "#FF9933"
min = 0.50
if(0.40 to 1.00) // Noon
low_brightness = 3.0
low_color = "#DDDDDD"
high_brightness = 10.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(new_brightness, new_color)
/datum/weather_holder/virgo4
temperature = T0C
allowed_weather_types = list(
WEATHER_CLEAR = new /datum/weather/virgo4/clear(),
WEATHER_OVERCAST = new /datum/weather/virgo4/overcast(),
WEATHER_LIGHT_SNOW = new /datum/weather/virgo4/light_snow(),
WEATHER_SNOW = new /datum/weather/virgo4/snow(),
WEATHER_BLIZZARD = new /datum/weather/virgo4/blizzard(),
WEATHER_RAIN = new /datum/weather/virgo4/rain(),
WEATHER_STORM = new /datum/weather/virgo4/storm(),
WEATHER_HAIL = new /datum/weather/virgo4/hail(),
WEATHER_BLOOD_MOON = new /datum/weather/virgo4/blood_moon(),
WEATHER_EMBERFALL = new /datum/weather/virgo4/emberfall(),
WEATHER_ASH_STORM = new /datum/weather/virgo4/ash_storm(),
WEATHER_FALLOUT = new /datum/weather/virgo4/fallout()
)
roundstart_weather_chances = list(
WEATHER_CLEAR = 50,
WEATHER_OVERCAST = 10,
WEATHER_RAIN = 1
)
/datum/weather/virgo4
name = "virgo4"
temp_high = 303.15 // 30c
temp_low = 298.15 // 25c
/datum/weather/virgo4/clear
name = "clear"
transition_chances = list(
WEATHER_CLEAR = 60,
WEATHER_OVERCAST = 20)
transition_messages = list(
"The sky clears up.",
"The sky is visible.",
"The weather is calm."
)
sky_visible = TRUE
observed_message = "The sky is clear."
/datum/weather/virgo4/overcast
name = "overcast"
temp_high = 293.15 // 20c
temp_low = 288.15 // 15c
light_modifier = 0.8
transition_chances = list(
WEATHER_CLEAR = 25,
WEATHER_OVERCAST = 50,
WEATHER_RAIN = 5
)
observed_message = "It is overcast, all you can see are clouds."
transition_messages = list(
"All you can see above are clouds.",
"Clouds cut off your view of the sky.",
"It's very cloudy."
)
/datum/weather/virgo4/light_snow
name = "light snow"
icon_state = "snowfall_light"
temp_high = 268.15 // -5c
temp_low = 263.15 // -10c
light_modifier = 0.7
transition_chances = list(
WEATHER_LIGHT_SNOW = 100
)
observed_message = "It is snowing lightly."
transition_messages = list(
"Small snowflakes begin to fall from above.",
"It begins to snow lightly.",
)
/datum/weather/virgo4/snow
name = "moderate snow"
icon_state = "snowfall_med"
temp_high = 268.15 // -5c
temp_low = 263.15 // -10c
wind_high = 2
wind_low = 0
light_modifier = 0.5
flight_failure_modifier = 5
transition_chances = list(
WEATHER_LIGHT_SNOW = 100
)
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/virgo4/snow/process_effects()
..()
for(var/turf/simulated/floor/outdoors/snow/S as anything 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 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/virgo4/blizzard
name = "blizzard"
icon_state = "snowfall_heavy"
temp_high = 268.15 // -5c
temp_low = 263.15 // -10c
wind_high = 4
wind_low = 2
light_modifier = 0.3
flight_failure_modifier = 10
transition_chances = list(
WEATHER_BLIZZARD = 100
)
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/virgo4/blizzard/process_effects()
..()
for(var/turf/simulated/floor/outdoors/snow/S as anything 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 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()
*/
/datum/weather/virgo4/rain
name = "rain"
icon_state = "rain"
temp_high = 288.15 // 15c
temp_low = 283.15 // 10c
wind_high = 2
wind_low = 1
light_modifier = 0.5
effect_message = span_warning("Rain falls on you.")
transition_chances = list(
WEATHER_OVERCAST = 25,
WEATHER_RAIN = 50
)
observed_message = "It is raining."
transition_messages = list(
"The sky is dark, and rain falls down upon you."
)
/datum/weather/virgo4/rain/process_effects()
..()
for(var/mob/living/L as anything in living_mob_list)
if(L.z in holder.our_planet.expected_z_levels)
var/turf/T = get_turf(L)
if(!T.is_outdoors())
continue // They're indoors, so no need to rain on them.
// If they have an open umbrella, it'll guard from rain
var/obj/item/melee/umbrella/U = L.get_active_hand()
if(!istype(U) || !U.open)
U = L.get_inactive_hand()
if(istype(U) && U.open)
if(show_message)
to_chat(L, span_notice("Rain patters softly onto your umbrella."))
continue
L.water_act(1)
if(show_message)
to_chat(L, effect_message)
/datum/weather/virgo4/storm
name = "storm"
icon_state = "storm"
wind_high = 4
wind_low = 2
light_modifier = 0.3
flight_failure_modifier = 10
effect_message = span_warning("Rain falls on you, drenching you in water.")
var/next_lightning_strike = 0 // world.time when lightning will strike.
var/min_lightning_cooldown = 5 SECONDS
var/max_lightning_cooldown = 1 MINUTE
observed_message = "An intense storm pours down over the region."
transition_messages = list(
"You feel intense winds hit you as the weather takes a turn for the worst.",
"Loud thunder is heard in the distance.",
"A bright flash heralds the approach of a storm."
)
transition_chances = list(
WEATHER_STORM = 100
)
/datum/weather/virgo4/storm/process_effects()
..()
for(var/mob/living/L as anything in living_mob_list)
if(L.z in holder.our_planet.expected_z_levels)
var/turf/T = get_turf(L)
if(!T.is_outdoors())
continue // They're indoors, so no need to rain on them.
// If they have an open umbrella, it'll guard from rain
var/obj/item/melee/umbrella/U = L.get_active_hand()
if(!istype(U) || !U.open)
U = L.get_inactive_hand()
if(istype(U) && U.open)
if(show_message)
to_chat(L, span_notice("Rain showers loudly onto your umbrella!"))
continue
L.water_act(2)
if(show_message)
to_chat(L, effect_message)
handle_lightning()
// This gets called to do lightning periodically.
// There is a seperate function to do the actual lightning strike, so that badmins can play with it.
/datum/weather/virgo4/storm/proc/handle_lightning()
if(world.time < next_lightning_strike)
return // It's too soon to strike again.
next_lightning_strike = world.time + rand(min_lightning_cooldown, max_lightning_cooldown)
var/turf/T = pick(holder.our_planet.planet_floors) // This has the chance to 'strike' the sky, but that might be a good thing, to scare reckless pilots.
lightning_strike(T)
/datum/weather/virgo4/hail
name = "hail"
icon_state = "hail"
light_modifier = 0.3
flight_failure_modifier = 15
timer_low_bound = 2
timer_high_bound = 5
effect_message = span_warning("The hail smacks into you!")
transition_chances = list(
WEATHER_HAIL = 100
)
observed_message = "Ice is falling from the sky."
transition_messages = list(
"Ice begins to fall from the sky.",
"It begins to hail.",
"An intense chill is felt, and chunks of ice start to fall from the sky, towards you."
)
/datum/weather/virgo4/hail/process_effects()
..()
for(var/mob/living/carbon/H as anything in human_mob_list)
if(H.z in holder.our_planet.expected_z_levels)
var/turf/T = get_turf(H)
if(!T.is_outdoors())
continue // They're indoors, so no need to pelt them with ice.
// If they have an open umbrella, it'll guard from hail
var/obj/item/melee/umbrella/U = H.get_active_hand()
if(!istype(U) || !U.open)
U = H.get_inactive_hand()
if(istype(U) && U.open)
if(show_message)
to_chat(H, span_notice("Hail patters onto your umbrella."))
continue
var/target_zone = pick(BP_ALL)
var/amount_blocked = H.run_armor_check(target_zone, "melee")
var/amount_soaked = H.get_armor_soak(target_zone, "melee")
var/damage = rand(1,3)
if(amount_blocked >= 30)
continue // No need to apply damage. Hardhats are 30. They should probably protect you from hail on your head.
//Voidsuits are likewise 40, and riot, 80. Clothes are all less than 30.
if(amount_soaked >= damage)
continue // No need to apply damage.
H.apply_damage(damage, BRUTE, target_zone, amount_blocked, amount_soaked, used_weapon = "hail")
if(show_message)
to_chat(H, effect_message)
/datum/weather/virgo4/blood_moon
name = "blood moon"
light_modifier = 0.5
light_color = "#FF0000"
temp_high = 293.15 // 20c
temp_low = 283.15 // 10c
flight_failure_modifier = 25
transition_chances = list(
WEATHER_BLOODMOON = 100
)
observed_message = "Everything is red. Something really ominous is going on."
transition_messages = list(
"The sky turns blood red!"
)
outdoor_sounds_type = /datum/looping_sound/weather/wind
indoor_sounds_type = /datum/looping_sound/weather/wind/indoors
// Ash and embers fall forever, such as from a volcano or something.
/datum/weather/virgo4/emberfall
name = "emberfall"
icon_state = "ashfall_light"
light_modifier = 0.7
light_color = "#880000"
temp_high = 293.15 // 20c
temp_low = 283.15 // 10c
flight_failure_modifier = 20
transition_chances = list(
WEATHER_EMBERFALL = 100
)
observed_message = "Soot, ash, and embers float down from above."
transition_messages = list(
"Gentle embers waft down around you like grotesque snow."
)
outdoor_sounds_type = /datum/looping_sound/weather/wind
indoor_sounds_type = /datum/looping_sound/weather/wind/indoors
// Like the above but a lot more harmful.
/datum/weather/virgo4/ash_storm
name = "ash storm"
icon_state = "ashfall_heavy"
light_modifier = 0.1
light_color = "#FF0000"
temp_high = 323.15 // 50c
temp_low = 313.15 // 40c
wind_high = 6
wind_low = 3
flight_failure_modifier = 50
transition_chances = list(
WEATHER_ASH_STORM = 100
)
observed_message = "All that can be seen is black smoldering ash."
transition_messages = list(
"Smoldering clouds of scorching ash billow down around you!"
)
// Lets recycle.
outdoor_sounds_type = /datum/looping_sound/weather/outside_blizzard
indoor_sounds_type = /datum/looping_sound/weather/inside_blizzard
/datum/weather/virgo4/ash_storm/process_effects()
..()
for(var/mob/living/L as anything in living_mob_list)
if(L.z in holder.our_planet.expected_z_levels)
var/turf/T = get_turf(L)
if(!T.is_outdoors())
continue // They're indoors, so no need to burn them with ash.
L.inflict_heat_damage(rand(1, 3))
// Totally radical.
/datum/weather/virgo4/fallout
name = "fallout"
icon_state = "fallout"
light_modifier = 0.7
light_color = "#CCFFCC"
flight_failure_modifier = 30
transition_chances = list(
WEATHER_FALLOUT = 100
)
observed_message = "Radioactive soot and ash rains down from the heavens."
transition_messages = list(
"Radioactive soot and ash start to float down around you, contaminating whatever they touch."
)
outdoor_sounds_type = /datum/looping_sound/weather/wind
indoor_sounds_type = /datum/looping_sound/weather/wind/indoors
// How much radiation a mob gets while on an outside tile.
var/direct_rad_low = RAD_LEVEL_LOW
var/direct_rad_high = RAD_LEVEL_MODERATE
// How much radiation is bursted onto a random tile near a mob.
var/fallout_rad_low = RAD_LEVEL_HIGH
var/fallout_rad_high = RAD_LEVEL_VERY_HIGH
/datum/weather/virgo4/fallout/process_effects()
..()
for(var/mob/living/L as anything in living_mob_list)
if(L.z in holder.our_planet.expected_z_levels)
irradiate_nearby_turf(L)
var/turf/T = get_turf(L)
if(!T.is_outdoors())
continue // They're indoors, so no need to irradiate them with fallout.
L.rad_act(rand(direct_rad_low, direct_rad_high))
// This makes random tiles near people radioactive for awhile.
// Tiles far away from people are left alone, for performance.
/datum/weather/virgo4/fallout/proc/irradiate_nearby_turf(mob/living/L)
if(!istype(L))
return
var/list/turfs = RANGE_TURFS(world.view, L)
var/turf/T = pick(turfs) // We get one try per tick.
if(!istype(T))
return
if(T.is_outdoors())
SSradiation.radiate(T, rand(fallout_rad_low, fallout_rad_high))
/turf/unsimulated/wall/planetary/normal/virgo4
name = "deep ocean"
alpha = 0
/obj/machinery/power/smes/buildable/offmap_spawn/empty/New()
..(1)
charge = 0
RCon = TRUE
input_level = input_level_max
output_level = output_level_max
input_attempt = TRUE

View File

@@ -52,15 +52,15 @@ var/datum/planet/virgo4/planet_virgo4 = null
low_brightness = 0.9
low_color = "#CC3300"
high_brightness = 3.0
high_brightness = 1.0
high_color = "#FF9933"
min = 0.50
if(0.40 to 1.00) // Noon
low_brightness = 3.0
low_brightness = 1.0
low_color = "#DDDDDD"
high_brightness = 10.0
high_brightness = 1.0
high_color = "#FFFFFF"
min = 0.70

View File

@@ -89,9 +89,6 @@
#include "code\__defines\jukebox.dm"
#include "code\__defines\life.dm"
#include "code\__defines\lighting.dm"
#include "code\__defines\lighting_ch.dm"
#include "code\__defines\lighting_source_ch.dm"
#include "code\__defines\lighting_vr.dm"
#include "code\__defines\logging.dm"
#include "code\__defines\lum.dm"
#include "code\__defines\machinery.dm"
@@ -2959,8 +2956,8 @@
#include "code\modules\lighting\lighting_setup.dm"
#include "code\modules\lighting\lighting_source.dm"
#include "code\modules\lighting\lighting_turf.dm"
#include "code\modules\lighting\planet_sunlight_ch.dm"
#include "code\modules\lighting\sunlight_handler_ch.dm"
#include "code\modules\lighting\planet_sunlight.dm"
#include "code\modules\lighting\sunlight_handler.dm"
#include "code\modules\looking_glass\lg_area.dm"
#include "code\modules\looking_glass\lg_console.dm"
#include "code\modules\looking_glass\lg_imageholder.dm"