1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 09:45:02 +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 { /* 0x084F */ union {
s8 actionVar1; 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 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 } 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_8084EED8(Player* this, PlayState* play);
void Player_Action_8084EFC0(Player* this, PlayState* play); void Player_Action_8084EFC0(Player* this, PlayState* play);
void Player_Action_ExchangeItem(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_8084F608(Player* this, PlayState* play);
void Player_Action_8084F698(Player* this, PlayState* play); void Player_Action_8084F698(Player* this, PlayState* play);
void Player_Action_8084F710(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) { s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) {
static LinkAnimationHeader* sSlopeSlipAnims[] = { static LinkAnimationHeader* sSlopeSlideAnims[] = {
&gPlayerAnim_link_normal_down_slope_slip, &gPlayerAnim_link_normal_down_slope_slip,
&gPlayerAnim_link_normal_up_slope_slip, &gPlayerAnim_link_normal_up_slope_slip,
}; };
@ -7235,7 +7235,7 @@ s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly)
f32 slopeSlowdownSpeedStep; f32 slopeSlowdownSpeedStep;
s16 velYawToDownwardSlope; 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)) { (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) == FLOOR_EFFECT_1)) {
// Get direction of movement relative to the downward direction of the slope // Get direction of movement relative to the downward direction of the slope
playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); 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; this->pushedYaw = downwardSlopeYaw;
Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep); Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep);
} else { } else {
// moving downward on the slope, causing player to slip // moving downward on the slope, causing player to slip and then slide down
Player_SetupAction(play, this, Player_Action_8084F390, 0); Player_SetupAction(play, this, Player_Action_SlideOnSlope, 0);
func_80832564(play, this); func_80832564(play, this);
if (sFloorShapePitch >= 0) { 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->speedXZ = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z));
this->yaw = playerVelYaw; this->yaw = playerVelYaw;
return true; return true;
@ -14188,22 +14188,20 @@ void Player_Action_8084F308(Player* this, PlayState* play) {
} }
} }
void Player_Action_8084F390(Player* this, PlayState* play) { void Player_Action_SlideOnSlope(Player* this, PlayState* play) {
CollisionPoly* floorPoly;
f32 sp50;
f32 sp4C;
f32 sp48;
s16 downwardSlopeYaw;
s16 sp44;
Vec3f slopeNormal;
this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6; this->stateFlags2 |= PLAYER_STATE2_5 | PLAYER_STATE2_6;
LinkAnimation_Update(play, &this->skelAnime); LinkAnimation_Update(play, &this->skelAnime);
func_8084269C(play, this); func_8084269C(play, this);
func_800F4138(&this->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, this->actor.speed); func_800F4138(&this->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, this->actor.speed);
if (Player_ActionHandler_13(this, play) == 0) { 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) { if (floorPoly == NULL) {
func_80837B9C(this, play); func_80837B9C(this, play);
@ -14212,42 +14210,42 @@ void Player_Action_8084F390(Player* this, PlayState* play) {
Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw);
sp44 = downwardSlopeYaw; shapeYawTarget = downwardSlopeYaw;
if (this->av1.actionVar1 != 0) { if (this->av1.facingUpSlope) {
sp44 = downwardSlopeYaw + 0x8000; shapeYawTarget = downwardSlopeYaw + 0x8000;
} }
if (this->speedXZ < 0) { if (this->speedXZ < 0) {
downwardSlopeYaw += 0x8000; downwardSlopeYaw += 0x8000;
} }
sp50 = (1.0f - slopeNormal.y) * 40.0f; xzSpeedTarget = (1.0f - slopeNormal.y) * 40.0f;
sp50 = CLAMP(sp50, 0, 10.0f); xzSpeedTarget = CLAMP(xzSpeedTarget, 0, 10.0f);
sp4C = (sp50 * sp50) * 0.015f; xzSpeedIncrStep = SQ(xzSpeedTarget) * 0.015f;
sp48 = slopeNormal.y * 0.01f; xzSpeedDecrStep = slopeNormal.y * 0.01f;
if (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1) { if (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1) {
sp50 = 0; xzSpeedTarget = 0;
sp48 = slopeNormal.y * 10.0f; xzSpeedDecrStep = slopeNormal.y * 10.0f;
} }
if (sp4C < 1.0f) { if (xzSpeedIncrStep < 1.0f) {
sp4C = 1.0f; xzSpeedIncrStep = 1.0f;
} }
if (Math_AsymStepToF(&this->speedXZ, sp50, sp4C, sp48) && (sp50 == 0)) { if (Math_AsymStepToF(&this->speedXZ, xzSpeedTarget, xzSpeedIncrStep, xzSpeedDecrStep) && (xzSpeedTarget == 0)) {
LinkAnimationHeader* anim; LinkAnimationHeader* slideAnimation;
if (this->av1.actionVar1 == 0) { if (!this->av1.facingUpSlope) {
anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType); slideAnimation = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType);
} else { } 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_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);
} }
} }