From ff17fa4a67b9e8fdd7e3286321129ac55af2d02b Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Sun, 12 Nov 2023 19:28:38 +0100 Subject: [PATCH] Add ON_COLLIDE_LEVEL_BOUNDS hook Called whenever Mario hits the level boundaries "wall" --- autogen/lua_definitions/constants.lua | 5 ++++- docs/lua/constants.md | 3 ++- src/game/mario_step.c | 4 ++++ src/pc/lua/smlua_constants_autogen.c | 3 ++- src/pc/lua/smlua_hooks.h | 2 ++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 184e350a..36e3742f 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -9066,7 +9066,10 @@ HOOK_DIALOG_SOUND = 35 HOOK_ON_HUD_RENDER_BEHIND = 36 --- @type LuaHookedEventType -HOOK_MAX = 37 +HOOK_ON_COLLIDE_LEVEL_BOUNDS = 37 + +--- @type LuaHookedEventType +HOOK_MAX = 38 --- @class HudDisplayFlags diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 1e19b11c..c8bbd972 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -3236,7 +3236,8 @@ | HOOK_ON_EXIT | 34 | | HOOK_DIALOG_SOUND | 35 | | HOOK_ON_HUD_RENDER_BEHIND | 36 | -| HOOK_MAX | 37 | +| HOOK_ON_COLLIDE_LEVEL_BOUNDS | 37 | +| HOOK_MAX | 38 | [:arrow_up_small:](#) diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 8a491157..e6bd675f 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -294,6 +294,8 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) { mario_update_wall(m, &upperWcd); if (floor == NULL) { + //HOOK_ON_COLLIDE_LEVEL_BOUNDS, coopdx + smlua_call_event_hooks_mario_param(HOOK_ON_COLLIDE_LEVEL_BOUNDS, m); return GROUND_STEP_HIT_WALL_STOP_QSTEPS; } @@ -468,6 +470,8 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr } m->pos[1] = nextPos[1]; + //HOOK_ON_COLLIDE_LEVEL_BOUNDS, coopdx + smlua_call_event_hooks_mario_param(HOOK_ON_COLLIDE_LEVEL_BOUNDS, m); return AIR_STEP_HIT_WALL; } diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 1ca65dca..fb82b08a 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -3214,7 +3214,8 @@ char gSmluaConstants[] = "" "HOOK_ON_EXIT = 34\n" "HOOK_DIALOG_SOUND = 35\n" "HOOK_ON_HUD_RENDER_BEHIND = 36\n" -"HOOK_MAX = 37\n" +"HOOK_ON_COLLIDE_LEVEL_BOUNDS = 37\n" +"HOOK_MAX = 38\n" "ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_MAX = 2\n" diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index 8d74a463..4700d018 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -48,6 +48,7 @@ enum LuaHookedEventType { HOOK_ON_EXIT, HOOK_DIALOG_SOUND, HOOK_ON_HUD_RENDER_BEHIND, + HOOK_ON_COLLIDE_LEVEL_BOUNDS, HOOK_MAX, }; @@ -89,6 +90,7 @@ static const char* LuaHookedEventTypeName[] = { "HOOK_ON_EXIT", "HOOK_DIALOG_SOUND", "HOOK_ON_HUD_RENDER_BEHIND", + "HOOK_ON_COLLIDE_LEVEL_BOUNDS", "HOOK_MAX" };