From 1bde63d3d8a4a6094f0ed7eab61a963afb513ade Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Sun, 30 Jun 2024 20:15:12 -0400 Subject: [PATCH] Expose should_push_or_pull_door() --- autogen/lua_definitions/functions.lua | 7 +++++++ docs/lua/functions-3.md | 21 +++++++++++++++++++++ docs/lua/functions.md | 1 + src/game/interaction.h | 1 + src/pc/lua/smlua_functions_autogen.c | 20 ++++++++++++++++++++ 5 files changed, 50 insertions(+) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index e3cc6d98..0b0d8fb2 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3797,6 +3797,13 @@ function passes_pvp_interaction_checks(attacker, victim) -- ... end +--- @param m MarioState +--- @param o Object +--- @return integer +function should_push_or_pull_door(m, o) + -- ... +end + --- @param m MarioState --- @param o Object --- @return integer diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 5ec6be4e..4771eb4b 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -4581,6 +4581,27 @@
+## [should_push_or_pull_door](#should_push_or_pull_door) + +### Lua Example +`local integerValue = should_push_or_pull_door(m, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u32 should_push_or_pull_door(struct MarioState *m, struct Object *o);` + +[:arrow_up_small:](#) + +
+ ## [take_damage_and_knock_back](#take_damage_and_knock_back) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 6fbb529f..332c87b6 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -884,6 +884,7 @@ - [mario_stop_riding_object](functions-3.md#mario_stop_riding_object) - [mario_throw_held_object](functions-3.md#mario_throw_held_object) - [passes_pvp_interaction_checks](functions-3.md#passes_pvp_interaction_checks) + - [should_push_or_pull_door](functions-3.md#should_push_or_pull_door) - [take_damage_and_knock_back](functions-3.md#take_damage_and_knock_back)
diff --git a/src/game/interaction.h b/src/game/interaction.h index 7fcfcda2..5485fcf5 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -168,6 +168,7 @@ u32 get_door_save_file_flag(struct Object *door); void mario_process_interactions(struct MarioState *m); void mario_handle_special_floors(struct MarioState *m); u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim); +u32 should_push_or_pull_door(struct MarioState *m, struct Object *o); u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o); u32 determine_interaction(struct MarioState *m, struct Object *o); u32 process_interaction(struct MarioState *m, u32 interactType, struct Object *o, u32 (*interact_function)(struct MarioState *, u32 interactType, struct Object *)); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 5bc0cfe5..6c8ad2f9 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -14484,6 +14484,25 @@ int smlua_func_passes_pvp_interaction_checks(lua_State* L) { return 1; } +int smlua_func_should_push_or_pull_door(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "should_push_or_pull_door", 2, top); + return 0; + } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "should_push_or_pull_door"); return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "should_push_or_pull_door"); return 0; } + + lua_pushinteger(L, should_push_or_pull_door(m, o)); + + return 1; +} + int smlua_func_take_damage_and_knock_back(lua_State* L) { if (L == NULL) { return 0; } @@ -33703,6 +33722,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "mario_stop_riding_object", smlua_func_mario_stop_riding_object); smlua_bind_function(L, "mario_throw_held_object", smlua_func_mario_throw_held_object); smlua_bind_function(L, "passes_pvp_interaction_checks", smlua_func_passes_pvp_interaction_checks); + smlua_bind_function(L, "should_push_or_pull_door", smlua_func_should_push_or_pull_door); smlua_bind_function(L, "take_damage_and_knock_back", smlua_func_take_damage_and_knock_back); // lag_compensation.h