diff --git a/assets/xml/objects/object_ddan_objects.xml b/assets/xml/objects/object_ddan_objects.xml
index 2ae6d679b7..3fc563b96f 100644
--- a/assets/xml/objects/object_ddan_objects.xml
+++ b/assets/xml/objects/object_ddan_objects.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/include/functions.h b/include/functions.h
index b475823d93..9fb1b0b923 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -478,7 +478,8 @@ void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s3
s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* globalCtx, s16 type);
void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 amountMinusOne,
f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting);
-void func_80033480(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, s32 arg3, s16 arg4, s16 arg5, u8 arg6);
+void func_80033480(GlobalContext* globalCtx, Vec3f* posBase, f32 randRangeDiameter, s32 amountMinusOne, s16 scaleBase,
+ s16 scaleStep, u8 arg6);
Actor* Actor_GetCollidedExplosive(GlobalContext* globalCtx, Collider* collider);
Actor* func_80033684(GlobalContext* globalCtx, Actor* explosiveActor);
Actor* Actor_GetProjectileActor(GlobalContext* globalCtx, Actor* refActor, f32 radius);
@@ -499,8 +500,8 @@ void func_8003424C(GlobalContext* globalCtx, Vec3f* arg1);
void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 xluFlag, s16 duration);
Hilite* func_800342EC(Vec3f* object, GlobalContext* globalCtx);
Hilite* func_8003435C(Vec3f* object, GlobalContext* globalCtx);
-s32 func_800343CC(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 interactRange, u16 (*unkFunc1)(GlobalContext*, Actor*),
- s16 (*unkFunc2)(GlobalContext*, Actor*));
+s32 func_800343CC(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 interactRange,
+ u16 (*unkFunc1)(GlobalContext*, Actor*), s16 (*unkFunc2)(GlobalContext*, Actor*));
s16 func_800347E8(s16 arg0);
void func_80034A14(Actor* actor, struct_80034A14_arg1* arg1, s16 arg2, s16 arg3);
void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw,
diff --git a/include/z64.h b/include/z64.h
index 709351cb10..c4edd0f743 100644
--- a/include/z64.h
+++ b/include/z64.h
@@ -931,7 +931,7 @@ typedef struct {
/* 0x38 */ DmaRequest dmaRequest;
/* 0x58 */ OSMesgQueue loadQueue;
/* 0x70 */ OSMesg loadMsg;
- /* 0x74 */ s16 unk_74[2];
+ /* 0x74 */ s16 unk_74[2]; // context-specific data used by the current scene draw config
} RoomContext; // size = 0x78
typedef struct {
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index 3046b9318d..0135508282 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -3160,7 +3160,8 @@ void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* pos
}
}
-void func_80033480(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) {
+void func_80033480(GlobalContext* globalCtx, Vec3f* posBase, f32 randRangeDiameter, s32 amountMinusOne, s16 scaleBase,
+ s16 scaleStep, u8 arg6) {
Vec3f pos;
Vec3f velocity = { 0.0f, 0.0f, 0.0f };
Vec3f accel = { 0.0f, 0.3f, 0.0f };
@@ -3168,12 +3169,12 @@ void func_80033480(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2, s32 arg3, s1
u32 var2;
s32 i;
- for (i = arg3; i >= 0; i--) {
- pos.x = arg1->x + ((Rand_ZeroOne() - 0.5f) * arg2);
- pos.y = arg1->y + ((Rand_ZeroOne() - 0.5f) * arg2);
- pos.z = arg1->z + ((Rand_ZeroOne() - 0.5f) * arg2);
+ for (i = amountMinusOne; i >= 0; i--) {
+ pos.x = posBase->x + ((Rand_ZeroOne() - 0.5f) * randRangeDiameter);
+ pos.y = posBase->y + ((Rand_ZeroOne() - 0.5f) * randRangeDiameter);
+ pos.z = posBase->z + ((Rand_ZeroOne() - 0.5f) * randRangeDiameter);
- scale = (s16)((Rand_ZeroOne() * arg4) * 0.2f) + arg4;
+ scale = (s16)((Rand_ZeroOne() * scaleBase) * 0.2f) + scaleBase;
var2 = arg6;
if (var2 != 0) {
diff --git a/src/code/z_scene_table.c b/src/code/z_scene_table.c
index 15f9b032a9..bdfe036510 100644
--- a/src/code/z_scene_table.c
+++ b/src/code/z_scene_table.c
@@ -21,6 +21,8 @@
#include "scenes/indoors/miharigoya/miharigoya_scene.h"
#include "scenes/dungeons/ice_doukutu/ice_doukutu_scene.h"
+#include "overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h"
+
#define ENTRANCE(scene, spawn, continueBgm, displayTitleCard, fadeIn, fadeOut) \
{ \
scene, spawn, \
@@ -1025,11 +1027,11 @@ void* sDCLavaFloorTextures[] = {
gDCLavaFloor5Tex, gDCLavaFloor6Tex, gDCLavaFloor7Tex, gDCLavaFloor8Tex,
};
-// Scene Draw Config 20
+// Scene Draw Config 20 - Dodongo's Cavern
void func_80099878(GlobalContext* globalCtx) {
u32 gameplayFrames;
s32 pad;
- Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 6 * sizeof(Gfx));
+ Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx[3]));
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4905);
@@ -1053,11 +1055,12 @@ void func_80099878(GlobalContext* globalCtx) {
gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead);
gDPPipeSync(displayListHead++);
- gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[0]);
+ gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT]);
gSPEndDisplayList(displayListHead++);
+
gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead);
gDPPipeSync(displayListHead++);
- gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[1]);
+ gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT]);
gSPEndDisplayList(displayListHead);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4956);
diff --git a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c
index 5e6091e83e..ad89f89c40 100644
--- a/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c
+++ b/src/overlays/actors/ovl_Bg_Ddan_Kd/z_bg_ddan_kd.c
@@ -16,7 +16,7 @@ void BgDdanKd_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx);
void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx);
-void func_80871838(BgDdanKd* this, GlobalContext* globalCtx);
+void BgDdanKd_DoNothing(BgDdanKd* this, GlobalContext* globalCtx);
const ActorInit Bg_Ddan_Kd_InitVars = {
ACTOR_BG_DDAN_KD,
@@ -76,11 +76,11 @@ void BgDdanKd_Init(Actor* thisx, GlobalContext* globalCtx) {
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
- if (Flags_GetSwitch(globalCtx, this->dyna.actor.params) == 0) {
+ if (!Flags_GetSwitch(globalCtx, this->dyna.actor.params)) {
BgDdanKd_SetupAction(this, BgDdanKd_CheckForExplosions);
} else {
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 200.0f - 20.0f;
- BgDdanKd_SetupAction(this, func_80871838);
+ BgDdanKd_SetupAction(this, BgDdanKd_DoNothing);
}
}
@@ -99,13 +99,14 @@ void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx) {
osSyncPrintf("dam %d\n", this->dyna.actor.colChkInfo.damage);
explosive->params = 2;
}
+
if ((explosive != NULL) && (this->prevExplosive != NULL) && (explosive != this->prevExplosive) &&
(Math_Vec3f_DistXZ(&this->prevExplosivePos, &explosive->world.pos) > 80.0f)) {
BgDdanKd_SetupAction(this, BgDdanKd_LowerStairs);
OnePointCutscene_Init(globalCtx, 3050, 999, &this->dyna.actor, MAIN_CAM);
} else {
if (this->timer != 0) {
- this->timer -= 1;
+ this->timer--;
} else {
this->prevExplosive = explosive;
if (explosive != NULL) {
@@ -119,61 +120,62 @@ void BgDdanKd_CheckForExplosions(BgDdanKd* this, GlobalContext* globalCtx) {
}
void BgDdanKd_LowerStairs(BgDdanKd* this, GlobalContext* globalCtx) {
- static Vec3f D_808718FC = { 0.0f, 5.0f, 0.0f };
- static Vec3f D_80871908 = { 0.0f, -0.45f, 0.0f };
- Vec3f sp5C;
- Vec3f sp50;
- f32 sp4C;
+ static Vec3f velocity = { 0.0f, 5.0f, 0.0f };
+ static Vec3f accel = { 0.0f, -0.45f, 0.0f };
+ Vec3f pos1;
+ Vec3f pos2;
+ f32 effectStrength;
Math_SmoothStepToF(&this->dyna.actor.speedXZ, 4.0f, 0.5f, 0.025f, 0.0f);
func_800AA000(500.0f, 0x78, 0x14, 0xA);
- if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, (this->dyna.actor.home.pos.y - 200.0f) - 20.0f, 0.075f,
+ if (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 200.0f - 20.0f, 0.075f,
this->dyna.actor.speedXZ, 0.0075f) == 0.0f) {
Flags_SetSwitch(globalCtx, this->dyna.actor.params);
- BgDdanKd_SetupAction(this, func_80871838);
+ BgDdanKd_SetupAction(this, BgDdanKd_DoNothing);
} else {
- sp4C = (this->dyna.actor.prevPos.y - this->dyna.actor.world.pos.y) + (this->dyna.actor.speedXZ * 0.25f);
+ effectStrength =
+ (this->dyna.actor.prevPos.y - this->dyna.actor.world.pos.y) + (this->dyna.actor.speedXZ * 0.25f);
if (globalCtx->state.frames & 1) {
- sp5C = sp50 = this->dyna.actor.world.pos;
+ pos1 = pos2 = this->dyna.actor.world.pos;
if (globalCtx->state.frames & 2) {
- sp5C.z += 210.0f + Rand_ZeroOne() * 230.0f;
- sp50.z += 210.0f + Rand_ZeroOne() * 230.0f;
+ pos1.z += 210.0f + Rand_ZeroOne() * 230.0f;
+ pos2.z += 210.0f + Rand_ZeroOne() * 230.0f;
} else {
- sp5C.z += 330.0f + Rand_ZeroOne() * 240.0f;
- sp50.z += 330.0f + Rand_ZeroOne() * 240.0f;
+ pos1.z += 330.0f + Rand_ZeroOne() * 240.0f;
+ pos2.z += 330.0f + Rand_ZeroOne() * 240.0f;
}
- sp5C.x += 80.0f + Rand_ZeroOne() * 10.0f;
- sp50.x -= 80.0f + Rand_ZeroOne() * 10.0f;
- sp5C.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne();
- sp50.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne();
+ pos1.x += 80.0f + Rand_ZeroOne() * 10.0f;
+ pos2.x -= 80.0f + Rand_ZeroOne() * 10.0f;
+ pos1.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne();
+ pos2.y = this->dyna.actor.floorHeight + 20.0f + Rand_ZeroOne();
- func_80033480(globalCtx, &sp5C, 20.0f, 1, sp4C * 135.0f, 60, 1);
- func_80033480(globalCtx, &sp50, 20.0f, 1, sp4C * 135.0f, 60, 1);
+ func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1);
+ func_80033480(globalCtx, &pos2, 20.0f, 1, effectStrength * 135.0f, 60, 1);
- D_808718FC.x = Rand_CenteredFloat(3.0f);
- D_808718FC.z = Rand_CenteredFloat(3.0f);
+ velocity.x = Rand_CenteredFloat(3.0f);
+ velocity.z = Rand_CenteredFloat(3.0f);
- func_8003555C(globalCtx, &sp5C, &D_808718FC, &D_80871908);
- func_8003555C(globalCtx, &sp50, &D_808718FC, &D_80871908);
+ func_8003555C(globalCtx, &pos1, &velocity, &accel);
+ func_8003555C(globalCtx, &pos2, &velocity, &accel);
- sp5C = this->dyna.actor.world.pos;
- sp5C.z += 560.0f + Rand_ZeroOne() * 5.0f;
- sp5C.x += (Rand_ZeroOne() - 0.5f) * 160.0f;
- sp5C.y = Rand_ZeroOne() * 3.0f + (this->dyna.actor.floorHeight + 20.0f);
+ pos1 = this->dyna.actor.world.pos;
+ pos1.z += 560.0f + Rand_ZeroOne() * 5.0f;
+ pos1.x += (Rand_ZeroOne() - 0.5f) * 160.0f;
+ pos1.y = Rand_ZeroOne() * 3.0f + (this->dyna.actor.floorHeight + 20.0f);
- func_80033480(globalCtx, &sp5C, 20.0f, 1, sp4C * 135.0f, 60, 1);
- func_8003555C(globalCtx, &sp5C, &D_808718FC, &D_80871908);
+ func_80033480(globalCtx, &pos1, 20.0f, 1, effectStrength * 135.0f, 60, 1);
+ func_8003555C(globalCtx, &pos1, &velocity, &accel);
}
- Camera_AddQuake(&globalCtx->mainCamera, 0, sp4C * 0.6f, 3);
+ Camera_AddQuake(&globalCtx->mainCamera, 0, effectStrength * 0.6f, 3);
Audio_PlaySoundGeneral(NA_SE_EV_PILLAR_SINK - SFX_FLAG, &this->dyna.actor.projectedPos, 4, &D_801333E0,
&D_801333E0, &D_801333E8);
}
}
-void func_80871838(BgDdanKd* this, GlobalContext* globalCtx) {
+void BgDdanKd_DoNothing(BgDdanKd* this, GlobalContext* globalCtx) {
}
void BgDdanKd_Update(Actor* thisx, GlobalContext* globalCtx) {
diff --git a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c
index c0ac2970a9..4f1c522f24 100644
--- a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c
+++ b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.c
@@ -15,10 +15,10 @@ void BgDodoago_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx);
void BgDodoago_Draw(Actor* thisx, GlobalContext* globalCtx);
-void func_80871CF4(BgDodoago* this, GlobalContext* globalCtx);
-void func_80871FB8(BgDodoago* this, GlobalContext* globalCtx);
+void BgDodoago_WaitExplosives(BgDodoago* this, GlobalContext* globalCtx);
+void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx);
void BgDodoago_DoNothing(BgDodoago* this, GlobalContext* globalCtx);
-void func_80872288(BgDodoago* this, GlobalContext* globalCtx);
+void BgDodoago_LightOneEye(BgDodoago* this, GlobalContext* globalCtx);
const ActorInit Bg_Dodoago_InitVars = {
ACTOR_BG_DODOAGO,
@@ -32,7 +32,7 @@ const ActorInit Bg_Dodoago_InitVars = {
(ActorFunc)BgDodoago_Draw,
};
-static ColliderCylinderInit sColCylinderInit0 = {
+static ColliderCylinderInit sColCylinderInitMain = {
{
COLTYPE_NONE,
AT_NONE,
@@ -52,7 +52,7 @@ static ColliderCylinderInit sColCylinderInit0 = {
{ 80, 30, 80, { 0, 0, 0 } },
};
-static ColliderCylinderInit sColCylinderInit1 = {
+static ColliderCylinderInit sColCylinderInitLeftRight = {
{
COLTYPE_NONE,
AT_NONE,
@@ -72,13 +72,19 @@ static ColliderCylinderInit sColCylinderInit1 = {
{ 50, 60, 280, { 0, 0, 0 } },
};
-static s16 sHasParent = false;
+static s16 sFirstExplosiveFlag = false;
+
+static u8 sDisableBombCatcher;
+
+static u8 sUnused[90]; // unknown length
+
+static s32 sTimer;
void BgDodoago_SetupAction(BgDodoago* this, BgDodoagoActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
-void BgDodoago_SpawnSparkles(Vec3f* vec, GlobalContext* globalCtx) {
+void BgDodoago_SpawnSparkles(Vec3f* meanPos, GlobalContext* globalCtx) {
Vec3f pos;
Color_RGBA8 primColor = { 100, 100, 100, 0 };
Color_RGBA8 envColor = { 40, 40, 40, 0 };
@@ -87,9 +93,9 @@ void BgDodoago_SpawnSparkles(Vec3f* vec, GlobalContext* globalCtx) {
s32 i;
for (i = 4; i > 0; i--) {
- pos.x = Rand_CenteredFloat(20.0f) + vec->x;
- pos.y = Rand_CenteredFloat(10.0f) + vec->y;
- pos.z = Rand_CenteredFloat(20.0f) + vec->z;
+ pos.x = Rand_CenteredFloat(20.0f) + meanPos->x;
+ pos.y = Rand_CenteredFloat(10.0f) + meanPos->y;
+ pos.z = Rand_CenteredFloat(20.0f) + meanPos->z;
EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &velocity, &acceleration, &primColor, &envColor);
}
}
@@ -101,10 +107,6 @@ static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneDownward, 800, ICHAIN_STOP),
};
-static u8 D_808727C0[100];
-
-static s32 D_80872824;
-
void BgDodoago_Init(Actor* thisx, GlobalContext* globalCtx) {
BgDodoago* this = (BgDodoago*)thisx;
s32 pad;
@@ -116,82 +118,89 @@ void BgDodoago_Init(Actor* thisx, GlobalContext* globalCtx) {
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
ActorShape_Init(&this->dyna.actor.shape, 0.0f, NULL, 0.0f);
- if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) {
+ if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
BgDodoago_SetupAction(this, BgDodoago_DoNothing);
this->dyna.actor.shape.rot.x = 0x1333;
- globalCtx->roomCtx.unk_74[0] = globalCtx->roomCtx.unk_74[1] = 0xFF;
+ globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] = globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] = 255;
return;
}
- Collider_InitCylinder(globalCtx, &this->colliders[0]);
- Collider_InitCylinder(globalCtx, &this->colliders[1]);
- Collider_InitCylinder(globalCtx, &this->colliders[2]);
- Collider_SetCylinder(globalCtx, &this->colliders[0], &this->dyna.actor, &sColCylinderInit0);
- Collider_SetCylinder(globalCtx, &this->colliders[1], &this->dyna.actor, &sColCylinderInit1);
- Collider_SetCylinder(globalCtx, &this->colliders[2], &this->dyna.actor, &sColCylinderInit1);
- BgDodoago_SetupAction(this, func_80871CF4);
- D_808727C0[0] = 0;
+ Collider_InitCylinder(globalCtx, &this->colliderMain);
+ Collider_InitCylinder(globalCtx, &this->colliderLeft);
+ Collider_InitCylinder(globalCtx, &this->colliderRight);
+ Collider_SetCylinder(globalCtx, &this->colliderMain, &this->dyna.actor, &sColCylinderInitMain);
+ Collider_SetCylinder(globalCtx, &this->colliderLeft, &this->dyna.actor, &sColCylinderInitLeftRight);
+ Collider_SetCylinder(globalCtx, &this->colliderRight, &this->dyna.actor, &sColCylinderInitLeftRight);
+
+ BgDodoago_SetupAction(this, BgDodoago_WaitExplosives);
+ sDisableBombCatcher = false;
}
void BgDodoago_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgDodoago* this = (BgDodoago*)thisx;
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
- Collider_DestroyCylinder(globalCtx, &this->colliders[0]);
- Collider_DestroyCylinder(globalCtx, &this->colliders[1]);
- Collider_DestroyCylinder(globalCtx, &this->colliders[2]);
+ Collider_DestroyCylinder(globalCtx, &this->colliderMain);
+ Collider_DestroyCylinder(globalCtx, &this->colliderLeft);
+ Collider_DestroyCylinder(globalCtx, &this->colliderRight);
}
-void func_80871CF4(BgDodoago* this, GlobalContext* globalCtx) {
- Actor* explosive = Actor_GetCollidedExplosive(globalCtx, &this->colliders[0].base);
+void BgDodoago_WaitExplosives(BgDodoago* this, GlobalContext* globalCtx) {
+ Actor* explosive = Actor_GetCollidedExplosive(globalCtx, &this->colliderMain.base);
if (explosive != NULL) {
- this->unk_164 =
- (Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &explosive->world.pos) >= this->dyna.actor.shape.rot.y) ? 1
- : 0;
-
- if (((globalCtx->roomCtx.unk_74[0] == 0xFF) && (this->unk_164 == 1)) ||
- ((globalCtx->roomCtx.unk_74[1] == 0xFF) && (this->unk_164 == 0))) {
- Flags_SetSwitch(globalCtx, (this->dyna.actor.params & 0x3F));
- this->unk_164 = 0;
+ this->state =
+ (Math_Vec3f_Yaw(&this->dyna.actor.world.pos, &explosive->world.pos) >= this->dyna.actor.shape.rot.y)
+ ? BGDODOAGO_EYE_RIGHT
+ : BGDODOAGO_EYE_LEFT;
+
+ if (((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] == 255) && (this->state == BGDODOAGO_EYE_RIGHT)) ||
+ ((globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] == 255) && (this->state == BGDODOAGO_EYE_LEFT))) {
+ Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F);
+ this->state = 0;
Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
- BgDodoago_SetupAction(this, func_80871FB8);
+ BgDodoago_SetupAction(this, BgDodoago_OpenJaw);
OnePointCutscene_Init(globalCtx, 3380, 160, &this->dyna.actor, MAIN_CAM);
- } else if (globalCtx->roomCtx.unk_74[this->unk_164] == 0) {
+ } else if (globalCtx->roomCtx.unk_74[this->state] == 0) {
OnePointCutscene_Init(globalCtx, 3065, 40, &this->dyna.actor, MAIN_CAM);
- BgDodoago_SetupAction(this, func_80872288);
+ BgDodoago_SetupAction(this, BgDodoago_LightOneEye);
Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
} else {
OnePointCutscene_Init(globalCtx, 3065, 20, &this->dyna.actor, MAIN_CAM);
Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
- D_80872824 += 0x1E;
+ sTimer += 30;
return;
}
- if (!sHasParent) {
+ // the flag is never set back to false, so this only runs once
+ if (!sFirstExplosiveFlag) {
+ // this disables the bomb catcher (see BgDodoago_Update) for a few seconds
this->dyna.actor.parent = explosive;
- sHasParent = true;
- D_80872824 = 0x32;
+ sFirstExplosiveFlag = true;
+ sTimer = 50;
}
} else if (Flags_GetEventChkInf(0xB0)) {
- Collider_UpdateCylinder(&this->dyna.actor, &this->colliders[0]);
- Collider_UpdateCylinder(&this->dyna.actor, &this->colliders[1]);
- Collider_UpdateCylinder(&this->dyna.actor, &this->colliders[2]);
- this->colliders[0].dim.pos.z += 200;
- this->colliders[1].dim.pos.z += 215;
- this->colliders[1].dim.pos.x += 90;
- this->colliders[2].dim.pos.z += 215;
- this->colliders[2].dim.pos.x -= 90;
-
- CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliders[0].base);
- CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[1].base);
- CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliders[2].base);
+ Collider_UpdateCylinder(&this->dyna.actor, &this->colliderMain);
+ Collider_UpdateCylinder(&this->dyna.actor, &this->colliderLeft);
+ Collider_UpdateCylinder(&this->dyna.actor, &this->colliderRight);
+
+ this->colliderMain.dim.pos.z += 200;
+
+ this->colliderLeft.dim.pos.z += 215;
+ this->colliderLeft.dim.pos.x += 90;
+
+ this->colliderRight.dim.pos.z += 215;
+ this->colliderRight.dim.pos.x -= 90;
+
+ CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->colliderMain.base);
+ CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderLeft.base);
+ CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderRight.base);
}
}
-void func_80871FB8(BgDodoago* this, GlobalContext* globalCtx) {
- Vec3f currentPos;
- Vec3f D_808725CC[] = {
+void BgDodoago_OpenJaw(BgDodoago* this, GlobalContext* globalCtx) {
+ Vec3f pos;
+ Vec3f dustOffsets[] = {
{ 0.0f, -200.0f, 430.0f }, { 20.0f, -200.0f, 420.0f }, { -20.0f, -200.0f, 420.0f },
{ 40.0, -200.0f, 380.0f }, { -40.0, -200.0f, 380.0f }, { 50.0, -200.0f, 350.0f },
{ -50.0f, -200.0f, 350.0f }, { 60.0f, -200.0f, 320.0f }, { -60.0f, -200.0f, 320.0f },
@@ -199,42 +208,42 @@ void func_80871FB8(BgDodoago* this, GlobalContext* globalCtx) {
};
s32 i;
- if (globalCtx->roomCtx.unk_74[0] < 0xFF) {
- globalCtx->roomCtx.unk_74[0] += 5;
+ // make both eyes red (one already is)
+ if (globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] < 255) {
+ globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] += 5;
}
- if (globalCtx->roomCtx.unk_74[1] < 0xFF) {
- globalCtx->roomCtx.unk_74[1] += 5;
+ if (globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] < 255) {
+ globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] += 5;
}
- if (globalCtx->roomCtx.unk_74[0] != 0xFF || globalCtx->roomCtx.unk_74[1] != 0xFF) {
- D_80872824--;
+ if (globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT] != 255 || globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT] != 255) {
+ sTimer--;
return;
}
- if (D_80872824 == 0x6C) {
- for (i = 10; i >= 0; i--) {
- currentPos.x = D_808725CC[i].x + this->dyna.actor.world.pos.x;
- currentPos.y = D_808725CC[i].y + this->dyna.actor.world.pos.y;
- currentPos.z = D_808725CC[i].z + this->dyna.actor.world.pos.z;
- func_80033480(globalCtx, ¤tPos, 2.0f, 3, 0xC8, 0x4B, 1);
+ if (sTimer == 108) {
+ for (i = ARRAY_COUNT(dustOffsets) - 1; i >= 0; i--) {
+ pos.x = dustOffsets[i].x + this->dyna.actor.world.pos.x;
+ pos.y = dustOffsets[i].y + this->dyna.actor.world.pos.y;
+ pos.z = dustOffsets[i].z + this->dyna.actor.world.pos.z;
+ func_80033480(globalCtx, &pos, 2.0f, 3, 200, 75, 1);
}
}
- currentPos.x = this->dyna.actor.world.pos.x + 200.0f;
- currentPos.y = this->dyna.actor.world.pos.y - 20.0f;
- currentPos.z = this->dyna.actor.world.pos.z + 100.0f;
-
- BgDodoago_SpawnSparkles(¤tPos, globalCtx);
+ pos.x = this->dyna.actor.world.pos.x + 200.0f;
+ pos.y = this->dyna.actor.world.pos.y - 20.0f;
+ pos.z = this->dyna.actor.world.pos.z + 100.0f;
+ BgDodoago_SpawnSparkles(&pos, globalCtx);
- currentPos.x = this->dyna.actor.world.pos.x - 200.0f;
- currentPos.y = this->dyna.actor.world.pos.y - 20.0f;
- currentPos.z = this->dyna.actor.world.pos.z + 100.0f;
+ pos.x = this->dyna.actor.world.pos.x - 200.0f;
+ pos.y = this->dyna.actor.world.pos.y - 20.0f;
+ pos.z = this->dyna.actor.world.pos.z + 100.0f;
+ BgDodoago_SpawnSparkles(&pos, globalCtx);
- BgDodoago_SpawnSparkles(¤tPos, globalCtx);
- Math_StepToS(&this->unk_164, 0x64, 3);
+ Math_StepToS(&this->state, 100, 3);
func_800AA000(500.0f, 0x78, 0x14, 0xA);
- if (Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, 0x1333, 0x6E - this->unk_164, 0x3E8, 0x32) == 0) {
+ if (Math_SmoothStepToS(&this->dyna.actor.shape.rot.x, 0x1333, 110 - this->state, 0x3E8, 0x32) == 0) {
BgDodoago_SetupAction(this, BgDodoago_DoNothing);
Audio_PlaySoundGeneral(NA_SE_EV_STONE_BOUND, &this->dyna.actor.projectedPos, 4, &D_801333E0, &D_801333E0,
&D_801333E8);
@@ -247,42 +256,48 @@ void func_80871FB8(BgDodoago* this, GlobalContext* globalCtx) {
void BgDodoago_DoNothing(BgDodoago* this, GlobalContext* globalCtx) {
}
-void func_80872288(BgDodoago* this, GlobalContext* globalCtx) {
- globalCtx->roomCtx.unk_74[this->unk_164] += 5;
+void BgDodoago_LightOneEye(BgDodoago* this, GlobalContext* globalCtx) {
+ globalCtx->roomCtx.unk_74[this->state] += 5;
- if (globalCtx->roomCtx.unk_74[this->unk_164] == 0xFF) {
- BgDodoago_SetupAction(this, func_80871CF4);
+ if (globalCtx->roomCtx.unk_74[this->state] == 255) {
+ BgDodoago_SetupAction(this, BgDodoago_WaitExplosives);
}
}
void BgDodoago_Update(Actor* thisx, GlobalContext* globalCtx) {
BgDodoago* this = (BgDodoago*)thisx;
+ Actor* actor;
EnBom* bomb;
if (this->dyna.actor.parent == NULL) {
- if ((s32)(this->colliders[1].base.ocFlags1 & OC1_HIT) || (this->colliders[2].base.ocFlags1 & OC1_HIT)) {
+ // this is a "bomb catcher", it kills the XZ speed and sets the timer for bombs that are dropped through the
+ // holes in the bridge above the skull
+ if ((this->colliderLeft.base.ocFlags1 & OC1_HIT) || (this->colliderRight.base.ocFlags1 & OC1_HIT)) {
- if ((s32)(this->colliders[1].base.ocFlags1 & OC1_HIT)) {
- bomb = (EnBom*)this->colliders[1].base.oc;
+ if (this->colliderLeft.base.ocFlags1 & OC1_HIT) {
+ actor = this->colliderLeft.base.oc;
} else {
- bomb = (EnBom*)this->colliders[2].base.oc;
+ actor = this->colliderRight.base.oc;
}
- this->colliders[1].base.ocFlags1 &= ~OC1_HIT;
- this->colliders[2].base.ocFlags1 &= ~OC1_HIT;
- if (bomb->actor.category == ACTORCAT_EXPLOSIVE && bomb->actor.id == ACTOR_EN_BOM &&
- bomb->actor.params == 0) {
+ this->colliderLeft.base.ocFlags1 &= ~OC1_HIT;
+ this->colliderRight.base.ocFlags1 &= ~OC1_HIT;
+
+ if (actor->category == ACTORCAT_EXPLOSIVE && actor->id == ACTOR_EN_BOM && actor->params == 0) {
+ bomb = (EnBom*)actor;
+ // disable the bomb catcher for a few seconds
this->dyna.actor.parent = &bomb->actor;
bomb->timer = 50;
bomb->actor.speedXZ = 0.0f;
- D_80872824 = 0;
+ sTimer = 0;
}
}
} else {
- D_80872824++;
+ sTimer++;
Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F);
- if (D_808727C0[0] == 0 && D_80872824 >= 0x8D) {
+ if (!sDisableBombCatcher && sTimer > 140) {
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
- D_808727C0[0]++;
+ // this prevents clearing the actor's parent pointer, effectively disabling the bomb catcher
+ sDisableBombCatcher++;
} else {
this->dyna.actor.parent = NULL;
}
@@ -298,7 +313,7 @@ void BgDodoago_Draw(Actor* thisx, GlobalContext* globalCtx) {
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_dodoago.c", 677),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
- gSPDisplayList(POLY_OPA_DISP++, gDodongoLowerJarDL);
+ gSPDisplayList(POLY_OPA_DISP++, gDodongoLowerJawDL);
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_dodoago.c", 681);
diff --git a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h
index 41994be8a2..9729162f85 100644
--- a/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h
+++ b/src/overlays/actors/ovl_Bg_Dodoago/z_bg_dodoago.h
@@ -4,14 +4,21 @@
#include "ultra64.h"
#include "global.h"
+typedef enum {
+ /* 0 */ BGDODOAGO_EYE_LEFT,
+ /* 1 */ BGDODOAGO_EYE_RIGHT
+} BgDodoagoEye;
+
struct BgDodoago;
typedef void (*BgDodoagoActionFunc)(struct BgDodoago*, GlobalContext*);
typedef struct BgDodoago {
/* 0x0000 */ DynaPolyActor dyna;
- /* 0x0164 */ s16 unk_164;
- /* 0x0168 */ ColliderCylinder colliders[3];
+ /* 0x0164 */ s16 state; // BgDodoagoEye or a timer-like value
+ /* 0x0168 */ ColliderCylinder colliderMain; // Used to detect explosions for lighting the eyes
+ /* 0x01B4 */ ColliderCylinder colliderLeft; // OC-colliding bombs have their xz speed cleared and timer set
+ /* 0x0200 */ ColliderCylinder colliderRight; // same as colliderLeft
/* 0x024C */ BgDodoagoActionFunc actionFunc;
} BgDodoago; // size = 0x0250