summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlejandro Asenjo <96613413+sonicdcer@users.noreply.github.com>2022-07-11 23:36:11 -0300
committerGitHub <noreply@github.com>2022-07-11 22:36:11 -0400
commita2f78fbc4453cb3cef02e7579366d07a1598b08d (patch)
treec7e56959aed92092c05e99c2ac77928f8f086191 /src
parent9726a30109b278192f52b2d36ac9abf36f3a3965 (diff)
ovl_En_Bh Decompiled (#906)
* ovl_En_Bh Decompiled * some minor things * Documentation * pr review * gEnBh - > gBh * noneSkel nonsense fix * pr review * pr review
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_En_Bh/z_en_bh.c94
-rw-r--r--src/overlays/actors/ovl_En_Bh/z_en_bh.h15
2 files changed, 98 insertions, 11 deletions
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 01284d2bf..b18bedfc9 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;
+
+ 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;
+}
+
+void EnBh_Destroy(Actor* thisx, PlayState* play) {
+}
+
+void func_80C22DEC(EnBh* this, PlayState* play) {
+ f32 xDiff;
+ f32 yDiff;
+ f32 zDiff;
+ f32 xzDist;
+ s16 xRot;
+ s16 yRot;
+ s16 zRot;
+
+ 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));
+
+ 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;
+ }
+
+ 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);
-extern UNK_TYPE D_06000074;
+ 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;
+ }
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Init.s")
+ 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);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Destroy.s")
+void EnBh_Update(Actor* thisx, PlayState* play) {
+ EnBh* this = THIS;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/func_80C22DEC.s")
+ 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);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Update.s")
+void EnBh_Draw(Actor* thisx, PlayState* play) {
+ EnBh* this = THIS;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Bh/EnBh_Draw.s")
+ 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 11c475e3f..b5e8a7c0c 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;