From 1dddfc759593dd6f6f864b8d3eb5f60e3d6eb235 Mon Sep 17 00:00:00 2001 From: ritorizo Date: Fri, 5 May 2023 06:06:07 +0200 Subject: [PATCH 1/7] pixelshifting 2 --- code/modules/mob/mob_defines.dm | 3 --- code/modules/mob/mob_movement.dm | 3 +++ code/modules/pixelshifting/pixelshift.dm | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 03bb89ff83ab..71083b4eabdb 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -223,8 +223,5 @@ /// Whether the typing indicator is on. Not on /living level because of verbs var/typing_indicator = FALSE - ///Is the mob pixel shifted? - var/is_shifted - ///Is the mob actively shifting? var/shifting diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 1a861dc304b4..7a58a552b536 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -90,6 +90,9 @@ if(mob.force_moving) return FALSE if(mob.shifting) + if (mob.pulling) + mob.pulling.pixel_shift(direct) + return FALSE mob.pixel_shift(direct) return FALSE else if(mob.is_shifted) //Cancels pixel offset on movement diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index 419f3249aa76..4f849cb022f7 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -1,38 +1,39 @@ -/mob/proc/unpixel_shift() +/atom/movable/proc/unpixel_shift() return -/mob/proc/pixel_shift(direction) +/atom/movable/proc/pixel_shift(direction) return +/atom/movable + // Is the atom shifted ? + var/is_shifted = FALSE + /mob/living/unpixel_shift() if(is_shifted) is_shifted = FALSE pixel_x = body_pixel_x_offset + base_pixel_x pixel_y = body_pixel_y_offset + base_pixel_y -/mob/living/pixel_shift(direction) +/atom/movable/pixel_shift(direction) switch(direction) if(NORTH) - if(!canface()) - return FALSE if(pixel_y <= 16 + base_pixel_y) pixel_y++ is_shifted = TRUE if(EAST) - if(!canface()) - return FALSE if(pixel_x <= 16 + base_pixel_x) pixel_x++ is_shifted = TRUE if(SOUTH) - if(!canface()) - return FALSE if(pixel_y >= -16 + base_pixel_y) pixel_y-- is_shifted = TRUE if(WEST) - if(!canface()) - return FALSE if(pixel_x >= -16 + base_pixel_x) pixel_x-- is_shifted = TRUE + +/mob/living/pixel_shift(direction) + if(!canface()) + return FALSE + ..() From 876a93f25e7daeacd637c69913e5dec7473ea861 Mon Sep 17 00:00:00 2001 From: ritorizo Date: Fri, 5 May 2023 06:42:40 +0200 Subject: [PATCH 2/7] slap to put em back --- code/modules/pixelshifting/pixelshift.dm | 36 ++++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index 4f849cb022f7..30a60a9a4ffe 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -1,20 +1,9 @@ -/atom/movable/proc/unpixel_shift() - return - -/atom/movable/proc/pixel_shift(direction) - return - /atom/movable // Is the atom shifted ? var/is_shifted = FALSE -/mob/living/unpixel_shift() - if(is_shifted) - is_shifted = FALSE - pixel_x = body_pixel_x_offset + base_pixel_x - pixel_y = body_pixel_y_offset + base_pixel_y -/atom/movable/pixel_shift(direction) +/atom/movable/proc/pixel_shift(direction) switch(direction) if(NORTH) if(pixel_y <= 16 + base_pixel_y) @@ -33,7 +22,30 @@ pixel_x-- is_shifted = TRUE +/atom/movable/proc/unpixel_shift() + if(is_shifted) + is_shifted = FALSE + pixel_x = base_pixel_x + pixel_y = base_pixel_y + +// Part about mobs /mob/living/pixel_shift(direction) if(!canface()) return FALSE ..() + +/mob/living/unpixel_shift() + if(is_shifted) + is_shifted = FALSE + pixel_x = body_pixel_x_offset + base_pixel_x + pixel_y = body_pixel_y_offset + base_pixel_y + +/obj/item/slapper/afterattack(atom/target, mob/user, proximity) + if (!proximity) + return + if (ismob(target)) + return + if (istype(target, /atom/movable)) + var/atom/movable/M = target + if(!M.anchored) + M.unpixel_shift() From 4366a592cf2233a4f833cbdde527a13e69ed2fd2 Mon Sep 17 00:00:00 2001 From: ritorizo Date: Fri, 5 May 2023 06:55:53 +0200 Subject: [PATCH 3/7] pixelshift other mobs --- code/modules/pixelshifting/pixelshift.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index 30a60a9a4ffe..5bf4042b7c80 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -30,7 +30,7 @@ // Part about mobs /mob/living/pixel_shift(direction) - if(!canface()) + if(!canface() && !pulledby) return FALSE ..() From 56a3658dc480e9fcf72907da6baba4ebb2984c2f Mon Sep 17 00:00:00 2001 From: ritorizo Date: Sat, 6 May 2023 18:42:18 +0200 Subject: [PATCH 4/7] fix the logspam, which was due to checkin for the client lasturn on clientless mobs --- code/modules/mob/mob.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 9e4b8cd84c84..c2e51d0a2695 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -908,7 +908,7 @@ * * we are not restrained */ /mob/proc/canface() - if(world.time < client.last_turn) + if(client && world.time < client.last_turn) return FALSE if(stat >= UNCONSCIOUS) return FALSE From 439655879fc0724259d6570ecb2c0948dea737a0 Mon Sep 17 00:00:00 2001 From: ritorizo Date: Mon, 24 Jul 2023 20:40:20 +0200 Subject: [PATCH 5/7] limit pixel shifting for dense object --- code/modules/pixelshifting/pixelshift.dm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index a41b66861d0c..e28b05ce67f5 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -12,21 +12,22 @@ pixel_y = base_pixel_y /atom/movable/proc/pixel_shift(direction) + var/max_shift = (!density | ismob(src)) ? MAXIMUM_PIXEL_SHIFT : PASSABLE_SHIFT_THRESHOLD switch(direction) if(NORTH) - if(pixel_y <= MAXIMUM_PIXEL_SHIFT + base_pixel_y) + if(pixel_y <= max_shift + base_pixel_y) pixel_y++ is_shifted = TRUE if(EAST) - if(pixel_x <= MAXIMUM_PIXEL_SHIFT + base_pixel_x) + if(pixel_x <= max_shift + base_pixel_x) pixel_x++ is_shifted = TRUE if(SOUTH) - if(pixel_y >= -MAXIMUM_PIXEL_SHIFT + base_pixel_y) + if(pixel_y >= -max_shift + base_pixel_y) pixel_y-- is_shifted = TRUE if(WEST) - if(pixel_x >= -MAXIMUM_PIXEL_SHIFT + base_pixel_x) + if(pixel_x >= -max_shift + base_pixel_x) pixel_x-- is_shifted = TRUE From 532a0c6cef7435a388de31df918078a05f5857d7 Mon Sep 17 00:00:00 2001 From: ritorizo Date: Mon, 24 Jul 2023 23:32:26 +0200 Subject: [PATCH 6/7] sacrifice a newborn to apease the linter gods --- code/modules/pixelshifting/pixelshift.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index e28b05ce67f5..357e7ddf2479 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -12,7 +12,7 @@ pixel_y = base_pixel_y /atom/movable/proc/pixel_shift(direction) - var/max_shift = (!density | ismob(src)) ? MAXIMUM_PIXEL_SHIFT : PASSABLE_SHIFT_THRESHOLD + var/max_shift = (!density || ismob(src)) ? MAXIMUM_PIXEL_SHIFT : PASSABLE_SHIFT_THRESHOLD switch(direction) if(NORTH) if(pixel_y <= max_shift + base_pixel_y) From 7635e61fdf6f37f4101beaeeeede4829f58aba6d Mon Sep 17 00:00:00 2001 From: ritorizo Date: Mon, 31 Jul 2023 03:43:35 +0200 Subject: [PATCH 7/7] move unpixelshiftin from the slapper to pixelshift+click keybind --- code/game/objects/buckling.dm | 9 +++++++++ code/modules/pixelshifting/pixelshift.dm | 13 ++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/code/game/objects/buckling.dm b/code/game/objects/buckling.dm index 845db56a794f..aede0abd2a90 100644 --- a/code/game/objects/buckling.dm +++ b/code/game/objects/buckling.dm @@ -21,6 +21,15 @@ if(user_unbuckle_mob(buckled_mobs[1],user)) return 1 + // Unpixelshifting part + if(user.shifting) + if(ismob(src)) + return ..() + if(!src.anchored) + src.unpixel_shift() + return TRUE + + //literally just the above extension of attack_hand(), but for silicons instead (with an adjacency check, since attack_robot() being called doesn't mean that you're adjacent to something) /atom/movable/attack_robot(mob/living/user) . = ..() diff --git a/code/modules/pixelshifting/pixelshift.dm b/code/modules/pixelshifting/pixelshift.dm index 357e7ddf2479..849cf49e68bd 100644 --- a/code/modules/pixelshifting/pixelshift.dm +++ b/code/modules/pixelshifting/pixelshift.dm @@ -1,6 +1,8 @@ #define MAXIMUM_PIXEL_SHIFT 16 #define PASSABLE_SHIFT_THRESHOLD 8 +// Unpixelshifting keybind is handeled in game/object/buckling.dm to avoid having multiple definition of /atom/mobable/attack_hand(mod/living/user) + /atom/movable // Is the atom shifted ? var/is_shifted = FALSE @@ -68,16 +70,5 @@ return TRUE return ..() -// Slap things back in place -/obj/item/slapper/afterattack(atom/target, mob/user, proximity) - if (!proximity) - return - if (ismob(target)) - return - if (istype(target, /atom/movable)) - var/atom/movable/M = target - if(!M.anchored) - M.unpixel_shift() - #undef MAXIMUM_PIXEL_SHIFT #undef PASSABLE_SHIFT_THRESHOLD