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

[modpack] Adds pixel shifting #197

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

NotRanged
Copy link

@NotRanged NotRanged commented Nov 24, 2021

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:

  • The direction you are facing (EAST/WEST) now influences the direction you lay down in.
  • canface() now checks for INCAPACITATION_UNRESISTING which means you can change facing direction and pixelshift while lying down, but not while dead.

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:

@NotRanged NotRanged closed this Nov 26, 2021
@NotRanged NotRanged reopened this Nov 26, 2021
Copy link
Contributor

@quardbreak quardbreak left a 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.

Comment on lines +507 to +513
// Modpack edit - pixel shifting
if(shifting)
pixel_shift(direct)
return FALSE
else if(is_shifted)
unpixel_shift()
// end modpack edit
Copy link
Contributor

@quardbreak quardbreak Dec 2, 2021

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)
Copy link
Contributor

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())
Copy link
Contributor

@quardbreak quardbreak Dec 2, 2021

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
Copy link
Contributor

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).

@quardbreak
Copy link
Contributor

quardbreak commented Dec 2, 2021

Oh, and you can remove angle and canface() edits.
I opened PR on upstream, so it will be natural for you: NebulaSS13/Nebula#2240

Comment on lines +13 to +14
pixel_x = initial(pixel_x)
pixel_y = initial(pixel_y)
Copy link
Contributor

@quardbreak quardbreak Dec 2, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Pixel Shifting
3 participants