1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +00:00

Player: AnimMovement (#2245)

* name top level stuff

* newlines

* Document Player AnimMovement

* tweak comment

* spelling

* review

* rework comment
This commit is contained in:
fig02 2024-10-04 13:52:03 -04:00 committed by GitHub
parent e9cbcb7ad9
commit 6b31fdad53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 145 additions and 100 deletions

View file

@ -144,7 +144,7 @@ typedef enum AnimationTapers {
// frames have their translation occur relative to this new starting point. // frames have their translation occur relative to this new starting point.
// //
// Note that for Player, this flag is only relevant when transitioning from an animation that was also using // Note that for Player, this flag is only relevant when transitioning from an animation that was also using
// ActorMovement. This is because of how `prevTransl` gets reset in `Player_AnimReplaceApplyFlags`. // ActorMovement. This is because of how `prevTransl` gets reset in `Player_StartAnimMovement`.
#define ANIM_FLAG_ADJUST_STARTING_POS (1 << 4) #define ANIM_FLAG_ADJUST_STARTING_POS (1 << 4)
// Disables "normal" movement from sources like speed/velocity and collisions, which allows the // Disables "normal" movement from sources like speed/velocity and collisions, which allows the

View file

@ -1693,7 +1693,7 @@ void Player_AnimPlayOnceAdjusted(PlayState* play, Player* this, LinkAnimationHea
LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, PLAYER_ANIM_ADJUSTED_SPEED);
} }
void func_808322FC(Player* this) { void Player_ApplyYawFromAnim(Player* this) {
this->actor.shape.rot.y += this->skelAnime.jointTable[1].y; this->actor.shape.rot.y += this->skelAnime.jointTable[1].y;
this->skelAnime.jointTable[1].y = 0; this->skelAnime.jointTable[1].y = 0;
} }
@ -1969,13 +1969,14 @@ s32 func_80832CB0(PlayState* play, Player* this, LinkAnimationHeader* anim) {
} }
} }
void Player_SkelAnimeResetPrevTranslRot(Player* this) { void Player_ResetAnimMovement(Player* this) {
this->skelAnime.prevTransl = this->skelAnime.baseTransl; this->skelAnime.prevTransl = this->skelAnime.baseTransl;
this->skelAnime.prevRot = this->actor.shape.rot.y; this->skelAnime.prevRot = this->actor.shape.rot.y;
} }
void Player_SkelAnimeResetPrevTranslRotAgeScale(Player* this) { void Player_ResetAnimMovementScaledByAge(Player* this) {
Player_SkelAnimeResetPrevTranslRot(this); Player_ResetAnimMovement(this);
this->skelAnime.prevTransl.x *= this->ageProperties->unk_08; this->skelAnime.prevTransl.x *= this->ageProperties->unk_08;
this->skelAnime.prevTransl.y *= this->ageProperties->unk_08; this->skelAnime.prevTransl.y *= this->ageProperties->unk_08;
this->skelAnime.prevTransl.z *= this->ageProperties->unk_08; this->skelAnime.prevTransl.z *= this->ageProperties->unk_08;
@ -1985,11 +1986,19 @@ void Player_ZeroRootLimbYaw(Player* this) {
this->skelAnime.jointTable[1].y = 0; this->skelAnime.jointTable[1].y = 0;
} }
void func_80832DBC(Player* this) { /**
* Finishes "AnimMovement" by resetting various aspects of Player's SkelAnime structure.
*
* This function is called in Player_SetupAction so it will run on every action change, but
* it can also be called within action functions to change animations in the middle of an action.
*/
void Player_FinishAnimMovement(Player* this) {
if (this->skelAnime.movementFlags != 0) { if (this->skelAnime.movementFlags != 0) {
func_808322FC(this); Player_ApplyYawFromAnim(this);
this->skelAnime.jointTable[0].x = this->skelAnime.baseTransl.x; this->skelAnime.jointTable[0].x = this->skelAnime.baseTransl.x;
this->skelAnime.jointTable[0].z = this->skelAnime.baseTransl.z; this->skelAnime.jointTable[0].z = this->skelAnime.baseTransl.z;
if (this->skelAnime.movementFlags & ANIM_FLAG_ENABLE_MOVEMENT) { if (this->skelAnime.movementFlags & ANIM_FLAG_ENABLE_MOVEMENT) {
if (this->skelAnime.movementFlags & ANIM_FLAG_UPDATE_Y) { if (this->skelAnime.movementFlags & ANIM_FLAG_UPDATE_Y) {
this->skelAnime.jointTable[0].y = this->skelAnime.prevTransl.y; this->skelAnime.jointTable[0].y = this->skelAnime.prevTransl.y;
@ -1997,59 +2006,95 @@ void func_80832DBC(Player* this) {
} else { } else {
this->skelAnime.jointTable[0].y = this->skelAnime.baseTransl.y; this->skelAnime.jointTable[0].y = this->skelAnime.baseTransl.y;
} }
Player_SkelAnimeResetPrevTranslRot(this);
Player_ResetAnimMovement(this);
this->skelAnime.movementFlags = 0; this->skelAnime.movementFlags = 0;
} }
} }
void func_80832E48(Player* this, s32 flags) { /**
Vec3f pos; * This is a reimplementation of `AnimTask_ActorMovement`.
*
* This achieves the same goal as `AnimTask_ActorMovement`but it adds
* the ability to scale the resulting movement according to age.
*
* When using the AnimTask variant, age specific scaling can only be applied visually
* to the root bone position and does not affect world position.
*/
void Player_ApplyAnimMovementScaledByAge(Player* this, s32 movementFlags) {
Vec3f diff;
this->skelAnime.movementFlags = flags; this->skelAnime.movementFlags = movementFlags;
this->skelAnime.prevTransl = this->skelAnime.baseTransl; this->skelAnime.prevTransl = this->skelAnime.baseTransl;
SkelAnime_UpdateTranslation(&this->skelAnime, &pos, this->actor.shape.rot.y);
if (flags & 1) { SkelAnime_UpdateTranslation(&this->skelAnime, &diff, this->actor.shape.rot.y);
if (movementFlags & ANIM_FLAG_UPDATE_XZ) {
if (!LINK_IS_ADULT) { if (!LINK_IS_ADULT) {
pos.x *= 0.64f; diff.x *= 0.64f;
pos.z *= 0.64f; diff.z *= 0.64f;
} }
this->actor.world.pos.x += pos.x * this->actor.scale.x;
this->actor.world.pos.z += pos.z * this->actor.scale.z; this->actor.world.pos.x += diff.x * this->actor.scale.x;
this->actor.world.pos.z += diff.z * this->actor.scale.z;
} }
if (flags & 2) { if (movementFlags & ANIM_FLAG_UPDATE_Y) {
if (!(flags & 4)) { if (!(movementFlags & ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT)) {
pos.y *= this->ageProperties->unk_08; diff.y *= this->ageProperties->unk_08;
} }
this->actor.world.pos.y += pos.y * this->actor.scale.y;
this->actor.world.pos.y += diff.y * this->actor.scale.y;
} }
func_808322FC(this); Player_ApplyYawFromAnim(this);
} }
#define ANIM_REPLACE_APPLY_FLAG_8 (1 << 8) #define PLAYER_ANIM_MOVEMENT_RESET (1 << 8)
#define ANIM_REPLACE_APPLY_FLAG_9 (1 << 9) #define PLAYER_ANIM_MOVEMENT_RESET_BY_AGE (1 << 9)
void Player_AnimReplaceApplyFlags(PlayState* play, Player* this, s32 flags) { /**
if (flags & ANIM_REPLACE_APPLY_FLAG_9) { * Starts "AnimMovement" so that Player will move according to the translation and rotation specified
Player_SkelAnimeResetPrevTranslRotAgeScale(this); * by the animation that is playing.
} else if ((flags & ANIM_REPLACE_APPLY_FLAG_8) || (this->skelAnime.movementFlags != 0)) { *
Player_SkelAnimeResetPrevTranslRot(this); * The `flags` field can be any of the SkelAnime system's `ANIM_FLAG_` flags, as well as Player-specific
* `PLAYER_ANIM_MOVEMENT_` flags.
*
* For AnimMovement features to be enabled, it is usually required to pass `ANIM_FLAG_ENABLE_MOVEMENT`
* as one of the flags, but there are a few niche cases where it can be desirable to omit it
* (for example to use `ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT` without any actual AnimMovement).
*
* Note: AnimMovement is always disabled during every action change.
* This means the order that functions are called matters.
* `Player_StartAnimMovement` must be called *after* a call to `Player_SetupAction`.
*/
void Player_StartAnimMovement(PlayState* play, Player* this, s32 flags) {
if (flags & PLAYER_ANIM_MOVEMENT_RESET_BY_AGE) {
Player_ResetAnimMovementScaledByAge(this);
} else if ((flags & PLAYER_ANIM_MOVEMENT_RESET) || (this->skelAnime.movementFlags != 0)) {
// If AnimMovement is already in use when this function is called and
// `PLAYER_ANIM_MOVEMENT_RESET_BY_AGE` is not set, then this case will be used.
Player_ResetAnimMovement(this);
} else { } else {
// Default case used when AnimMovement was not enabled previously.
// This sets prevTransl and prevRot to Players current translation and yaw.
this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0];
this->skelAnime.prevRot = this->actor.shape.rot.y; this->skelAnime.prevRot = this->actor.shape.rot.y;
} }
// Remove Player specific flags by masking the lower byte before setting to `skelAnime.movementFlags`
this->skelAnime.movementFlags = flags & 0xFF; this->skelAnime.movementFlags = flags & 0xFF;
Player_ZeroSpeedXZ(this); Player_ZeroSpeedXZ(this);
AnimTaskQueue_DisableTransformTasksForGroup(play); AnimTaskQueue_DisableTransformTasksForGroup(play);
} }
// TODO: Change all of these wrapper functions below to use "AnimMovement" instead of "AnimReplace"
void Player_AnimReplacePlayOnceSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, void Player_AnimReplacePlayOnceSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags,
f32 playbackSpeed) { f32 playbackSpeed) {
LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, playbackSpeed); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, playbackSpeed);
Player_AnimReplaceApplyFlags(play, this, flags); Player_StartAnimMovement(play, this, flags);
} }
void Player_AnimReplacePlayOnce(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { void Player_AnimReplacePlayOnce(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) {
@ -2069,7 +2114,7 @@ void Player_AnimReplaceNormalPlayOnceAdjusted(PlayState* play, Player* this, Lin
void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags,
f32 playbackSpeed) { f32 playbackSpeed) {
LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, playbackSpeed); LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, playbackSpeed);
Player_AnimReplaceApplyFlags(play, this, flags); Player_StartAnimMovement(play, this, flags);
} }
void Player_AnimReplacePlayLoop(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) { void Player_AnimReplacePlayLoop(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags) {
@ -3309,7 +3354,7 @@ s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFun
this->stateFlags1 &= ~PLAYER_STATE1_22; this->stateFlags1 &= ~PLAYER_STATE1_22;
} }
func_80832DBC(this); Player_FinishAnimMovement(this);
this->stateFlags1 &= ~(PLAYER_STATE1_2 | PLAYER_STATE1_6 | PLAYER_STATE1_26 | PLAYER_STATE1_28 | PLAYER_STATE1_29 | this->stateFlags1 &= ~(PLAYER_STATE1_2 | PLAYER_STATE1_6 | PLAYER_STATE1_26 | PLAYER_STATE1_28 | PLAYER_STATE1_29 |
PLAYER_STATE1_31); PLAYER_STATE1_31);
@ -3541,9 +3586,9 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) {
Player_SetupAction(play, this, Player_Action_80850AEC, 1); Player_SetupAction(play, this, Player_Action_80850AEC, 1);
this->stateFlags3 |= PLAYER_STATE3_FLYING_WITH_HOOKSHOT; this->stateFlags3 |= PLAYER_STATE3_FLYING_WITH_HOOKSHOT;
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
func_80832224(this); func_80832224(this);
this->yaw = this->actor.shape.rot.y; this->yaw = this->actor.shape.rot.y;
this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND;
@ -4355,8 +4400,8 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) {
Player_AnimPlayOnceAdjusted(play, this, D_80854190[arg2].unk_00); Player_AnimPlayOnceAdjusted(play, this, D_80854190[arg2].unk_00);
if ((arg2 != PLAYER_MWA_FLIPSLASH_START) && (arg2 != PLAYER_MWA_JUMPSLASH_START)) { if ((arg2 != PLAYER_MWA_FLIPSLASH_START) && (arg2 != PLAYER_MWA_JUMPSLASH_START)) {
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_ENABLE_MOVEMENT); PLAYER_ANIM_MOVEMENT_RESET_BY_AGE | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_ENABLE_MOVEMENT);
} }
this->yaw = this->actor.shape.rot.y; this->yaw = this->actor.shape.rot.y;
@ -4424,7 +4469,7 @@ s32 func_80837B18(PlayState* play, Player* this, s32 damage) {
void func_80837B60(Player* this) { void func_80837B60(Player* this) {
this->skelAnime.prevTransl = this->skelAnime.jointTable[0]; this->skelAnime.prevTransl = this->skelAnime.jointTable[0];
func_80832E48(this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y); Player_ApplyAnimMovementScaledByAge(this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y);
} }
void func_80837B9C(Player* this, PlayState* play) { void func_80837B9C(Player* this, PlayState* play) {
@ -5297,10 +5342,10 @@ s32 Player_ActionHandler_1(Player* this, PlayState* play) {
} }
func_80832224(this); func_80832224(this);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | PLAYER_ANIM_MOVEMENT_RESET_BY_AGE | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y |
ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
// If this door is the second half of a double door (spawned as child) // If this door is the second half of a double door (spawned as child)
if (doorActor->parent != NULL) { if (doorActor->parent != NULL) {
@ -5555,7 +5600,7 @@ void func_8083A5C4(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3,
this->actor.shape.rot.y = this->yaw = Math_Atan2S(nz, nx); this->actor.shape.rot.y = this->yaw = Math_Atan2S(nz, nx);
func_80832224(this); func_80832224(this);
Player_SkelAnimeResetPrevTranslRot(this); Player_ResetAnimMovement(this);
} }
s32 func_8083A6AC(Player* this, PlayState* play) { s32 func_8083A6AC(Player* this, PlayState* play) {
@ -5609,10 +5654,10 @@ s32 func_8083A6AC(Player* this, PlayState* play) {
this->actor.shape.rot.y = this->yaw; this->actor.shape.rot.y = this->yaw;
this->stateFlags1 |= PLAYER_STATE1_21; this->stateFlags1 |= PLAYER_STATE1_21;
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y |
ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
this->av2.actionVar2 = -1; this->av2.actionVar2 = -1;
this->av1.actionVar1 = sp50; this->av1.actionVar1 = sp50;
@ -6352,7 +6397,7 @@ s32 Player_ActionHandler_11(Player* this, PlayState* play) {
LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f); LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, frame, frame, ANIMMODE_ONCE, 0.0f);
if (Player_IsChildWithHylianShield(this)) { if (Player_IsChildWithHylianShield(this)) {
Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT); Player_StartAnimMovement(play, this, ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT);
} }
Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE); Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE);
@ -7028,9 +7073,9 @@ s32 Player_ActionHandler_3(Player* this, PlayState* play) {
Actor_MountHorse(play, this, &rideActor->actor); Actor_MountHorse(play, this, &rideActor->actor);
Player_AnimPlayOnce(play, this, D_80854578[temp].anim); Player_AnimPlayOnce(play, this, D_80854578[temp].anim);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
this->actor.parent = this->rideActor; this->actor.parent = this->rideActor;
func_80832224(this); func_80832224(this);
@ -7196,10 +7241,10 @@ s32 Player_ActionHandler_2(Player* this, PlayState* play) {
if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) && if ((giEntry->itemId != ITEM_NONE) && (giEntry->gi >= 0) &&
(Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) {
Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_98); Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_98);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | PLAYER_ANIM_MOVEMENT_RESET_BY_AGE | ANIM_FLAG_UPDATE_XZ |
ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT |
ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_OVERRIDE_MOVEMENT);
chest->unk_1F4 = 1; chest->unk_1F4 = 1;
Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS); Camera_RequestSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SLOW_CHEST_CS);
} else { } else {
@ -7375,10 +7420,10 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) {
func_80832224(this); func_80832224(this);
Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos);
Player_AnimPlayOnce(play, this, anim); Player_AnimPlayOnce(play, this, anim);
Player_AnimReplaceApplyFlags( Player_StartAnimMovement(play, this,
play, this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y |
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
return true; return true;
} }
@ -7457,10 +7502,10 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall
func_80832224(this); func_80832224(this);
this->actor.prevPos = this->actor.world.pos; this->actor.prevPos = this->actor.world.pos;
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT |
ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
return true; return true;
} }
@ -7548,10 +7593,10 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
// Leaving a crawlspace forwards // Leaving a crawlspace forwards
this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; this->actor.shape.rot.y = this->actor.wallYaw + 0x8000;
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_end);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT |
ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
OnePointCutscene_Init(play, 9601, 999, NULL, CAM_ID_MAIN); OnePointCutscene_Init(play, 9601, 999, NULL, CAM_ID_MAIN);
} else { } else {
// Leaving a crawlspace backwards // Leaving a crawlspace backwards
@ -7559,10 +7604,10 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) {
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f, LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_child_tunnel_start, -1.0f,
Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f, ANIMMODE_ONCE, Animation_GetLastFrame(&gPlayerAnim_link_child_tunnel_start), 0.0f, ANIMMODE_ONCE,
0.0f); 0.0f);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT |
ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
OnePointCutscene_Init(play, 9602, 999, NULL, CAM_ID_MAIN); OnePointCutscene_Init(play, 9602, 999, NULL, CAM_ID_MAIN);
} }
@ -7867,7 +7912,7 @@ void Player_Action_80840450(Player* this, PlayState* play) {
if (this->av2.actionVar2 != 0) { if (this->av2.actionVar2 != 0) {
if (LinkAnimation_Update(play, &this->skelAnime)) { if (LinkAnimation_Update(play, &this->skelAnime)) {
func_80832DBC(this); Player_FinishAnimMovement(this);
Player_AnimPlayLoop(play, this, func_808334E4(this)); Player_AnimPlayLoop(play, this, func_808334E4(this));
this->av2.actionVar2 = 0; this->av2.actionVar2 = 0;
this->stateFlags3 &= ~PLAYER_STATE3_3; this->stateFlags3 &= ~PLAYER_STATE3_3;
@ -7940,7 +7985,7 @@ void Player_Action_808407CC(Player* this, PlayState* play) {
s32 temp3; s32 temp3;
if (LinkAnimation_Update(play, &this->skelAnime)) { if (LinkAnimation_Update(play, &this->skelAnime)) {
func_80832DBC(this); Player_FinishAnimMovement(this);
Player_AnimPlayOnce(play, this, Player_GetIdleAnimationForCurrentModelAnimType(this)); Player_AnimPlayOnce(play, this, Player_GetIdleAnimationForCurrentModelAnimType(this));
} }
@ -8063,7 +8108,7 @@ void Player_Action_80840BC8(Player* this, PlayState* play) {
this->skelAnime.jointTable[0].y = this->skelAnime.jointTable[0].y =
(this->skelAnime.jointTable[0].y + ((this->av2.actionVar2 & 1) * 0x50)) - 0x28; (this->skelAnime.jointTable[0].y + ((this->av2.actionVar2 & 1) * 0x50)) - 0x28;
} else { } else {
func_80832DBC(this); Player_FinishAnimMovement(this);
func_808409CC(play, this); func_808409CC(play, this);
} }
} }
@ -8970,7 +9015,7 @@ void Player_Action_80843188(Player* this, PlayState* play) {
LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_clink_normal_defense_ALL, 1.0f, LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_clink_normal_defense_ALL, 1.0f,
Animation_GetLastFrame(&gPlayerAnim_clink_normal_defense_ALL), 0.0f, Animation_GetLastFrame(&gPlayerAnim_clink_normal_defense_ALL), 0.0f,
ANIMMODE_ONCE, 0.0f); ANIMMODE_ONCE, 0.0f);
Player_AnimReplaceApplyFlags(play, this, ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT); Player_StartAnimMovement(play, this, ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT);
} else { } else {
if (this->itemAction < 0) { if (this->itemAction < 0) {
func_8008EC70(this); func_8008EC70(this);
@ -9616,7 +9661,7 @@ void Player_Action_80844E68(Player* this, PlayState* play) {
this->stateFlags1 |= PLAYER_STATE1_CHARGING_SPIN_ATTACK; this->stateFlags1 |= PLAYER_STATE1_CHARGING_SPIN_ATTACK;
if (LinkAnimation_Update(play, &this->skelAnime)) { if (LinkAnimation_Update(play, &this->skelAnime)) {
func_80832DBC(this); Player_FinishAnimMovement(this);
Player_SetParallel(this); Player_SetParallel(this);
this->stateFlags1 &= ~PLAYER_STATE1_PARALLEL; this->stateFlags1 &= ~PLAYER_STATE1_PARALLEL;
Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]);
@ -10304,10 +10349,10 @@ void func_808467D4(PlayState* play, Player* this) {
this->yaw = this->actor.shape.rot.y = -0x8000; this->yaw = this->actor.shape.rot.y = -0x8000;
LinkAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, LinkAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE,
0.0f); 0.0f);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | PLAYER_ANIM_MOVEMENT_RESET_BY_AGE | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y |
ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
if (LINK_IS_ADULT) { if (LINK_IS_ADULT) {
func_80846720(play, this, 0); func_80846720(play, this, 0);
} }
@ -10316,9 +10361,9 @@ void func_808467D4(PlayState* play, Player* this) {
void func_808468A8(PlayState* play, Player* this) { void func_808468A8(PlayState* play, Player* this) {
Player_SetupAction(play, this, Player_Action_8084F9A0, 0); Player_SetupAction(play, this, Player_Action_8084F9A0, 0);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
} }
void func_808468E8(PlayState* play, Player* this) { void func_808468E8(PlayState* play, Player* this) {
@ -11485,9 +11530,9 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) {
func_8083A360(play, this); func_8083A360(play, this);
this->stateFlags1 |= PLAYER_STATE1_23; this->stateFlags1 |= PLAYER_STATE1_23;
Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
this->av2.actionVar2 = 99; this->av2.actionVar2 = 99;
} }
@ -12295,7 +12340,7 @@ void Player_Action_8084B530(Player* this, PlayState* play) {
Player_Action_8084D610(this, play); Player_Action_8084D610(this, play);
} else if (!Player_CheckHostileLockOn(this) && LinkAnimation_Update(play, &this->skelAnime)) { } else if (!Player_CheckHostileLockOn(this) && LinkAnimation_Update(play, &this->skelAnime)) {
if (this->skelAnime.movementFlags != 0) { if (this->skelAnime.movementFlags != 0) {
func_80832DBC(this); Player_FinishAnimMovement(this);
if ((this->talkActor->category == ACTORCAT_NPC) && (this->heldItemAction != PLAYER_IA_FISHING_POLE)) { if ((this->talkActor->category == ACTORCAT_NPC) && (this->heldItemAction != PLAYER_IA_FISHING_POLE)) {
Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_talk_free); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_talk_free);
} else { } else {
@ -12508,7 +12553,7 @@ void Player_Action_8084BDFC(Player* this, PlayState* play) {
this->stateFlags2 |= PLAYER_STATE2_6; this->stateFlags2 |= PLAYER_STATE2_6;
if (LinkAnimation_Update(play, &this->skelAnime)) { if (LinkAnimation_Update(play, &this->skelAnime)) {
func_80832E48(this, ANIM_FLAG_UPDATE_XZ); Player_ApplyAnimMovementScaledByAge(this, ANIM_FLAG_UPDATE_XZ);
func_8083C0E8(this, play); func_8083C0E8(this, play);
return; return;
} }
@ -13379,7 +13424,7 @@ void func_8084DF6C(PlayState* play, Player* this) {
void func_8084DFAC(PlayState* play, Player* this) { void func_8084DFAC(PlayState* play, Player* this) {
func_8084DF6C(play, this); func_8084DF6C(play, this);
func_808322FC(this); Player_ApplyYawFromAnim(this);
func_8083C0E8(this, play); func_8083C0E8(this, play);
this->yaw = this->actor.shape.rot.y; this->yaw = this->actor.shape.rot.y;
} }
@ -13590,7 +13635,7 @@ void Player_Action_8084E6D4(Player* this, PlayState* play) {
} }
} }
} else { } else {
func_80832DBC(this); Player_FinishAnimMovement(this);
if (this->getItemId == GI_ICE_TRAP) { if (this->getItemId == GI_ICE_TRAP) {
this->stateFlags1 &= ~(PLAYER_STATE1_10 | PLAYER_STATE1_CARRYING_ACTOR); this->stateFlags1 &= ~(PLAYER_STATE1_10 | PLAYER_STATE1_CARRYING_ACTOR);
@ -14965,7 +15010,7 @@ void func_808511FC(PlayState* play, Player* this, void* anim) {
void func_80851248(PlayState* play, Player* this, void* anim) { void func_80851248(PlayState* play, Player* this, void* anim) {
if (LinkAnimation_Update(play, &this->skelAnime)) { if (LinkAnimation_Update(play, &this->skelAnime)) {
func_80832DBC(this); Player_FinishAnimMovement(this);
Player_AnimPlayLoopAdjusted(play, this, anim); Player_AnimPlayLoopAdjusted(play, this, anim);
} }
} }
@ -15178,10 +15223,10 @@ void func_808519EC(PlayState* play, Player* this, CsCmdActorCue* cue) {
Math_Vec3f_Copy(&this->actor.world.pos, &D_80855198); Math_Vec3f_Copy(&this->actor.world.pos, &D_80855198);
this->actor.shape.rot.y = -0x8000; this->actor.shape.rot.y = -0x8000;
Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_9C); Player_AnimPlayOnceAdjusted(play, this, this->ageProperties->unk_9C);
Player_AnimReplaceApplyFlags(play, this, Player_StartAnimMovement(play, this,
ANIM_REPLACE_APPLY_FLAG_9 | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y | PLAYER_ANIM_MOVEMENT_RESET_BY_AGE | ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_UPDATE_Y |
ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_DISABLE_CHILD_ROOT_ADJUSTMENT | ANIM_FLAG_ENABLE_MOVEMENT |
ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_OVERRIDE_MOVEMENT);
} }
static struct_808551A4 D_808551A4[] = { static struct_808551A4 D_808551A4[] = {
@ -15420,8 +15465,8 @@ void func_80852234(PlayState* play, Player* this, CsCmdActorCue* cue) {
} }
void func_8085225C(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_8085225C(PlayState* play, Player* this, CsCmdActorCue* cue) {
Player_AnimReplaceApplyFlags( Player_StartAnimMovement(play, this,
play, this, ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT); ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS | ANIM_FLAG_OVERRIDE_MOVEMENT);
} }
void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) { void func_80852280(PlayState* play, Player* this, CsCmdActorCue* cue) {
@ -15704,7 +15749,7 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorCue* cueUnused) {
D_80858AA0 = this->skelAnime.movementFlags; D_80858AA0 = this->skelAnime.movementFlags;
func_80832DBC(this); Player_FinishAnimMovement(this);
PRINTF("TOOL MODE=%d\n", csAction); PRINTF("TOOL MODE=%d\n", csAction);
func_80852C0C(play, this, ABS(csAction)); func_80852C0C(play, this, ABS(csAction));
func_80852B4C(play, this, cue, &D_80854B18[ABS(csAction)]); func_80852B4C(play, this, cue, &D_80854B18[ABS(csAction)]);
@ -15723,7 +15768,7 @@ void Player_Action_CsAction(Player* this, PlayState* play) {
if (this->csAction != this->prevCsAction) { if (this->csAction != this->prevCsAction) {
D_80858AA0 = this->skelAnime.movementFlags; D_80858AA0 = this->skelAnime.movementFlags;
func_80832DBC(this); Player_FinishAnimMovement(this);
this->prevCsAction = this->csAction; this->prevCsAction = this->csAction;
PRINTF("DEMO MODE=%d\n", this->csAction); PRINTF("DEMO MODE=%d\n", this->csAction);
func_80852C0C(play, this, this->csAction); func_80852C0C(play, this, this->csAction);
@ -15856,7 +15901,7 @@ void func_80853148(PlayState* play, Actor* actor) {
} }
if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) { if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) {
Player_AnimReplaceApplyFlags( Player_StartAnimMovement(
play, this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS); play, this, ANIM_FLAG_UPDATE_XZ | ANIM_FLAG_ENABLE_MOVEMENT | ANIM_FLAG_ADJUST_STARTING_POS);
} }