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

Raycast Step Implementation #498

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
65 changes: 49 additions & 16 deletions autogen/lua_definitions/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8734,28 +8734,28 @@ ACT_WATER_SHOCKED = 0x300222C8
ACT_WATER_THROW = 0x300024E0

--- @type integer
AIR_STEP_CHECK_HANG = 0x00000002
AIR_STEP_CHECK_HANG = STEP_CHECK_HANG

--- @type integer
AIR_STEP_CHECK_LEDGE_GRAB = 0x00000001
AIR_STEP_CHECK_LEDGE_GRAB = STEP_CHECK_LEDGE_GRAB

--- @type integer
AIR_STEP_GRABBED_CEILING = 4
AIR_STEP_GRABBED_CEILING = STEP_GRAB_CEILING

--- @type integer
AIR_STEP_GRABBED_LEDGE = 3
AIR_STEP_GRABBED_LEDGE = STEP_GRAB_LEDGE

--- @type integer
AIR_STEP_HIT_LAVA_WALL = 6
AIR_STEP_HIT_LAVA_WALL = STEP_HIT_LAVA

--- @type integer
AIR_STEP_HIT_WALL = 2
AIR_STEP_HIT_WALL = STEP_HIT_WALL

--- @type integer
AIR_STEP_LANDED = 1
AIR_STEP_LANDED = STEP_ON_GROUND

--- @type integer
AIR_STEP_NONE = 0
AIR_STEP_NONE = STEP_IN_AIR

--- @type integer
C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
Expand All @@ -8764,19 +8764,19 @@ C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
END_DEMO = (1 << 7)

--- @type integer
GROUND_STEP_HIT_WALL = 2
GROUND_STEP_HIT_WALL = STEP_HIT_WALL

--- @type integer
GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS = 3

--- @type integer
GROUND_STEP_HIT_WALL_STOP_QSTEPS = 2
GROUND_STEP_HIT_WALL_STOP_QSTEPS = STEP_HIT_CEILING

--- @type integer
GROUND_STEP_LEFT_GROUND = 0
GROUND_STEP_LEFT_GROUND = STEP_IN_AIR

--- @type integer
GROUND_STEP_NONE = 1
GROUND_STEP_NONE = STEP_ON_GROUND

--- @type integer
INPUT_ABOVE_SLIDE = 0x0008
Expand Down Expand Up @@ -8979,6 +8979,39 @@ PARTICLE_WATER_SPLASH = (1 << 6)
--- @type integer
PARTICLE_WAVE_TRAIL = (1 << 10)

--- @type integer
STEP_CHECK_HANG = 0x00000002

--- @type integer
STEP_CHECK_LEDGE_GRAB = 0x00000001

--- @type integer
STEP_GRAB_CEILING = 4

--- @type integer
STEP_GRAB_LEDGE = 3

--- @type integer
STEP_HIT_CEILING = 6

--- @type integer
STEP_HIT_LAVA = 5

--- @type integer
STEP_HIT_WALL = 2

--- @type integer
STEP_IN_AIR = 0

--- @type integer
STEP_NO_GRAVITY = 0x00000004

--- @type integer
STEP_ON_GROUND = 1

--- @type integer
STEP_SNAP_TO_FLOOR = 0x00000008

--- @type integer
STEP_TYPE_AIR = 2

Expand All @@ -8998,16 +9031,16 @@ VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD |
WATER_STEP_CANCELLED = 3

--- @type integer
WATER_STEP_HIT_CEILING = 2
WATER_STEP_HIT_CEILING = STEP_HIT_CEILING

--- @type integer
WATER_STEP_HIT_FLOOR = 1
WATER_STEP_HIT_FLOOR = STEP_ON_GROUND

--- @type integer
WATER_STEP_HIT_WALL = 4
WATER_STEP_HIT_WALL = STEP_HIT_WALL

--- @type integer
WATER_STEP_NONE = 0
WATER_STEP_NONE = STEP_IN_AIR

--- @class LuaActionHookType

Expand Down
9 changes: 9 additions & 0 deletions autogen/lua_definitions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4925,6 +4925,15 @@ function bhv_unlock_door_star_loop()
-- ...
end

--- @param m MarioState
--- @param wall Surface
--- @param intendedPos Vec3f
--- @param nextPos Vec3f
--- @return integer
function check_ledge_grab(m, wall, intendedPos, nextPos)
-- ...
end

--- @return number
function get_additive_y_vel_for_jumps()
-- ...
Expand Down
1 change: 1 addition & 0 deletions autogen/lua_definitions/structs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
--- @field public KoopaBobAgility number
--- @field public KoopaCatchupAgility number
--- @field public KoopaThiAgility number
--- @field public MarioRaycastSteps integer
--- @field public MipsStar1Requirement integer
--- @field public MipsStar2Requirement integer
--- @field public MultipleCapCollection integer
Expand Down
11 changes: 11 additions & 0 deletions docs/lua/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -3225,6 +3225,17 @@
- PARTICLE_VERTICAL_STAR
- PARTICLE_WATER_SPLASH
- PARTICLE_WAVE_TRAIL
- STEP_CHECK_HANG
- STEP_CHECK_LEDGE_GRAB
- STEP_GRAB_CEILING
- STEP_GRAB_LEDGE
- STEP_HIT_CEILING
- STEP_HIT_LAVA
- STEP_HIT_WALL
- STEP_IN_AIR
- STEP_NO_GRAVITY
- STEP_ON_GROUND
- STEP_SNAP_TO_FLOOR
- STEP_TYPE_AIR
- STEP_TYPE_GROUND
- STEP_TYPE_HANG
Expand Down
23 changes: 23 additions & 0 deletions docs/lua/functions-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8321,6 +8321,29 @@
<br />


## [check_ledge_grab](#check_ledge_grab)

### Lua Example
`local integerValue = check_ledge_grab(m, wall, intendedPos, nextPos)`

### Parameters
| Field | Type |
| ----- | ---- |
| m | [MarioState](structs.md#MarioState) |
| wall | [Surface](structs.md#Surface) |
| intendedPos | [Vec3f](structs.md#Vec3f) |
| nextPos | [Vec3f](structs.md#Vec3f) |

### Returns
- `integer`

### C Prototype
`u32 check_ledge_grab(struct MarioState *m, struct Surface *wall, Vec3f intendedPos, Vec3f nextPos);`

[:arrow_up_small:](#)

<br />

## [get_additive_y_vel_for_jumps](#get_additive_y_vel_for_jumps)

### Lua Example
Expand Down
1 change: 1 addition & 0 deletions docs/lua/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@
<br />

- mario_step.h
- [check_ledge_grab](functions-3.md#check_ledge_grab)
- [get_additive_y_vel_for_jumps](functions-3.md#get_additive_y_vel_for_jumps)
- [init_bully_collision_data](functions-3.md#init_bully_collision_data)
- [mario_bonk_reflection](functions-3.md#mario_bonk_reflection)
Expand Down
1 change: 1 addition & 0 deletions docs/lua/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
| KoopaBobAgility | `number` | |
| KoopaCatchupAgility | `number` | |
| KoopaThiAgility | `number` | |
| MarioRaycastSteps | `integer` | |
| MipsStar1Requirement | `integer` | |
| MipsStar2Requirement | `integer` | |
| MultipleCapCollection | `integer` | |
Expand Down
57 changes: 36 additions & 21 deletions include/sm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,42 @@
#define INPUT_Z_DOWN 0x4000
#define INPUT_Z_PRESSED 0x8000

#define GROUND_STEP_LEFT_GROUND 0
#define GROUND_STEP_NONE 1
#define GROUND_STEP_HIT_WALL 2
#define GROUND_STEP_HIT_WALL_STOP_QSTEPS 2
#define GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS 3

#define AIR_STEP_CHECK_LEDGE_GRAB 0x00000001
#define AIR_STEP_CHECK_HANG 0x00000002

#define AIR_STEP_NONE 0
#define AIR_STEP_LANDED 1
#define AIR_STEP_HIT_WALL 2
#define AIR_STEP_GRABBED_LEDGE 3
#define AIR_STEP_GRABBED_CEILING 4
#define AIR_STEP_HIT_LAVA_WALL 6

#define WATER_STEP_NONE 0
#define WATER_STEP_HIT_FLOOR 1
#define WATER_STEP_HIT_CEILING 2
#define WATER_STEP_CANCELLED 3
#define WATER_STEP_HIT_WALL 4
#define STEP_IN_AIR 0
#define STEP_ON_GROUND 1
#define STEP_HIT_WALL 2
#define STEP_HIT_WALL_CONTINUE 3
#define STEP_HIT_CEILING 3
#define STEP_GRAB_LEDGE 5
#define STEP_GRAB_CEILING 6
#define STEP_HIT_LAVA 7
#define STEP_CANCEL 8

#define STEP_CHECK_LEDGE_GRAB 0x00000001
#define STEP_CHECK_HANG 0x00000002
#define STEP_NO_GRAVITY 0x00000004
#define STEP_SNAP_TO_FLOOR 0x00000008

#define GROUND_STEP_LEFT_GROUND STEP_IN_AIR
#define GROUND_STEP_NONE STEP_ON_GROUND
#define GROUND_STEP_HIT_WALL STEP_HIT_WALL
#define GROUND_STEP_HIT_WALL_STOP_QSTEPS STEP_HIT_CEILING
#define GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS STEP_HIT_WALL_CONTINUE

#define AIR_STEP_CHECK_LEDGE_GRAB STEP_CHECK_LEDGE_GRAB
#define AIR_STEP_CHECK_HANG STEP_CHECK_HANG

#define AIR_STEP_NONE STEP_IN_AIR
#define AIR_STEP_LANDED STEP_ON_GROUND
#define AIR_STEP_HIT_WALL STEP_HIT_WALL
#define AIR_STEP_GRABBED_LEDGE STEP_GRAB_LEDGE
#define AIR_STEP_GRABBED_CEILING STEP_GRAB_CEILING
#define AIR_STEP_HIT_LAVA_WALL STEP_HIT_LAVA

#define WATER_STEP_NONE STEP_IN_AIR
#define WATER_STEP_HIT_FLOOR STEP_ON_GROUND
#define WATER_STEP_HIT_CEILING STEP_HIT_CEILING
#define WATER_STEP_CANCELLED STEP_CANCEL
#define WATER_STEP_HIT_WALL STEP_HIT_WALL

#define STEP_TYPE_GROUND 1
#define STEP_TYPE_AIR 2
Expand Down
7 changes: 7 additions & 0 deletions src/engine/math_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

#include "types.h"

/**
* Converts an angle in degrees to sm64's s16 angle units. For example, DEGREES(90) == 0x4000
* This should be used mainly to make camera code clearer at first glance.
*/
// #define DEGREES(x) ((x) * 0x10000 / 360)
#define DEGREES(x) ((x) * 0x2000 / 45)

/*
* The sine and cosine tables overlap, but "#define gCosineTable (gSineTable +
* 0x400)" doesn't give expected codegen; gSineTable and gCosineTable need to
Expand Down
Loading