ovl_En_Encount4 OK (#989)

* `ovl_En_Encount4` decompiled

* Style changes

* Suggested changes

* Suggested changes

* Formatting

* review

* review

Co-authored-by: EllipticEllipsis <elliptic.ellipsis@gmail.com>

* a

Co-authored-by: angie <angheloalf95@gmail.com>
Co-authored-by: EllipticEllipsis <elliptic.ellipsis@gmail.com>
This commit is contained in:
Lucas 2022-10-21 17:44:20 -05:00 committed by GitHub
parent 7d753ddabb
commit 6842a065f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 197 additions and 21 deletions

3
spec
View File

@ -2268,8 +2268,7 @@ beginseg
name "ovl_En_Encount4"
compress
include "build/src/overlays/actors/ovl_En_Encount4/z_en_encount4.o"
include "build/data/ovl_En_Encount4/ovl_En_Encount4.data.o"
include "build/data/ovl_En_Encount4/ovl_En_Encount4.reloc.o"
include "build/src/overlays/actors/ovl_En_Encount4/ovl_En_Encount4_reloc.o"
endseg
beginseg

View File

@ -193,7 +193,7 @@ void BgFireWall_Update(Actor* thisx, PlayState* play2) {
if (this->actionFunc != func_809AC970) {
if (this->actor.parent != NULL) {
EnEncount4* parent = (EnEncount4*)this->actor.parent;
if ((parent->actor.update != NULL) && (parent->unk_150 != 0)) {
if ((parent->actor.update != NULL) && (parent->timer != 0)) {
this->actionFunc = func_809AC970;
}
}

View File

@ -7,6 +7,11 @@ struct BgFireWall;
typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*);
typedef enum {
/* 0 */ BGFIREWALL_PARAMS_0,
/* 1 */ BGFIREWALL_PARAMS_1,
} BgFireWallParams;
typedef struct BgFireWall {
/* 0x000 */ Actor actor;
/* 0x144 */ BgFireWallActionFunc actionFunc;

View File

@ -11,7 +11,9 @@ typedef struct EnBsb {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x140];
/* 0x0284 */ EnBsbActionFunc actionFunc;
/* 0x0288 */ char unk_288[0xED0];
/* 0x0288 */ char unk_288[0x54];
/* 0x02DC */ s32 unk2DC;
/* 0x02E0 */ char unk2E0[0xE78];
} EnBsb; // size = 0x1158
#endif // Z_EN_BSB_H

View File

@ -20,7 +20,6 @@ void func_809C42A8(EnEncount4* this, PlayState* play);
void func_809C4598(EnEncount4* this, PlayState* play);
void func_809C464C(EnEncount4* this, PlayState* play);
#if 0
ActorInit En_Encount4_InitVars = {
ACTOR_EN_ENCOUNT4,
ACTORCAT_PROP,
@ -33,20 +32,180 @@ ActorInit En_Encount4_InitVars = {
(ActorFunc)NULL,
};
#endif
s16 D_809C46D0[] = {
0x4000, 0xC000, 0x4000, 0, 0xC000,
};
f32 D_809C46DC[] = {
200.0f, 200.0f, 100.0f, 0.0f, 100.0f,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Init.s")
void EnEncount4_Init(Actor* thisx, PlayState* play) {
s32 pad;
EnEncount4* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Destroy.s")
this->unk_148 = ENENCOUNT4_GET_F000(thisx);
this->switchFlag = ENENCOUNT4_GET_FLAG(thisx);
if (this->switchFlag == 0x7F) {
this->switchFlag = -1;
}
if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) {
Actor_Kill(&this->actor);
return;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C3FD8.s")
this->actor.flags &= ~ACTOR_FLAG_1;
this->actionFunc = func_809C3FD8;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4078.s")
void EnEncount4_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C42A8.s")
void func_809C3FD8(EnEncount4* this, PlayState* play) {
Actor* actor;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4598.s")
this->unk_14E = 0;
if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) {
this->timer = 100;
this->actionFunc = func_809C464C;
} else {
actor = play->actorCtx.actorLists[ACTORCAT_BOSS].first;
while (actor != NULL) {
if (actor->id != ACTOR_EN_BSB) {
actor = actor->next;
} else {
this->captainKeeta = (EnBsb*)actor;
this->actionFunc = func_809C4078;
break;
}
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C464C.s")
void func_809C4078(EnEncount4* this, PlayState* play) {
s16 rotY;
Vec3f pos;
s32 fireWallParams;
s32 i;
EnBsb* captainKeeta = this->captainKeeta;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Update.s")
if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) {
this->timer = 100;
this->actionFunc = func_809C464C;
} else if (BREG(1) == 0) {
if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) {
Actor_Kill(&this->actor);
return;
}
if ((this->unk_148 != 0) || (this->actor.xzDistToPlayer < 240.0f)) {
if ((this->unk_148 == 0) && (captainKeeta->unk2DC != 0)) {
Actor_Kill(&this->actor);
return;
}
fireWallParams = BGFIREWALL_PARAMS_0;
if ((this->unk_148 == 0) || (captainKeeta->unk2DC != 0)) {
i = 0;
if (this->unk_148 != 0) {
fireWallParams = BGFIREWALL_PARAMS_1;
i = 2;
}
while (i < ARRAY_COUNT(D_809C46DC)) {
rotY = D_809C46D0[i] + this->actor.world.rot.y;
pos.x = Math_SinS(rotY) * D_809C46DC[i] + this->actor.world.pos.x;
pos.y = this->actor.world.pos.y;
pos.z = Math_CosS(rotY) * D_809C46DC[i] + this->actor.world.pos.z;
Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BG_FIRE_WALL, pos.x, pos.y, pos.z, 0,
this->actor.world.rot.y, 0, fireWallParams);
i++;
}
this->actionFunc = func_809C42A8;
}
}
}
}
void func_809C42A8(EnEncount4* this, PlayState* play) {
Player* actor = GET_PLAYER(play);
EnBsb* captainKeeta = this->captainKeeta;
Vec3f pos;
f32 yIntersect;
s16 yRot;
CollisionPoly* colPoly;
s32 bgId;
if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) {
this->timer = 100;
this->actionFunc = func_809C464C;
return;
}
if (this->unk_148 == 1) {
if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) {
Actor_Kill(&this->actor);
}
return;
} else if (this->unk_14E >= 2) {
this->timer = 100;
this->actionFunc = func_809C464C;
return;
} else if ((gSaveContext.save.weekEventReg[85] & 0x40) || (this->unk_14C >= 2) ||
(this->actor.xzDistToPlayer > 240.0f)) {
return;
}
pos.x = (Math_SinS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.x;
pos.y = actor->actor.floorHeight + 120.0f;
pos.z = (Math_CosS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.z;
yIntersect = BgCheck_EntityRaycastFloor5(&play->colCtx, &colPoly, &bgId, &this->actor, &pos);
if ((yIntersect <= BGCHECK_Y_MIN) || ((actor->actor.depthInWater != BGCHECK_Y_MIN) &&
(yIntersect < (actor->actor.world.pos.y - actor->actor.depthInWater)))) {
return;
}
pos.y = yIntersect;
yRot = (s32)Rand_ZeroFloat(512.0f) + this->actor.world.rot.y + 0x3800;
if (this->unk_14C != 0) {
yRot += 0x8000;
}
pos.x += Math_SinS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f));
pos.z += Math_CosS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f));
if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SKB, pos.x, pos.y, pos.z, 0, 0, 0,
ENSKB_PARAMS_0) != NULL) {
this->unk_14C++;
if (this->unk_14C >= 2) {
this->actionFunc = func_809C4598;
}
}
}
void func_809C4598(EnEncount4* this, PlayState* play) {
if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) {
this->timer = 100;
this->actionFunc = func_809C464C;
} else if (this->unk_14E >= 2) {
this->timer = 100;
if (this->switchFlag >= 0) {
Flags_SetSwitch(play, this->switchFlag);
}
this->actionFunc = func_809C464C;
} else if (this->unk_14C == 0) {
this->actionFunc = func_809C42A8;
}
}
void func_809C464C(EnEncount4* this, PlayState* play) {
if (this->timer == 0) {
Actor_Kill(&this->actor);
}
}
void EnEncount4_Update(Actor* thisx, PlayState* play) {
EnEncount4* this = THIS;
DECR(this->timer);
this->actionFunc(this, play);
}

View File

@ -2,19 +2,26 @@
#define Z_EN_ENCOUNT4_H
#include "global.h"
#include "overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h"
#include "overlays/actors/ovl_En_Bsb/z_en_bsb.h"
#include "overlays/actors/ovl_En_Skb/z_en_skb.h"
struct EnEncount4;
typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, PlayState*);
#define ENENCOUNT4_GET_FLAG(thisx) ((thisx)->params & 0x7F)
#define ENENCOUNT4_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF)
typedef struct EnEncount4 {
/* 0x0000 */ Actor actor;
/* 0x0144 */ EnEncount4ActionFunc actionFunc;
/* 0x0148 */ char unk_148[0x4];
/* 0x014C */ s16 unk_14C;
/* 0x014E */ s16 unk_14E;
/* 0x0150 */ s16 unk_150;
/* 0x0152 */ char unk_152[0x6];
/* 0x000 */ Actor actor;
/* 0x144 */ EnEncount4ActionFunc actionFunc;
/* 0x148 */ s16 unk_148;
/* 0x14A */ s16 switchFlag;
/* 0x14C */ s16 unk_14C;
/* 0x14E */ s16 unk_14E;
/* 0x150 */ s16 timer;
/* 0x154 */ EnBsb* captainKeeta;
} EnEncount4; // size = 0x158
#endif // Z_EN_ENCOUNT4_H

View File

@ -9,6 +9,10 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*);
#define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF)
typedef enum {
/* 0 */ ENSKB_PARAMS_0,
} EnSkbParams;
typedef struct EnSkb {
/* 0x000 */ Actor actor;
/* 0x144 */ SkelAnime skelAnime;