added HOOK_ON_INTERACTIONS

this is called after mario's interactions are processed
This commit is contained in:
Isaac0-dev 2025-02-11 17:58:57 +10:00
parent 2526109484
commit 9a13c298ad
10 changed files with 58 additions and 47 deletions

View file

@ -9187,7 +9187,10 @@ HOOK_ON_GEO_PROCESS_CHILDREN = 50
HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS = 51
--- @type LuaHookedEventType
HOOK_MAX = 52
HOOK_ON_INTERACTIONS = 52
--- @type LuaHookedEventType
HOOK_MAX = 53
--- @class LuaModMenuElementType

View file

@ -4214,11 +4214,6 @@ function set_first_person_enabled(enable)
-- ...
end
--- @param state integer
function set_dialog_box_state(state)
-- ...
end
--- @param dialog integer
function create_dialog_box(dialog)
-- ...
@ -4252,6 +4247,11 @@ function reset_dialog_render_state()
-- ...
end
--- @param state integer
function set_dialog_box_state(state)
-- ...
end
--- @param bgR integer
--- @param bgG integer
--- @param bgB integer

View file

@ -3349,7 +3349,8 @@
| HOOK_BEFORE_GEO_PROCESS | 49 |
| HOOK_ON_GEO_PROCESS_CHILDREN | 50 |
| HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS | 51 |
| HOOK_MAX | 52 |
| HOOK_ON_INTERACTIONS | 52 |
| HOOK_MAX | 53 |
### [enum LuaModMenuElementType](#LuaModMenuElementType)
| Identifier | Value |

View file

@ -4356,26 +4356,6 @@ Sets if first person is enabled
<br />
## [set_dialog_box_state](#set_dialog_box_state)
### Lua Example
`set_dialog_box_state(state)`
### Parameters
| Field | Type |
| ----- | ---- |
| state | `integer` |
### Returns
- None
### C Prototype
`void set_dialog_box_state(u8 state);`
[:arrow_up_small:](#)
<br />
## [create_dialog_box](#create_dialog_box)
### Lua Example
@ -4511,6 +4491,26 @@ Sets if first person is enabled
<br />
## [set_dialog_box_state](#set_dialog_box_state)
### Lua Example
`set_dialog_box_state(state)`
### Parameters
| Field | Type |
| ----- | ---- |
| state | `integer` |
### Returns
- None
### C Prototype
`void set_dialog_box_state(u8 state);`
[:arrow_up_small:](#)
<br />
## [set_dialog_override_color](#set_dialog_override_color)
### Lua Example

View file

@ -842,7 +842,6 @@
<br />
- ingame_menu.h
- [set_dialog_box_state](functions-3.md#set_dialog_box_state)
- [create_dialog_box](functions-3.md#create_dialog_box)
- [create_dialog_box_with_response](functions-3.md#create_dialog_box_with_response)
- [create_dialog_box_with_var](functions-3.md#create_dialog_box_with_var)
@ -850,6 +849,7 @@
- [reset_dialog_override_color](functions-3.md#reset_dialog_override_color)
- [reset_dialog_override_pos](functions-3.md#reset_dialog_override_pos)
- [reset_dialog_render_state](functions-3.md#reset_dialog_render_state)
- [set_dialog_box_state](functions-3.md#set_dialog_box_state)
- [set_dialog_override_color](functions-3.md#set_dialog_override_color)
- [set_dialog_override_pos](functions-3.md#set_dialog_override_pos)
- [set_menu_mode](functions-3.md#set_menu_mode)

View file

@ -142,6 +142,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
| HOOK_ON_GEO_PROCESS | Called when a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_BEFORE_GEO_PROCESS | Called before a GeoLayout is processed **Note:** You must set the `hookProcess` field of the graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_ON_GEO_PROCESS_CHILDREN | Called when the children of a GeoLayout node is processed **Note:** You must set the `hookProcess` field of the parent graph node to a non-zero value | [GraphNode](../structs.md#GraphNode) graphNode, `integer` matStackIndex |
| HOOK_ON_INTERACTIONS | Called when the Mario interactions are processed | [MarioState](../structs.md#MarioState) mario |
### Parameters

View file

@ -2349,6 +2349,8 @@ void mario_process_interactions(struct MarioState *m) {
m->invincTimer -= 1;
}
smlua_call_event_hooks_mario_param(HOOK_ON_INTERACTIONS, m);
//! If the kick/punch flags are set and an object collision changes Mario's
// action, he will get the kick/punch wall speed anyway.
check_kick_or_punch_wall(m);

View file

@ -3211,7 +3211,8 @@ char gSmluaConstants[] = ""
"HOOK_BEFORE_GEO_PROCESS = 49\n"
"HOOK_ON_GEO_PROCESS_CHILDREN = 50\n"
"HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS = 51\n"
"HOOK_MAX = 52\n"
"HOOK_ON_INTERACTIONS = 52\n"
"HOOK_MAX = 53\n"
"ACTION_HOOK_EVERY_FRAME = 0\n"
"ACTION_HOOK_GRAVITY = 1\n"
"ACTION_HOOK_MAX = 2\n"

View file

@ -13388,23 +13388,6 @@ int smlua_func_set_first_person_enabled(lua_State* L) {
// ingame_menu.h //
///////////////////
int smlua_func_set_dialog_box_state(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_dialog_box_state", 1, top);
return 0;
}
u8 state = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_dialog_box_state"); return 0; }
set_dialog_box_state(state);
return 1;
}
int smlua_func_create_dialog_box(lua_State* L) {
if (L == NULL) { return 0; }
@ -13520,6 +13503,23 @@ int smlua_func_reset_dialog_render_state(UNUSED lua_State* L) {
return 1;
}
int smlua_func_set_dialog_box_state(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 1) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_dialog_box_state", 1, top);
return 0;
}
u8 state = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_dialog_box_state"); return 0; }
set_dialog_box_state(state);
return 1;
}
int smlua_func_set_dialog_override_color(lua_State* L) {
if (L == NULL) { return 0; }
@ -32822,7 +32822,6 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "set_first_person_enabled", smlua_func_set_first_person_enabled);
// ingame_menu.h
smlua_bind_function(L, "set_dialog_box_state", smlua_func_set_dialog_box_state);
smlua_bind_function(L, "create_dialog_box", smlua_func_create_dialog_box);
smlua_bind_function(L, "create_dialog_box_with_response", smlua_func_create_dialog_box_with_response);
smlua_bind_function(L, "create_dialog_box_with_var", smlua_func_create_dialog_box_with_var);
@ -32830,6 +32829,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "reset_dialog_override_color", smlua_func_reset_dialog_override_color);
smlua_bind_function(L, "reset_dialog_override_pos", smlua_func_reset_dialog_override_pos);
smlua_bind_function(L, "reset_dialog_render_state", smlua_func_reset_dialog_render_state);
smlua_bind_function(L, "set_dialog_box_state", smlua_func_set_dialog_box_state);
smlua_bind_function(L, "set_dialog_override_color", smlua_func_set_dialog_override_color);
smlua_bind_function(L, "set_dialog_override_pos", smlua_func_set_dialog_override_pos);
smlua_bind_function(L, "set_menu_mode", smlua_func_set_menu_mode);

View file

@ -10,6 +10,7 @@
// forward declare
struct Camera;
// ! Hooks must be added at the end
enum LuaHookedEventType {
HOOK_UPDATE,
HOOK_MARIO_UPDATE,
@ -63,6 +64,7 @@ enum LuaHookedEventType {
HOOK_BEFORE_GEO_PROCESS,
HOOK_ON_GEO_PROCESS_CHILDREN,
HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS,
HOOK_ON_INTERACTIONS,
HOOK_MAX,
};
@ -119,6 +121,7 @@ static const char* LuaHookedEventTypeName[] = {
"HOOK_BEFORE_GEO_PROCESS",
"HOOK_ON_GEO_PROCESS_CHILDREN",
"HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS",
"HOOK_ON_INTERACTIONS",
"HOOK_MAX"
};