mirror of
https://github.com/zeldaret/oot.git
synced 2025-02-03 10:04:31 +00:00
Player: Document "WaitForPutAway" (#1936)
* document put away delay * functions.txt * add a note on delaying indefinitely * format * typo * delay -> wait for put away * revert unintended formatting change * add comment to struct member * format * fix functions.txt
This commit is contained in:
parent
f643499462
commit
295a8669b8
3 changed files with 63 additions and 32 deletions
|
@ -717,7 +717,7 @@ typedef struct {
|
|||
|
||||
typedef void (*PlayerActionFunc)(struct Player*, struct PlayState*);
|
||||
typedef s32 (*UpperActionFunc)(struct Player*, struct PlayState*);
|
||||
typedef void (*PlayerFuncA74)(struct PlayState*, struct Player*);
|
||||
typedef void (*AfterPutAwayFunc)(struct PlayState*, struct Player*);
|
||||
|
||||
typedef struct Player {
|
||||
/* 0x0000 */ Actor actor;
|
||||
|
@ -892,7 +892,7 @@ typedef struct Player {
|
|||
/* 0x0A60 */ u8 bodyIsBurning;
|
||||
/* 0x0A61 */ u8 bodyFlameTimers[PLAYER_BODYPART_MAX]; // one flame per body part
|
||||
/* 0x0A73 */ u8 unk_A73;
|
||||
/* 0x0A74 */ PlayerFuncA74 func_A74;
|
||||
/* 0x0A74 */ AfterPutAwayFunc afterPutAwayFunc; // See `Player_SetupWaitForPutAway` and `Player_Action_WaitForPutAway`
|
||||
/* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame)
|
||||
/* 0x0A79 */ u8 floorTypeTimer; // counts up every frame the current floor type is the same as the last frame
|
||||
/* 0x0A7A */ u8 floorProperty;
|
||||
|
|
|
@ -292,7 +292,7 @@ void Player_Action_80844E68(Player* this, PlayState* play);
|
|||
void Player_Action_80845000(Player* this, PlayState* play);
|
||||
void Player_Action_80845308(Player* this, PlayState* play);
|
||||
void Player_Action_80845668(Player* this, PlayState* play);
|
||||
void Player_Action_808458D0(Player* this, PlayState* play);
|
||||
void Player_Action_WaitForPutAway(Player* this, PlayState* play);
|
||||
void Player_Action_80845CA4(Player* this, PlayState* play);
|
||||
void Player_Action_80845EF8(Player* this, PlayState* play);
|
||||
void Player_Action_80846050(Player* this, PlayState* play);
|
||||
|
@ -1719,12 +1719,16 @@ void func_80832440(PlayState* play, Player* this) {
|
|||
this->unk_845 = this->unk_844 = 0;
|
||||
}
|
||||
|
||||
s32 func_80832528(PlayState* play, Player* this) {
|
||||
/**
|
||||
* Puts away item currently in hand, if holding any.
|
||||
* @return true if an item needs to be put away, false if not.
|
||||
*/
|
||||
s32 Player_PutAwayHeldItem(PlayState* play, Player* this) {
|
||||
if (this->heldItemAction >= PLAYER_IA_FISHING_POLE) {
|
||||
Player_UseItem(play, this, ITEM_NONE);
|
||||
return 1;
|
||||
return true;
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2216,7 +2220,7 @@ void Player_InitExplosiveIA(PlayState* play, Player* this) {
|
|||
Actor* spawnedActor;
|
||||
|
||||
if (this->stateFlags1 & PLAYER_STATE1_11) {
|
||||
func_80832528(play, this);
|
||||
Player_PutAwayHeldItem(play, this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3360,7 +3364,7 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) {
|
|||
}
|
||||
|
||||
int Player_CanUpdateItems(Player* this) {
|
||||
return (!(Player_Action_808458D0 == this->actionFunc) ||
|
||||
return (!(Player_Action_WaitForPutAway == this->actionFunc) ||
|
||||
((this->stateFlags1 & PLAYER_STATE1_START_CHANGING_HELD_ITEM) &&
|
||||
((this->heldItemId == ITEM_SWORD_CS) || (this->heldItemId == ITEM_NONE)))) &&
|
||||
(!(Player_UpperAction_ChangeHeldItem == this->upperActionFunc) ||
|
||||
|
@ -3414,11 +3418,21 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
s32 func_80836898(PlayState* play, Player* this, PlayerFuncA74 func) {
|
||||
this->func_A74 = func;
|
||||
Player_SetupAction(play, this, Player_Action_808458D0, 0);
|
||||
/**
|
||||
* Sets up `Player_Action_WaitForPutAway`, which will allow the held item put away process
|
||||
* to complete before moving on to a new action.
|
||||
*
|
||||
* The function provided by the `afterPutAwayFunc` argument will run after the put away is complete.
|
||||
* This function is expected to set a new action and move execution away from `Player_Action_WaitForPutAway`.
|
||||
*
|
||||
* @return From `Player_PutAwayHeldItem`: true if an item needs to be put away, false if not.
|
||||
*/
|
||||
s32 Player_SetupWaitForPutAway(PlayState* play, Player* this, AfterPutAwayFunc afterPutAwayFunc) {
|
||||
this->afterPutAwayFunc = afterPutAwayFunc;
|
||||
Player_SetupAction(play, this, Player_Action_WaitForPutAway, 0);
|
||||
this->stateFlags2 |= PLAYER_STATE2_6;
|
||||
return func_80832528(play, this);
|
||||
|
||||
return Player_PutAwayHeldItem(play, this);
|
||||
}
|
||||
|
||||
void func_808368EC(Player* this, PlayState* play) {
|
||||
|
@ -4946,7 +4960,7 @@ s32 Player_ActionChange_1(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
Player_SetupAction(play, this, Player_Action_80845EF8, 0);
|
||||
func_80832528(play, this);
|
||||
Player_PutAwayHeldItem(play, this);
|
||||
|
||||
if (doorDirection < 0) {
|
||||
this->actor.shape.rot.y = doorActor->shape.rot.y;
|
||||
|
@ -5272,7 +5286,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) {
|
|||
sp50 ? &gPlayerAnim_link_normal_Fclimb_startB : &gPlayerAnim_link_normal_fall);
|
||||
|
||||
if (sp50) {
|
||||
func_80836898(play, this, func_8083A3B0);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A3B0);
|
||||
|
||||
this->yaw += 0x8000;
|
||||
this->actor.shape.rot.y = this->yaw;
|
||||
|
@ -6604,7 +6618,7 @@ s32 Player_ActionChange_3(Player* this, PlayState* play) {
|
|||
sp38 = Math_CosS(rideActor->actor.shape.rot.y);
|
||||
sp34 = Math_SinS(rideActor->actor.shape.rot.y);
|
||||
|
||||
func_80836898(play, this, func_8083A360);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A360);
|
||||
|
||||
this->stateFlags1 |= PLAYER_STATE1_23;
|
||||
this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER;
|
||||
|
@ -6756,7 +6770,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) {
|
|||
func_8083AE40(this, giEntry->objectId);
|
||||
|
||||
if (!(this->stateFlags2 & PLAYER_STATE2_10) || (this->currentBoots == PLAYER_BOOTS_IRON)) {
|
||||
func_80836898(play, this, func_8083A434);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A434);
|
||||
Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_get_itemB);
|
||||
func_80835EA4(play, 9);
|
||||
}
|
||||
|
@ -6783,7 +6797,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) {
|
|||
}
|
||||
}
|
||||
|
||||
func_80836898(play, this, func_8083A434);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A434);
|
||||
this->stateFlags1 |= PLAYER_STATE1_10 | PLAYER_STATE1_11 | PLAYER_STATE1_29;
|
||||
func_8083AE40(this, giEntry->objectId);
|
||||
this->actor.world.pos.x =
|
||||
|
@ -6817,7 +6831,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) {
|
|||
this->itemAction = PLAYER_IA_NONE;
|
||||
this->modelAnimType = PLAYER_ANIMTYPE_0;
|
||||
this->heldItemAction = this->itemAction;
|
||||
func_80836898(play, this, func_8083A0F4);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A0F4);
|
||||
|
||||
if (sp24 == PLAYER_IA_SWORD_MASTER) {
|
||||
this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_IA_SWORD_CS);
|
||||
|
@ -6833,7 +6847,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
func_80836898(play, this, func_8083A0F4);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A0F4);
|
||||
}
|
||||
|
||||
func_80832224(this);
|
||||
|
@ -6945,7 +6959,7 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) {
|
|||
f32 sp34 = this->distToInteractWall;
|
||||
LinkAnimationHeader* anim;
|
||||
|
||||
func_80836898(play, this, func_8083A3B0);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A3B0);
|
||||
this->stateFlags1 |= PLAYER_STATE1_21;
|
||||
this->stateFlags1 &= ~PLAYER_STATE1_27;
|
||||
|
||||
|
@ -7048,7 +7062,7 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall
|
|||
f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z);
|
||||
f32 distToInteractWall = this->distToInteractWall;
|
||||
|
||||
func_80836898(play, this, func_8083A40C);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A40C);
|
||||
this->stateFlags2 |= PLAYER_STATE2_CRAWLING;
|
||||
this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000;
|
||||
this->actor.world.pos.x = xVertex1 + (distToInteractWall * wallPolyNormalX);
|
||||
|
@ -7173,7 +7187,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
|
|||
}
|
||||
|
||||
void func_8083F72C(Player* this, LinkAnimationHeader* anim, PlayState* play) {
|
||||
if (!func_80836898(play, this, func_8083A388)) {
|
||||
if (!Player_SetupWaitForPutAway(play, this, func_8083A388)) {
|
||||
Player_SetupAction(play, this, Player_Action_8084B78C, 0);
|
||||
}
|
||||
|
||||
|
@ -7210,7 +7224,7 @@ s32 Player_ActionChange_5(Player* this, PlayState* play) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
func_80836898(play, this, func_8083A0F4);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A0F4);
|
||||
this->stateFlags1 |= PLAYER_STATE1_11;
|
||||
this->interactRangeActor = &wallPolyActor->actor;
|
||||
this->getItemId = GI_NONE;
|
||||
|
@ -9420,13 +9434,30 @@ void Player_Action_80845668(Player* this, PlayState* play) {
|
|||
}
|
||||
}
|
||||
|
||||
void Player_Action_808458D0(Player* this, PlayState* play) {
|
||||
/**
|
||||
* Allow the held item put away process to complete before running `afterPutAwayFunc`
|
||||
*/
|
||||
void Player_Action_WaitForPutAway(Player* this, PlayState* play) {
|
||||
this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6;
|
||||
LinkAnimation_Update(play, &this->skelAnime);
|
||||
|
||||
// Wait for the held item put away process to complete.
|
||||
// Determining if the put away process is complete is a bit complicated:
|
||||
// `Player_UpdateUpperBody` will only return false if the current UpperAction returns false.
|
||||
// The UpperAction responsible for putting away items, `Player_UpperAction_ChangeHeldItem`, constantly
|
||||
// returns true until the item change is done. False won't be returned until the item change is done, and a new
|
||||
// UpperAction is running and can return false itself.
|
||||
// Note that this implementation allows for delaying indefinitely by, for example, holding shield
|
||||
// during the item put away. The shield UpperAction will return true while shielding and targeting.
|
||||
// Meaning, `afterPutAwayFunc` will be delayed until the player decides to let go of shield.
|
||||
// This quirk can contribute to the possibility of other bugs manifesting.
|
||||
//
|
||||
// The other conditions listed will force the put away delay function to run instantly if carrying an actor.
|
||||
// This is necessary because the UpperAction for carrying actors will always return true while holding
|
||||
// the actor, so `!Player_UpdateUpperBody` could never pass.
|
||||
if (((this->stateFlags1 & PLAYER_STATE1_11) && (this->heldActor != NULL) && (this->getItemId == GI_NONE)) ||
|
||||
!Player_UpdateUpperBody(this, play)) {
|
||||
this->func_A74(play, this);
|
||||
this->afterPutAwayFunc(play, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15289,7 +15320,7 @@ void func_80853148(PlayState* play, Actor* actor) {
|
|||
if (actor->textId == 0xFFFF) {
|
||||
Player_SetCsActionWithHaltedActors(play, actor, PLAYER_CSACTION_1);
|
||||
actor->flags |= ACTOR_FLAG_TALK;
|
||||
func_80832528(play, this);
|
||||
Player_PutAwayHeldItem(play, this);
|
||||
} else {
|
||||
if (this->actor.flags & ACTOR_FLAG_TALK) {
|
||||
this->actor.textId = 0;
|
||||
|
@ -15301,13 +15332,13 @@ void func_80853148(PlayState* play, Actor* actor) {
|
|||
if (this->stateFlags1 & PLAYER_STATE1_23) {
|
||||
s32 sp24 = this->av2.actionVar2;
|
||||
|
||||
func_80832528(play, this);
|
||||
Player_PutAwayHeldItem(play, this);
|
||||
func_8083A2F8(play, this);
|
||||
|
||||
this->av2.actionVar2 = sp24;
|
||||
} else {
|
||||
if (func_808332B8(this)) {
|
||||
func_80836898(play, this, func_8083A2F8);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A2F8);
|
||||
Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait);
|
||||
} else if ((actor->category != ACTORCAT_NPC) || (this->heldItemAction == PLAYER_IA_FISHING_POLE)) {
|
||||
func_8083A2F8(play, this);
|
||||
|
@ -15320,7 +15351,7 @@ void func_80853148(PlayState* play, Actor* actor) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
func_80836898(play, this, func_8083A2F8);
|
||||
Player_SetupWaitForPutAway(play, this, func_8083A2F8);
|
||||
Player_AnimPlayOnceAdjusted(play, this,
|
||||
(actor->xzDistToPlayer < 40.0f) ? &gPlayerAnim_link_normal_backspace
|
||||
: &gPlayerAnim_link_normal_talk_free);
|
||||
|
|
|
@ -3265,7 +3265,7 @@ func_80832318 = 0x8082EDB4; // type:func
|
|||
func_80832340 = 0x8082EDE0; // type:func
|
||||
Player_DetachHeldActor = 0x8082EE50; // type:func
|
||||
func_80832440 = 0x8082EEDC; // type:func
|
||||
func_80832528 = 0x8082EFC4; // type:func
|
||||
Player_PutAwayHeldItem = 0x8082EFC4; // type:func
|
||||
func_80832564 = 0x8082F000; // type:func
|
||||
func_80832594 = 0x8082F038; // type:func
|
||||
func_80832630 = 0x8082F0D8; // type:func
|
||||
|
@ -3386,7 +3386,7 @@ Player_UseItem = 0x80832AE4; // type:func
|
|||
func_80836448 = 0x80832FEC; // type:func
|
||||
Player_CanUpdateItems = 0x8083316C; // type:func
|
||||
Player_UpdateUpperBody = 0x80833218; // type:func
|
||||
func_80836898 = 0x80833440; // type:func
|
||||
Player_SetupWaitForPutAway = 0x80833440; // type:func
|
||||
func_808368EC = 0x80833498; // type:func
|
||||
func_808369C8 = 0x80833574; // type:func
|
||||
func_80836AB8 = 0x80833660; // type:func
|
||||
|
@ -3593,7 +3593,7 @@ Player_Action_80844E68 = 0x80841AB8; // type:func
|
|||
Player_Action_80845000 = 0x80841C50; // type:func
|
||||
Player_Action_80845308 = 0x80841F58; // type:func
|
||||
Player_Action_80845668 = 0x808422B8; // type:func
|
||||
Player_Action_808458D0 = 0x80842524; // type:func
|
||||
Player_Action_WaitForPutAway = 0x80842524; // type:func
|
||||
func_80845964 = 0x808425B8; // type:func
|
||||
func_80845BA0 = 0x808427FC; // type:func
|
||||
func_80845C68 = 0x808428C8; // type:func
|
||||
|
|
Loading…
Add table
Reference in a new issue