Skip to content

Commit

Permalink
Document flag for swinging bottle (zeldaret#1272)
Browse files Browse the repository at this point in the history
* Document flag for swinging bottle

* Add bug, minor documentation to func_8084ECA4

* Update comments

* Add newline to z64cutscene_commands.h

* Review
  • Loading branch information
EllipticEllipsis committed Jun 12, 2022
1 parent 826924a commit be57b6b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions include/z64cutscene_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/z64player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/code/audio_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_En_Fhg_Fire/z_en_fhg_fire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
25 changes: 14 additions & 11 deletions src/overlays/actors/ovl_player_actor/z_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand All @@ -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;
}
}

Expand Down

0 comments on commit be57b6b

Please sign in to comment.