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

z_en_bird doc (#1431)

* `z_en_bird` doc

Documented `z_en_bird`

* `Z_en_bird` changes from feedback

* Update z_en_bird.c

* `z_en_bird`: suggested changes

* `z_en_bird`: changes based on feedback

animation speed mod field changed, redundant comments removed.
This commit is contained in:
blackgamma7 2022-11-17 15:44:40 -05:00 committed by GitHub
parent 7ecafcfe7d
commit edb6a25cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 57 deletions

View File

@ -14,10 +14,10 @@ void EnBird_Destroy(Actor* thisx, PlayState* play);
void EnBird_Update(Actor* thisx, PlayState* play); void EnBird_Update(Actor* thisx, PlayState* play);
void EnBird_Draw(Actor* thisx, PlayState* play); void EnBird_Draw(Actor* thisx, PlayState* play);
void func_809C1E00(EnBird* this, s16 params); void EnBird_SetupMove(EnBird* this, s16 params);
void func_809C1E40(EnBird* this, PlayState* play); void EnBird_Move(EnBird* this, PlayState* play);
void func_809C1D60(EnBird* this, PlayState* play); void EnBird_Idle(EnBird* this, PlayState* play);
void func_809C1CAC(EnBird* this, s16 params); void EnBird_SetupIdle(EnBird* this, s16 params);
ActorInit En_Bird_InitVars = { ActorInit En_Bird_InitVars = {
ACTOR_EN_BIRD, ACTOR_EN_BIRD,
@ -47,81 +47,75 @@ void EnBird_Init(Actor* thisx, PlayState* play) {
SkelAnime_Init(play, &this->skelAnime, &gBirdSkel, &gBirdFlyAnim, NULL, NULL, 0); SkelAnime_Init(play, &this->skelAnime, &gBirdSkel, &gBirdFlyAnim, NULL, NULL, 0);
ActorShape_Init(&this->actor.shape, 5500, ActorShadow_DrawCircle, 4); ActorShape_Init(&this->actor.shape, 5500, ActorShadow_DrawCircle, 4);
this->unk_194 = 0; this->unk_194 = 0;
this->unk_198 = 0; this->timer = 0;
this->unk_1C0 = 0x9C4; this->rotYStep = 2500;
this->actor.colChkInfo.mass = 0; this->actor.colChkInfo.mass = 0;
this->unk_1A8 = 1.5f; this->speedXZTarget = 1.5f;
this->unk_1AC = 0.5f; this->speedXZStep = 0.5f;
this->unk_1A0 = 0.0f; this->posYMag = 0.0f;
this->unk_1A4 = 0.0f; this->rotYMag = 0.0f;
this->unk_1B8 = 0.0f; this->posYPhaseStep = 0.0f;
this->unk_1B0 = 40.0f; this->flightDistance = 40.0f;
this->unk_1BC = 70.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 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 frameCount = Animation_GetLastFrame(&gBirdFlyAnim);
f32 playbackSpeed = this->unk_19C ? 0.0f : 1.0f; f32 playbackSpeed = this->scaleAnimSpeed ? 0.0f : 1.0f;
AnimationHeader* anim = &gBirdFlyAnim;
this->unk_198 = Rand_S16Offset(5, 0x23); this->timer = Rand_S16Offset(5, 35);
Animation_Change(&this->skelAnime, anim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f); Animation_Change(&this->skelAnime, &gBirdFlyAnim, playbackSpeed, 0.0f, frameCount, ANIMMODE_LOOP, 0.0f);
EnBird_SetupAction(this, func_809C1D60); EnBird_SetupAction(this, EnBird_Idle);
} }
void func_809C1D60(EnBird* this, PlayState* play) { void EnBird_Idle(EnBird* this, PlayState* play) {
f32 fVar2 = sinf(this->unk_1B4); this->actor.shape.yOffset += sinf(this->posYPhase) * this->posYMag;
this->actor.shape.yOffset = this->actor.shape.yOffset + fVar2 * this->unk_1A0;
Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f); Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 0.1f, 0.5f, 0.0f);
if (this->unk_19C != 0) { if (this->scaleAnimSpeed) {
this->skelAnime.playSpeed = this->actor.speedXZ + this->actor.speedXZ; this->skelAnime.playSpeed = this->actor.speedXZ * 2.0f;
} }
SkelAnime_Update(&this->skelAnime); SkelAnime_Update(&this->skelAnime);
this->unk_198 -= 1; this->timer--;
if (this->unk_198 <= 0) { if (this->timer <= 0) {
func_809C1E00(this, this->actor.params); EnBird_SetupMove(this, this->actor.params);
} }
} }
void func_809C1E00(EnBird* this, s16 params) { void EnBird_SetupMove(EnBird* this, s16 params) {
this->unk_198 = Rand_S16Offset(0x14, 0x2D); this->timer = Rand_S16Offset(20, 45);
EnBird_SetupAction(this, func_809C1E40); EnBird_SetupAction(this, EnBird_Move);
} }
void func_809C1E40(EnBird* this, PlayState* play) { void EnBird_Move(EnBird* this, PlayState* play) {
f32 fVar4 = sinf(this->unk_1B4); 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; if (this->flightDistance < Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) || this->timer < 4) {
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) {
Math_StepToAngleS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos), Math_StepToAngleS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->actor.home.pos),
this->unk_1C0); this->rotYStep);
} else { } else {
fVar4 = sinf(this->unk_1B4); this->actor.world.rot.y += (s16)(sinf(this->posYPhase) * this->rotYMag);
this->actor.world.rot.y += (s16)(fVar4 * this->unk_1A4);
} }
this->actor.shape.rot.y = this->actor.world.rot.y; this->actor.shape.rot.y = this->actor.world.rot.y;
SkelAnime_Update(&this->skelAnime); SkelAnime_Update(&this->skelAnime);
this->unk_198 -= 1; this->timer--;
if (this->unk_198 < 0) { if (this->timer < 0) {
func_809C1CAC(this, this->actor.params); EnBird_SetupIdle(this, this->actor.params);
} }
} }
void EnBird_Update(Actor* thisx, PlayState* play) { void EnBird_Update(Actor* thisx, PlayState* play) {
EnBird* this = (EnBird*)thisx; EnBird* this = (EnBird*)thisx;
this->unk_1B4 += this->unk_1B8; this->posYPhase += this->posYPhaseStep;
this->actionFunc(this, play); this->actionFunc(this, play);
} }

View File

@ -12,19 +12,18 @@ typedef struct EnBird {
/* 0x0000 */ Actor actor; /* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime; /* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ EnBirdActionFunc actionFunc; /* 0x0190 */ EnBirdActionFunc actionFunc;
/* 0x0194 */ u32 unk_194; /* 0x0194 */ u32 unk_194; // set to 0 but otherwise unused
/* 0x0198 */ s32 unk_198; /* 0x0198 */ s32 timer;
/* 0x019C */ s16 unk_19C; /* 0x019C */ s16 scaleAnimSpeed; // when true, anim speed scales with XZ speed while slowing down. otherwise anim plays full speed
/* 0x019E */ char unk_19E[0x2]; /* 0x01A0 */ f32 posYMag;
/* 0x01A0 */ f32 unk_1A0; /* 0x01A4 */ f32 rotYMag;
/* 0x01A4 */ f32 unk_1A4; /* 0x01A8 */ f32 speedXZTarget;
/* 0x01A8 */ f32 unk_1A8; /* 0x01AC */ f32 speedXZStep;
/* 0x01AC */ f32 unk_1AC; /* 0x01B0 */ f32 flightDistance; // radius of "home" area
/* 0x01B0 */ f32 unk_1B0; /* 0x01B4 */ f32 posYPhase;
/* 0x01B4 */ f32 unk_1B4; /* 0x01B8 */ f32 posYPhaseStep;
/* 0x01B8 */ f32 unk_1B8; /* 0x01BC */ f32 unk_1BC; // set but otherwise unused.
/* 0x01BC */ f32 unk_1BC; /* 0x01C0 */ s16 rotYStep;
/* 0x01C0 */ s16 unk_1C0;
/* 0x01C2 */ char unk_1C2[0x1A]; /* 0x01C2 */ char unk_1C2[0x1A];
} EnBird; // size = 0x01DC } EnBird; // size = 0x01DC