From be57b6bf4c8164f3ce2bc00fff3ca449242f72a3 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis Date: Sun, 12 Jun 2022 23:58:13 +0100 Subject: [PATCH] Document flag for swinging bottle (#1272) * Document flag for swinging bottle * Add bug, minor documentation to func_8084ECA4 * Update comments * Add newline to z64cutscene_commands.h * Review --- include/z64cutscene_commands.h | 1 + include/z64player.h | 2 +- src/code/audio_effects.c | 2 +- .../actors/ovl_Boss_Ganon/z_boss_ganon.c | 2 +- .../actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c | 2 +- .../actors/ovl_player_actor/z_player.c | 25 +++++++++++-------- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/z64cutscene_commands.h b/include/z64cutscene_commands.h index 1150a2eaad..85e7166f45 100644 --- a/include/z64cutscene_commands.h +++ b/include/z64cutscene_commands.h @@ -98,6 +98,7 @@ */ #define CS_LIGHTING_LIST(entries) CS_CMD_SET_LIGHTING, CMD_W(entries) + /** * ARGS * s16 setting (m), s16 startFrame (s), s16 endFrame (e) diff --git a/include/z64player.h b/include/z64player.h index 863252f6e4..ca28b06169 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -384,7 +384,7 @@ typedef struct { } WeaponInfo; // size = 0x1C #define PLAYER_STATE1_0 (1 << 0) -#define PLAYER_STATE1_1 (1 << 1) +#define PLAYER_STATE1_SWINGING_BOTTLE (1 << 1) #define PLAYER_STATE1_2 (1 << 2) #define PLAYER_STATE1_3 (1 << 3) #define PLAYER_STATE1_4 (1 << 4) diff --git a/src/code/audio_effects.c b/src/code/audio_effects.c index 5e71318dd0..241e99c02c 100644 --- a/src/code/audio_effects.c +++ b/src/code/audio_effects.c @@ -242,8 +242,8 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { case ADSR_STATE_START_LOOP: adsr->envIndex = 0; adsr->action.s.state = ADSR_STATE_LOOP; - FALLTHROUGH; retry:; + FALLTHROUGH; case ADSR_STATE_LOOP: adsr->delay = adsr->envelope[adsr->envIndex].delay; switch (adsr->delay) { diff --git a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index bc6d2fd122..e7d0d107c2 100644 --- a/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -3923,7 +3923,7 @@ void BossGanon_LightBall_Update(Actor* thisx, PlayState* play2) { switch (this->unk_1C2) { case 0: - if ((player->stateFlags1 & PLAYER_STATE1_1) && + if ((player->stateFlags1 & PLAYER_STATE1_SWINGING_BOTTLE) && (ABS((s16)(player->actor.shape.rot.y - (s16)(ganondorf->actor.yawTowardsPlayer + 0x8000))) < 0x2000) && (sqrtf(SQ(xDistFromLink) + SQ(yDistFromLink) + SQ(zDistFromLink)) <= 25.0f)) { diff --git a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c index 51b260a62b..0045c590d0 100644 --- a/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c +++ b/src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c @@ -469,7 +469,7 @@ void EnFhgFire_EnergyBall(EnFhgFire* this, PlayState* play) { switch (this->work[FHGFIRE_FIRE_MODE]) { case FHGFIRE_LIGHT_GREEN: canBottleReflect1 = - ((player->stateFlags1 & PLAYER_STATE1_1) && + ((player->stateFlags1 & PLAYER_STATE1_SWINGING_BOTTLE) && (ABS((s16)(player->actor.shape.rot.y - (s16)(bossGnd->actor.yawTowardsPlayer + 0x8000))) < 0x2000) && (sqrtf(SQ(dxL) + SQ(dyL) + SQ(dzL)) <= 25.0f)) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 5818e350dd..df8f665818 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10394,7 +10394,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->stateFlags2 &= ~(PLAYER_STATE2_1 | PLAYER_STATE2_21); } - this->stateFlags1 &= ~(PLAYER_STATE1_1 | PLAYER_STATE1_9 | PLAYER_STATE1_12 | PLAYER_STATE1_22); + this->stateFlags1 &= ~(PLAYER_STATE1_SWINGING_BOTTLE | PLAYER_STATE1_9 | PLAYER_STATE1_12 | PLAYER_STATE1_22); this->stateFlags2 &= ~(PLAYER_STATE2_0 | PLAYER_STATE2_2 | PLAYER_STATE2_3 | PLAYER_STATE2_5 | PLAYER_STATE2_6 | PLAYER_STATE2_8 | PLAYER_STATE2_9 | PLAYER_STATE2_12 | PLAYER_STATE2_14 | PLAYER_STATE2_16 | PLAYER_STATE2_22 | PLAYER_STATE2_26); @@ -12378,11 +12378,11 @@ void func_8084EAC0(Player* this, PlayState* play) { } } -static BottleCatchInfo D_80854A04[] = { - { ACTOR_EN_ELF, ITEM_FAIRY, 0x2A, 0x46 }, - { ACTOR_EN_FISH, ITEM_FISH, 0x1F, 0x47 }, - { ACTOR_EN_ICE_HONO, ITEM_BLUE_FIRE, 0x20, 0x5D }, - { ACTOR_EN_INSECT, ITEM_BUG, 0x21, 0x7A }, +static BottleCatchInfo sBottleCatchInfos[] = { + { ACTOR_EN_ELF, ITEM_FAIRY, PLAYER_AP_BOTTLE_FAIRY, 0x46 }, + { ACTOR_EN_FISH, ITEM_FISH, PLAYER_AP_BOTTLE_FISH, 0x47 }, + { ACTOR_EN_ICE_HONO, ITEM_BLUE_FIRE, PLAYER_AP_BOTTLE_FIRE, 0x5D }, + { ACTOR_EN_INSECT, ITEM_BUG, PLAYER_AP_BOTTLE_BUG, 0x7A }, }; void func_8084ECA4(Player* this, PlayState* play) { @@ -12397,7 +12397,7 @@ void func_8084ECA4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (this->unk_84F != 0) { if (this->unk_850 == 0) { - Message_StartTextbox(play, D_80854A04[this->unk_84F - 1].textId, &this->actor); + Message_StartTextbox(play, sBottleCatchInfos[this->unk_84F - 1].textId, &this->actor); Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); this->unk_850 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { @@ -12420,14 +12420,14 @@ void func_8084ECA4(Player* this, PlayState* play) { } if (this->interactRangeActor != NULL) { - catchInfo = &D_80854A04[0]; - for (i = 0; i < 4; i++, catchInfo++) { + catchInfo = &sBottleCatchInfos[0]; + for (i = 0; i < ARRAY_COUNT(sBottleCatchInfos); i++, catchInfo++) { if (this->interactRangeActor->id == catchInfo->actorId) { break; } } - if (i < 4) { + if (i < ARRAY_COUNT(sBottleCatchInfos)) { this->unk_84F = i + 1; this->unk_850 = 0; this->stateFlags1 |= PLAYER_STATE1_28 | PLAYER_STATE1_29; @@ -12442,8 +12442,11 @@ void func_8084ECA4(Player* this, PlayState* play) { } } + //! @bug If the animation is changed at any point above (such as by func_8083C0E8() or func_808322D0()), it will + //! change the curFrame to 0. This causes this flag to be set for one frame, at a time when it does not look like + //! Player is swinging the bottle. if (this->skelAnime.curFrame <= 7.0f) { - this->stateFlags1 |= PLAYER_STATE1_1; + this->stateFlags1 |= PLAYER_STATE1_SWINGING_BOTTLE; } }