diff --git a/assets/xml/objects/object_bee.xml b/assets/xml/objects/object_bee.xml index 735d191f39..8fcd930fac 100644 --- a/assets/xml/objects/object_bee.xml +++ b/assets/xml/objects/object_bee.xml @@ -1,28 +1,38 @@  + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c index 8f02a8bb45..0bb112b437 100644 --- a/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c +++ b/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.c @@ -31,7 +31,7 @@ const ActorInit Dm_Char09_InitVars = { }; static AnimationInfo sAnimationInfo[] = { - { &object_bee_Anim_00005C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &gBeeFlyingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, }; void DmChar09_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { @@ -53,8 +53,8 @@ void DmChar09_Init(Actor* thisx, PlayState* play) { DmChar09* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); - SkelAnime_Init(play, &this->skelAnime, &object_bee_Skel_001398, &object_bee_Anim_00005C, this->jointTable, - this->morphTable, OBJECT_BEE_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gBeeSkel, &gBeeFlyingAnim, this->jointTable, this->morphTable, + OBJECT_BEE_LIMB_MAX); DmChar09_ChangeAnim(&this->skelAnime, sAnimationInfo, 0); Actor_SetScale(&this->actor, 0.01f); this->unk_228 = Rand_ZeroOne() * 65535.0f; diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.c b/src/overlays/actors/ovl_En_Bee/z_en_bee.c index 0a0c6dd3fd..7d40e99313 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.c +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.c @@ -15,12 +15,12 @@ void EnBee_Destroy(Actor* thisx, PlayState* play); void EnBee_Update(Actor* thisx, PlayState* play); void EnBee_Draw(Actor* thisx, PlayState* play); -void func_80B5A9E8(EnBee* this, PlayState* play); -void func_80B5AC3C(EnBee* this, PlayState* play); -void func_80B5A854(EnBee* this); -void func_80B5ABC4(EnBee* this); +void EnBee_SetupFlyIdle(EnBee* this); +void EnBee_FlyIdle(EnBee* this, PlayState* play); +void EnBee_SetupAttack(EnBee* this); +void EnBee_Attack(EnBee* this, PlayState* play); -s32 D_80B5B1F0 = 0; +s32 sNumLoadedBees = 0; const ActorInit En_Bee_InitVars = { ACTOR_EN_BEE, @@ -94,14 +94,14 @@ void EnBee_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = 10; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); - SkelAnime_Init(play, &this->skelAnime, &object_bee_Skel_001398, &object_bee_Anim_00005C, this->morphTable, - this->jointTable, OBJECT_BEE_LIMB_MAX); + SkelAnime_Init(play, &this->skelAnime, &gBeeSkel, &gBeeFlyingAnim, this->morphTable, this->jointTable, + OBJECT_BEE_LIMB_MAX); this->actor.colChkInfo.health = 1; this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.targetMode = 6; Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->unk_218 = D_80B5B1F0; - D_80B5B1F0++; + this->instanceId = sNumLoadedBees; + sNumLoadedBees++; this->actor.shape.shadowScale = 12.0f; if (ActorCutscene_GetCurrentIndex() != -1) { @@ -109,7 +109,7 @@ void EnBee_Init(Actor* thisx, PlayState* play) { } this->actor.hintId = TATL_HINT_ID_GIANT_BEE; - func_80B5A854(this); + EnBee_SetupFlyIdle(this); } void EnBee_Destroy(Actor* thisx, PlayState* play) { @@ -118,121 +118,122 @@ void EnBee_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80B5A854(EnBee* this) { +void EnBee_SetupFlyIdle(EnBee* this) { s32 pad; - Vec3f sp48; - s16 sp46; + Vec3f tempPos; + s16 yawOffset; - Animation_Change(&this->skelAnime, &object_bee_Anim_00005C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_bee_Anim_00005C), 0, -10.0f); - Math_Vec3f_Copy(&sp48, &this->actor.home.pos); + Animation_Change(&this->skelAnime, &gBeeFlyingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeeFlyingAnim), 0, -10.0f); + Math_Vec3f_Copy(&tempPos, &this->actor.home.pos); - sp46 = (this->unk_218 * 0x700) + 0x2000; - sp48.x += Math_SinS(sp46) * 50.0f; - sp48.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); - sp48.z += Math_CosS(sp46) * 50.0f; + yawOffset = (this->instanceId * 0x700) + 0x2000; + tempPos.x += Math_SinS(yawOffset) * 50.0f; + tempPos.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + tempPos.z += Math_CosS(yawOffset) * 50.0f; - Math_Vec3f_Copy(&this->unk_21C[0], &sp48); - Math_Vec3f_Copy(&sp48, &this->actor.home.pos); + Math_Vec3f_Copy(&this->targetPos[0], &tempPos); + Math_Vec3f_Copy(&tempPos, &this->actor.home.pos); - sp48.x += Math_SinS(sp46 - 0x4000) * 50.0f; - sp48.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); - sp48.z += Math_CosS(sp46 - 0x4000) * 50.0f; + tempPos.x += Math_SinS(yawOffset - 0x4000) * 50.0f; + tempPos.y = Rand_ZeroFloat(50.0f) + (this->actor.floorHeight + 30.0f); + tempPos.z += Math_CosS(yawOffset - 0x4000) * 50.0f; - Math_Vec3f_Copy(&this->unk_21C[1], &sp48); + Math_Vec3f_Copy(&this->targetPos[1], &tempPos); - this->unk_204 = Rand_S16Offset(0x14, 0x1E); - this->unk_208 = 0; - this->actionFunc = func_80B5A9E8; + this->attackDelayTimer = Rand_S16Offset(20, 30); + this->isHostile = false; + this->actionFunc = EnBee_FlyIdle; } -void func_80B5A9E8(EnBee* this, PlayState* play) { - Vec3f sp3C; +void EnBee_FlyIdle(EnBee* this, PlayState* play) { + Vec3f nextPos; s32 pad[2]; if ((this->actor.category != ACTORCAT_ENEMY) && (ActorCutscene_GetCurrentIndex() == -1)) { func_800BC154(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); } - Math_Vec3f_Copy(&sp3C, &this->unk_21C[this->unk_214]); - sp3C.x += Math_SinS(this->unk_20C) * 30.0f; - sp3C.z += Math_CosS(this->unk_20C) * 30.0f; + Math_Vec3f_Copy(&nextPos, &this->targetPos[this->posIndex]); + nextPos.x += Math_SinS(this->targetYaw) * 30.0f; + nextPos.z += Math_CosS(this->targetYaw) * 30.0f; - if (!(this->unk_218 & 1)) { - this->unk_20C += (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + if ((this->instanceId % 2) == 0) { + this->targetYaw += (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); } else { - this->unk_20C -= (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); + this->targetYaw -= (s16)((s32)randPlusMinusPoint5Scaled(1000.0f) + 4000); } - this->unk_210 += 1000; - this->actor.velocity.y = Math_SinS(this->unk_210); + this->flightHoverOffset += 1000; + this->actor.velocity.y = Math_SinS(this->flightHoverOffset); - if (this->unk_20C > 0x10000) { - this->unk_20C = 0; - this->unk_214++; - this->unk_214 &= 1; + if (this->targetYaw > 0x10000) { + this->targetYaw = 0; + this->posIndex++; + this->posIndex &= 1; } - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp3C), 1, 0x7D0, 0); + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x7D0, 0); Math_ApproachF(&this->actor.speedXZ, 3.0f, 0.3f, 1.0f); - if ((this->unk_204 == 0) && (this->actor.params != 0)) { - func_80B5ABC4(this); + if ((this->attackDelayTimer == 0) && (this->actor.params != BEE_BEHAVIOR_IDLE)) { + EnBee_SetupAttack(this); } } -void func_80B5ABC4(EnBee* this) { - Animation_Change(&this->skelAnime, &object_bee_Anim_00005C, 1.0f, 0.0f, - Animation_GetLastFrame(&object_bee_Anim_00005C), 0, -10.0f); - this->unk_208 = 1; - this->actionFunc = func_80B5AC3C; +void EnBee_SetupAttack(EnBee* this) { + Animation_Change(&this->skelAnime, &gBeeFlyingAnim, 1.0f, 0.0f, Animation_GetLastFrame(&gBeeFlyingAnim), 0, -10.0f); + this->isHostile = true; + this->actionFunc = EnBee_Attack; } -void func_80B5AC3C(EnBee* this, PlayState* play) { +void EnBee_Attack(EnBee* this, PlayState* play) { Player* player = GET_PLAYER(play); - Vec3f sp88; - f32 rnd; - f32 phi_fs1; + Vec3f nextPos; + f32 rand; + f32 yawOffset; s32 i; - Math_Vec3f_Copy(&sp88, &player->actor.world.pos); - phi_fs1 = (this->unk_218 * 0x700) + 0x2000; + Math_Vec3f_Copy(&nextPos, &player->actor.world.pos); + yawOffset = (this->instanceId * 0x700) + 0x2000; for (i = 0; i < 2; i++) { - rnd = randPlusMinusPoint5Scaled(20.0f); - sp88.x += Math_SinS((this->actor.yawTowardsPlayer + ((f32)this->unk_20C)) + phi_fs1) * (rnd + 30.0f); - sp88.y = (Math_SinS(this->unk_210) * 10.0f) + (player->actor.floorHeight + 40.0f); - rnd = randPlusMinusPoint5Scaled(20.0f); - sp88.z += Math_CosS((f32)this->actor.yawTowardsPlayer + this->unk_20C + phi_fs1) * (rnd + 30.0f); - Math_Vec3f_Copy(&this->unk_21C[i], &sp88); - phi_fs1 -= 16384.0f; + rand = randPlusMinusPoint5Scaled(20.0f); + nextPos.x += Math_SinS((f32)this->actor.yawTowardsPlayer + this->targetYaw + yawOffset) * (rand + 30.0f); + nextPos.y = (Math_SinS(this->flightHoverOffset) * 10.0f) + (player->actor.floorHeight + 40.0f); + rand = randPlusMinusPoint5Scaled(20.0f); + + nextPos.z += Math_CosS((f32)this->actor.yawTowardsPlayer + this->targetYaw + yawOffset) * (rand + 30.0f); + Math_Vec3f_Copy(&this->targetPos[i], &nextPos); + yawOffset -= 0x4000; } - Math_Vec3f_Copy(&sp88, &this->unk_21C[this->unk_214]); + Math_Vec3f_Copy(&nextPos, &this->targetPos[this->posIndex]); - if (!(this->unk_218 & 1)) { - this->unk_20C += (this->unk_218 * 0x700) + (s32)randPlusMinusPoint5Scaled((this->unk_218 * 0x700) * 0.5f); + if ((this->instanceId % 2) == 0) { + this->targetYaw += + (this->instanceId * 0x700) + (s32)randPlusMinusPoint5Scaled((this->instanceId * 0x700) * 0.5f); } else { - this->unk_20C -= (this->unk_218 * 0x700) + (s32)randPlusMinusPoint5Scaled((this->unk_218 * 0x700) * 0.5f); + this->targetYaw -= + (this->instanceId * 0x700) + (s32)randPlusMinusPoint5Scaled((this->instanceId * 0x700) * 0.5f); } - this->unk_210 += (s32)randPlusMinusPoint5Scaled(500.0f) + 1000; + this->flightHoverOffset += (s32)randPlusMinusPoint5Scaled(500.0f) + 1000; - if (this->unk_20C > 0x10000) { - this->unk_20C = 0; - this->unk_214++; - this->unk_214 &= 1; + if (this->targetYaw > 0x10000) { + this->targetYaw = 0; + this->posIndex++; + this->posIndex &= 1; } - Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp88), 1, 0x1388, 0); - Math_ApproachF(&this->actor.world.pos.y, sp88.y, 0.3f, 3.0f); + Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &nextPos), 1, 0x1388, 0); + Math_ApproachF(&this->actor.world.pos.y, nextPos.y, 0.3f, 3.0f); Math_ApproachF(&this->actor.speedXZ, 5.0f, 0.3f, 1.0f); } -void func_80B5AF80(EnBee* this, PlayState* play) { - if ((this->unk_206 == 0) && (this->collider.base.atFlags & AC_HIT)) { +void EnBee_UpdateDamage(EnBee* this, PlayState* play) { + if ((this->sfxHitTimer == 0) && (this->collider.base.atFlags & AT_HIT)) { AudioSfx_StopByPosAndId(&this->actor.projectedPos, NA_SE_EN_BEE_FLY - SFX_FLAG); - this->unk_206 = 5; + this->sfxHitTimer = 5; } if (this->collider.base.acFlags & AC_HIT) { @@ -253,16 +254,16 @@ void EnBee_Update(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (this->actor.category == ACTORCAT_ENEMY) { - if (this->unk_204 != 0) { - this->unk_204--; + if (this->attackDelayTimer != 0) { + this->attackDelayTimer--; } - if (this->unk_206 != 0) { - this->unk_206--; + if (this->sfxHitTimer != 0) { + this->sfxHitTimer--; } } Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_BEE_FLY - SFX_FLAG); - func_80B5AF80(this, play); + EnBee_UpdateDamage(this, play); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Actor_SetFocus(&this->actor, 0.0f); Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Bee/z_en_bee.h b/src/overlays/actors/ovl_En_Bee/z_en_bee.h index 1638407ee0..851a0a2162 100644 --- a/src/overlays/actors/ovl_En_Bee/z_en_bee.h +++ b/src/overlays/actors/ovl_En_Bee/z_en_bee.h @@ -8,20 +8,25 @@ struct EnBee; typedef void (*EnBeeActionFunc)(struct EnBee*, PlayState*); +typedef enum { + /* 0 */ BEE_BEHAVIOR_IDLE = 0, + /* 1 */ BEE_BEHAVIOR_ATTACK, +} BeeBehaviorType; + typedef struct EnBee { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s morphTable[OBJECT_BEE_LIMB_MAX]; /* 0x1C4 */ Vec3s jointTable[OBJECT_BEE_LIMB_MAX]; /* 0x200 */ EnBeeActionFunc actionFunc; - /* 0x204 */ s16 unk_204; - /* 0x206 */ s16 unk_206; - /* 0x208 */ s16 unk_208; - /* 0x20C */ s32 unk_20C; - /* 0x210 */ s32 unk_210; - /* 0x214 */ s32 unk_214; - /* 0x218 */ s32 unk_218; - /* 0x21C */ Vec3f unk_21C[2]; + /* 0x204 */ s16 attackDelayTimer; + /* 0x206 */ s16 sfxHitTimer; + /* 0x208 */ s16 isHostile; // set and not used + /* 0x20C */ s32 targetYaw; + /* 0x210 */ s32 flightHoverOffset; + /* 0x214 */ s32 posIndex; + /* 0x218 */ s32 instanceId; + /* 0x21C */ Vec3f targetPos[2]; /* 0x234 */ UNK_TYPE1 pad234[8]; /* 0x23C */ ColliderCylinder collider; } EnBee; // size = 0x288