diff --git a/src/overlays/actors/ovl_En_Bird/z_en_bird.c b/src/overlays/actors/ovl_En_Bird/z_en_bird.c index 7ee366a324..a526cea4d8 100644 --- a/src/overlays/actors/ovl_En_Bird/z_en_bird.c +++ b/src/overlays/actors/ovl_En_Bird/z_en_bird.c @@ -14,10 +14,10 @@ void EnBird_Destroy(Actor* thisx, PlayState* play); void EnBird_Update(Actor* thisx, PlayState* play); void EnBird_Draw(Actor* thisx, PlayState* play); -void func_809C1E00(EnBird* this, s16 params); -void func_809C1E40(EnBird* this, PlayState* play); -void func_809C1D60(EnBird* this, PlayState* play); -void func_809C1CAC(EnBird* this, s16 params); +void EnBird_SetupMove(EnBird* this, s16 params); +void EnBird_Move(EnBird* this, PlayState* play); +void EnBird_Idle(EnBird* this, PlayState* play); +void EnBird_SetupIdle(EnBird* this, s16 params); ActorInit En_Bird_InitVars = { ACTOR_EN_BIRD, @@ -47,81 +47,75 @@ void EnBird_Init(Actor* thisx, PlayState* play) { SkelAnime_Init(play, &this->skelAnime, &gBirdSkel, &gBirdFlyAnim, NULL, NULL, 0); ActorShape_Init(&this->actor.shape, 5500, ActorShadow_DrawCircle, 4); this->unk_194 = 0; - this->unk_198 = 0; - this->unk_1C0 = 0x9C4; + this->timer = 0; + this->rotYStep = 2500; this->actor.colChkInfo.mass = 0; - this->unk_1A8 = 1.5f; - this->unk_1AC = 0.5f; - this->unk_1A0 = 0.0f; - this->unk_1A4 = 0.0f; - this->unk_1B8 = 0.0f; - this->unk_1B0 = 40.0f; + this->speedXZTarget = 1.5f; + this->speedXZStep = 0.5f; + this->posYMag = 0.0f; + this->rotYMag = 0.0f; + this->posYPhaseStep = 0.0f; + this->flightDistance = 40.0f; this->unk_1BC = 70.0f; - func_809C1CAC(this, this->actor.params); + EnBird_SetupIdle(this, this->actor.params); } void EnBird_Destroy(Actor* thisx, PlayState* play) { } -void func_809C1CAC(EnBird* this, s16 params) { +void EnBird_SetupIdle(EnBird* this, s16 params) { f32 frameCount = Animation_GetLastFrame(&gBirdFlyAnim); - f32 playbackSpeed = this->unk_19C ? 0.0f : 1.0f; - AnimationHeader* anim = &gBirdFlyAnim; + f32 playbackSpeed = this->scaleAnimSpeed ? 0.0f : 1.0f; - this->unk_198 = Rand_S16Offset(5, 0x23); - Animation_Change(&this->skelAnime, anim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); - EnBird_SetupAction(this, func_809C1D60); + this->timer = Rand_S16Offset(5, 35); + Animation_Change(&this->skelAnime, &gBirdFlyAnim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); + EnBird_SetupAction(this, EnBird_Idle); } -void func_809C1D60(EnBird* this, PlayState* play) { - f32 fVar2 = sinf(this->unk_1B4); - - this->actor.shape.yOffset = this->actor.shape.yOffset + fVar2 * this->unk_1A0; +void EnBird_Idle(EnBird* this, PlayState* play) { + this->actor.shape.yOffset += sinf(this->posYPhase) * this->posYMag; Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); - if (this->unk_19C != 0) { - this->skelAnime.playSpeed = this->actor.speedXZ + this->actor.speedXZ; + if (this->scaleAnimSpeed) { + this->skelAnime.playSpeed = this->actor.speedXZ * 2.0f; } SkelAnime_Update(&this->skelAnime); - this->unk_198 -= 1; + this->timer--; - if (this->unk_198 <= 0) { - func_809C1E00(this, this->actor.params); + if (this->timer <= 0) { + EnBird_SetupMove(this, this->actor.params); } } -void func_809C1E00(EnBird* this, s16 params) { - this->unk_198 = Rand_S16Offset(0x14, 0x2D); - EnBird_SetupAction(this, func_809C1E40); +void EnBird_SetupMove(EnBird* this, s16 params) { + this->timer = Rand_S16Offset(20, 45); + EnBird_SetupAction(this, EnBird_Move); } -void func_809C1E40(EnBird* this, PlayState* play) { - f32 fVar4 = sinf(this->unk_1B4); +void EnBird_Move(EnBird* this, PlayState* play) { + this->actor.shape.yOffset += sinf(this->posYPhase) * this->posYMag; + Math_SmoothStepToF(&this->actor.speedXZ, this->speedXZTarget, 0.1f, this->speedXZStep, 0.0f); - this->actor.shape.yOffset += fVar4 * this->unk_1A0; - Math_SmoothStepToF(&this->actor.speedXZ, this->unk_1A8, 0.1f, this->unk_1AC, 0.0f); - - if (this->unk_1B0 < Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) || this->unk_198 < 4) { + if (this->flightDistance < Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) || this->timer < 4) { Math_StepToAngleS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), - this->unk_1C0); + this->rotYStep); } else { - fVar4 = sinf(this->unk_1B4); - this->actor.world.rot.y += (s16)(fVar4 * this->unk_1A4); + this->actor.world.rot.y += (s16)(sinf(this->posYPhase) * this->rotYMag); } this->actor.shape.rot.y = this->actor.world.rot.y; SkelAnime_Update(&this->skelAnime); - this->unk_198 -= 1; - if (this->unk_198 < 0) { - func_809C1CAC(this, this->actor.params); + this->timer--; + if (this->timer < 0) { + EnBird_SetupIdle(this, this->actor.params); } } void EnBird_Update(Actor* thisx, PlayState* play) { EnBird* this = (EnBird*)thisx; - this->unk_1B4 += this->unk_1B8; + this->posYPhase += this->posYPhaseStep; this->actionFunc(this, play); } diff --git a/src/overlays/actors/ovl_En_Bird/z_en_bird.h b/src/overlays/actors/ovl_En_Bird/z_en_bird.h index a8a745f2da..589b72b01f 100644 --- a/src/overlays/actors/ovl_En_Bird/z_en_bird.h +++ b/src/overlays/actors/ovl_En_Bird/z_en_bird.h @@ -12,19 +12,18 @@ typedef struct EnBird { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; /* 0x0190 */ EnBirdActionFunc actionFunc; - /* 0x0194 */ u32 unk_194; - /* 0x0198 */ s32 unk_198; - /* 0x019C */ s16 unk_19C; - /* 0x019E */ char unk_19E[0x2]; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ f32 unk_1A4; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ f32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ f32 unk_1B4; - /* 0x01B8 */ f32 unk_1B8; - /* 0x01BC */ f32 unk_1BC; - /* 0x01C0 */ s16 unk_1C0; + /* 0x0194 */ u32 unk_194; // set to 0 but otherwise unused + /* 0x0198 */ s32 timer; + /* 0x019C */ s16 scaleAnimSpeed; // when true, anim speed scales with XZ speed while slowing down. otherwise anim plays full speed + /* 0x01A0 */ f32 posYMag; + /* 0x01A4 */ f32 rotYMag; + /* 0x01A8 */ f32 speedXZTarget; + /* 0x01AC */ f32 speedXZStep; + /* 0x01B0 */ f32 flightDistance; // radius of "home" area + /* 0x01B4 */ f32 posYPhase; + /* 0x01B8 */ f32 posYPhaseStep; + /* 0x01BC */ f32 unk_1BC; // set but otherwise unused. + /* 0x01C0 */ s16 rotYStep; /* 0x01C2 */ char unk_1C2[0x1A]; } EnBird; // size = 0x01DC