Movement steps: Difference between revisions
m (MMMMMMMMMMMMM moved page Movement Steps to Movement steps: Sentence casify the wiki) |
Icecream17 (talk | contribs) (add stationary step) |
||
Line 2: | Line 2: | ||
Steps are also responsible for detecting collision with [[surfaces]], updating Mario's [[referenced surfaces]], and updating Mario's [[Water|water level]]. However, quarter steps don't detect object collisions or warps. | Steps are also responsible for detecting collision with [[surfaces]], updating Mario's [[referenced surfaces]], and updating Mario's [[Water|water level]]. However, quarter steps don't detect object collisions or warps. | ||
== Stationary Step == | |||
https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L236 | |||
# Mario's x and z forward velocity and sliding velocity is set to 0 | |||
# mario_update_moving_sand | |||
# mario_update_windy_ground | |||
# If updated by moving sand or windy ground, return perform_ground_step | |||
# Else, set Mario's y position to the floor, (possibly causing a [[downwarp]]), and update graphics. Return GROUND_STEP_NONE. | |||
== Air Step == | == Air Step == | ||
Line 7: | Line 16: | ||
When an action performs a ''common'' air step, the first thing Mario does is update his horizontal velocity/sideways position via [[straining]]. This is only for the common air step and is not part of the quarter-frame checks. | When an action performs a ''common'' air step, the first thing Mario does is update his horizontal velocity/sideways position via [[straining]]. This is only for the common air step and is not part of the quarter-frame checks. | ||
=== Quarter-Frame Checks === | === Quarter-Frame Checks === | ||
After that is updated, the movement is split into "quarter-steps" that breakdown Mario's movement and determine what his outcome of each step is. The checks for the quarter-steps are as follows: | After that is updated, the movement is split into "quarter-steps" that breakdown Mario's movement and determine what his outcome of each step is. The checks for the quarter-steps are as follows: | ||
# The position a quarter of Mario's velocity ahead of Mario is checked for cancels/outcomes. Anything in bold is an exit out of the rest of the checks. | # The position a quarter of Mario's velocity ahead of Mario is checked for cancels/outcomes. Anything in bold is an exit out of the rest of the checks. | ||
Line 42: | Line 49: | ||
# This repeats until Mario encounters something besides '''nothing happens''', up to four times including the initial time. | # This repeats until Mario encounters something besides '''nothing happens''', up to four times including the initial time. | ||
# Mario tracks his "exit", with '''nothing happens''' being tracked if the whole process completed four times. | # Mario tracks his "exit", with '''nothing happens''' being tracked if the whole process completed four times. | ||
With the outcome selected and the movement mostly done, a series of things happen. | With the outcome selected and the movement mostly done, a series of things happen. | ||
* If Mario's velocity is not negative, his "peak height" is updated. | * If Mario's velocity is not negative, his "peak height" is updated. | ||
Line 50: | Line 56: | ||
* Mario's visual position is updated to Mario's position. | * Mario's visual position is updated to Mario's position. | ||
* Mario's yaw is updated to match the in-game angle. | * Mario's yaw is updated to match the in-game angle. | ||
=== Common Air Step Results === | === Common Air Step Results === | ||
If doing a common air step, Mario now decides what to do based off the "exit" from the quarter-frame checks before. Here is what he does for each exit: | If doing a common air step, Mario now decides what to do based off the "exit" from the quarter-frame checks before. Here is what he does for each exit: | ||
* '''Nothing Happens''': | * '''Nothing Happens''': | ||
** Mario's animation is now applied. | ** Mario's animation is now applied. | ||
* '''Lands''': | * '''Lands''': | ||
Line 77: | Line 82: | ||
*** Mario plays a noise depending on whether or not he is wearing a metal cap. | *** Mario plays a noise depending on whether or not he is wearing a metal cap. | ||
** If Mario's forward velocity is more than 16 and he is not in contact with a physical wall/surface (i.e. OOB): | ** If Mario's forward velocity is more than 16 and he is not in contact with a physical wall/surface (i.e. OOB): | ||
*** A different sound is played, but Mario's yaw is not reflected. | *** A different sound is played, but Mario's yaw is not reflected. | ||
** If Mario is in contact with a wall, his action is set to the [[Air Hit Wall|air hit wall]] action. | ** If Mario is in contact with a wall, his action is set to the [[Air Hit Wall|air hit wall]] action. | ||
** If Mario is not in contact with a wall (i.e. hitting OOB): | ** If Mario is not in contact with a wall (i.e. hitting OOB): | ||
Line 94: | Line 99: | ||
** If Mario is not wearing a metal cap, he is hurt 12 (or 18 without his hat). | ** If Mario is not wearing a metal cap, he is hurt 12 (or 18 without his hat). | ||
** Mario plays the noise for being burned. | ** Mario plays the noise for being burned. | ||
** The camera preset is set to the area's default preset. | ** The camera preset is set to the area's default preset. | ||
** Mario enters the [[Lava Boost|lava boost]] action while dropping any held objects and no longer riding a shell. | ** Mario enters the [[Lava Boost|lava boost]] action while dropping any held objects and no longer riding a shell. | ||
[[Category:Action Mechanics]] | [[Category:Action Mechanics]] |
Revision as of 21:47, 5 March 2023
Typically, Mario's position is updated incrementally using his velocity. These increments are called steps, and they behave differently when Mario is on the ground, in the air, in water, hanging, and climbing a pole. When on the ground or in the air, these steps typically occur four times per frame, and are commonly referred to as quarter steps or sometimes quarter frames.
Steps are also responsible for detecting collision with surfaces, updating Mario's referenced surfaces, and updating Mario's water level. However, quarter steps don't detect object collisions or warps.
Stationary Step
- Mario's x and z forward velocity and sliding velocity is set to 0
- mario_update_moving_sand
- mario_update_windy_ground
- If updated by moving sand or windy ground, return perform_ground_step
- Else, set Mario's y position to the floor, (possibly causing a downwarp), and update graphics. Return GROUND_STEP_NONE.
Air Step
Certain things here are more explained on their individual pages. If something lacks detail, check the link for more information.
When an action performs a common air step, the first thing Mario does is update his horizontal velocity/sideways position via straining. This is only for the common air step and is not part of the quarter-frame checks.
Quarter-Frame Checks
After that is updated, the movement is split into "quarter-steps" that breakdown Mario's movement and determine what his outcome of each step is. The checks for the quarter-steps are as follows:
- The position a quarter of Mario's velocity ahead of Mario is checked for cancels/outcomes. Anything in bold is an exit out of the rest of the checks.
- If the position is above OOB but below Mario's current floor height, Mario's height is changed to the floor height and he lands.
- If the position is above OOB but not below Mario's current floor height, Mario's height is set to the new height and he hits a wall.
- If the action has the "riding shell" flag and the water level at the position is above the position's floor (up to 78 units above the position):
- The floor height from here on is the water height.
- The floor from this point on is a "fake" floor on the surface of the water.
- The floor's origin offset is set to the water height.
- If the position's height is 78 units or less below a floor and there is not a ceiling 160 units or less above it (because of how variable types an overflow jump may occur here):
- Mario's position horizontally is updated to the new position.
- Mario's height is set to that of the floor's height.
- Mario's floor and floor height are updated.
- Mario lands.
- If the position's height is 78 units or less below a floor and there is a ceiling 160 units or less above it (because of how variable types an overflow jump may occur here):
- Mario's height is set to that of the floor's height.
- Mario lands. (Because Mario's floor is not updated, this is where a pedro spot may occur)
- If the position's height is 160 units under, at, or above a ceiling and his vertical velocity is positive or zero:
- Mario's vertical velocity is set to zero.
- If the ceiling above Mario is hangable and the air step has the "check hang" flag, Mario hangs. (Since this did not use the new position's ceiling/location, this is potentially a hangable-ceiling upwarp.)
- Otherwise, nothing happens.
- If the position's height is 160 units under, at, or above a ceiling and his vertical velocity is negative:
- If the position's height is at or below Mario's floor height, Mario's height is set to the floor height, and he lands.
- Otherwise, Mario's height is set to the new height and he hits a wall.
- If there is a wall 30 units above the position but not 150 units above the position and the air step has the "check ledge grab" flag:
- If Mario's velocity is positive, Mario is pushed by the wall opposite the velocity direction, and there is a floor 60 units behind the wall within 238 units upward, Mario ledge grabs. (Potentially a GLG)
- Otherwise Mario's position is set to the new position, his floor and floor height are updated, and nothing happens.
- Mario's position is set to the new position and his floor and floor height are updated.
- If Mario is colliding with a wall 150 or 30 units up and the upper or only wall is lava, he lava wall boosts.
- If Mario is colliding with a wall 150 or 30 units up and Mario is facing perpendicular to 0x6000 units away, he hits a wall.
- If no other exit has occurred, nothing happens.
- This repeats until Mario encounters something besides nothing happens, up to four times including the initial time.
- Mario tracks his "exit", with nothing happens being tracked if the whole process completed four times.
With the outcome selected and the movement mostly done, a series of things happen.
- If Mario's velocity is not negative, his "peak height" is updated.
- Mario's step noise is updated based on his floor.
- If Mario is not flying, gravity is applied.
- Vertical wind is now applied/accounted for.
- Mario's visual position is updated to Mario's position.
- Mario's yaw is updated to match the in-game angle.
Common Air Step Results
If doing a common air step, Mario now decides what to do based off the "exit" from the quarter-frame checks before. Here is what he does for each exit:
- Nothing Happens:
- Mario's animation is now applied.
- Lands:
- If Mario is not over a hard surface, the terrain is either snow or desert, Mario's peak height is more than 1000 units above him, the surface does not belong to an object, and the Y normal of the surface is not less than .8660254 (square root of 3 divided by 2):
- Mario plays an OOF noise, dependent on which version of the game.
- Mario spawns particles.
- Mario's action is set to the feet stuck in ground action and the lands checks stop.
- If Mario's action is not twirling, the floor is not lava, his negative velocity is less than -55, and the distance from the peak height to Mario is more than 3000 units:
- Mario is hurt by 16 (24 without his hat).
- The camera shakes.
- Mario plays the "attacked" noise.
- Mario is set to the hard backward ground knockback action and the lands checks stop.
- If Mario's action is not twirling, the floor is not lava, his negative velocity is less than -55, and the distance from the peak height to Mario is more than 1150 units:
- Mario is hurt by 8 (12 without his hat).
- Mario is squished for 30.
- The camera shakes.
- Mario plays the "attacked" noise.
- Mario is set to his action's landing action.
- If Mario is not over a hard surface, the terrain is either snow or desert, Mario's peak height is more than 1000 units above him, the surface does not belong to an object, and the Y normal of the surface is not less than .8660254 (square root of 3 divided by 2):
- Hits a Wall:
- Mario's animation is now applied.
- If Mario's forward velocity is more than 16 and is in contact with a physical wall/surface:
- Mario's yaw is "reflected" across the most recent wall Mario collided with, up to the first 4 walls. (This can be glitchy with more than 1 wall, i.e. unreferenced walls).
- Mario plays a noise depending on whether or not he is wearing a metal cap.
- If Mario's forward velocity is more than 16 and he is not in contact with a physical wall/surface (i.e. OOB):
- A different sound is played, but Mario's yaw is not reflected.
- If Mario is in contact with a wall, his action is set to the air hit wall action.
- If Mario is not in contact with a wall (i.e. hitting OOB):
- Any positive vertical speed is capped to 0.
- If Mario's forward velocity is 38 or more, spawn particles and set his action to the backward air knockback action.
- If Mario's forward velocity is more than 8 but less than 38, set Mario's forward speed to -8 and set his action to the soft bonk action.
- If Mario's forward velocity is 16 or less (initially, not after these other changes), set the forward velocity to 0.
- Ledge Grabs
- Mario's animation is set the idle ledge grab animation.
- Mario enters the ledge grab action while dropping any held objects and no longer riding a shell.
- Hangs
- Mario's action is set to the start hanging action.
- Lava Wall Boosts
- Mario's yaw is set perpendicular to the wall.
- Mario's forward speed is capped to 24.
- If Mario is not wearing a metal cap, he is hurt 12 (or 18 without his hat).
- Mario plays the noise for being burned.
- The camera preset is set to the area's default preset.
- Mario enters the lava boost action while dropping any held objects and no longer riding a shell.