diff --git a/include/z64player.h b/include/z64player.h index 6d3749206e..03f6cdb0ee 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -181,6 +181,8 @@ typedef enum PlayerItemAction { /* 0x43 */ PLAYER_IA_MAX } PlayerItemAction; +#define ACTION_TO_BOTTLE(action) (action - PLAYER_IA_BOTTLE) + typedef enum PlayerLimb { /* 0x00 */ PLAYER_LIMB_NONE, /* 0x01 */ PLAYER_LIMB_ROOT, @@ -927,7 +929,7 @@ typedef struct Player { s16 csDelayTimer; // Player_Action_WaitForCutscene: Number of frames to wait before responding to a cutscene s16 playedLandingSfx; // Player_Action_BlueWarpArrive: Played sfx when landing on the ground s16 appearTimer; // Player_Action_FaroresWindArrive: Counts up, appear at 20 frames (1 second) - s16 drinkingState; // Player_Action_DrinkFromBottle: Uses values 0-2 to determine which part of the drinking action is currently active + s16 drinkingState; // Player_Action_DrinkFromBottle: Uses values 0-2 to determine which part of the drinking action is currently active (see DrinkingState enum) } av2; // "Action Variable 2": context dependent variable that has different meanings depending on what action is currently running /* 0x0854 */ f32 unk_854; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 798ba82462..40aa6b80cc 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -880,9 +880,9 @@ int Player_HoldsBrokenKnife(Player* this) { } s32 Player_ActionToBottle(Player* this, s32 itemAction) { - s32 bottle = itemAction - PLAYER_IA_BOTTLE; + s32 bottle = ACTION_TO_BOTTLE(itemAction); - if ((bottle >= 0) && (bottle < 13)) { + if ((bottle >= ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE)) && (bottle <= ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE_FAIRY))) { return bottle; } else { return -1; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index b797bec193..7344cd1e72 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -6082,14 +6082,14 @@ s32 Player_ActionHandler_13(Player* this, PlayState* play) { } sp2C = Player_ActionToBottle(this, this->itemAction); -#define ACTION_TO_BOTTLE_ACTION(action) (action - PLAYER_IA_BOTTLE) - if (sp2C >= ACTION_TO_BOTTLE_ACTION(PLAYER_IA_BOTTLE)) { - if (sp2C == ACTION_TO_BOTTLE_ACTION(PLAYER_IA_BOTTLE_FAIRY)) { + + if (sp2C >= ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE)) { + if (sp2C == ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE_FAIRY)) { Player_SetupActionPreserveItemAction(play, this, Player_Action_UseFairyFromBottle, 0); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_bug_out); func_80835EA4(play, 3); - } else if ((sp2C >= ACTION_TO_BOTTLE_ACTION(PLAYER_IA_BOTTLE_FISH)) && - (sp2C <= ACTION_TO_BOTTLE_ACTION(PLAYER_IA_BOTTLE_BUG))) { + } else if ((sp2C >= ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE_FISH)) && + (sp2C <= ACTION_TO_BOTTLE(PLAYER_IA_BOTTLE_BUG))) { Player_SetupActionPreserveItemAction(play, this, Player_Action_DropActorFromBottle, 0); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_fish_out); func_80835EA4(play, (sp2C == 1) ? 1 : 5);