From 816f595fcc30f4357c17c9768f44b22ee5e78bee Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 13 Apr 2023 22:17:01 -0700 Subject: [PATCH] Clear interaction's invulnerable flag after each player has been processed --- src/game/interaction.c | 16 ++++++++-------- src/game/interaction.h | 1 + src/game/object_list_processor.c | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/game/interaction.c b/src/game/interaction.c index f7c9b4c1..6c1ff96d 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -59,7 +59,7 @@ enum InteractionFlag { (INT_SLIDE_KICK | INT_FAST_ATTACK_OR_SHELL) u8 sDelayInvincTimer; -s16 sInvulnerable; +s16 gInteractionInvulnerable; u32 interact_coin(struct MarioState *, u32, struct Object *); u32 interact_water_ring(struct MarioState *, u32, struct Object *); u32 interact_star_or_key(struct MarioState *, u32, struct Object *); @@ -824,7 +824,7 @@ u32 take_damage_from_interact_object(struct MarioState *m) { u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o) { u32 damage; - if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP) + if (!gInteractionInvulnerable && !(m->flags & MARIO_VANISH_CAP) && !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { o->oInteractStatus = INT_STATUS_INTERACTED | INT_STATUS_ATTACKED_MARIO; m->interactObj = o; @@ -1589,7 +1589,7 @@ u32 interact_strong_wind(struct MarioState *m, UNUSED u32 interactType, struct O u32 interact_flame(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { u32 burningAction = ACT_BURNING_JUMP; - if (!sInvulnerable && !(m->flags & MARIO_METAL_CAP) && !(m->flags & MARIO_VANISH_CAP) + if (!gInteractionInvulnerable && !(m->flags & MARIO_METAL_CAP) && !(m->flags & MARIO_VANISH_CAP) && !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { queue_rumble_data_mario(m, 5, 80); @@ -1616,7 +1616,7 @@ u32 interact_flame(struct MarioState *m, UNUSED u32 interactType, struct Object } u32 interact_snufit_bullet(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { - if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP)) { + if (!gInteractionInvulnerable && !(m->flags & MARIO_VANISH_CAP)) { if (m->flags & MARIO_METAL_CAP) { o->oInteractStatus = INT_STATUS_INTERACTED | INT_STATUS_WAS_ATTACKED; play_sound(SOUND_ACTION_UNKNOWN458, m->marioObj->header.gfx.cameraToObject); @@ -1681,7 +1681,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object return TRUE; } - else if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP) + else if (!gInteractionInvulnerable && !(m->flags & MARIO_VANISH_CAP) && !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { o->oInteractStatus = INT_STATUS_INTERACTED; m->invincTimer = 2; @@ -1701,7 +1701,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object } u32 interact_shock(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { - if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP) + if (!gInteractionInvulnerable && !(m->flags & MARIO_VANISH_CAP) && !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) { u32 actionArg = (m->action & (ACT_FLAG_AIR | ACT_FLAG_ON_POLE | ACT_FLAG_HANGING)) == 0; @@ -1918,7 +1918,7 @@ u32 interact_koopa_shell(struct MarioState *m, UNUSED u32 interactType, struct O u32 check_object_grab_mario(struct MarioState *m, UNUSED u32 interactType, struct Object *o) { if (m != &gMarioStates[0]) { return false; } - if ((!(m->action & (ACT_FLAG_AIR | ACT_FLAG_INVULNERABLE | ACT_FLAG_ATTACKING)) || !sInvulnerable) + if ((!(m->action & (ACT_FLAG_AIR | ACT_FLAG_INVULNERABLE | ACT_FLAG_ATTACKING)) || !gInteractionInvulnerable) && (o->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO)) { if (object_facing_mario(m, o, 0x2AAA)) { mario_stop_riding_and_holding(m); @@ -2224,7 +2224,7 @@ void check_kick_or_punch_wall(struct MarioState *m) { void mario_process_interactions(struct MarioState *m) { sDelayInvincTimer = FALSE; - sInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0; + gInteractionInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0; if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0 && is_player_active(m)) { s32 i; diff --git a/src/game/interaction.h b/src/game/interaction.h index 6ab63441..5be968c4 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -98,6 +98,7 @@ enum InteractionType { #define INT_STATUS_STOP_RIDING (1 << 22) /* 0x00400000 */ #define INT_STATUS_TOUCHED_BOB_OMB (1 << 23) /* 0x00800000 */ +extern s16 gInteractionInvulnerable; extern u8 gPssSlideStarted; s16 mario_obj_angle_to_object(struct MarioState *m, struct Object *o); diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index af4219f9..7d0015bf 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -337,6 +337,7 @@ void bhv_mario_update(void) { update_character_anim_offset(gMarioState); // reset mario state to the local player + gInteractionInvulnerable = false; gMarioState = &gMarioStates[0]; }