ovl_En_Encount1 OK (#1005)

* 1 Non matching

* all functions matching

* new reloc problems

* Documenting

* ovl_En_Encount1 decompiled

* Co-authored-by: Synray synray@users.noreply.github.com

* Co-authored-by: petrie911 petrie911@users.noreply.github.com

* Co-authored-by: Fig02 fig02srl@gmail.com

* Co-authored-by: Maide eeeedddccc@hotmail.co.uk

* Co-authored-by: EllipticEllipsis EllipticEllipsis@users.noreply.github.com

* uncomment old reloc

* pr review
This commit is contained in:
Alejandro Asenjo
2022-09-14 13:12:31 -03:00
committed by GitHub
parent 33f7ede84f
commit 420403a09a
3 changed files with 144 additions and 10 deletions
+1 -2
View File
@@ -1162,8 +1162,7 @@ beginseg
name "ovl_En_Encount1"
compress
include "build/src/overlays/actors/ovl_En_Encount1/z_en_encount1.o"
include "build/data/ovl_En_Encount1/ovl_En_Encount1.data.o"
include "build/data/ovl_En_Encount1/ovl_En_Encount1.reloc.o"
include "build/src/overlays/actors/ovl_En_Encount1/ovl_En_Encount1_reloc.o"
endseg
beginseg
@@ -15,7 +15,6 @@ void EnEncount1_Update(Actor* thisx, PlayState* play);
void func_808E0954(EnEncount1* this, PlayState* play);
#if 0
const ActorInit En_Encount1_InitVars = {
ACTOR_EN_ENCOUNT1,
ACTORCAT_PROP,
@@ -28,10 +27,129 @@ const ActorInit En_Encount1_InitVars = {
(ActorFunc)NULL,
};
#endif
static s16 sActorList[] = {
ACTOR_EN_GRASSHOPPER,
ACTOR_EN_WALLMAS,
ACTOR_EN_PR2,
ACTOR_EN_PR2,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Init.s")
static s16 sActorParams[] = { 1, 0, 1, 3 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/func_808E0954.s")
void EnEncount1_Init(Actor* thisx, PlayState* play) {
EnEncount1* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount1/EnEncount1_Update.s")
if (this->actor.params <= 0) {
Actor_MarkForDeath(&this->actor);
return;
}
this->actorType = ENENCOUNT1_GET_TYPE(&this->actor);
this->unk_14C = ENENCOUNT1_GET_7C0(&this->actor);
this->unk_154 = ENENCOUNT1_GET_PATH(&this->actor);
this->unk_158 = this->actor.world.rot.x;
this->unk_15C = this->actor.world.rot.y;
this->unk_160 = (this->actor.world.rot.z * 40.0f) + 120.0f;
if (this->unk_154 >= 0x3F) {
this->unk_154 = -1;
}
if (this->actor.world.rot.z < 0) {
this->unk_160 = -1.0f;
}
if (this->actorType == EN_ENCOUNT1_SKULLFISH_2) {
this->unk_15A = ENENCOUNT1_GET_PATH(&this->actor);
this->path = SubS_GetPathByIndex(play, this->unk_15A, 0x3F);
this->unk_154 = -1;
this->unk_160 = -1.0f;
}
this->actor.flags &= ~ACTOR_FLAG_1;
this->actionFunc = func_808E0954;
}
void func_808E0954(EnEncount1* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Vec3f spawnPos;
f32 sp64;
f32 temp_fv0_2;
s16 sp5E;
s16 actorList;
s32 actorParams;
CollisionPoly* sp54;
s32 sp50;
if (((this->unk_14E >= this->unk_14C) || ((this->unk_160 > 0.0f) && (this->unk_160 < this->actor.xzDistToPlayer)) ||
((this->unk_154 > 0) && (this->unk_154 <= this->unk_152)))) {
return;
} else if (this->unk_156 != 0) {
this->unk_156++;
if (this->unk_156 < this->unk_158) {
return;
}
}
this->unk_156 = 0;
switch (this->actorType) {
case EN_ENCOUNT1_GRASSHOPPER:
sp64 = randPlusMinusPoint5Scaled(40.0f) + 200.0f;
sp5E = player->actor.shape.rot.y;
if (this->unk_14E & 1) {
sp5E = -sp5E;
sp64 = randPlusMinusPoint5Scaled(20.0f) + 100.0f;
}
spawnPos.x = player->actor.world.pos.x + (Math_SinS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f);
spawnPos.y = player->actor.floorHeight + 120.0f;
spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f);
temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos);
if ((temp_fv0_2 <= BGCHECK_Y_MIN) ||
((player->actor.depthInWater != BGCHECK_Y_MIN) &&
(temp_fv0_2 < (player->actor.world.pos.y - player->actor.depthInWater)))) {
return;
}
spawnPos.y = temp_fv0_2;
break;
case EN_ENCOUNT1_WALLMASTER:
Math_Vec3f_Copy(&spawnPos, &player->actor.world.pos);
break;
case EN_ENCOUNT1_SKULLFISH:
sp64 = randPlusMinusPoint5Scaled(250.0f) + 500.0f;
sp5E = player->actor.shape.rot.y;
spawnPos.x = player->actor.world.pos.x + Math_SinS(sp5E) * sp64 + randPlusMinusPoint5Scaled(40.0f);
spawnPos.y = player->actor.world.pos.y - Rand_ZeroFloat(20.0f);
spawnPos.z = player->actor.world.pos.z + (Math_CosS(sp5E) * sp64) + randPlusMinusPoint5Scaled(40.0f);
temp_fv0_2 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp54, &sp50, &this->actor, &spawnPos);
if ((!(player->stateFlags1 & 0x8000000) || (temp_fv0_2 <= (BGCHECK_Y_MIN)) ||
(player->actor.depthInWater < temp_fv0_2))) {
return;
}
break;
case EN_ENCOUNT1_SKULLFISH_2:
if ((this->path != NULL) && (!SubS_CopyPointFromPath(this->path, 0, &spawnPos))) {
Actor_MarkForDeath(&this->actor);
}
break;
}
actorList = sActorList[this->actorType];
actorParams = sActorParams[this->actorType];
if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, actorList, spawnPos.x, spawnPos.y, spawnPos.z, 0, 0, 0,
actorParams) != NULL) {
this->unk_14E++;
if (this->unk_154 > 0) {
this->unk_152++;
}
if ((this->unk_14E >= this->unk_14C) && (this->unk_158 != 0)) {
this->unk_156 = 1;
}
}
}
void EnEncount1_Update(Actor* thisx, PlayState* play) {
EnEncount1* this = THIS;
this->actionFunc(this, play);
}
@@ -3,6 +3,17 @@
#include "global.h"
#define ENENCOUNT1_GET_TYPE(thisx) (((thisx)->params >> 11) & 0x1F)
#define ENENCOUNT1_GET_7C0(thisx) (((thisx)->params >> 6) & 0x1F)
#define ENENCOUNT1_GET_PATH(thisx) ((thisx)->params & 0x3F)
typedef enum EnEncount1Enemy {
/* 0x0 */ EN_ENCOUNT1_GRASSHOPPER,
/* 0x1 */ EN_ENCOUNT1_WALLMASTER,
/* 0x2 */ EN_ENCOUNT1_SKULLFISH,
/* 0x3 */ EN_ENCOUNT1_SKULLFISH_2,
} EnEncount1Enemy;
struct EnEncount1;
typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*);
@@ -10,11 +21,17 @@ typedef void (*EnEncount1ActionFunc)(struct EnEncount1*, PlayState*);
typedef struct EnEncount1 {
/* 0x000 */ Actor actor;
/* 0x144 */ EnEncount1ActionFunc actionFunc;
/* 0x148 */ char unk_148[0x6];
/* 0x148 */ Path* path;
/* 0x14C */ s16 unk_14C;
/* 0x14E */ s16 unk_14E;
/* 0x150 */ char unk_150[0xA];
/* 0x150 */ s16 actorType;
/* 0x152 */ s16 unk_152;
/* 0x154 */ s16 unk_154;
/* 0x156 */ s16 unk_156;
/* 0x158 */ s16 unk_158;
/* 0x15A */ s16 unk_15A;
/* 0x15C */ char unk_15C[0x8];
/* 0x15C */ s32 unk_15C;
/* 0x160 */ f32 unk_160;
} EnEncount1; // size = 0x164
extern const ActorInit En_Encount1_InitVars;