Bg_Sinkai_Kabe OK and documented, object_sinkai_kabe documented (#786)

* Bg_Sinkai_Kabe OK and documented, object_sinkai_kabe documented

* Respond to Elliptic's review

* Drop "child" from deepPythonChild
This commit is contained in:
Tom Overton
2022-04-21 20:21:42 -07:00
committed by GitHub
parent bb784413b9
commit cc759afc9e
8 changed files with 141 additions and 30 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
<Root>
<!-- The collision for the front of the Deep Python's den (the invisible wall) -->
<File Name="object_sinkai_kabe" Segment="6">
<Collision Name="object_sinkai_kabe_Colheader_000048" Offset="0x48" />
<Collision Name="gPinnacleRockPythonDenCol" Offset="0x48" />
</File>
</Root>
+1 -2
View File
@@ -4095,8 +4095,7 @@ beginseg
name "ovl_Bg_Sinkai_Kabe"
compress
include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/z_bg_sinkai_kabe.o"
include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.data.o"
include "build/data/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe.reloc.o"
include "build/src/overlays/actors/ovl_Bg_Sinkai_Kabe/ovl_Bg_Sinkai_Kabe_reloc.o"
endseg
beginseg
@@ -1,10 +1,18 @@
/*
* File: z_bg_sinkai_kabe.c
* Overlay: ovl_Bg_Sinkai_Kabe
* Description: Manages the Deep Pythons and Seahorse in Pinnacle Rock
* Description: Manages the Deep Pythons in Pinnacle Rock
*
* While its name describes one of its responsibilities ("Deep Sea Wall", aka the invisible
* wall blocking a Deep Python's den before you defeat it), it is also responsible for
* spawning in the Deep Pythons when the area first loads, as well as signalling to the
* Deep Python that it should extend its body. Furthermore, if the player defeats all
* eight Deep Pythons and spawns the second Seahorse, this actor is responsible for spawning
* it again if the player leaves and re-enters Pinnacle Rock.
*/
#include "z_bg_sinkai_kabe.h"
#include "objects/object_sinkai_kabe/object_sinkai_kabe.h"
#define FLAGS (ACTOR_FLAG_10)
@@ -14,7 +22,8 @@ void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx);
void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx);
#if 0
void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx);
const ActorInit Bg_Sinkai_Kabe_InitVars = {
ACTOR_BG_SINKAI_KABE,
ACTORCAT_ITEMACTION,
@@ -27,14 +36,117 @@ const ActorInit Bg_Sinkai_Kabe_InitVars = {
(ActorFunc)NULL,
};
#endif
static s32 sCurrentPythonIndex = 0;
extern UNK_TYPE D_06000048;
void BgSinkaiKabe_Init(Actor* thisx, GlobalContext* globalCtx) {
BgSinkaiKabe* this = THIS;
s32 pad;
CollisionHeader* colHeader = NULL;
Vec3f pos;
s32 pad2;
s32 shouldSpawnSeahorse;
s32 cs;
s32 i;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Init.s")
DynaPolyActor_Init(&this->dyna, 0);
CollisionHeader_GetVirtual(&gPinnacleRockPythonDenCol, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
Math_Vec3f_Copy(&pos, &this->dyna.actor.world.pos);
pos.x += Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f;
pos.z += Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 3000.0f;
cs = this->dyna.actor.cutscene;
i = 0;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Destroy.s")
// clang-format off
while (cs != -1) { this->cutscenes[i] = cs; cs = ActorCutscene_GetAdditionalCutscene(cs); i++; }
// clang-format on
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/func_80B6DA20.s")
this->dyna.actor.scale.x = 0.1f;
this->dyna.actor.scale.y = 0.1f;
this->dyna.actor.scale.z = 0.1f;
this->pythonIndex = sCurrentPythonIndex;
sCurrentPythonIndex++;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Sinkai_Kabe/BgSinkaiKabe_Update.s")
if (!(gSaveContext.save.weekEventReg[13] & 1)) {
this->deepPython =
Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_EN_DRAGON, pos.x, pos.y, pos.z,
0, this->dyna.actor.world.rot.y, 1, this->dyna.actor.params);
if (this->deepPython != NULL) {
EnDragon* dragon = (EnDragon*)this->deepPython;
dragon->grabCutsceneIndex = this->cutscenes[0];
dragon->deathCutsceneIndex = this->cutscenes[1];
dragon->actor.cutscene = this->dyna.actor.cutscene;
Math_Vec3f_Copy(&dragon->burrowEntrancePos, &this->dyna.actor.world.pos);
dragon->pythonIndex = this->pythonIndex;
}
} else {
shouldSpawnSeahorse = false;
if (((this->dyna.actor.params == 0) && (gSaveContext.save.weekEventReg[83] & 0x10)) ||
((this->dyna.actor.params == 1) && (gSaveContext.save.weekEventReg[83] & 0x20)) ||
((this->dyna.actor.params == 2) && (gSaveContext.save.weekEventReg[83] & 0x40)) ||
((this->dyna.actor.params == 3) && (gSaveContext.save.weekEventReg[83] & 0x80)) ||
((this->dyna.actor.params == 4) && (gSaveContext.save.weekEventReg[84] & 1)) ||
((this->dyna.actor.params == 5) && (gSaveContext.save.weekEventReg[84] & 2)) ||
((this->dyna.actor.params == 6) && (gSaveContext.save.weekEventReg[84] & 4)) ||
((this->dyna.actor.params == 7) && (gSaveContext.save.weekEventReg[84] & 8))) {
shouldSpawnSeahorse = true;
}
Math_Vec3f_Copy(&pos, &this->dyna.actor.home.pos);
pos.x += (Math_SinS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f);
pos.y += -100.0f;
pos.z += (Math_CosS(this->dyna.actor.world.rot.y + 0x8000) * 500.0f);
if (shouldSpawnSeahorse) {
Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_OT, pos.x, pos.y, pos.z, 0,
this->dyna.actor.shape.rot.y, 0, 0x4000, this->dyna.actor.cutscene,
this->dyna.actor.unk20, NULL);
}
Actor_MarkForDeath(&this->dyna.actor);
}
this->actionFunc = BgSinkaiKabe_WaitForPlayer;
}
void BgSinkaiKabe_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgSinkaiKabe* this = THIS;
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
/**
* Extends this actor's Deep Python if the player gets close enough.
*/
void BgSinkaiKabe_WaitForPlayer(BgSinkaiKabe* this, GlobalContext* globalCtx) {
if (this->deepPython != NULL) {
if (this->deepPython->update != NULL) {
EnDragon* dragon = (EnDragon*)this->deepPython;
if (dragon->action == DEEP_PYTHON_ACTION_IDLE) {
Player* player = GET_PLAYER(globalCtx);
if ((this->dyna.actor.xzDistToPlayer < 500.0f) ||
((ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, this->dyna.actor.world.rot.y)) < 0x2000) &&
(this->dyna.actor.xzDistToPlayer < 700.0f))) {
if (fabsf(this->dyna.actor.world.pos.y - player->actor.world.pos.y) < 400.0f) {
dragon->action = DEEP_PYTHON_ACTION_EXTEND;
}
}
}
} else {
this->deepPython = NULL;
}
}
if (this->deepPython == NULL) {
Actor_MarkForDeath(&this->dyna.actor);
}
}
void BgSinkaiKabe_Update(Actor* thisx, GlobalContext* globalCtx) {
BgSinkaiKabe* this = THIS;
this->actionFunc(this, globalCtx);
}
@@ -2,16 +2,19 @@
#define Z_BG_SINKAI_KABE_H
#include "global.h"
#include "overlays/actors/ovl_En_Dragon/z_en_dragon.h"
struct BgSinkaiKabe;
typedef void (*BgSinkaiKabeActionFunc)(struct BgSinkaiKabe*, GlobalContext*);
typedef struct BgSinkaiKabe {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x18];
/* 0x015C */ BgSinkaiKabeActionFunc actionFunc;
/* 0x0160 */ char unk_160[0x10];
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ BgSinkaiKabeActionFunc actionFunc;
/* 0x160 */ Actor* deepPython;
/* 0x164 */ s16 cutscenes[2];
/* 0x168 */ UNK_TYPE1 unk_168[0x4];
/* 0x16C */ s32 pythonIndex;
} BgSinkaiKabe; // size = 0x170
extern const ActorInit Bg_Sinkai_Kabe_InitVars;
@@ -31,16 +31,6 @@ typedef enum {
/* 3 */ DEEP_PYTHON_ANIMATION_IDLE
} DeepPythonAnimationIndex;
typedef enum {
/* 0 */ DEEP_PYTHON_ACTION_IDLE,
/* 1 */ DEEP_PYTHON_ACTION_EXTEND,
/* 2 */ DEEP_PYTHON_ACTION_GRAB,
/* 3 */ DEEP_PYTHON_ACTION_DAMAGE,
/* 4 */ DEEP_PYTHON_ACTION_RETREAT,
/* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD,
/* 6 */ DEEP_PYTHON_ACTION_DEAD,
} DeepPythonAction;
typedef enum {
/* 0 */ DEEP_PYTHON_EXTEND_STATE_NOT_FULLY_EXTENDED,
/* 1 */ DEEP_PYTHON_EXTEND_STATE_FULLY_EXTENDED,
@@ -6,6 +6,16 @@
#define EN_DRAGON_GET_PYTHON_INDEX(thisx) (((thisx)->params >> 7) & 0x1F)
typedef enum {
/* 0 */ DEEP_PYTHON_ACTION_IDLE,
/* 1 */ DEEP_PYTHON_ACTION_EXTEND,
/* 2 */ DEEP_PYTHON_ACTION_GRAB,
/* 3 */ DEEP_PYTHON_ACTION_DAMAGE,
/* 4 */ DEEP_PYTHON_ACTION_RETREAT,
/* 5 */ DEEP_PYTHON_ACTION_SETUP_DEAD,
/* 6 */ DEEP_PYTHON_ACTION_DEAD,
} DeepPythonAction;
struct EnDragon;
typedef void (*EnDragonActionFunc)(struct EnDragon*, GlobalContext*);
+1 -1
View File
@@ -14278,7 +14278,7 @@
0x80B6849C:("func_80B6849C",),
0x80B6D660:("BgSinkaiKabe_Init",),
0x80B6D9EC:("BgSinkaiKabe_Destroy",),
0x80B6DA20:("func_80B6DA20",),
0x80B6DA20:("BgSinkaiKabe_WaitForPlayer",),
0x80B6DB20:("BgSinkaiKabe_Update",),
0x80B6DBE0:("BgHakaCurtain_Init",),
0x80B6DC64:("BgHakaCurtain_Destroy",),
-4
View File
@@ -685,10 +685,6 @@ D_06001A60 = 0x06001A60;
D_06001B40 = 0x06001B40;
D_06002CE0 = 0x06002CE0;
// ovl_Bg_Sinkai_Kabe
D_06000048 = 0x06000048;
// ovl_Bg_Spout_Fire
D_06000040 = 0x06000040;