diff --git a/assets/xml/objects/object_bh.xml b/assets/xml/objects/object_bh.xml index 84f3050c01..56b7de5f9b 100644 --- a/assets/xml/objects/object_bh.xml +++ b/assets/xml/objects/object_bh.xml @@ -1,18 +1,18 @@  - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/spec b/spec index 8202925c8a..dabaf8bb84 100644 --- a/spec +++ b/spec @@ -5154,8 +5154,7 @@ beginseg name "ovl_En_Bh" compress include "build/src/overlays/actors/ovl_En_Bh/z_en_bh.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.data.o" - include "build/data/ovl_En_Bh/ovl_En_Bh.reloc.o" + include "build/src/overlays/actors/ovl_En_Bh/ovl_En_Bh_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.c b/src/overlays/actors/ovl_En_Bh/z_en_bh.c index 01284d2bf9..b18bedfc94 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.c +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.c @@ -15,7 +15,8 @@ void EnBh_Destroy(Actor* thisx, PlayState* play); void EnBh_Update(Actor* thisx, PlayState* play); void EnBh_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80C22DEC(EnBh* this, PlayState* play); + const ActorInit En_Bh_InitVars = { ACTOR_EN_BH, ACTORCAT_ITEMACTION, @@ -28,16 +29,93 @@ const ActorInit En_Bh_InitVars = { (ActorFunc)EnBh_Draw, }; -#endif +void EnBh_Init(Actor* thisx, PlayState* play) { + EnBh* this = THIS; -extern UNK_TYPE D_06000074; + this->actor.flags &= ~ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + SkelAnime_InitFlex(play, &this->skelanime, &gBhSkel, &gBhFlyingAnim, this->jointTable, this->morphTable, + OBJECT_BH_LIMB_MAX); + Animation_PlayLoop(&this->skelanime, &gBhFlyingAnim); + this->actionFunc = func_80C22DEC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Init.s") +void EnBh_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Destroy.s") +void func_80C22DEC(EnBh* this, PlayState* play) { + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 xzDist; + s16 xRot; + s16 yRot; + s16 zRot; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/func_80C22DEC.s") + this->actor.speedXZ = 3.0f; + xDiff = this->pos.x - this->actor.world.pos.x; + yDiff = this->pos.y - this->actor.world.pos.y; + zDiff = this->pos.z - this->actor.world.pos.z; + xzDist = sqrtf(SQ(xDiff) + SQ(zDiff)); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Update.s") + if ((this->timer2 == 0) || (xzDist < 100.0f)) { + this->pos.x = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.x; + this->pos.y = randPlusMinusPoint5Scaled(100.0f) + this->actor.home.pos.y; + this->pos.z = randPlusMinusPoint5Scaled(300.0f) + this->actor.home.pos.z; + this->timer2 = Rand_ZeroFloat(50.0f) + 30.0f; + this->step = 0; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Draw.s") + yRot = Math_Atan2S(xDiff, zDiff); + xRot = Math_Atan2S(yDiff, xzDist); + zRot = Math_SmoothStepToS(&this->actor.world.rot.y, yRot, 0xA, this->step, 0); + + if (zRot > 0x1000) { + zRot = 0x1000; + } else if (zRot < -0x1000) { + zRot = -0x1000; + } + + Math_ApproachS(&this->actor.world.rot.x, xRot, 0xA, this->step); + Math_ApproachS(&this->actor.world.rot.z, -zRot, 0xA, this->step); + Math_ApproachS(&this->step, 0x200, 1, 0x10); + + if ((s32)this->skelanime.playSpeed == 0) { + if (this->timer == 0) { + this->skelanime.playSpeed = 1.0f; + this->timer = Rand_ZeroFloat(70.0f) + 50.0f; + } else if (((this->timer & 7) == 7) && (Rand_ZeroOne() < 0.5f)) { + this->unk1E4 = randPlusMinusPoint5Scaled(3000.0f); + } + } else { + SkelAnime_Update(&this->skelanime); + if ((this->timer == 0) && (Animation_OnFrame(&this->skelanime, 6.0f))) { + this->skelanime.playSpeed = 0.0f; + this->timer = Rand_ZeroFloat(50.0f) + 50.0f; + } + } + + this->actor.shape.rot.x = -this->actor.world.rot.x; + this->actor.shape.rot.y = this->actor.world.rot.y; + this->actor.shape.rot.z = this->actor.world.rot.z; + Math_ApproachS(&this->unk1E2, this->unk1E4, 3, 0x3E8); +} + +void EnBh_Update(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + Actor_MoveWithoutGravity(&this->actor); + DECR(this->timer2); + DECR(this->timer); + this->actionFunc(this, play); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); +} + +void EnBh_Draw(Actor* thisx, PlayState* play) { + EnBh* this = THIS; + + func_8012C28C(play->state.gfxCtx); + Matrix_RotateZS(this->unk1E2, MTXMODE_APPLY); + SkelAnime_DrawFlexOpa(play, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, NULL, + NULL, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Bh/z_en_bh.h b/src/overlays/actors/ovl_En_Bh/z_en_bh.h index 11c475e3ff..b5e8a7c0c9 100644 --- a/src/overlays/actors/ovl_En_Bh/z_en_bh.h +++ b/src/overlays/actors/ovl_En_Bh/z_en_bh.h @@ -2,15 +2,24 @@ #define Z_EN_BH_H #include "global.h" +#include "objects/object_bh/object_bh.h" struct EnBh; typedef void (*EnBhActionFunc)(struct EnBh*, PlayState*); typedef struct EnBh { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xA4]; - /* 0x01E8 */ EnBhActionFunc actionFunc; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelanime; + /* 0x188 */ Vec3s jointTable[OBJECT_BH_LIMB_MAX]; + /* 0x1AC */ Vec3s morphTable[OBJECT_BH_LIMB_MAX]; + /* 0x1D0 */ Vec3f pos; + /* 0x1DC */ s16 timer; + /* 0x1DE */ s16 timer2; + /* 0x1E0 */ s16 step; + /* 0x1E2 */ s16 unk1E2; + /* 0x1E4 */ s16 unk1E4; + /* 0x1E8 */ EnBhActionFunc actionFunc; } EnBh; // size = 0x1EC extern const ActorInit En_Bh_InitVars;