Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhials committed May 29, 2024
2 parents 7692ec0 + 2f69201 commit 6800422
Show file tree
Hide file tree
Showing 71 changed files with 619 additions and 395 deletions.
4 changes: 2 additions & 2 deletions _maps/map_files/IceBoxStation/IceBoxStation.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -74302,8 +74302,8 @@
/obj/machinery/atmospherics/pipe/smart/manifold4w/scrubbers/hidden/layer2,
/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4,
/obj/structure/cable,
/obj/structure/disposalpipe/junction/flip{
dir = 4
/obj/structure/disposalpipe/junction{
dir = 8
},
/turf/open/floor/iron,
/area/station/hallway/primary/starboard)
Expand Down
18 changes: 9 additions & 9 deletions code/__DEFINES/diseases.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,28 @@ DEFINE_BITFIELD(spread_flags, list(
//// Adjust to make it faster or slower to cure once the virus has reached its peak.
#define DISEASE_PEAKED_RECOVERY_MULTIPLIER 1.2
/// Slowdown Recovery Bonus - set this to the maximum extra chance per tick you want people to get to recover from spaceacillin or other slowdown/virus resistance effects
#define DISEASE_SLOWDOWN_RECOVERY_BONUS 1
/// Slowdown Recovery Bonus Duration - set this to the maximum # of cycles you want things that cause slowdown/virus resistance to be able to add a bonus up to DISEASE_SLOWDOWN_RECOVERY_BONUS.______qdel_list_wrapper(list/L)
#define DISEASE_SLOWDOWN_RECOVERY_BONUS 3
/// Slowdown Recovery Bonus Duration - set this to the maximum # of cycles you want things that cause slowdown/virus resistance to be able to add a bonus up to DISEASE_SLOWDOWN_RECOVERY_BONUS.
//// Scales down linearly over time.
#define DISEASE_SLOWDOWN_RECOVERY_BONUS_DURATION 100
#define DISEASE_SLOWDOWN_RECOVERY_BONUS_DURATION 200
/// Negative Malnutrition Recovery Penalty
//// Flat penalty to recovery chance if malnourished or starving
#define DISEASE_MALNUTRITION_RECOVERY_PENALTY 1.5
#define DISEASE_MALNUTRITION_RECOVERY_PENALTY 3
/// Satiety Recovery Multiplier - added chance to recover based on positive satiety
//// Multiplier of satiety/max_satiety if satiety is positive or zero. Increase to make satiety more valuable, decrease for less.
#define DISEASE_SATIETY_RECOVERY_MULTIPLIER 1
#define DISEASE_SATIETY_RECOVERY_MULTIPLIER 3
/// Good Sleeping Recovery Bonus - additive benefits for various types of good sleep (blanket, bed, darkness, pillows.)
//// Raise to make each factor add this much chance to recover.
#define DISEASE_GOOD_SLEEPING_RECOVERY_BONUS 0.2
#define DISEASE_GOOD_SLEEPING_RECOVERY_BONUS 0.6
/// Sleeping Recovery Multiplier - multiplies ALL recovery chance effects by this amount.
//// Set to 1 for no effect on recovery chances from sleeping.
#define DISEASE_SLEEPING_RECOVERY_MULTIPLIER 2
#define DISEASE_SLEEPING_RECOVERY_MULTIPLIER 6
/// Final Cure Chance Multiplier - multiplies the disease's cure chance to get the probability of moving from stage 1 to a final cure.
//// Must be greater than zero for diseases to self cure.
#define DISEASE_FINAL_CURE_CHANCE_MULTIPLIER 3
#define DISEASE_FINAL_CURE_CHANCE_MULTIPLIER 6
/// Symptom Offset Duration - number of cycles over which sleeping/having spaceacillin or a slowdown effect can prevent symptoms appearing
//// Set to maximum # of cycles you want to be able to offset symptoms. Scales down linearly over time.
#define DISEASE_SYMPTOM_OFFSET_DURATION 100
#define DISEASE_SYMPTOM_OFFSET_DURATION 200

/// Symptom Frequency Modifier
//// Raise to make symptoms fire less frequently, lower to make them fire more frequently. Keep at 0 or above.
Expand Down
29 changes: 27 additions & 2 deletions code/_onclick/click_alt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
client.loot_panel.open(tile)
return

// Turfs don't have a click_alt currently, so this saves some time.
if(!isturf(target) && can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY)))
var/can_use_click_action = FALSE
if(isturf(target))
// Turfs are special because they can't be used with can_perform_action
can_use_click_action = can_perform_turf_action(target)
else
can_use_click_action = can_perform_action(target, (target.interaction_flags_click | SILENT_ADJACENCY))

if(can_use_click_action)
// If it has a signal handler that returns a click action, done.
if(SEND_SIGNAL(target, COMSIG_CLICK_ALT, src) & CLICK_ACTION_ANY)
return
Expand All @@ -38,6 +44,13 @@
if(HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING))
return

/// No loot panel if it's on our person
if(isobj(target) && isliving(src))
var/mob/living/user = src
if(target in user.get_all_gear())
to_chat(user, span_warning("You can't search for this item, it's already in your inventory! Take it off first."))
return

client.loot_panel.open(tile)


Expand Down Expand Up @@ -71,3 +84,15 @@
/atom/proc/click_alt(mob/user)
SHOULD_CALL_PARENT(FALSE)
return NONE


/// Helper proc to validate turfs. Used because can_perform_action does not support turfs.
/mob/proc/can_perform_turf_action(turf/target)
if(!CanReach(target)) // No error message for parity with SILENT_ADJACENCY
return FALSE

if(incapacitated())
to_chat(src, span_warning("You can't use this!"))
return FALSE

return TRUE
166 changes: 84 additions & 82 deletions code/_onclick/hud/parallax/parallax.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
for(var/atom/movable/screen/plane_master/parallax as anything in get_true_plane_masters(PLANE_SPACE_PARALLAX))
parallax.unhide_plane(screenmob)

if(isnull(C.parallax_rock))
C.parallax_rock = new(null, src)
C.screen |= C.parallax_rock

if(!length(C.parallax_layers_cached))
C.parallax_layers_cached = list()
C.parallax_layers_cached += new /atom/movable/screen/parallax_layer/layer_1(null, src)
Expand All @@ -25,7 +29,7 @@
if (length(C.parallax_layers) > C.parallax_layers_max)
C.parallax_layers.len = C.parallax_layers_max

C.screen |= (C.parallax_layers)
C.parallax_rock.vis_contents = C.parallax_layers
// We could do not do parallax for anything except the main plane group
// This could be changed, but it would require refactoring this whole thing
// And adding non client particular hooks for all the inputs, and I do not have the time I'm sorry :(
Expand All @@ -44,7 +48,7 @@
/datum/hud/proc/remove_parallax(mob/viewmob)
var/mob/screenmob = viewmob || mymob
var/client/C = screenmob.client
C.screen -= (C.parallax_layers_cached)
C.screen -= (C.parallax_rock)
for(var/atom/movable/screen/plane_master/plane_master as anything in screenmob.hud_used.get_true_plane_masters(PLANE_SPACE))
if(screenmob != mymob)
C.screen -= locate(/atom/movable/screen/plane_master/parallax_white) in C.screen
Expand Down Expand Up @@ -104,83 +108,65 @@
update_parallax(screen_mob)

// This sets which way the current shuttle is moving (returns true if the shuttle has stopped moving so the caller can append their animation)
/datum/hud/proc/set_parallax_movedir(new_parallax_movedir = 0, skip_windups, mob/viewmob)
/datum/hud/proc/set_parallax_movedir(new_parallax_movedir = NONE, skip_windups, mob/viewmob)
. = FALSE
var/mob/screenmob = viewmob || mymob
var/client/C = screenmob.client
if(new_parallax_movedir == C.parallax_movedir)
return
var/animatedir = new_parallax_movedir
if(new_parallax_movedir == FALSE)
var/animate_time = 0
for(var/thing in C.parallax_layers)
var/atom/movable/screen/parallax_layer/L = thing
L.icon_state = initial(L.icon_state)
L.update_o(C.view)
var/T = PARALLAX_LOOP_TIME / L.speed
if (T > animate_time)
animate_time = T
C.dont_animate_parallax = world.time + min(animate_time, PARALLAX_LOOP_TIME)
animatedir = C.parallax_movedir

var/matrix/newtransform
switch(animatedir)

var/animation_dir = new_parallax_movedir || C.parallax_movedir
var/matrix/new_transform
switch(animation_dir)
if(NORTH)
newtransform = matrix(1, 0, 0, 0, 1, 480)
new_transform = matrix(1, 0, 0, 0, 1, 480)
if(SOUTH)
newtransform = matrix(1, 0, 0, 0, 1,-480)
new_transform = matrix(1, 0, 0, 0, 1,-480)
if(EAST)
newtransform = matrix(1, 0, 480, 0, 1, 0)
new_transform = matrix(1, 0, 480, 0, 1, 0)
if(WEST)
newtransform = matrix(1, 0,-480, 0, 1, 0)

var/shortesttimer
if(!skip_windups)
for(var/thing in C.parallax_layers)
var/atom/movable/screen/parallax_layer/L = thing

var/T = PARALLAX_LOOP_TIME / L.speed
if (isnull(shortesttimer))
shortesttimer = T
if (T < shortesttimer)
shortesttimer = T
L.transform = newtransform
animate(L, transform = matrix(), time = T, easing = QUAD_EASING | (new_parallax_movedir ? EASE_IN : EASE_OUT), flags = ANIMATION_END_NOW)
if (new_parallax_movedir)
L.transform = newtransform
animate(transform = matrix(), time = T) //queue up another animate so lag doesn't create a shutter
new_transform = matrix(1, 0,-480, 0, 1, 0)

var/longest_timer = 0
for(var/key in C.parallax_animate_timers)
deltimer(C.parallax_animate_timers[key])
C.parallax_animate_timers = list()
for(var/atom/movable/screen/parallax_layer/layer as anything in C.parallax_layers)
var/scaled_time = PARALLAX_LOOP_TIME / layer.speed
if(new_parallax_movedir == NONE) // If we're stopping, we need to stop on the same dime, yeah?
scaled_time = PARALLAX_LOOP_TIME
longest_timer = max(longest_timer, scaled_time)

if(skip_windups)
update_parallax_motionblur(C, layer, new_parallax_movedir, new_transform)
continue

C.parallax_movedir = new_parallax_movedir
if (C.parallax_animate_timer)
deltimer(C.parallax_animate_timer)
var/datum/callback/CB = CALLBACK(src, PROC_REF(update_parallax_motionblur), C, animatedir, new_parallax_movedir, newtransform)
if(skip_windups)
CB.Invoke()
else
C.parallax_animate_timer = addtimer(CB, min(shortesttimer, PARALLAX_LOOP_TIME), TIMER_CLIENT_TIME|TIMER_STOPPABLE)
layer.transform = new_transform
animate(layer, transform = matrix(), time = scaled_time, easing = QUAD_EASING | (new_parallax_movedir ? EASE_IN : EASE_OUT))
if (new_parallax_movedir == NONE)
continue
//queue up another animate so lag doesn't create a shutter
animate(transform = new_transform, time = 0)
animate(transform = matrix(), time = scaled_time / 2)
C.parallax_animate_timers[layer] = addtimer(CALLBACK(src, PROC_REF(update_parallax_motionblur), C, layer, new_parallax_movedir, new_transform), scaled_time, TIMER_CLIENT_TIME|TIMER_STOPPABLE)

C.dont_animate_parallax = world.time + min(longest_timer, PARALLAX_LOOP_TIME)
C.parallax_movedir = new_parallax_movedir

/datum/hud/proc/update_parallax_motionblur(client/C, animatedir, new_parallax_movedir, matrix/newtransform)
/datum/hud/proc/update_parallax_motionblur(client/C, atom/movable/screen/parallax_layer/layer, new_parallax_movedir, matrix/new_transform)
if(!C)
return
C.parallax_animate_timer = FALSE
for(var/thing in C.parallax_layers)
var/atom/movable/screen/parallax_layer/L = thing
if (!new_parallax_movedir)
animate(L)
continue

var/newstate = initial(L.icon_state)
var/T = PARALLAX_LOOP_TIME / L.speed

if (newstate in icon_states(L.icon))
L.icon_state = newstate
L.update_o(C.view)

L.transform = newtransform

animate(L, transform = L.transform, time = 0, loop = -1, flags = ANIMATION_END_NOW)
animate(transform = matrix(), time = T)
C.parallax_animate_timers -= layer

// If we are moving in a direction, we used the QUAD_EASING function with EASE_IN
// This means our position function is x^2. This is always LESS then the linear we're using here
// But if we just used the same time delay, our rate of change would mismatch. f'(1) = 2x for quad easing, rather then the 1 we get for linear
// (This is because of how derivatives work right?)
// Because of this, while our actual rate of change from before was PARALLAX_LOOP_TIME, our perceived rate of change was PARALLAX_LOOP_TIME / 2 (lower == faster).
// Let's account for that here
var/scaled_time = (PARALLAX_LOOP_TIME / layer.speed) / 2
animate(layer, transform = new_transform, time = 0, loop = -1, flags = ANIMATION_END_NOW)
animate(transform = matrix(), time = scaled_time)

/datum/hud/proc/update_parallax(mob/viewmob)
var/mob/screenmob = viewmob || mymob
Expand Down Expand Up @@ -217,36 +203,41 @@
var/our_speed = parallax_layer.speed
var/change_x
var/change_y
var/old_x = parallax_layer.offset_x
var/old_y = parallax_layer.offset_y
if(parallax_layer.absolute)
// We use change here so the typically large absolute objects (just lavaland for now) don't jitter so much
change_x = (posobj.x - SSparallax.planet_x_offset) * our_speed + parallax_layer.offset_x
change_y = (posobj.y - SSparallax.planet_y_offset) * our_speed + parallax_layer.offset_y
change_x = (posobj.x - SSparallax.planet_x_offset) * our_speed + old_x
change_y = (posobj.y - SSparallax.planet_y_offset) * our_speed + old_y
else
change_x = offset_x * our_speed
change_y = offset_y * our_speed

// This is how we tile parralax sprites
// It doesn't use change because we really don't want to animate this
if(parallax_layer.offset_x - change_x > 240)
if(old_x - change_x > 240)
parallax_layer.offset_x -= 480
else if(parallax_layer.offset_x - change_x < -240)
parallax_layer.pixel_w = parallax_layer.offset_x
else if(old_x - change_x < -240)
parallax_layer.offset_x += 480
if(parallax_layer.offset_y - change_y > 240)
parallax_layer.pixel_w = parallax_layer.offset_x
if(old_y - change_y > 240)
parallax_layer.offset_y -= 480
else if(parallax_layer.offset_y - change_y < -240)
parallax_layer.pixel_z = parallax_layer.offset_y
else if(old_y - change_y < -240)
parallax_layer.offset_y += 480
parallax_layer.pixel_z = parallax_layer.offset_y

// Now that we have our offsets, let's do our positioning
parallax_layer.offset_x -= change_x
parallax_layer.offset_y -= change_y

parallax_layer.screen_loc = "CENTER-7:[round(parallax_layer.offset_x, 1)],CENTER-7:[round(parallax_layer.offset_y, 1)]"

// We're going to use a transform to "glide" that last movement out, so it looks nicer
// Now that we have our offsets, let's do our positioning
// We're going to use an animate to "glide" that last movement out, so it looks nicer
// Don't do any animates if we're not actually moving enough distance yeah? thanks lad
if(run_parralax && (largest_change * our_speed > 1))
parallax_layer.transform = matrix(1,0,change_x, 0,1,change_y)
animate(parallax_layer, transform=matrix(), time = glide_rate)
animate(parallax_layer, pixel_w = round(parallax_layer.offset_x, 1), pixel_z = round(parallax_layer.offset_y, 1), time = glide_rate)
else
parallax_layer.pixel_w = round(parallax_layer.offset_x, 1)
parallax_layer.pixel_z = round(parallax_layer.offset_y, 1)

/atom/movable/proc/update_parallax_contents()
for(var/mob/client_mob as anything in client_mobs_in_contents)
Expand All @@ -258,6 +249,15 @@
var/area/areaobj = get_area(client.eye)
hud_used.set_parallax_movedir(areaobj.parallax_movedir, TRUE)

// Root object for parallax, all parallax layers are drawn onto this
INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_home)
/atom/movable/screen/parallax_home
icon = null
blend_mode = BLEND_ADD
plane = PLANE_SPACE_PARALLAX
screen_loc = "CENTER-7,CENTER-7"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT

// We need parallax to always pass its args down into initialize, so we immediate init it
INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)
/atom/movable/screen/parallax_layer
Expand All @@ -266,9 +266,9 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)
var/offset_x = 0
var/offset_y = 0
var/absolute = FALSE
appearance_flags = APPEARANCE_UI | KEEP_TOGETHER
blend_mode = BLEND_ADD
plane = PLANE_SPACE_PARALLAX
screen_loc = "CENTER-7,CENTER-7"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT

/atom/movable/screen/parallax_layer/Initialize(mapload, datum/hud/hud_owner, template = FALSE)
Expand Down Expand Up @@ -302,15 +302,17 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_layer)

// Turn the view size into a grid of correctly scaled overlays
var/list/viewscales = getviewsize(view)
var/countx = CEILING((viewscales[1] / 2) * parallax_scaler, 1) + 1
var/county = CEILING((viewscales[2] / 2) * parallax_scaler, 1) + 1
// This could be half the size but we need to provide space for parallax movement on mob movement, and movement on scroll from shuttles, so like this instead
var/countx = (CEILING((viewscales[1] / 2) * parallax_scaler, 1) + 1)
var/county = (CEILING((viewscales[2] / 2) * parallax_scaler, 1) + 1)
var/list/new_overlays = new
for(var/x in -countx to countx)
for(var/y in -county to county)
if(x == 0 && y == 0)
continue
var/mutable_appearance/texture_overlay = mutable_appearance(icon, icon_state)
texture_overlay.transform = matrix(1, 0, x*480, 0, 1, y*480)
texture_overlay.pixel_w += 480 * x
texture_overlay.pixel_z += 480 * y
new_overlays += texture_overlay
cut_overlays()
add_overlay(new_overlays)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/splash)
food_image = image(icon = food_icon, icon_state = food_icon_state, pixel_x = -5)
food_image.plane = plane
food_image.appearance_flags |= KEEP_APART // To be unaffected by filters applied to src
food_image.add_filter("simple_outline", 2, outline_filter(1, COLOR_BLACK))
food_image.add_filter("simple_outline", 2, outline_filter(1, COLOR_BLACK, OUTLINE_SHARP))
underlays += food_image // To be below filters applied to src

SetInvisibility(INVISIBILITY_ABSTRACT, name) // Start invisible, update later
Expand Down
11 changes: 3 additions & 8 deletions code/controllers/subsystem/profiler.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#define PROFILER_FILENAME "profiler.json"
#define SENDMAPS_FILENAME "sendmaps.json"

SUBSYSTEM_DEF(profiler)
name = "Profiler"
init_order = INIT_ORDER_PROFILER
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
wait = 3000
wait = 300 SECONDS
var/fetch_cost = 0
var/write_cost = 0

Expand Down Expand Up @@ -56,12 +53,12 @@ SUBSYSTEM_DEF(profiler)

if(!length(current_profile_data)) //Would be nice to have explicit proc to check this
stack_trace("Warning, profiling stopped manually before dump.")
var/prof_file = file("[GLOB.log_directory]/[PROFILER_FILENAME]")
var/prof_file = file("[GLOB.log_directory]/profiler/profiler-[round(world.time * 0.1, 10)].json")
if(fexists(prof_file))
fdel(prof_file)
if(!length(current_sendmaps_data)) //Would be nice to have explicit proc to check this
stack_trace("Warning, sendmaps profiling stopped manually before dump.")
var/sendmaps_file = file("[GLOB.log_directory]/[SENDMAPS_FILENAME]")
var/sendmaps_file = file("[GLOB.log_directory]/profiler/sendmaps-[round(world.time * 0.1, 10)].json")
if(fexists(sendmaps_file))
fdel(sendmaps_file)

Expand All @@ -70,5 +67,3 @@ SUBSYSTEM_DEF(profiler)
WRITE_FILE(sendmaps_file, current_sendmaps_data)
write_cost = MC_AVERAGE(write_cost, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))

#undef PROFILER_FILENAME
#undef SENDMAPS_FILENAME
Loading

0 comments on commit 6800422

Please sign in to comment.