diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 94b73498..f5ae7037 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3707,6 +3707,9 @@ INT_TWIRL = (1 << 8) --- @type InteractionFlag INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL) +--- @type InteractionFlag +INT_LUA = (1 << 31) + --- @class InteractionType --- @type InteractionType diff --git a/docs/lua/constants.md b/docs/lua/constants.md index ff544ae3..683e6a3b 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1309,6 +1309,7 @@ | INT_HIT_FROM_BELOW | (1 << 7) | | INT_TWIRL | (1 << 8) | | INT_GROUND_POUND_OR_TWIRL | (INT_GROUND_POUND | INT_TWIRL) | +| INT_LUA | (1 << 31) | ### [enum InteractionType](#InteractionType) | Identifier | Value | diff --git a/src/game/interaction.c b/src/game/interaction.c index 3f760335..b6f34487 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -158,7 +158,8 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) { if (interaction == 0 && action & ACT_FLAG_ATTACKING) { u32 flags = (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING); - if (m->flags & flags) { + if ((action == ACT_PUNCHING || action == ACT_MOVE_PUNCHING || action == ACT_JUMP_KICK) || + (m->flags & flags && interaction & INT_LUA)) { s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; if (m->flags & MARIO_PUNCHING) { @@ -236,6 +237,7 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) { u32 attack_object(struct MarioState* m, struct Object *o, s32 interaction) { if (!o) { return 0; } u32 attackType = 0; + interaction &= ~INT_LUA; switch (interaction) { case INT_GROUND_POUND: @@ -1868,7 +1870,7 @@ u32 interact_breakable(struct MarioState *m, UNUSED u32 interactType, struct Obj m->interactObj = o; - switch (interaction) { + switch (interaction & ~INT_LUA) { case INT_HIT_FROM_ABOVE: bounce_off_object(m, o, 30.0f); //! Not in the 0x8F mask break; @@ -1900,7 +1902,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O if (!(m->action & ACT_FLAG_RIDING_SHELL)) { u32 interaction = determine_interaction(m, o); - if (interaction == INT_HIT_FROM_ABOVE || m->action == ACT_WALKING + if (interaction & INT_HIT_FROM_ABOVE || m->action == ACT_WALKING || m->action == ACT_HOLD_WALKING) { m->interactObj = o; m->usedObj = o; diff --git a/src/game/interaction.h b/src/game/interaction.h index 9f5526c2..045937a8 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -53,6 +53,7 @@ enum InteractionFlag { INT_HIT_FROM_BELOW = /* 0x00000080 */ (1 << 7), INT_TWIRL = /* 0x00000100 */ (1 << 8), INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL), + INT_LUA = /* 0x10000000 */ (1 << 31) , }; #define INT_ATTACK_NOT_FROM_BELOW (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE) diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 5f2f8453..6db7b604 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2635,7 +2635,8 @@ s32 cur_obj_is_mario_ground_pounding_platform(void) { if (!is_player_active(&gMarioStates[i])) { continue; } if (!gMarioStates[i].marioObj) { continue; } if (gMarioStates[i].marioObj->platform == o) { - if ((determine_interaction(&gMarioStates[i], o) & INT_GROUND_POUND) || (gMarioStates[i].action == ACT_GROUND_POUND_LAND)) { + u32 interaction = determine_interaction(&gMarioStates[i], o); + if ((gMarioStates[i].action == ACT_GROUND_POUND_LAND) || (interaction & INT_GROUND_POUND && interaction & INT_LUA)) { return TRUE; } } diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index e52b244d..f80a2607 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1419,6 +1419,7 @@ char gSmluaConstants[] = "" "INT_HIT_FROM_BELOW = (1 << 7)\n" "INT_TWIRL = (1 << 8)\n" "INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL)\n" +"INT_LUA = (1 << 31)\n" "INT_ATTACK_NOT_FROM_BELOW = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE)\n" "INT_ANY_ATTACK = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL | INT_HIT_FROM_ABOVE | INT_HIT_FROM_BELOW)\n" "INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW)\n" diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index f7c086ee..7725b78b 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -1217,6 +1217,7 @@ int smlua_hook_mario_action(lua_State* L) { lua_Integer interactionType = 0; if (paramCount >= 3) { interactionType = smlua_to_integer(L, 3); + interactionType |= (1 << 31); /* INT_LUA */ if (!gSmLuaConvertSuccess) { LOG_LUA_LINE("Hook Action: tried to hook invalid interactionType: %lld, %u", interactionType, gSmLuaConvertSuccess); return 0;