From 3ab4c944ac376f0688df988c2e20649dce78042f Mon Sep 17 00:00:00 2001 From: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com> Date: Tue, 9 May 2023 21:38:29 +0200 Subject: [PATCH] better kick/punch/trip, gp and flying detection (#388) --- autogen/lua_definitions/constants.lua | 85 +++++++++++++++------------ autogen/lua_definitions/functions.lua | 7 +++ docs/lua/constants.md | 37 ++++++------ docs/lua/functions-3.md | 21 +++++++ docs/lua/functions.md | 1 + include/sm64.h | 1 + src/game/behaviors/blue_coin.inc.c | 2 +- src/game/behaviors/thi_top.inc.c | 2 +- src/game/bettercamera.inc.h | 4 +- src/game/interaction.c | 49 ++++++--------- src/game/interaction.h | 19 ++++++ src/game/object_helpers.c | 2 +- src/pc/lua/smlua_constants_autogen.c | 27 +++++---- src/pc/lua/smlua_functions_autogen.c | 20 +++++++ 14 files changed, 175 insertions(+), 102 deletions(-) diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 968e20a1..cf4617af 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -3461,44 +3461,6 @@ GRAPH_RENDER_PLAYER = (1 << 7) --- @type integer GRAPH_RENDER_Z_BUFFER = (1 << 3) ---- @type integer -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) - ---- @type integer -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) - ---- @type integer -INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW) - ---- @type integer -INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL) - ---- @class InteractionFlag - ---- @type InteractionFlag -INT_GROUND_POUND_OR_TWIRL = (1 << 0) - ---- @type InteractionFlag -INT_PUNCH = (1 << 1) - ---- @type InteractionFlag -INT_KICK = (1 << 2) - ---- @type InteractionFlag -INT_TRIP = (1 << 3) - ---- @type InteractionFlag -INT_SLIDE_KICK = (1 << 4) - ---- @type InteractionFlag -INT_FAST_ATTACK_OR_SHELL = (1 << 5) - ---- @type InteractionFlag -INT_HIT_FROM_ABOVE = (1 << 6) - ---- @type InteractionFlag -INT_HIT_FROM_BELOW = (1 << 7) - --- @type integer ATTACK_FAST_ATTACK = 5 @@ -3517,6 +3479,18 @@ ATTACK_KICK_OR_TRIP = 2 --- @type integer ATTACK_PUNCH = 1 +--- @type integer +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) + +--- @type integer +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) + +--- @type integer +INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW) + +--- @type integer +INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL) + --- @type integer INT_STATUS_ATTACKED_MARIO = (1 << 13) @@ -3613,6 +3587,38 @@ INT_SUBTYPE_STAR_DOOR = 0x00000020 --- @type integer INT_SUBTYPE_TWIRL_BOUNCE = 0x00000080 +--- @class InteractionFlag + +--- @type InteractionFlag +INT_GROUND_POUND = (1 << 0) + +--- @type InteractionFlag +INT_PUNCH = (1 << 1) + +--- @type InteractionFlag +INT_KICK = (1 << 2) + +--- @type InteractionFlag +INT_TRIP = (1 << 3) + +--- @type InteractionFlag +INT_SLIDE_KICK = (1 << 4) + +--- @type InteractionFlag +INT_FAST_ATTACK_OR_SHELL = (1 << 5) + +--- @type InteractionFlag +INT_HIT_FROM_ABOVE = (1 << 6) + +--- @type InteractionFlag +INT_HIT_FROM_BELOW = (1 << 7) + +--- @type InteractionFlag +INT_TWIRL = (1 << 8) + +--- @type InteractionFlag +INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL) + --- @class InteractionType --- @type InteractionType @@ -7286,6 +7292,9 @@ ACT_FLAG_CUSTOM_ACTION = (1 << 30) --- @type integer ACT_FLAG_DIVING = (1 << 19) +--- @type integer +ACT_FLAG_FLYING = (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING) + --- @type integer ACT_FLAG_HANGING = (1 << 21) diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index dd0d6c4e..a89049eb 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3931,6 +3931,13 @@ function stop_sounds_in_continuous_banks() -- ... end +--- @param m MarioState +--- @param o Object +--- @return integer +function determine_interaction(m, o) + -- ... +end + --- @param m MarioState --- @return integer function does_mario_have_normal_cap_on_head(m) diff --git a/docs/lua/constants.md b/docs/lua/constants.md index a323ca2b..86f0ecc1 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -19,8 +19,8 @@ - [geo_commands.h](#geo_commandsh) - [graph_node.h](#graph_nodeh) - [interaction.c](#interactionc) - - [enum InteractionFlag](#enum-InteractionFlag) - [interaction.h](#interactionh) + - [enum InteractionFlag](#enum-InteractionFlag) - [enum InteractionType](#enum-InteractionType) - [level_commands.h](#level_commandsh) - [level_defines.h](#level_definesh) @@ -1193,22 +1193,6 @@
## [interaction.c](#interaction.c) -- INT_ANY_ATTACK -- INT_ATTACK_NOT_FROM_BELOW -- INT_ATTACK_NOT_WEAK_FROM_ABOVE -- INT_ATTACK_SLIDE - -### [enum InteractionFlag](#InteractionFlag) -| Identifier | Value | -| :--------- | :---- | -| INT_GROUND_POUND_OR_TWIRL | (1 << 0) | -| INT_PUNCH | (1 << 1) | -| INT_KICK | (1 << 2) | -| INT_TRIP | (1 << 3) | -| INT_SLIDE_KICK | (1 << 4) | -| INT_FAST_ATTACK_OR_SHELL | (1 << 5) | -| INT_HIT_FROM_ABOVE | (1 << 6) | -| INT_HIT_FROM_BELOW | (1 << 7) | [:arrow_up_small:](#) @@ -1221,6 +1205,10 @@ - ATTACK_GROUND_POUND_OR_TWIRL - ATTACK_KICK_OR_TRIP - ATTACK_PUNCH +- INT_ANY_ATTACK +- INT_ATTACK_NOT_FROM_BELOW +- INT_ATTACK_NOT_WEAK_FROM_ABOVE +- INT_ATTACK_SLIDE - INT_STATUS_ATTACKED_MARIO - INT_STATUS_ATTACK_MASK - INT_STATUS_GRABBED_MARIO @@ -1254,6 +1242,20 @@ - INT_SUBTYPE_STAR_DOOR - INT_SUBTYPE_TWIRL_BOUNCE +### [enum InteractionFlag](#InteractionFlag) +| Identifier | Value | +| :--------- | :---- | +| INT_GROUND_POUND | (1 << 0) | +| INT_PUNCH | (1 << 1) | +| INT_KICK | (1 << 2) | +| INT_TRIP | (1 << 3) | +| INT_SLIDE_KICK | (1 << 4) | +| INT_FAST_ATTACK_OR_SHELL | (1 << 5) | +| INT_HIT_FROM_ABOVE | (1 << 6) | +| INT_HIT_FROM_BELOW | (1 << 7) | +| INT_TWIRL | (1 << 8) | +| INT_GROUND_POUND_OR_TWIRL | (INT_GROUND_POUND | INT_TWIRL) | + ### [enum InteractionType](#InteractionType) | Identifier | Value | | :--------- | :---- | @@ -2614,6 +2616,7 @@ - ACT_FLAG_CONTROL_JUMP_HEIGHT - ACT_FLAG_CUSTOM_ACTION - ACT_FLAG_DIVING +- ACT_FLAG_FLYING - ACT_FLAG_HANGING - ACT_FLAG_IDLE - ACT_FLAG_INTANGIBLE diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index d0c228c5..e9cc9a5f 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -3037,6 +3037,27 @@
+## [determine_interaction](#determine_interaction) + +### Lua Example +`local integerValue = determine_interaction(m, o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| o | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u32 determine_interaction(struct MarioState *m, struct Object *o);` + +[:arrow_up_small:](#) + +
+ ## [does_mario_have_normal_cap_on_head](#does_mario_have_normal_cap_on_head) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index bddc69a4..fe4e7c93 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -776,6 +776,7 @@
- interaction.h + - [determine_interaction](functions-3.md#determine_interaction) - [does_mario_have_normal_cap_on_head](functions-3.md#does_mario_have_normal_cap_on_head) - [get_door_save_file_flag](functions-3.md#get_door_save_file_flag) - [interact_damage](functions-3.md#interact_damage) diff --git a/include/sm64.h b/include/sm64.h index e31e3eda..ea034896 100644 --- a/include/sm64.h +++ b/include/sm64.h @@ -169,6 +169,7 @@ #define ACT_FLAG_WATER_OR_TEXT /* 0x20000000 */ (1 << 29) #define ACT_FLAG_CUSTOM_ACTION /* 0x40000000 */ (1 << 30) #define ACT_FLAG_THROWING /* 0x80000000 */ (1 << 31) +#define ACT_FLAG_FLYING (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING) #define ACT_UNINITIALIZED 0x00000000 // (0x000) diff --git a/src/game/behaviors/blue_coin.inc.c b/src/game/behaviors/blue_coin.inc.c index 93f9ddd4..4479e132 100644 --- a/src/game/behaviors/blue_coin.inc.c +++ b/src/game/behaviors/blue_coin.inc.c @@ -136,7 +136,7 @@ void bhv_blue_coin_switch_loop(void) { // If Mario is on the switch and has ground-pounded, // recede and get ready to start ticking. if (gMarioObject->platform == o) { - if (gMarioStates[0].action == ACT_GROUND_POUND_LAND) { + if (determine_interaction(&gMarioStates[0], o) & INT_GROUND_POUND) { // Set to BLUE_COIN_SWITCH_ACT_RECEDING o->oAction++; diff --git a/src/game/behaviors/thi_top.inc.c b/src/game/behaviors/thi_top.inc.c index 7ada56f9..e59164ff 100644 --- a/src/game/behaviors/thi_top.inc.c +++ b/src/game/behaviors/thi_top.inc.c @@ -31,7 +31,7 @@ void bhv_thi_tiny_island_top_loop(void) { if (!(gTHIWaterDrained & 1)) { if (o->oAction == 0) { if (distanceToPlayer < 500.0f) - if (marioState && marioState->action == ACT_GROUND_POUND_LAND) { + if (marioState && !(marioState->action & ACT_FLAG_AIR) && (determine_interaction(marioState, o) & INT_GROUND_POUND) != 0) { o->oAction++; cur_obj_spawn_particles(&D_8032F134); spawn_triangle_break_particles(20, 138, 0.3f, 3); diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 76c655ed..fbc990fd 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -463,8 +463,8 @@ static void newcam_update_values(void) { } } - switch (gMarioStates[0].action) { - case ACT_FLYING: centering = 1; break; + if ((gMarioStates[0].action & ACT_FLAG_FLYING) == ACT_FLAG_FLYING) { + centering = 1; } static u32 sLastAction = 0; diff --git a/src/game/interaction.c b/src/game/interaction.c index 7f18e852..087ef3d5 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -33,31 +33,6 @@ #include "pc/lua/smlua_hooks.h" #include "pc/cheats.h" -enum InteractionFlag { - INT_GROUND_POUND_OR_TWIRL = (1 << 0), // 0x01 - INT_PUNCH = (1 << 1), // 0x02 - INT_KICK = (1 << 2), // 0x04 - INT_TRIP = (1 << 3), // 0x08 - INT_SLIDE_KICK = (1 << 4), // 0x10 - INT_FAST_ATTACK_OR_SHELL = (1 << 5), // 0x20 - INT_HIT_FROM_ABOVE = (1 << 6), // 0x40 - INT_HIT_FROM_BELOW = (1 << 7), // 0x80 -}; - -#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) - -#define 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) - -#define INT_ATTACK_NOT_WEAK_FROM_ABOVE \ - (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW) - -#define INT_ATTACK_SLIDE \ - (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL) - u8 sDelayInvincTimer; s16 gInteractionInvulnerable; u32 interact_coin(struct MarioState *, u32, struct Object *); @@ -208,7 +183,7 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o } if (interaction == 0 && action & ACT_FLAG_ATTACKING) { - if (action == ACT_PUNCHING || action == ACT_MOVE_PUNCHING || action == ACT_JUMP_KICK) { + if (m->flags & (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING)) { s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; if (m->flags & MARIO_PUNCHING) { @@ -230,17 +205,29 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o } } - } else if (action == ACT_GROUND_POUND || action == ACT_TWIRLING) { + } else if (action == ACT_GROUND_POUND) { if (m->vel[1] < 0.0f) { - interaction = INT_GROUND_POUND_OR_TWIRL; + interaction = INT_GROUND_POUND; } - } else if (action == ACT_GROUND_POUND_LAND || action == ACT_TWIRL_LAND) { + } else if (action == ACT_TWIRLING) { + if (m->vel[1] < 0.0f) { + interaction = INT_TWIRL; + } + } else if (action == ACT_GROUND_POUND_LAND) { // Neither ground pounding nor twirling change Mario's vertical speed on landing., // so the speed check is nearly always true (perhaps not if you land while going upwards?) // Additionally, actionState it set on each first thing in their action, so this is // only true prior to the very first frame (i.e. active 1 frame prior to it run). if (m->vel[1] < 0.0f && m->actionState == 0) { - interaction = INT_GROUND_POUND_OR_TWIRL; + interaction = INT_GROUND_POUND; + } + } else if (action == ACT_TWIRL_LAND) { + // Neither ground pounding nor twirling change Mario's vertical speed on landing., + // so the speed check is nearly always true (perhaps not if you land while going upwards?) + // Additionally, actionState it set on each first thing in their action, so this is + // only true prior to the very first frame (i.e. active 1 frame prior to it run). + if (m->vel[1] < 0.0f && m->actionState == 0) { + interaction = INT_TWIRL; } } else if (action == ACT_SLIDE_KICK || action == ACT_SLIDE_KICK_SLIDE) { interaction = INT_SLIDE_KICK; @@ -284,6 +271,8 @@ u32 attack_object(struct Object *o, s32 interaction) { u32 attackType = 0; switch (interaction) { + case INT_GROUND_POUND: + case INT_TWIRL: case INT_GROUND_POUND_OR_TWIRL: attackType = ATTACK_GROUND_POUND_OR_TWIRL; break; diff --git a/src/game/interaction.h b/src/game/interaction.h index 5be968c4..043dd8aa 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -40,6 +40,24 @@ enum InteractionType { INTERACT_PLAYER = /* 0x80000000 */ (1 << 31), }; +enum InteractionFlag { + INT_GROUND_POUND = /* 0x00000001 */ (1 << 0), + INT_PUNCH = /* 0x00000002 */ (1 << 1), + INT_KICK = /* 0x00000004 */ (1 << 2), + INT_TRIP = /* 0x00000008 */ (1 << 3), + INT_SLIDE_KICK = /* 0x00000010 */ (1 << 4), + INT_FAST_ATTACK_OR_SHELL = /* 0x00000020 */ (1 << 5), + INT_HIT_FROM_ABOVE = /* 0x00000040 */ (1 << 6), + INT_HIT_FROM_BELOW = /* 0x00000080 */ (1 << 7), + INT_TWIRL = /* 0x00000100 */ (1 << 8), + INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL), +}; + +#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) +#define 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) +#define INT_ATTACK_NOT_WEAK_FROM_ABOVE (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW) +#define INT_ATTACK_SLIDE (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL) + // INTERACT_WARP #define INT_SUBTYPE_FADING_WARP 0x00000001 @@ -119,5 +137,6 @@ 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); +u32 determine_interaction(struct MarioState *m, struct Object *o); #endif // INTERACTION_H diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 8401189a..88ab10c5 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2533,7 +2533,7 @@ s32 cur_obj_is_mario_ground_pounding_platform(void) { for (s32 i = 0; i < MAX_PLAYERS; i++) { if (!is_player_active(&gMarioStates[i])) { continue; } if (gMarioStates[i].marioObj->platform == o) { - if (gMarioStates[i].action == ACT_GROUND_POUND_LAND) { + if (determine_interaction(&gMarioStates[i], o) & INT_GROUND_POUND) { return TRUE; } } diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 2875683e..b7a14bdf 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1344,18 +1344,6 @@ char gSmluaConstants[] = "" "GEO_CONTEXT_AREA_LOAD = 3\n" "GEO_CONTEXT_AREA_INIT = 4\n" "GEO_CONTEXT_HELD_OBJ = 5\n" -"INT_GROUND_POUND_OR_TWIRL = (1 << 0)\n" -"INT_PUNCH = (1 << 1)\n" -"INT_KICK = (1 << 2)\n" -"INT_TRIP = (1 << 3)\n" -"INT_SLIDE_KICK = (1 << 4)\n" -"INT_FAST_ATTACK_OR_SHELL = (1 << 5)\n" -"INT_HIT_FROM_ABOVE = (1 << 6)\n" -"INT_HIT_FROM_BELOW = (1 << 7)\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" -"INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)\n" "INTERACT_HOOT = (1 << 0)\n" "INTERACT_GRABBABLE = (1 << 1)\n" "INTERACT_DOOR = (1 << 2)\n" @@ -1388,6 +1376,20 @@ char gSmluaConstants[] = "" "INTERACT_SHOCK = (1 << 29)\n" "INTERACT_IGLOO_BARRIER = (1 << 30)\n" "INTERACT_PLAYER = (1 << 31)\n" +"INT_GROUND_POUND = (1 << 0)\n" +"INT_PUNCH = (1 << 1)\n" +"INT_KICK = (1 << 2)\n" +"INT_TRIP = (1 << 3)\n" +"INT_SLIDE_KICK = (1 << 4)\n" +"INT_FAST_ATTACK_OR_SHELL = (1 << 5)\n" +"INT_HIT_FROM_ABOVE = (1 << 6)\n" +"INT_HIT_FROM_BELOW = (1 << 7)\n" +"INT_TWIRL = (1 << 8)\n" +"INT_GROUND_POUND_OR_TWIRL = (INT_GROUND_POUND | INT_TWIRL)\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" +"INT_ATTACK_SLIDE = (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL)\n" "INT_SUBTYPE_FADING_WARP = 0x00000001\n" "INT_SUBTYPE_DELAY_INVINCIBILITY = 0x00000002\n" "INT_SUBTYPE_BIG_KNOCKBACK = 0x00000008\n" @@ -2658,6 +2660,7 @@ char gSmluaConstants[] = "" "ACT_FLAG_WATER_OR_TEXT = (1 << 29)\n" "ACT_FLAG_CUSTOM_ACTION = (1 << 30)\n" "ACT_FLAG_THROWING = (1 << 31)\n" +"ACT_FLAG_FLYING = (ACT_FLAG_AIR | ACT_FLAG_DIVING | ACT_FLAG_ATTACKING | ACT_FLAG_SWIMMING_OR_FLYING)\n" "ACT_UNINITIALIZED = 0x00000000\n" "ACT_IDLE = 0x0C400201\n" "ACT_START_SLEEPING = 0x0C400202\n" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index eb3862cc..2d008675 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -12425,6 +12425,25 @@ int smlua_func_stop_sounds_in_continuous_banks(UNUSED lua_State* L) { // interaction.h // /////////////////// +int smlua_func_determine_interaction(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", "determine_interaction", 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, "determine_interaction"); 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, "determine_interaction"); return 0; } + + lua_pushinteger(L, determine_interaction(m, o)); + + return 1; +} + int smlua_func_does_mario_have_normal_cap_on_head(lua_State* L) { if (L == NULL) { return 0; } @@ -30163,6 +30182,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "stop_sounds_in_continuous_banks", smlua_func_stop_sounds_in_continuous_banks); // interaction.h + smlua_bind_function(L, "determine_interaction", smlua_func_determine_interaction); 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);