1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-26 14:46:16 +00:00

Player Docs: "sUpperBodyIsBusy" (#1944)

* document upperbodybusy

* change wording for comment and rename upperanimblendweight

* format

* review
This commit is contained in:
fig02 2024-04-17 16:24:52 -04:00 committed by GitHub
parent 681f276f8a
commit 30eb05321d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 75 additions and 46 deletions

View file

@ -824,7 +824,7 @@ typedef struct Player {
/* 0x070C */ Vec3s upperJointTable[PLAYER_LIMB_BUF_COUNT]; /* 0x070C */ Vec3s upperJointTable[PLAYER_LIMB_BUF_COUNT];
/* 0x079C */ Vec3s upperMorphTable[PLAYER_LIMB_BUF_COUNT]; /* 0x079C */ Vec3s upperMorphTable[PLAYER_LIMB_BUF_COUNT];
/* 0x082C */ UpperActionFunc upperActionFunc; /* 0x082C */ UpperActionFunc upperActionFunc;
/* 0x0830 */ f32 upperAnimBlendWeight; /* 0x0830 */ f32 upperAnimInterpWeight;
/* 0x0834 */ s16 unk_834; /* 0x0834 */ s16 unk_834;
/* 0x0836 */ s8 unk_836; /* 0x0836 */ s8 unk_836;
/* 0x0837 */ u8 unk_837; /* 0x0837 */ u8 unk_837;

View file

@ -509,7 +509,7 @@ static u32 sNoclipEnabled = false;
static f32 sControlStickMagnitude = 0.0f; static f32 sControlStickMagnitude = 0.0f;
static s16 sControlStickAngle = 0; static s16 sControlStickAngle = 0;
static s16 D_808535DC = 0; static s16 D_808535DC = 0;
static s32 D_808535E0 = 0; static s32 sUpperBodyIsBusy = false; // see `Player_UpdateUpperBody`
static s32 sFloorType = FLOOR_TYPE_0; static s32 sFloorType = FLOOR_TYPE_0;
static f32 D_808535E8 = 1.0f; static f32 D_808535E8 = 1.0f;
static f32 D_808535EC = 1.0f; static f32 D_808535EC = 1.0f;
@ -2157,7 +2157,7 @@ LinkAnimationHeader* func_808335F4(Player* this) {
void Player_SetUpperActionFunc(Player* this, UpperActionFunc upperActionFunc) { void Player_SetUpperActionFunc(Player* this, UpperActionFunc upperActionFunc) {
this->upperActionFunc = upperActionFunc; this->upperActionFunc = upperActionFunc;
this->unk_836 = 0; this->unk_836 = 0;
this->upperAnimBlendWeight = 0.0f; this->upperAnimInterpWeight = 0.0f;
func_808326F0(this); func_808326F0(this);
} }
@ -2630,9 +2630,9 @@ s32 func_80834758(PlayState* play, Player* this) {
s32 func_8083485C(Player* this, PlayState* play) { s32 func_8083485C(Player* this, PlayState* play) {
if (func_80834758(play, this)) { if (func_80834758(play, this)) {
return 1; return true;
} else { } else {
return 0; return false;
} }
} }
@ -2677,9 +2677,9 @@ s32 func_8083499C(Player* this, PlayState* play) {
*/ */
s32 Player_UpperAction_Sword(Player* this, PlayState* play) { s32 Player_UpperAction_Sword(Player* this, PlayState* play) {
if (func_80834758(play, this) || func_8083499C(this, play)) { if (func_80834758(play, this) || func_8083499C(this, play)) {
return 1; return true;
} else { } else {
return 0; return false;
} }
} }
@ -2692,6 +2692,7 @@ s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play) {
this->unk_834 = 0; this->unk_834 = 0;
this->unk_6AC = 0; this->unk_6AC = 0;
sHeldItemButtonIsHeldDown = sUseHeldItem; sHeldItemButtonIsHeldDown = sUseHeldItem;
return this->upperActionFunc(this, play); return this->upperActionFunc(this, play);
} }
@ -2703,7 +2704,7 @@ s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play) {
Player_WaitToFinishItemChange(play, this); Player_WaitToFinishItemChange(play, this);
} }
return 1; return true;
} }
s32 func_80834B5C(Player* this, PlayState* play) { s32 func_80834B5C(Player* this, PlayState* play) {
@ -2711,11 +2712,11 @@ s32 func_80834B5C(Player* this, PlayState* play) {
if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) { if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_R)) {
func_80834894(this); func_80834894(this);
return 1; return true;
} else { } else {
this->stateFlags1 |= PLAYER_STATE1_22; this->stateFlags1 |= PLAYER_STATE1_22;
Player_SetModelsForHoldingShield(this); Player_SetModelsForHoldingShield(this);
return 1; return true;
} }
} }
@ -2732,7 +2733,7 @@ s32 func_80834BD4(Player* this, PlayState* play) {
this->stateFlags1 |= PLAYER_STATE1_22; this->stateFlags1 |= PLAYER_STATE1_22;
Player_SetModelsForHoldingShield(this); Player_SetModelsForHoldingShield(this);
return 1; return true;
} }
s32 func_80834C74(Player* this, PlayState* play) { s32 func_80834C74(Player* this, PlayState* play) {
@ -2744,10 +2745,11 @@ s32 func_80834C74(Player* this, PlayState* play) {
GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType));
this->unk_6AC = 0; this->unk_6AC = 0;
this->upperActionFunc(this, play); this->upperActionFunc(this, play);
return 0;
return false;
} }
return 1; return true;
} }
s32 func_80834D2C(Player* this, PlayState* play) { s32 func_80834D2C(Player* this, PlayState* play) {
@ -2834,10 +2836,10 @@ s32 func_8083501C(Player* this, PlayState* play) {
if ((!Player_HoldsHookshot(this) || func_80834FBC(this)) && !func_80834758(play, this) && if ((!Player_HoldsHookshot(this) || func_80834FBC(this)) && !func_80834758(play, this) &&
!func_80834F2C(this, play)) { !func_80834F2C(this, play)) {
return 0; return false;
} }
return 1; return true;
} }
s32 func_808350A4(PlayState* play, Player* this) { s32 func_808350A4(PlayState* play, Player* this) {
@ -2924,14 +2926,14 @@ s32 func_808351D4(Player* this, PlayState* play) {
this->stateFlags1 |= PLAYER_STATE1_9; this->stateFlags1 |= PLAYER_STATE1_9;
} }
return 1; return true;
} }
s32 func_808353D8(Player* this, PlayState* play) { s32 func_808353D8(Player* this, PlayState* play) {
LinkAnimation_Update(play, &this->upperSkelAnime); LinkAnimation_Update(play, &this->upperSkelAnime);
if (Player_HoldsHookshot(this) && !func_80834FBC(this)) { if (Player_HoldsHookshot(this) && !func_80834FBC(this)) {
return 1; return true;
} }
if (!func_80834758(play, this) && if (!func_80834758(play, this) &&
@ -2954,7 +2956,8 @@ s32 func_808353D8(Player* this, PlayState* play) {
if (this->unk_834 == 0) { if (this->unk_834 == 0) {
this->unk_834++; this->unk_834++;
} }
return 1;
return true;
} }
if (Player_HoldsHookshot(this)) { if (Player_HoldsHookshot(this)) {
@ -2967,7 +2970,7 @@ s32 func_808353D8(Player* this, PlayState* play) {
this->unk_834 = 0; this->unk_834 = 0;
} }
return 1; return true;
} }
s32 func_80835588(Player* this, PlayState* play) { s32 func_80835588(Player* this, PlayState* play) {
@ -2975,7 +2978,7 @@ s32 func_80835588(Player* this, PlayState* play) {
Player_SetUpperActionFunc(this, func_8083501C); Player_SetUpperActionFunc(this, func_8083501C);
} }
return 1; return true;
} }
void func_808355DC(Player* this) { void func_808355DC(Player* this) {
@ -3014,7 +3017,7 @@ s32 Player_UpperAction_CarryActor(Player* this, PlayState* play) {
} }
if (func_80834758(play, this)) { if (func_80834758(play, this)) {
return 1; return true;
} }
if (this->stateFlags1 & PLAYER_STATE1_11) { if (this->stateFlags1 & PLAYER_STATE1_11) {
@ -3028,7 +3031,7 @@ s32 Player_UpperAction_CarryActor(Player* this, PlayState* play) {
this->fallStartHeight = this->actor.world.pos.y; this->fallStartHeight = this->actor.world.pos.y;
} }
return 1; return true;
} }
return func_8083485C(this, play); return func_8083485C(this, play);
@ -3040,16 +3043,16 @@ void func_808357E8(Player* this, Gfx** dLists) {
s32 func_80835800(Player* this, PlayState* play) { s32 func_80835800(Player* this, PlayState* play) {
if (func_80834758(play, this)) { if (func_80834758(play, this)) {
return 1; return true;
} }
if (this->stateFlags1 & PLAYER_STATE1_25) { if (this->stateFlags1 & PLAYER_STATE1_25) {
Player_SetUpperActionFunc(this, func_80835B60); Player_SetUpperActionFunc(this, func_80835B60);
} else if (func_80834F2C(this, play)) { } else if (func_80834F2C(this, play)) {
return 1; return true;
} }
return 0; return false;
} }
s32 func_80835884(Player* this, PlayState* play) { s32 func_80835884(Player* this, PlayState* play) {
@ -3060,7 +3063,7 @@ s32 func_80835884(Player* this, PlayState* play) {
func_80834EB8(this, play); func_80834EB8(this, play);
return 1; return true;
} }
s32 func_808358F0(Player* this, PlayState* play) { s32 func_808358F0(Player* this, PlayState* play) {
@ -3082,7 +3085,7 @@ s32 func_808358F0(Player* this, PlayState* play) {
(this->unk_870 < 0.5f) ? &gPlayerAnim_link_boom_throwR : &gPlayerAnim_link_boom_throwL); (this->unk_870 < 0.5f) ? &gPlayerAnim_link_boom_throwR : &gPlayerAnim_link_boom_throwL);
} }
return 1; return true;
} }
s32 func_808359FC(Player* this, PlayState* play) { s32 func_808359FC(Player* this, PlayState* play) {
@ -3111,12 +3114,12 @@ s32 func_808359FC(Player* this, PlayState* play) {
} }
} }
return 1; return true;
} }
s32 func_80835B60(Player* this, PlayState* play) { s32 func_80835B60(Player* this, PlayState* play) {
if (func_80834758(play, this)) { if (func_80834758(play, this)) {
return 1; return true;
} }
if (!(this->stateFlags1 & PLAYER_STATE1_25)) { if (!(this->stateFlags1 & PLAYER_STATE1_25)) {
@ -3125,10 +3128,11 @@ s32 func_80835B60(Player* this, PlayState* play) {
func_808357E8(this, gPlayerLeftHandBoomerangDLs); func_808357E8(this, gPlayerLeftHandBoomerangDLs);
Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG); Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG);
func_80832698(this, NA_SE_VO_LI_SWORD_N); func_80832698(this, NA_SE_VO_LI_SWORD_N);
return 1;
return true;
} }
return 0; return false;
} }
s32 func_80835C08(Player* this, PlayState* play) { s32 func_80835C08(Player* this, PlayState* play) {
@ -3136,7 +3140,7 @@ s32 func_80835C08(Player* this, PlayState* play) {
Player_SetUpperActionFunc(this, func_80835800); Player_SetUpperActionFunc(this, func_80835800);
} }
return 1; return true;
} }
s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) { s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 flags) {
@ -3371,6 +3375,24 @@ int Player_CanUpdateItems(Player* this) {
(Player_ItemToItemAction(this->heldItemId) == this->heldItemAction)); (Player_ItemToItemAction(this->heldItemId) == this->heldItemAction));
} }
/**
* Updates the Upper Body system.
* The Upper Body system is composed of an upper action function and
* a separate skelanime that can play an animation which is different
* from the main skelanime.
*
* @return true if the upper body is "busy", false otherwise.
*
* The upper body being "busy" can mean a few things:
* - Hookshot has just connected with something that Player can fly to
* - A deku nut is currently being thrown
* - The current upper action function has indicated that it is busy
*
* If an upper action indicates being busy by returning true, the
* animation playing in the upper body skeleton will be used.
* This animation may be used for all limbs or only the upper body limbs
* depending on some conditions. See details below.
*/
s32 Player_UpdateUpperBody(Player* this, PlayState* play) { s32 Player_UpdateUpperBody(Player* this, PlayState* play) {
if (!(this->stateFlags1 & PLAYER_STATE1_23) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) { if (!(this->stateFlags1 & PLAYER_STATE1_23) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) {
Player_SetupAction(play, this, Player_Action_80850AEC, 1); Player_SetupAction(play, this, Player_Action_80850AEC, 1);
@ -3385,37 +3407,43 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) {
this->hoverBootsTimer = 0; this->hoverBootsTimer = 0;
this->unk_6AE |= 0x43; this->unk_6AE |= 0x43;
func_80832698(this, NA_SE_VO_LI_LASH); func_80832698(this, NA_SE_VO_LI_LASH);
return 1; return true;
} }
if (Player_CanUpdateItems(this)) { if (Player_CanUpdateItems(this)) {
Player_UpdateItems(this, play); Player_UpdateItems(this, play);
if (Player_Action_8084E604 == this->actionFunc) { if (Player_Action_8084E604 == this->actionFunc) {
return 1; return true;
} }
} }
if (!this->upperActionFunc(this, play)) { if (!this->upperActionFunc(this, play)) {
return 0; return false;
} }
if (this->upperAnimBlendWeight != 0.0f) { if (this->upperAnimInterpWeight != 0.0f) {
// The functionality contained within this block of code is never used in practice
// because `upperAnimInterpWeight` is always 0.
if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) { if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) {
AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->upperSkelAnime.jointTable, AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->upperSkelAnime.jointTable,
this->skelAnime.jointTable, sUpperBodyLimbCopyMap); this->skelAnime.jointTable, sUpperBodyLimbCopyMap);
} }
Math_StepToF(&this->upperAnimBlendWeight, 0.0f, 0.25f); Math_StepToF(&this->upperAnimInterpWeight, 0.0f, 0.25f);
AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable,
this->upperSkelAnime.jointTable, 1.0f - this->upperAnimBlendWeight); this->upperSkelAnime.jointTable, 1.0f - this->upperAnimInterpWeight);
} else if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) { } else if ((func_80833350(this) == 0) || (this->speedXZ != 0.0f)) {
// Only copy the upper body animation to the upper body limbs in the main skeleton.
// Doing so allows the main skeleton to play its own animation for the lower body limbs.
AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable,
this->upperSkelAnime.jointTable, sUpperBodyLimbCopyMap); this->upperSkelAnime.jointTable, sUpperBodyLimbCopyMap);
} else { } else {
// Copy all of the upper body animation into the whole main skeleton.
// The upper body has full control of all limbs.
AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable,
this->upperSkelAnime.jointTable); this->upperSkelAnime.jointTable);
} }
return 1; return true;
} }
/** /**
@ -3857,7 +3885,7 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi
if (!(this->stateFlags1 & (PLAYER_STATE1_0 | PLAYER_STATE1_7 | PLAYER_STATE1_29))) { if (!(this->stateFlags1 & (PLAYER_STATE1_0 | PLAYER_STATE1_7 | PLAYER_STATE1_29))) {
if (updateUpperBody) { if (updateUpperBody) {
D_808535E0 = Player_UpdateUpperBody(this, play); sUpperBodyIsBusy = Player_UpdateUpperBody(this, play);
if (Player_Action_8084E604 == this->actionFunc) { if (Player_Action_8084E604 == this->actionFunc) {
return true; return true;
@ -5932,7 +5960,7 @@ void func_8083C148(Player* this, PlayState* play) {
} }
s32 Player_ActionChange_6(Player* this, PlayState* play) { s32 Player_ActionChange_6(Player* this, PlayState* play) {
if (!func_80833B54(this) && (D_808535E0 == 0) && !(this->stateFlags1 & PLAYER_STATE1_23) && if (!func_80833B54(this) && !sUpperBodyIsBusy && !(this->stateFlags1 & PLAYER_STATE1_23) &&
CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) {
if (func_8083BC7C(this, play)) { if (func_8083BC7C(this, play)) {
return 1; return 1;
@ -8610,7 +8638,7 @@ void Player_Action_808435C4(Player* this, PlayState* play) {
func_8083721C(this); func_8083721C(this);
if (this->av1.actionVar1 == 0) { if (this->av1.actionVar1 == 0) {
D_808535E0 = Player_UpdateUpperBody(this, play); sUpperBodyIsBusy = Player_UpdateUpperBody(this, play);
if ((func_80834B5C == this->upperActionFunc) || (func_808374A0(play, this, &this->upperSkelAnime, 4.0f) > 0)) { if ((func_80834B5C == this->upperActionFunc) || (func_808374A0(play, this, &this->upperSkelAnime, 4.0f) > 0)) {
Player_SetupAction(play, this, Player_Action_80840450, 1); Player_SetupAction(play, this, Player_Action_80840450, 1);
} }
@ -12525,7 +12553,7 @@ void Player_Action_8084CC98(Player* this, PlayState* play) {
} }
if (this->av2.actionVar2 == 1) { if (this->av2.actionVar2 == 1) {
if ((D_808535E0 != 0) || func_8083224C(play)) { if (sUpperBodyIsBusy || func_8083224C(play)) {
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_3); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_3);
} else if (LinkAnimation_Update(play, &this->skelAnime)) { } else if (LinkAnimation_Update(play, &this->skelAnime)) {
this->av2.actionVar2 = 99; this->av2.actionVar2 = 99;
@ -12547,8 +12575,9 @@ void Player_Action_8084CC98(Player* this, PlayState* play) {
this->unk_6AD = 0; this->unk_6AD = 0;
this->av1.actionVar1 = 0; this->av1.actionVar1 = 0;
} else if ((this->av2.actionVar2 < 2) || (this->av2.actionVar2 >= 4)) { } else if ((this->av2.actionVar2 < 2) || (this->av2.actionVar2 >= 4)) {
D_808535E0 = Player_UpdateUpperBody(this, play); sUpperBodyIsBusy = Player_UpdateUpperBody(this, play);
if (D_808535E0 != 0) {
if (sUpperBodyIsBusy) {
this->av1.actionVar1 = 0; this->av1.actionVar1 = 0;
} }
} }
@ -12562,7 +12591,7 @@ void Player_Action_8084CC98(Player* this, PlayState* play) {
if ((this->csAction != PLAYER_CSACTION_NONE) || if ((this->csAction != PLAYER_CSACTION_NONE) ||
(!func_8083224C(play) && ((rideActor->actor.speed != 0.0f) || !Player_ActionChange_4(this, play)) && (!func_8083224C(play) && ((rideActor->actor.speed != 0.0f) || !Player_ActionChange_4(this, play)) &&
!Player_ActionChange_6(this, play))) { !Player_ActionChange_6(this, play))) {
if (D_808535E0 == 0) { if (!sUpperBodyIsBusy) {
if (this->av1.actionVar1 != 0) { if (this->av1.actionVar1 != 0) {
if (LinkAnimation_Update(play, &this->upperSkelAnime)) { if (LinkAnimation_Update(play, &this->upperSkelAnime)) {
rideActor->stateFlags &= ~ENHORSE_FLAG_8; rideActor->stateFlags &= ~ENHORSE_FLAG_8;