-
Notifications
You must be signed in to change notification settings - Fork 40
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
[modpack] Adds pixel shifting #197
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I come to help, because I have similar feature on my downstream and have some improvements hints to modularize it.
// Modpack edit - pixel shifting | ||
if(shifting) | ||
pixel_shift(direct) | ||
return FALSE | ||
else if(is_shifted) | ||
unpixel_shift() | ||
// end modpack edit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This edit will conflict with upstream.
You probably want to move it to modpack as well, since those functions work only if you include it.
I used this code in my downstream to separate from core to modpack:
/mob/living/Move()
. = ..()
if(is_shifted && !buckled)
is_shifted = FALSE
pixel_x = default_pixel_x
pixel_y = default_pixel_y
After some tweaks for you, it will look like this:
I use this code to separate from core to modpack:
/mob/living/Move()
if(shifting)
pixel_shift(direct)
return FALSE
else if((is_shifted && !buckled)
unpixel_shift()
. = ..()
if(NORTH) | ||
if(!canface()) | ||
return FALSE | ||
if(pixel_y <= 16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace magic numbers like 16 with define like DEFAULT_SHIFT_MAX
.
I use 8 at this moment, but would like to change it to 16 if this visually better.
/mob/living/pixel_shift(direction) | ||
switch(direction) | ||
if(NORTH) | ||
if(!canface()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the first check inside this function. No need to duplicate it for every direction.
Use this:
/mob/proc/can_pixel_shift()
return !(incapacitated() || buckled || LAZYLEN(grabbed_by))
/mob/proc/pixel_shift(direction)
return
/mob/living/pixel_shift(direction)
if(!canface() || !can_shift())
return FALSE
(...)
return FALSE | ||
if(pixel_x >= -16) | ||
pixel_x-- | ||
is_shifted = TRUE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can just copypaste my proc:
#define SHIFT_MAX 8
/mob/proc/pixel_shift(dir)
if(!canface() || !can_shift())
return FALSE
switch(dir)
if(NORTH)
if(pixel_y <= SHIFT_MAX)
pixel_y++
if(EAST)
if(pixel_x <= SHIFT_MAX)
pixel_x++
if(SOUTH)
if(pixel_y >= -SHIFT_MAX)
pixel_y--
if(WEST)
if(pixel_x >= -SHIFT_MAX)
pixel_x--
else
CRASH("Invalid argument supplied!")
is_shifted = TRUE
UPDATE_OO_IF_PRESENT
#undef SHIFT_MAX
Note about the UPDATE_OO_IF_PRESENT
. It will update a openspace overlay above you (so people above will see your character is shifted).
Oh, and you can remove angle and canface() edits. |
pixel_x = initial(pixel_x) | ||
pixel_y = initial(pixel_y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pixel_x = default_pixel_x
pixel_y = default_pixel_y
Some species/mobs have their own default pixel. Use them.
Description of changes
Adds pixel shifting, default keybind to hold down is 'alt', pixel shift is reset upon moving.
Additional semi-related changes in this PR:
closes #169
Why and what will this PR improve
Imagine being a RP server in 2021 without pixel shifting.
This is the first time I've used this weird modpack system so let me know if I messed it all up somehow. All changes were tested and working locally.
Authorship
Code is a mix of Skyrat-SS13/Skyrat-tg#870 and my own modifications to it.
Changelog
🆑
rscadd: Added pixel shifting.
tweak: Lying down while facing left or right now lays you down left or right.
tweak: You can now pixel shift and change facing direction while lying down.
/:cl: