diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index b478326b..277ab463 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3760,6 +3760,14 @@ function get_door_save_file_flag(door) -- ... end +--- @param m MarioState +--- @param interactType integer +--- @param o Object +--- @return integer +function interact_damage(m, interactType, o) + -- ... +end + --- @param m MarioState --- @param capSpeed number --- @return nil @@ -3837,6 +3845,13 @@ function passes_pvp_interaction_checks(attacker, victim) -- ... end +--- @param m MarioState +--- @param o Object +--- @return integer +function take_damage_and_knock_back(m, o) + -- ... +end + --- @param courseNum integer --- @param levelNum integer --- @param areaIndex integer diff --git a/docs/lua/functions.md b/docs/lua/functions.md index dadf234d..3794259e 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -732,6 +732,7 @@ - interaction.h - [does_mario_have_normal_cap_on_head](#does_mario_have_normal_cap_on_head) - [get_door_save_file_flag](#get_door_save_file_flag) + - [interact_damage](#interact_damage) - [mario_blow_off_cap](#mario_blow_off_cap) - [mario_check_object_grab](#mario_check_object_grab) - [mario_drop_held_object](#mario_drop_held_object) @@ -744,6 +745,7 @@ - [mario_stop_riding_object](#mario_stop_riding_object) - [mario_throw_held_object](#mario_throw_held_object) - [passes_pvp_interaction_checks](#passes_pvp_interaction_checks) + - [take_damage_and_knock_back](#take_damage_and_knock_back)
@@ -14407,6 +14409,28 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [interact_damage](#interact_damage) + +### Lua Example +`local integerValue = interact_damage(m, interactType, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| interactType | `integer` | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u32 interact_damage(struct MarioState *m, UNUSED u32 interactType, struct Object *o);` + +[:arrow_up_small:](#) + +
+ ## [mario_blow_off_cap](#mario_blow_off_cap) ### Lua Example @@ -14652,6 +14676,27 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
+## [take_damage_and_knock_back](#take_damage_and_knock_back) + +### Lua Example +`local integerValue = take_damage_and_knock_back(m, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o);` + +[:arrow_up_small:](#) + +
+ --- # functions from level_info.h diff --git a/src/game/interaction.c b/src/game/interaction.c index 75aad960..c02ad828 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2160,10 +2160,14 @@ void mario_process_interactions(struct MarioState *m) { sDelayInvincTimer = FALSE; sInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0; - if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0 && is_player_active(m) && m->playerIndex == 0) { + if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0 && is_player_active(m)) { s32 i; for (i = 0; i < 32; i++) { u32 interactType = sInteractionHandlers[i].interactType; + if (m->playerIndex != 0 && interactType != (u32)INTERACT_PLAYER) { + // skip interactions for remote + continue; + } if (m->collidedObjInteractTypes & interactType) { struct Object *object = mario_get_collided_object(m, interactType); diff --git a/src/game/interaction.h b/src/game/interaction.h index 58d53556..6ab63441 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -116,5 +116,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 take_damage_and_knock_back(struct MarioState *m, struct Object *o); +u32 interact_damage(struct MarioState *m, UNUSED u32 interactType, struct Object *o); #endif // INTERACTION_H diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index c060f316..a4d246d9 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -7693,6 +7693,21 @@ int smlua_func_get_door_save_file_flag(lua_State* L) { return 1; } +int smlua_func_interact_damage(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 3)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + u32 interactType = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 3, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, interact_damage(m, interactType, o)); + + return 1; +} + int smlua_func_mario_blow_off_cap(lua_State* L) { if(!smlua_functions_valid_param_count(L, 2)) { return 0; } @@ -7835,6 +7850,19 @@ int smlua_func_passes_pvp_interaction_checks(lua_State* L) { return 1; } +int smlua_func_take_damage_and_knock_back(lua_State* L) { + if(!smlua_functions_valid_param_count(L, 2)) { return 0; } + + struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE); + if (!gSmLuaConvertSuccess) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { return 0; } + + lua_pushinteger(L, take_damage_and_knock_back(m, o)); + + return 1; +} + ////////////////// // level_info.h // ////////////////// @@ -16492,6 +16520,7 @@ void smlua_bind_functions_autogen(void) { // interaction.h smlua_bind_function(L, "does_mario_have_normal_cap_on_head", smlua_func_does_mario_have_normal_cap_on_head); smlua_bind_function(L, "get_door_save_file_flag", smlua_func_get_door_save_file_flag); + smlua_bind_function(L, "interact_damage", smlua_func_interact_damage); smlua_bind_function(L, "mario_blow_off_cap", smlua_func_mario_blow_off_cap); smlua_bind_function(L, "mario_check_object_grab", smlua_func_mario_check_object_grab); smlua_bind_function(L, "mario_drop_held_object", smlua_func_mario_drop_held_object); @@ -16504,6 +16533,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, "take_damage_and_knock_back", smlua_func_take_damage_and_knock_back); // level_info.h smlua_bind_function(L, "get_level_name", smlua_func_get_level_name);