Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel shift 2 #1941

Closed
wants to merge 13 commits into from
9 changes: 9 additions & 0 deletions code/game/objects/buckling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,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
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@
/// 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

Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 33 additions & 30 deletions code/modules/pixelshifting/pixelshift.dm
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
#define MAXIMUM_PIXEL_SHIFT 16
#define PASSABLE_SHIFT_THRESHOLD 8

/mob/proc/unpixel_shift()
return
// Unpixelshifting keybind is handeled in game/object/buckling.dm to avoid having multiple definition of /atom/mobable/attack_hand(mod/living/user)

/mob/proc/pixel_shift(direction)
return
/atom/movable
// Is the atom shifted ?
var/is_shifted = FALSE

/mob/living/unpixel_shift()
. = ..()
passthroughable = NONE
/atom/movable/proc/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/set_pull_offsets(mob/living/pull_target, grab_state)
pull_target.unpixel_shift()
return ..()
pixel_x = base_pixel_x
pixel_y = base_pixel_y

/mob/living/reset_pull_offsets(mob/living/pull_target, override)
pull_target.unpixel_shift()
return ..()

/mob/living/pixel_shift(direction)
passthroughable = NONE
/atom/movable/proc/pixel_shift(direction)
var/max_shift = (!density || ismob(src)) ? MAXIMUM_PIXEL_SHIFT : PASSABLE_SHIFT_THRESHOLD
switch(direction)
if(NORTH)
if(!canface())
return FALSE
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(!canface())
return FALSE
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(!canface())
return FALSE
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(!canface())
return FALSE
if(pixel_x >= -MAXIMUM_PIXEL_SHIFT + base_pixel_x)
if(pixel_x >= -max_shift + base_pixel_x)
pixel_x--
is_shifted = TRUE

// Part about mobs
/mob/living/unpixel_shift()
. = ..()
passthroughable = NONE

/mob/living/set_pull_offsets(mob/living/pull_target, grab_state)
pull_target.unpixel_shift()
return ..()

/mob/living/reset_pull_offsets(mob/living/pull_target, override)
if(!pull_target.is_shifted)
pull_target.unpixel_shift()
return ..()

/mob/living/pixel_shift(direction)
passthroughable = NONE
if(!canface() && !pulledby)
return FALSE
..()

// Yes, I know this sets it to true for everything if more than one is matched.
// Movement doesn't check diagonals, and instead just checks EAST or WEST, depending on where you are for those.
if(pixel_y > PASSABLE_SHIFT_THRESHOLD)
Expand Down