# Gravity

Gravity is the general idea of accelerating towards a center of mass, often "down". In Mario 64, this is less consistent than real life and depends significantly on the object and the situation. This could be an acceleration or more of a velocity depending on the situation.

## Mario

Mario generally does a series of checks and changes his velocity depending on the situation. Once Mario performs any changes to his vertical speed, he is done with gravity and applies no more changes.

1. If Mario is in the twirling action and has negative Y-speed:
1. If Mario is spinning with a yaw speed faster than 1024:
• Mario's terminal velocity is set to -75 * 1024 / Mario's yaw speed.
• Mario's vertical speed is increased by -4 * 1024 / Mario's yaw speed.
2. Otherwise:
• Mario's terminal velocity is set to -75.
• Mario's vertical speed is decreased by 4.
3. If Mario's vertical speed is less than his terminal velocity, it is set to the terminal velocity instead.
4. Mario now stops these gravity checks.
2. If Mario is in the shot from cannon action:
1. Mario's vertical speed is decreased by 1.
2. If Mario's vertical speed is less than -75, it is capped/set to -75.
3. Mario now stops these gravity checks.
3. If Mario is in the long jump, slide kick, or BBH enter spin actions:
1. Mario's vertical speed is decreased by 2.
2. If Mario's vertical speed is less than -75, it is capped/set to -75.
3. Mario now stops these gravity checks.
4. If Mario is in the lava boost or fall from star grab actions:
1. Mario's vertical speed is decreased by 3.2.
2. If Mario's vertical speed is less than -65, it is capped/set to -65.
3. Mario now stops these gravity checks.
5. If Mario is in the getting blown action:
1. Mario's vertical speed is decreased by some number that is set elsewhere.
2. If Mario's vertical speed is less than -75, it is capped/set to -75.
3. Mario now stops these gravity checks.
6. If Mario has the 0x100 flag, his action does not have the "invulnerable" or "intangible" but has the "control jump height" action flags, his vertical speed is more than 20, and A is not held:
1. Mario's vertical speed is set to a quarter of its value.
2. Mario now stops these gravity checks.
7. If Mario's action has the "metal water" flag (metal cap and underwater):
1. Mario's vertical speed is decreased by 1.6.
2. If Mario's vertical speed is less than -16, it is capped/set to -16.
3. Mario now stops these gravity checks.
8. If Mario has the wing cap, A is held, and Mario's vertical speed is negative:
1. Mario's animation is changed
2. Mario's vertical speed is decreased by 2.
3. If Mario's vertical speed is less than -37.5, it is increased by 4.
• Then if Mario's vertical speed is more than -37.5, it is capped/set to -37.5.
4. Mario now stops these gravity checks.
9. If Mario is still in these checks:
1. Mario's vertical speed is decreased by 4.
2. If Mario's vertical speed is less than -75, it is capped/set to -75.