From 41f4948621f59006f2115b4efe4b8d3e4dccb30d Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 2 Mar 2021 17:13:14 -0500 Subject: [PATCH] Earlyports Stair fix from Polaris https://github.com/PolarisSS13/Polaris/pull/7943 --- code/game/atoms_movable.dm | 2 + code/game/objects/buckling.dm | 5 +- code/modules/multiz/stairs.dm | 216 ++++++++++-------------- code/modules/multiz/turf.dm | 2 +- code/modules/organs/internal/augment.dm | 2 +- 5 files changed, 96 insertions(+), 131 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 510b8bf762..872d3d5126 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -462,6 +462,8 @@ minor_dir = dx minor_dist = dist_x + range = min(dist_x + dist_y, range) + while(src && target && src.throwing && istype(src.loc, /turf) \ && ((abs(target.x - src.x)+abs(target.y - src.y) > 0 && dist_travelled < range) \ || (a && a.has_gravity == 0) \ diff --git a/code/game/objects/buckling.dm b/code/game/objects/buckling.dm index 533414d50c..088ed16440 100644 --- a/code/game/objects/buckling.dm +++ b/code/game/objects/buckling.dm @@ -40,10 +40,7 @@ return TRUE /atom/movable/proc/has_buckled_mobs() - if(!buckled_mobs) - return FALSE - if(buckled_mobs.len) - return TRUE + return LAZYLEN(buckled_mobs) /atom/movable/Destroy() unbuckle_all_mobs() diff --git a/code/modules/multiz/stairs.dm b/code/modules/multiz/stairs.dm index fdb4a02ac4..99be42a858 100644 --- a/code/modules/multiz/stairs.dm +++ b/code/modules/multiz/stairs.dm @@ -61,6 +61,9 @@ /obj/structure/stairs/proc/use_stairs(var/atom/movable/AM, var/atom/oldloc) return +/obj/structure/stairs/proc/instant_stairs(var/atom/movable/AM) + return + ////////////////////////////////////////////////////////////////////// // Bottom piece that you step ontor ////////////////////////////////// ////////////////////////////////////////////////////////////////////// @@ -133,7 +136,11 @@ return FALSE /obj/structure/stairs/bottom/Crossed(var/atom/movable/AM, var/atom/oldloc) - use_stairs(AM, oldloc) + if(isliving(AM)) + var/mob/living/L = AM + if(L.has_AI()) + use_stairs(AM, oldloc) + ..() /obj/structure/stairs/bottom/use_stairs(var/atom/movable/AM, var/atom/oldloc) // If we're coming from the top of the stairs, don't trap us in an infinite staircase @@ -147,7 +154,9 @@ if(AM.pulledby) // Animating the movement of pulled things is handled when the puller goes up the stairs return - var/animation_delay = STAIR_MOVE_DELAY // Default value + if(AM.has_buckled_mobs()) // Similarly, the rider entering the turf will bring along whatever they're buckled to + return + var/list/atom/movable/pulling = list() // Will also include grabbed mobs if(isliving(AM)) var/mob/living/L = AM @@ -155,8 +164,8 @@ if(L.grabbed_by.len) // Same as pulledby, whoever's holding you will keep you from going down stairs. return - // If the object has a measurable movement delay, use that - animation_delay = L.movement_delay() + if(L.buckled) + pulling |= L.buckled // If the object is pulling or grabbing anything, we'll want to move those too. A grab chain may be disrupted in doing so. if(L.pulling && !L.pulling.anchored) @@ -167,72 +176,48 @@ // If the stairs aren't broken, go up. if(check_integrity()) AM.dir = src.dir - // Animate moving onto M - switch(src.dir) - if(NORTH) - animate(AM, AM.pixel_y += 32, time = animation_delay) - if(SOUTH) - animate(AM, AM.pixel_y += -32, time = animation_delay) - if(EAST) - animate(AM, AM.pixel_x += 32, time = animation_delay) - if(WEST) - animate(AM, AM.pixel_x += -32, time = animation_delay) // Bring the pulled/grabbed object(s) along behind us for(var/atom/movable/P in pulling) P.forceMove(get_turf(src)) // They will move onto the turf but won't get past the check earlier in crossed. Aligns animation more cleanly - switch(src.dir) - if(NORTH) - animate(P, P.pixel_y += 32, time = animation_delay) - if(SOUTH) - animate(P, P.pixel_y += -32, time = animation_delay) - if(EAST) - animate(P, P.pixel_x += 32, time = animation_delay) - if(WEST) - animate(P, P.pixel_x += -32, time = animation_delay) - - // Go up the stairs - spawn(animation_delay) - // Move to Top - AM.forceMove(get_turf(top)) - - // Animate moving from O to T - switch(src.dir) - if(NORTH) - AM.pixel_y -= 64 - animate(AM, AM.pixel_y += 32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(SOUTH) - AM.pixel_y -= -64 - animate(AM, AM.pixel_y += -32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(EAST) - AM.pixel_x -= 64 - animate(AM, AM.pixel_x += 32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(WEST) - AM.pixel_x -= -64 - animate(AM, AM.pixel_x += -32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - - - // If something is being pulled, bring it along directly to avoid the mob being torn away from it due to movement delays - for(var/atom/movable/P in pulling) - spawn(animation_delay) - switch(src.dir) - if(NORTH) - P.pixel_y -= 32 - if(SOUTH) - P.pixel_y -= -32 - if(EAST) - P.pixel_x -= 32 - if(WEST) - P.pixel_x -= -32 - P.forceMove(get_turf(top)) // Just bring it along directly, no fussing with animation timing - if(isliving(P)) - var/mob/living/L = P - if(L.client) - L.client.Process_Grab() // Update any miscellanous grabs, possibly break grab-chains + // Move to Top + AM.forceMove(get_turf(top)) + // If something is being pulled, bring it along directly to avoid the mob being torn away from it due to movement delays + for(var/atom/movable/P in pulling) + P.forceMove(get_turf(top)) // Just bring it along directly, no fussing with animation timing + if(isliving(P)) + var/mob/living/L = P + if(L.client) + L.client.Process_Grab() // Update any miscellanous grabs, possibly break grab-chains return TRUE +/obj/structure/stairs/bottom/instant_stairs(var/atom/movable/AM) + if(isliving(AM)) + var/mob/living/L = AM + + if(L.grabbed_by.len) // Same as pulledby, whoever's holding you will keep you from going down stairs. + return + + if(L.has_buckled_mobs()) + return + + if(L.buckled) + L.buckled.forceMove(get_turf(top)) + + // If the object is pulling or grabbing anything, we'll want to move those too. A grab chain may be disrupted in doing so. + if(L.pulling && !L.pulling.anchored) + L.pulling.forceMove(get_turf(top)) + + for(var/obj/item/weapon/grab/G in list(L.l_hand, L.r_hand)) + G.affecting.forceMove(get_turf(top)) + + if(L.client) + L.client.Process_Grab() + + AM.forceMove(get_turf(top)) + ////////////////////////////////////////////////////////////////////// // Middle piece that you are animated onto/off of //////////////////// ////////////////////////////////////////////////////////////////////// @@ -318,7 +303,7 @@ /obj/structure/stairs/middle/Bumped(mob/user) if(check_integrity() && bottom && (bottom in get_turf(user))) // Bottom must be enforced because the middle stairs don't actually need the bottom - user.forceMove(get_turf(top)) + bottom.instant_stairs(user) ////////////////////////////////////////////////////////////////////// // Top piece that you step onto ////////////////////////////////////// @@ -391,8 +376,11 @@ return /obj/structure/stairs/top/Crossed(var/atom/movable/AM, var/atom/oldloc) - use_stairs(AM, oldloc) - . = ..() + if(isliving(AM)) + var/mob/living/L = AM + if(L.has_AI()) + use_stairs(AM, oldloc) + ..() /obj/structure/stairs/top/use_stairs(var/atom/movable/AM, var/atom/oldloc) // If we're coming from the bottom of the stairs, don't trap us in an infinite staircase @@ -406,7 +394,9 @@ if(AM.pulledby) // Animating the movement of pulled things is handled when the puller goes up the stairs return - var/animation_delay = STAIR_MOVE_DELAY // Default value + if(AM.has_buckled_mobs()) // Similarly, the rider entering the turf will bring along whatever they're buckled to + return + var/list/atom/movable/pulling = list() // Will also include grabbed mobs if(isliving(AM)) var/mob/living/L = AM @@ -414,8 +404,8 @@ if(L.grabbed_by.len) // Same as pulledby, whoever's holding you will keep you from going down stairs. return - // If the object has a measurable movement delay, use that - animation_delay = L.movement_delay() + if(L.buckled) + pulling |= L.buckled // If the object is pulling or grabbing anything, we'll want to move those too. A grab chain may be disrupted in doing so. if(L.pulling && !L.pulling.anchored) @@ -426,71 +416,47 @@ // If the stairs aren't broken, go up. if(check_integrity()) AM.dir = turn(src.dir, 180) - // Animate moving onto M - switch(src.dir) - if(NORTH) - animate(AM, AM.pixel_y -= 32, time = animation_delay) // Incrementing/decrementing to preserve prior values - if(SOUTH) - animate(AM, AM.pixel_y -= -32, time = animation_delay) - if(EAST) - animate(AM, AM.pixel_x -= 32, time = animation_delay) - if(WEST) - animate(AM, AM.pixel_x -= -32, time = animation_delay) // Bring the pulled/grabbed object(s) along behind us for(var/atom/movable/P in pulling) P.forceMove(get_turf(src)) // They will move onto the turf but won't get past the check earlier in crossed. Aligns animation more cleanly - switch(src.dir) - if(NORTH) - animate(P, P.pixel_y -= 32, time = animation_delay) - if(SOUTH) - animate(P, P.pixel_y -= -32, time = animation_delay) - if(EAST) - animate(P, P.pixel_x -= 32, time = animation_delay) - if(WEST) - animate(P, P.pixel_x -= -32, time = animation_delay) - // Go up the stairs - spawn(animation_delay) - // Move to Top - AM.forceMove(get_turf(bottom)) - - // Animate moving from O to T - switch(src.dir) - if(NORTH) - AM.pixel_y += 64 - animate(AM, AM.pixel_y -= 32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(SOUTH) - AM.pixel_y += -64 - animate(AM, AM.pixel_y -= -32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(EAST) - AM.pixel_x += 64 - animate(AM, AM.pixel_x -= 32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - if(WEST) - AM.pixel_x += -64 - animate(AM, AM.pixel_x -= -32, time = animation_delay)//, easing = SINE_EASING | EASE_OUT) - - - // If something is being pulled, bring it along directly to avoid the mob being torn away from it due to movement delays - for(var/atom/movable/P in pulling) - spawn(animation_delay) - switch(src.dir) - if(NORTH) - P.pixel_y += 32 - if(SOUTH) - P.pixel_y += -32 - if(EAST) - P.pixel_x += 32 - if(WEST) - P.pixel_x += -32 - P.forceMove(get_turf(bottom)) // Just bring it along directly, no fussing with animation timing - if(isliving(P)) - var/mob/living/L = P - if(L.client) - L.client.Process_Grab() // Update any miscellanous grabs, possibly break grab-chains + // Move to Top + AM.forceMove(get_turf(bottom)) + // If something is being pulled, bring it along directly to avoid the mob being torn away from it due to movement delays + for(var/atom/movable/P in pulling) + P.forceMove(get_turf(bottom)) // Just bring it along directly, no fussing with animation timing + if(isliving(P)) + var/mob/living/L = P + if(L.client) + L.client.Process_Grab() // Update any miscellanous grabs, possibly break grab-chains return TRUE +/obj/structure/stairs/top/instant_stairs(var/atom/movable/AM) + if(isliving(AM)) + var/mob/living/L = AM + + if(L.grabbed_by.len) // Same as pulledby, whoever's holding you will keep you from going down stairs. + return + + if(L.has_buckled_mobs()) + return + + if(L.buckled) + L.buckled.forceMove(get_turf(bottom)) + + // If the object is pulling or grabbing anything, we'll want to move those too. A grab chain may be disrupted in doing so. + if(L.pulling && !L.pulling.anchored) + L.pulling.forceMove(get_turf(bottom)) + + for(var/obj/item/weapon/grab/G in list(L.l_hand, L.r_hand)) + G.affecting.forceMove(get_turf(bottom)) + + if(L.client) + L.client.Process_Grab() + + AM.forceMove(get_turf(bottom)) // Mapping pieces, placed at the bottommost part of the stairs /obj/structure/stairs/spawner diff --git a/code/modules/multiz/turf.dm b/code/modules/multiz/turf.dm index 360e16f4e1..4f8781317e 100644 --- a/code/modules/multiz/turf.dm +++ b/code/modules/multiz/turf.dm @@ -62,7 +62,7 @@ // Going down stairs from the topstair piece var/obj/structure/stairs/top/T = locate(/obj/structure/stairs/top) in oldloc if(T && mover.dir == turn(T.dir, 180) && T.check_integrity()) - T.use_stairs(mover, oldloc) + T.instant_stairs(mover) return mover.fall() diff --git a/code/modules/organs/internal/augment.dm b/code/modules/organs/internal/augment.dm index 831d9d3b89..cfd5768846 100644 --- a/code/modules/organs/internal/augment.dm +++ b/code/modules/organs/internal/augment.dm @@ -31,7 +31,7 @@ var/last_activate = null /obj/item/organ/internal/augment/Initialize() - . ..() + . = ..() setup_radial_icon() if(integrated_object_type) integrated_object = new integrated_object_type(src)