1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 01:34:18 +00:00

Document Player_Action_8084F390 (#2264)

* Document Player_Action_8084F390

* Rename linkYawToStepTowards into shapeYawTarget

* Fix BSS

* Address reviews

* Fix format

* Address Review
This commit is contained in:
Pepe20129 2024-10-13 19:33:16 +02:00 committed by GitHub
parent b275588728
commit d0b4725869
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 34 additions and 35 deletions

View file

@ -877,6 +877,7 @@ typedef struct Player {
/* 0x084F */ union {
s8 actionVar1;
s8 facingUpSlope; // Player_Action_SlideOnSlope: facing uphill when sliding on a slope
s8 bottleCatchType; // Player_Action_SwingBottle: entry type for `sBottleCatchInfo`, corresponds to actor caught in a bottle
} av1; // "Action Variable 1": context dependent variable that has different meanings depending on what action is currently running

View file

@ -320,7 +320,7 @@ void Player_Action_SwingBottle(Player* this, PlayState* play);
void Player_Action_8084EED8(Player* this, PlayState* play);
void Player_Action_8084EFC0(Player* this, PlayState* play);
void Player_Action_ExchangeItem(Player* this, PlayState* play);
void Player_Action_8084F390(Player* this, PlayState* play);
void Player_Action_SlideOnSlope(Player* this, PlayState* play);
void Player_Action_8084F608(Player* this, PlayState* play);
void Player_Action_8084F698(Player* this, PlayState* play);
void Player_Action_8084F710(Player* this, PlayState* play);
@ -7223,7 +7223,7 @@ void Player_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16*
}
s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) {
static LinkAnimationHeader* sSlopeSlipAnims[] = {
static LinkAnimationHeader* sSlopeSlideAnims[] = {
&gPlayerAnim_link_normal_down_slope_slip,
&gPlayerAnim_link_normal_up_slope_slip,
};
@ -7235,7 +7235,7 @@ s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly)
f32 slopeSlowdownSpeedStep;
s16 velYawToDownwardSlope;
if (!Player_InBlockingCsMode(play, this) && (Player_Action_8084F390 != this->actionFunc) &&
if (!Player_InBlockingCsMode(play, this) && (Player_Action_SlideOnSlope != this->actionFunc) &&
(SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) == FLOOR_EFFECT_1)) {
// Get direction of movement relative to the downward direction of the slope
playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x);
@ -7255,14 +7255,14 @@ s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly)
this->pushedYaw = downwardSlopeYaw;
Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep);
} else {
// moving downward on the slope, causing player to slip
Player_SetupAction(play, this, Player_Action_8084F390, 0);
// moving downward on the slope, causing player to slip and then slide down
Player_SetupAction(play, this, Player_Action_SlideOnSlope, 0);
func_80832564(play, this);
if (sFloorShapePitch >= 0) {
this->av1.actionVar1 = 1;
this->av1.facingUpSlope = true;
}
Player_AnimChangeLoopMorph(play, this, sSlopeSlipAnims[this->av1.actionVar1]);
Player_AnimChangeLoopMorph(play, this, sSlopeSlideAnims[this->av1.actionVar1]);
this->speedXZ = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z));
this->yaw = playerVelYaw;
return true;
@ -14188,22 +14188,20 @@ void Player_Action_8084F308(Player* this, PlayState* play) {
}
}
void Player_Action_8084F390(Player* this, PlayState* play) {
CollisionPoly* floorPoly;
f32 sp50;
f32 sp4C;
f32 sp48;
s16 downwardSlopeYaw;
s16 sp44;
Vec3f slopeNormal;
void Player_Action_SlideOnSlope(Player* this, PlayState* play) {
this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6;
LinkAnimation_Update(play, &this->skelAnime);
func_8084269C(play, this);
func_800F4138(&this->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, this->actor.speed);
if (Player_ActionHandler_13(this, play) == 0) {
floorPoly = this->actor.floorPoly;
CollisionPoly* floorPoly = this->actor.floorPoly;
f32 xzSpeedTarget;
f32 xzSpeedIncrStep;
f32 xzSpeedDecrStep;
s16 downwardSlopeYaw;
s16 shapeYawTarget;
Vec3f slopeNormal;
if (floorPoly == NULL) {
func_80837B9C(this, play);
@ -14212,42 +14210,42 @@ void Player_Action_8084F390(Player* this, PlayState* play) {
Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw);
sp44 = downwardSlopeYaw;
if (this->av1.actionVar1 != 0) {
sp44 = downwardSlopeYaw + 0x8000;
shapeYawTarget = downwardSlopeYaw;
if (this->av1.facingUpSlope) {
shapeYawTarget = downwardSlopeYaw + 0x8000;
}
if (this->speedXZ < 0) {
downwardSlopeYaw += 0x8000;
}
sp50 = (1.0f - slopeNormal.y) * 40.0f;
sp50 = CLAMP(sp50, 0, 10.0f);
sp4C = (sp50 * sp50) * 0.015f;
sp48 = slopeNormal.y * 0.01f;
xzSpeedTarget = (1.0f - slopeNormal.y) * 40.0f;
xzSpeedTarget = CLAMP(xzSpeedTarget, 0, 10.0f);
xzSpeedIncrStep = SQ(xzSpeedTarget) * 0.015f;
xzSpeedDecrStep = slopeNormal.y * 0.01f;
if (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1) {
sp50 = 0;
sp48 = slopeNormal.y * 10.0f;
xzSpeedTarget = 0;
xzSpeedDecrStep = slopeNormal.y * 10.0f;
}
if (sp4C < 1.0f) {
sp4C = 1.0f;
if (xzSpeedIncrStep < 1.0f) {
xzSpeedIncrStep = 1.0f;
}
if (Math_AsymStepToF(&this->speedXZ, sp50, sp4C, sp48) && (sp50 == 0)) {
LinkAnimationHeader* anim;
if (Math_AsymStepToF(&this->speedXZ, xzSpeedTarget, xzSpeedIncrStep, xzSpeedDecrStep) && (xzSpeedTarget == 0)) {
LinkAnimationHeader* slideAnimation;
if (this->av1.actionVar1 == 0) {
anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType);
if (!this->av1.facingUpSlope) {
slideAnimation = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType);
} else {
anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_up_slope_slip_end, this->modelAnimType);
slideAnimation = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_up_slope_slip_end, this->modelAnimType);
}
func_8083A098(this, anim, play);
func_8083A098(this, slideAnimation, play);
}
Math_SmoothStepToS(&this->yaw, downwardSlopeYaw, 10, 4000, 800);
Math_ScaledStepToS(&this->actor.shape.rot.y, sp44, 2000);
Math_ScaledStepToS(&this->actor.shape.rot.y, shapeYawTarget, 2000);
}
}