1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

Cleanup player speed and yaw variable names (#1480)

* initial changes

* add comments
This commit is contained in:
fig02 2023-01-02 06:15:48 -05:00 committed by GitHub
parent e77b83cf1b
commit b4c97ce17e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 341 additions and 340 deletions

View File

@ -686,9 +686,9 @@ typedef struct Player {
/* 0x0834 */ s16 unk_834;
/* 0x0836 */ s8 unk_836;
/* 0x0837 */ u8 unk_837;
/* 0x0838 */ f32 linearVelocity;
/* 0x083C */ s16 currentYaw;
/* 0x083E */ s16 targetYaw;
/* 0x0838 */ f32 speedXZ; // Controls horizontal speed, used for `actor.speed`. Current or target value depending on context.
/* 0x083C */ s16 yaw; // General yaw value, used both for world and shape rotation. Current or target value depending on context.
/* 0x083E */ s16 zTargetYaw; // yaw relating to Z targeting/"parallel" mode
/* 0x0840 */ u16 underwaterTimer;
/* 0x0842 */ s8 meleeWeaponAnimation;
/* 0x0843 */ s8 meleeWeaponState;

View File

@ -59,7 +59,7 @@ void DynaPolyActor_UpdateCarriedActorRotY(CollisionContext* colCtx, s32 bgId, Ac
s16 rotY = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y;
if (carriedActor->id == ACTOR_PLAYER) {
((Player*)carriedActor)->currentYaw += rotY;
((Player*)carriedActor)->yaw += rotY;
}
carriedActor->shape.rot.y += rotY;

View File

@ -664,7 +664,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
Play_SetCameraAtEye(play, subCamId, &spC0, &spB4);
subCam->roll = 0;
subCam->fov = 75.0f;
player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spD0.yaw + 0x7FFF;
player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = spD0.yaw + 0x7FFF;
func_8002DF54(play, NULL, PLAYER_CSMODE_8);
break;
@ -708,7 +708,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
break;
case 3390:
player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = -0x3FD9;
player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = -0x3FD9;
csInfo->keyFrames = D_80121DB4;
csInfo->keyFrameCount = ARRAY_COUNT(D_80121DB4);
@ -733,7 +733,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
D_80121F1C[0].eyeTargetInit = play->view.eye;
D_80121F1C[0].fovTargetInit = play->view.fovy;
Actor_GetFocus(&spA0, actor);
player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spA0.rot.y;
player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = spA0.rot.y;
csInfo->keyFrames = D_80121F1C;
csInfo->keyFrameCount = ARRAY_COUNT(D_80121F1C);
@ -857,7 +857,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act
csInfo->keyFrames = D_801225D4;
csInfo->keyFrameCount = ARRAY_COUNT(D_801225D4);
player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = 0x3FFC;
player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = 0x3FFC;
Play_InitCameraDataUsingPlayer(play, subCamId, player, CAM_SET_CS_C);
func_8002DF54(play, NULL, PLAYER_CSMODE_8);
break;

View File

@ -363,10 +363,10 @@ void BossSst_HeadSetupIntro(BossSst* this, PlayState* play) {
player->actor.world.pos.x = sRoomCenter.x;
player->actor.world.pos.y = ROOM_CENTER_Y + 1000.0f;
player->actor.world.pos.z = sRoomCenter.z;
player->linearVelocity = player->actor.velocity.y = 0.0f;
player->speedXZ = player->actor.velocity.y = 0.0f;
player->actor.shape.rot.y = -0x8000;
player->targetYaw = -0x8000;
player->currentYaw = -0x8000;
player->zTargetYaw = -0x8000;
player->yaw = -0x8000;
player->fallStartHeight = 0;
player->stateFlags1 |= PLAYER_STATE1_5;
@ -422,10 +422,10 @@ void BossSst_HeadIntro(BossSst* this, PlayState* play) {
if (player->actor.world.pos.y > 100.0f) {
player->actor.world.pos.x = sRoomCenter.x;
player->actor.world.pos.z = sRoomCenter.z;
player->linearVelocity = 0;
player->speedXZ = 0;
player->actor.shape.rot.y = -0x8000;
player->targetYaw = -0x8000;
player->currentYaw = -0x8000;
player->zTargetYaw = -0x8000;
player->yaw = -0x8000;
}
Math_Vec3f_Copy(&sSubCamAt, &player->actor.world.pos);

View File

@ -203,7 +203,7 @@ void EnEncount2_SpawnRocks(EnEncount2* this, PlayState* play) {
tempVec2X = Rand_CenteredFloat(10.0f) + player->actor.world.pos.x;
tempVec2Z = Rand_CenteredFloat(10.0f) + player->actor.world.pos.z;
} else {
if (player->linearVelocity != 0.0f) {
if (player->speedXZ != 0.0f) {
// rock spawn pos is between 300 and 600 units from the camera depending on the camera yaw.
// Rocks will generally spawn closer to the camera in the X axis than in the Z axis.
tempVec2X = Rand_CenteredFloat(200.0f) + (play->view.eye.x + (tempVec2X * 300.0f));

View File

@ -620,7 +620,7 @@ void EnFr_Idle(EnFr* this, PlayState* play) {
player->actor.world.pos.x = this->actor.world.pos.x; // x = 990.0f
player->actor.world.pos.y = this->actor.world.pos.y; // y = 205.0f
player->actor.world.pos.z = this->actor.world.pos.z; // z = -1220.0f
player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y;
player->yaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y;
this->reward = GI_NONE;
this->actionFunc = EnFr_Activate;
} else if (EnFr_IsAboveAndWithin30DistXZ(player, this)) {

View File

@ -178,12 +178,13 @@ void EnReeba_Destroy(Actor* thisx, PlayState* play) {
void EnReeba_SetupSurface(EnReeba* this, PlayState* play) {
f32 frames = Animation_GetLastFrame(&object_reeba_Anim_0001E4);
Player* player = GET_PLAYER(play);
s16 playerSpeed;
s16 absPlayerSpeedXZ;
Animation_Change(&this->skelanime, &object_reeba_Anim_0001E4, 2.0f, 0.0f, frames, ANIMMODE_LOOP, -10.0f);
playerSpeed = fabsf(player->linearVelocity);
this->waitTimer = 20 - playerSpeed * 2;
absPlayerSpeedXZ = fabsf(player->speedXZ);
this->waitTimer = 20 - absPlayerSpeedXZ * 2;
if (this->waitTimer < 0) {
this->waitTimer = 2;
}
@ -205,7 +206,7 @@ void EnReeba_SetupSurface(EnReeba* this, PlayState* play) {
void EnReeba_Surface(EnReeba* this, PlayState* play) {
Player* player = GET_PLAYER(play);
f32 playerLinearVel;
f32 playerSpeedXZ;
SkelAnime_Update(&this->skelanime);
@ -222,23 +223,23 @@ void EnReeba_Surface(EnReeba* this, PlayState* play) {
} else {
this->yOffsetStep = 0.0f;
this->actor.shape.yOffset = 0.0f;
playerLinearVel = player->linearVelocity;
playerSpeedXZ = player->speedXZ;
switch (this->aimType) {
case 0:
this->actor.world.rot.y = this->actor.yawTowardsPlayer;
break;
case 1:
this->actor.world.rot.y = this->actor.yawTowardsPlayer + (800.0f * playerLinearVel);
this->actor.world.rot.y = this->actor.yawTowardsPlayer + (800.0f * playerSpeedXZ);
break;
case 2:
case 3:
this->actor.world.rot.y =
this->actor.yawTowardsPlayer +
(player->actor.shape.rot.y - this->actor.yawTowardsPlayer) * (playerLinearVel * 0.15f);
(player->actor.shape.rot.y - this->actor.yawTowardsPlayer) * (playerSpeedXZ * 0.15f);
break;
case 4:
this->actor.world.rot.y = this->actor.yawTowardsPlayer - (800.0f * playerLinearVel);
this->actor.world.rot.y = this->actor.yawTowardsPlayer - (800.0f * playerSpeedXZ);
break;
}

View File

@ -859,7 +859,7 @@ void func_80AEC780(EnRu1* this, PlayState* play) {
play->csCtx.script = D_80AF0880;
gSaveContext.cutsceneTrigger = 1;
player->linearVelocity = 0.0f;
player->speedXZ = 0.0f;
this->action = 8;
}
}

View File

@ -153,12 +153,12 @@ void func_80AFBE8C(EnSiofuki* this, PlayState* play) {
speedScale = dist2d / (this->dyna.actor.scale.x * 40.0f * 10.0f);
speedScale = CLAMP_MIN(speedScale, 0.0f);
speedScale = CLAMP_MAX(speedScale, 1.0f);
player->linearVelocity *= speedScale;
player->speedXZ *= speedScale;
Math_ApproachF(&this->targetAppliedSpeed, 3.0f, 1.0f, 1.0f);
Math_ApproachF(&this->appliedSpeed, this->targetAppliedSpeed, 1.0f, 0.3f * speedScale);
} else {
this->appliedYaw = player->actor.world.rot.y;
player->linearVelocity /= 2.0f;
player->speedXZ /= 2.0f;
Math_ApproachF(&this->targetAppliedSpeed, 3.0f, 1.0f, 1.0f);
Math_ApproachF(&this->appliedSpeed, this->targetAppliedSpeed, 1.0f, 0.1f);
}
@ -168,8 +168,8 @@ void func_80AFBE8C(EnSiofuki* this, PlayState* play) {
}
} else {
if (this->applySpeed) {
player->linearVelocity = this->appliedSpeed + player->linearVelocity;
player->currentYaw = this->appliedYaw;
player->speedXZ = this->appliedSpeed + player->speedXZ;
player->yaw = this->appliedYaw;
}
this->targetAppliedSpeed = 0.0f;

View File

@ -1356,7 +1356,7 @@ void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, PlayState* play) {
void EnSkj_TurnPlayer(EnSkj* this, Player* player) {
Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.world.rot.y, 5, 2000, 0);
player->actor.world.rot.y = player->actor.shape.rot.y;
player->currentYaw = player->actor.shape.rot.y;
player->yaw = player->actor.shape.rot.y;
}
void EnSkj_SetupWaitForOcarina(EnSkj* this, PlayState* play) {

View File

@ -105,7 +105,7 @@ void EnSyatekiItm_Idle(EnSyatekiItm* this, PlayState* play) {
player->actor.world.pos.x = -12.0f;
player->actor.world.pos.y = 20.0f;
player->actor.world.pos.z = 182.0f;
player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = 0x7F03;
player->yaw = player->actor.world.rot.y = player->actor.shape.rot.y = 0x7F03;
player->actor.world.rot.x = player->actor.shape.rot.x = player->actor.world.rot.z = player->actor.shape.rot.z =
0;
func_8008EF44(play, 15);

View File

@ -153,7 +153,7 @@ s32 EnTorch2_SwingSword(PlayState* play, Input* input, Player* this) {
s32 attackDelay = 7;
Player* player = GET_PLAYER(play);
if ((this->linearVelocity < 0.0f) || (player->linearVelocity < 0.0f)) {
if ((this->speedXZ < 0.0f) || (player->speedXZ < 0.0f)) {
return 0;
}
if (gSaveContext.health < 0x50) {
@ -368,9 +368,9 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
this->actor.flags &= ~ACTOR_FLAG_0;
sSwordJumpTimer = 27;
player->meleeWeaponState = 0;
player->linearVelocity = 0.0f;
player->speedXZ = 0.0f;
this->invincibilityTimer = -7;
this->linearVelocity = 0.0f;
this->speedXZ = 0.0f;
player->skelAnime.curFrame = 2.0f;
LinkAnimation_Update(play, &player->skelAnime);
sHoldShieldTimer = 0;
@ -630,7 +630,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
*/
input->cur.button = 0;
input->press.button = 0;
this->linearVelocity = 0.0f;
this->speedXZ = 0.0f;
}
play->playerUpdate(this, play, input);
@ -639,17 +639,17 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
* Handles sword clanks and removes their recoil for both Links. Dark Link staggers
* if he's had to counter with enough different sword animations in a row.
*/
if (this->linearVelocity == -18.0f) {
if (this->speedXZ == -18.0f) {
staggerThreshold = (u32)Rand_CenteredFloat(2.0f) + 6;
if (gSaveContext.health < 0x50) {
staggerThreshold = (u32)Rand_CenteredFloat(2.0f) + 3;
}
if (this->actor.xzDistToPlayer > 80.0f) {
this->linearVelocity = 1.2f;
this->speedXZ = 1.2f;
} else if (this->actor.xzDistToPlayer < 70.0f) {
this->linearVelocity = -1.5f;
this->speedXZ = -1.5f;
} else {
this->linearVelocity = 1.0f;
this->speedXZ = 1.0f;
}
if (staggerThreshold < sStaggerCount) {
this->skelAnime.playSpeed *= 0.6f;
@ -658,13 +658,13 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) {
sStaggerCount = 0;
}
}
if (player->linearVelocity == -18.0f) {
if (player->speedXZ == -18.0f) {
if (this->actor.xzDistToPlayer > 80.0f) {
player->linearVelocity = 1.2f;
player->speedXZ = 1.2f;
} else if (this->actor.xzDistToPlayer < 70.0f) {
player->linearVelocity = -1.5f;
player->speedXZ = -1.5f;
} else {
player->linearVelocity = 1.0f;
player->speedXZ = 1.0f;
}
}
/*

View File

@ -382,7 +382,7 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) {
if (this->unk_14C >= -1) {
if (((player->rideActor == NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 20.0) &&
(player->linearVelocity != 0.0f)) ||
(player->speedXZ != 0.0f)) ||
((player->rideActor != NULL) && (sqrt(this->actor.xyzDistToPlayerSq) < 60.0) &&
(player->rideActor->speed != 0.0f))) {
if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) {

View File

@ -326,7 +326,7 @@ s32 EnZl4_SetupFromLegendCs(EnZl4* this, PlayState* play) {
playerx->world.pos.x += 56.0f * Math_SinS(rotY);
playerx->world.pos.z += 56.0f * Math_CosS(rotY);
player->linearVelocity = playerx->speed = 0.0f;
player->speedXZ = playerx->speed = 0.0f;
EnZl4_SetActiveCamMove(play, 5);
Letterbox_SetSizeTarget(32);
@ -438,7 +438,7 @@ s32 EnZl4_CsWaitForPlayer(EnZl4* this, PlayState* play) {
playerx->world.pos.x += 56.0f * Math_SinS(rotY);
playerx->world.pos.z += 56.0f * Math_CosS(rotY);
playerx->speed = 0.0f;
player->linearVelocity = 0.0f;
player->speedXZ = 0.0f;
return true;
}

File diff suppressed because it is too large Load Diff