summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaide <34639600+Kelebek1@users.noreply.github.com>2021-09-02 17:27:11 +0100
committerGitHub <noreply@github.com>2021-09-02 12:27:11 -0400
commitda1265f4bcaec99bc884cb9ee0a5f61535780014 (patch)
tree1efd06812f425daadf418c78869bdfecf562367e /src
parent6ecea0ec6f5571246cb58ccd8696d9634c282458 (diff)
En_Dns (#241)
* En_Dns * NBS * PR * PR * Fix warnings * PR Co-authored-by: Angie <angheloalf95@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_En_Dai/z_en_dai.c2
-rw-r--r--src/overlays/actors/ovl_En_Dnp/z_en_dnp.c2
-rw-r--r--src/overlays/actors/ovl_En_Dnq/z_en_dnq.c2
-rw-r--r--src/overlays/actors/ovl_En_Dns/z_en_dns.c672
-rw-r--r--src/overlays/actors/ovl_En_Dns/z_en_dns.h50
5 files changed, 652 insertions, 76 deletions
diff --git a/src/overlays/actors/ovl_En_Dai/z_en_dai.c b/src/overlays/actors/ovl_En_Dai/z_en_dai.c
index 67127b164..c09c0dd3a 100644
--- a/src/overlays/actors/ovl_En_Dai/z_en_dai.c
+++ b/src/overlays/actors/ovl_En_Dai/z_en_dai.c
@@ -440,7 +440,7 @@ void func_80B3EEDC(EnDai* this, GlobalContext* globalCtx) {
}
void func_80B3EF90(EnDai* this, GlobalContext* globalCtx) {
- if (func_8010BF58(&this->actor, globalCtx, D_80B3FC8C, 0, &this->unk_1D0)) {
+ if (func_8010BF58(&this->actor, globalCtx, D_80B3FC8C, NULL, &this->unk_1D0)) {
func_8013AED4(&this->unk_1CE, 3, 7);
this->unk_1D0 = 0;
this->actionFunc = func_80B3F00C;
diff --git a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c
index 4fc548fcd..30b40c499 100644
--- a/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c
+++ b/src/overlays/actors/ovl_En_Dnp/z_en_dnp.c
@@ -321,7 +321,7 @@ void func_80B3D338(EnDnp* this, GlobalContext* globalCtx) {
}
void func_80B3D3F8(EnDnp* this, GlobalContext* globalCtx) {
- if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, 0, &this->unk_328)) {
+ if (func_8010BF58(&this->actor, globalCtx, D_80B3DE58, NULL, &this->unk_328)) {
func_8013AED4(&this->unk_322, 3, 7);
this->unk_322 &= ~8;
this->actionFunc = func_80B3D2D4;
diff --git a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c
index e553ea0f3..4a16868aa 100644
--- a/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c
+++ b/src/overlays/actors/ovl_En_Dnq/z_en_dnq.c
@@ -379,7 +379,7 @@ void func_80A52DC8(EnDnq* this, GlobalContext* globalCtx) {
void func_80A52FB8(EnDnq* this, GlobalContext* globalCtx) {
s16 sp2E = this->actor.yawTowardsPlayer;
- if (func_8010BF58(&this->actor, globalCtx, this->unk_380, 0, &this->unk_1E0)) {
+ if (func_8010BF58(&this->actor, globalCtx, this->unk_380, NULL, &this->unk_1E0)) {
func_8013AED4(&this->unk_37C, 3, 7);
this->unk_386 = 0;
this->actionFunc = func_80A52DC8;
diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/src/overlays/actors/ovl_En_Dns/z_en_dns.c
index 23092aacd..98f8dd5d3 100644
--- a/src/overlays/actors/ovl_En_Dns/z_en_dns.c
+++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.c
@@ -1,3 +1,9 @@
+/*
+ * File: z_en_dns.c
+ * Overlay: ovl_En_Dns
+ * Description: Deku Palace - King's Chamber Deku Guard
+ */
+
#include "z_en_dns.h"
#define FLAGS 0x00000019
@@ -9,12 +15,30 @@ void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnDns_Update(Actor* thisx, GlobalContext* globalCtx);
void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx);
-void func_8092D1B8(EnDns* this, GlobalContext* globalCtx);
-void func_8092D320(EnDns* this, GlobalContext* globalCtx);
void func_8092D330(EnDns* this, GlobalContext* globalCtx);
+void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx);
void func_8092D4D8(EnDns* this, GlobalContext* globalCtx);
-#if 0
+extern AnimationHeader D_060002A8;
+extern AnimationHeader D_06000734;
+extern AnimationHeader D_060008F4;
+extern AnimationHeader D_06000BD8;
+extern AnimationHeader D_06000D58;
+extern AnimationHeader D_06000FEC;
+extern TexturePtr D_060028E8;
+extern TexturePtr D_06002968;
+extern TexturePtr D_060029E8;
+extern Gfx D_06002C48[];
+extern SkeletonHeader D_06002DD8;
+extern AnimationHeader D_06003310;
+extern AnimationHeader D_060034EC;
+
+static s32 D_8092DCB0[] = {
+ 0x00172000, 0x050E082F, 0x0C100E08, 0x200C1000, 0x00172000, 0x050E0830, 0x0C100E08, 0x210C1000,
+ 0x00172000, 0x050E0831, 0x0C100E08, 0x220C1000, 0x00172000, 0x050E0832, 0x0C100E08, 0x230C1000,
+ 0x0E08330C, 0x09000015, 0x1C014016, 0x10000000, 0x0E082E0C, 0x10000000,
+};
+
const ActorInit En_Dns_InitVars = {
ACTOR_EN_DNS,
ACTORCAT_NPC,
@@ -27,74 +51,584 @@ const ActorInit En_Dns_InitVars = {
(ActorFunc)EnDns_Draw,
};
-// static ColliderCylinderInit sCylinderInit = {
-static ColliderCylinderInit D_8092DD28 = {
- { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, },
- { ELEMTYPE_UNK1, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, },
+static ColliderCylinderInit sCylinderInit = {
+ {
+ COLTYPE_HIT0,
+ AT_NONE,
+ AC_ON | AC_TYPE_PLAYER,
+ OC1_ON | OC1_TYPE_ALL,
+ OC2_TYPE_1,
+ COLSHAPE_CYLINDER,
+ },
+ {
+ ELEMTYPE_UNK1,
+ { 0x00000000, 0x00, 0x00 },
+ { 0xF7CFFFFF, 0x00, 0x00 },
+ TOUCH_NONE | TOUCH_SFX_NORMAL,
+ BUMP_ON,
+ OCELEM_ON,
+ },
{ 18, 46, 0, { 0, 0, 0 } },
};
-// sColChkInfoInit
-static CollisionCheckInfoInit2 D_8092DD54 = { 1, 0, 0, 0, MASS_IMMOVABLE };
-
-#endif
-
-extern ColliderCylinderInit D_8092DD28;
-extern CollisionCheckInfoInit2 D_8092DD54;
-
-extern UNK_TYPE D_06002C48;
-extern UNK_TYPE D_06002DD8;
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C5C0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C63C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C6FC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C740.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C86C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C934.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092C9BC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CA74.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CAD0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CB98.s")
+static CollisionCheckInfoInit2 sColChkInfoInit = { 1, 0, 0, 0, MASS_IMMOVABLE };
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CC68.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CCEC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092CE38.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D068.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D108.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D1B8.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D320.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D330.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D4D8.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D5E8.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/EnDns_Init.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/EnDns_Destroy.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/EnDns_Update.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092D954.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092DA68.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/func_8092DA94.s")
+static ActorAnimationEntryS sAnimations[] = {
+ { &D_06003310, 1.0f, 0, -1, 0, 0 }, { &D_06003310, 1.0f, 0, -1, 0, -4 }, { &D_060034EC, 1.0f, 0, -1, 0, 0 },
+ { &D_060034EC, 1.0f, 0, -1, 0, -4 }, { &D_060008F4, 1.0f, 0, -1, 2, 0 }, { &D_06000BD8, 1.0f, 0, -1, 0, 0 },
+ { &D_06000D58, 1.0f, 0, -1, 2, 0 }, { &D_06000FEC, 1.0f, 0, -1, 0, 0 }, { &D_060002A8, 1.0f, 0, -1, 2, 0 },
+ { &D_06000734, 1.0f, 0, -1, 2, 0 },
+};
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dns/EnDns_Draw.s")
+void func_8092C5C0(EnDns* this) {
+ s32 pad;
+
+ if (((this->unk_2F8 == 2) || (this->unk_2F8 == 3) || (this->unk_2F8 == 6) || (this->unk_2F8 == 7)) &&
+ (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 3.0f))) {
+ Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK);
+ }
+}
+
+s32 func_8092C63C(EnDns* this, s32 arg1) {
+ s32 phi_v1 = false;
+ s32 ret = 0;
+
+ switch (arg1) {
+ case 0:
+ case 1:
+ if ((this->unk_2F8 != 0) && (this->unk_2F8 != 1)) {
+ phi_v1 = true;
+ }
+ break;
+
+ case 2:
+ case 3:
+ if ((this->unk_2F8 != 2) && (this->unk_2F8 != 3)) {
+ phi_v1 = true;
+ }
+ break;
+
+ default:
+ if (this->unk_2F8 != arg1) {
+ phi_v1 = true;
+ }
+ }
+
+ if (phi_v1) {
+ this->unk_2F8 = arg1;
+ ret = func_8013BC6C(&this->skelAnime, sAnimations, arg1);
+ }
+
+ return ret;
+}
+
+void func_8092C6FC(EnDns* this, GlobalContext* globalCtx) {
+ Collider_UpdateCylinder(&this->actor, &this->collider);
+ CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
+}
+
+void func_8092C740(EnDns* this, GlobalContext* globalCtx) {
+ Player* player = PLAYER;
+ s16 temp = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
+ Vec3f sp34;
+ Vec3f sp28;
+
+ Math_ApproachS(&this->unk_2CE, temp, 4, 0x2AA8);
+ this->unk_2CE = CLAMP(this->unk_2CE, -0x3FFC, 0x3FFC);
+
+ Math_Vec3f_Copy(&sp28, &player->actor.world.pos);
+ sp28.y = player->bodyPartsPos[7].y + 3.0f;
+ Math_Vec3f_Copy(&sp34, &this->actor.world.pos);
+ sp34.y += 10.0f;
+ temp = Math_Vec3f_Pitch(&sp34, &sp28);
+ Math_ApproachS(&this->unk_2CC, temp, 4, 0x2AA8);
+ this->unk_2CC = CLAMP(this->unk_2CC, -0x16C0, 0xE38);
+}
+
+void func_8092C86C(EnDns* this, GlobalContext* globalCtx) {
+ if ((this->unk_2C6 & 8) && (DECR(this->unk_2DC) == 0)) {
+ func_8092C740(this, globalCtx);
+ this->unk_2C6 &= ~0x10;
+ this->unk_2C6 |= 0x20;
+ } else if (this->unk_2C6 & 0x20) {
+ this->unk_2C6 &= ~0x20;
+ this->unk_2CC = 0;
+ this->unk_2CE = 0;
+ this->unk_2DC = 20;
+ } else if (DECR(this->unk_2DC) == 0) {
+ this->unk_2C6 |= 0x10;
+ }
+}
+
+void func_8092C934(EnDns* this) {
+ if ((this->unk_2C6 & 0x40) && (DECR(this->unk_2DE) == 0)) {
+ this->unk_2E0++;
+ if (this->unk_2E0 >= 4) {
+ this->unk_2DE = Rand_S16Offset(30, 30);
+ this->unk_2E0 = 0;
+ }
+ }
+}
+
+s32* func_8092C9BC(EnDns* this, GlobalContext* globalCtx) {
+ Player* player = PLAYER;
+
+ if (!(gSaveContext.weekEventReg[23] & 0x20)) {
+ if (player->transformation != PLAYER_FORM_DEKU) {
+ return &D_8092DCB0[16];
+ } else if (this->unk_2FC != 0) {
+ return &D_8092DCB0[20];
+ }
+ }
+
+ switch (ENDNS_GET_7(&this->actor)) {
+ case ENDNS_GET_7_0:
+ return &D_8092DCB0[0];
+
+ case ENDNS_GET_7_1:
+ return &D_8092DCB0[4];
+
+ case ENDNS_GET_7_2:
+ return &D_8092DCB0[8];
+
+ case ENDNS_GET_7_3:
+ return &D_8092DCB0[12];
+ }
+
+ return 0;
+}
+
+s32 func_8092CA74(EnDns* this) {
+ switch (ENDNS_GET_7(&this->actor)) {
+ case ENDNS_GET_7_0:
+ return 0x1D1;
+
+ case ENDNS_GET_7_1:
+ return 0x1D2;
+
+ case ENDNS_GET_7_2:
+ return 0x1D3;
+
+ case ENDNS_GET_7_3:
+ return 0x1D4;
+ }
+
+ return 0;
+}
+
+s32 func_8092CAD0(EnDns* this, GlobalContext* globalCtx) {
+ s32 ret = false;
+
+ if (this->unk_2C6 & 7) {
+ if (func_800B84D0(&this->actor, globalCtx)) {
+ func_8013AED4(&this->unk_2C6, 0, 7);
+ this->unk_2C6 &= ~0x10;
+ if (ENDNS_GET_4000(&this->actor)) {
+ this->unk_2F0 = 0.0f;
+ if (this->unk_2D2 != 0) {
+ this->unk_2F0 = this->skelAnime.animCurrentFrame;
+ func_8092C63C(this, 2);
+ }
+ this->unk_2DA = this->actor.world.rot.y;
+ }
+ this->unk_1E0 = func_8092C9BC(this, globalCtx);
+ this->actionFunc = func_8092D4D8;
+ ret = true;
+ }
+ }
+ return ret;
+}
+
+s32 func_8092CB98(EnDns* this, GlobalContext* globalCtx) {
+ s32 phi_v1 = 0;
+
+ if (globalCtx->csCtx.state != 0) {
+ if (!(this->unk_2C6 & 0x80)) {
+ this->unk_2C8 = func_8092CA74(this);
+ this->actor.flags &= ~0x1;
+ func_8013AED4(&this->unk_2C6, 0, 7);
+ this->unk_2C6 |= 0x80;
+ this->unk_1D8 = 0xFF;
+ }
+ phi_v1 = 1;
+ } else if (this->unk_2C6 & 0x80) {
+ this->actor.flags |= 1;
+ func_8013AED4(&this->unk_2C6, 3, 7);
+ this->unk_2C6 &= ~0x80;
+ }
+ return phi_v1;
+}
+
+s32 func_8092CC68(GlobalContext* globalCtx) {
+ Player* player = PLAYER;
+ s32 pad[2];
+ s32 ret = false;
+ s16 bgId;
+
+ if (!func_801690CC(globalCtx) && (player->actor.bgCheckFlags & 1) && (player->transformation != PLAYER_FORM_DEKU)) {
+ bgId = player->actor.floorBgId;
+ if (func_800C99AC(&globalCtx->colCtx, player->actor.floorPoly, bgId) != 4) {
+ ret = true;
+ }
+ }
+
+ return ret;
+}
+
+s32 func_8092CCEC(EnDns* this, GlobalContext* globalCtx) {
+ Player* player = PLAYER;
+ s32 pad;
+ Vec3f sp3C = player->actor.world.pos;
+ Vec3f sp30 = this->actor.world.pos;
+ s16 sp2E;
+
+ Math_Vec3f_Copy(&sp30, &this->actor.world.pos);
+ Math_Vec3f_Copy(&sp3C, &player->actor.world.pos);
+ this->unk_2D6 = Math_Vec3f_Yaw(&D_801D15B0, &sp3C);
+ this->unk_2D4 = Math_Vec3f_Yaw(&D_801D15B0, &sp30);
+ this->unk_2EC = Math_Vec3f_DistXZ(&sp30, &D_801D15B0);
+ sp2E = Math_Vec3f_Yaw(&D_801D15B0, &sp3C);
+ sp2E -= Math_Vec3f_Yaw(&D_801D15B0, &sp30);
+ this->unk_2D8 = (Rand_ZeroOne() * 182.0f) + 182.0f;
+ this->unk_2D8 = (sp2E > 0) ? this->unk_2D8 : -this->unk_2D8;
+ this->unk_2D0 = 0x28;
+ this->actor.shape.shadowDraw = func_800B3FC0;
+ return 1;
+}
+
+s32 func_8092CE38(EnDns* this) {
+ static s32 D_8092DE00[] = { 8, 8, 9 };
+ s16 frame;
+ s32 pad;
+ Vec3f sp2C;
+ s32 ret = false;
+
+ if ((this->unk_2C6 & 0x200) || func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) {
+ func_8092C63C(this, D_8092DE00[this->unk_2D2]);
+ this->unk_2C6 &= ~0x200;
+ this->skelAnime.animCurrentFrame = 0.0f;
+ if (this->unk_2D2 == 2) {
+ Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP);
+ }
+ this->unk_2D2++;
+ if (this->unk_2D2 >= 3) {
+ this->unk_2D2 = 0;
+ }
+ ret = true;
+ } else {
+ if (this->unk_2D2 == 0) {
+ if (func_801378B8(&this->skelAnime, 13.0f)) {
+ this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y);
+ this->unk_2E4 = 0.0f;
+ this->actor.shape.rot.y = this->actor.world.rot.y;
+ Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_JUMP);
+ } else if (this->skelAnime.animCurrentFrame < 13.0f) {
+ frame = this->skelAnime.animCurrentFrame;
+ this->actor.shape.rot.y = this->actor.world.rot.y;
+ frame *= 2520;
+ this->actor.shape.rot.y += frame;
+ this->unk_2E4 -= -(40.0f / 13.0f);
+ }
+ } else {
+ if (func_801378B8(&this->skelAnime, 0.0f) || func_801378B8(&this->skelAnime, 6.0f) ||
+ func_801378B8(&this->skelAnime, 13.0f)) {
+ Audio_PlayActorSound2(&this->actor, NA_SE_EN_NUTS_WALK);
+ }
+
+ if (this->skelAnime.animCurrentFrame > 7.0f) {
+ this->unk_2E4 += -(20.0f / 13.0f);
+ }
+ }
+ sp2C.x = this->unk_2E4;
+ sp2C.y = 0.0f;
+ sp2C.z = 0.0f;
+ Lib_Vec3f_TranslateAndRotateY(&this->actor.home.pos, this->actor.world.rot.y, &sp2C, &this->actor.world.pos);
+ }
+
+ return ret;
+}
+
+s32 func_8092D068(EnDns* this) {
+ s32 ret = false;
+
+ if (ENDNS_GET_8000(&this->actor)) {
+ if (gSaveContext.weekEventReg[23] & 0x20) {
+ ret = true;
+ }
+ } else if (ENDNS_GET_4000(&this->actor)) {
+ if ((gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) {
+ ret = true;
+ }
+ } else if (!(gSaveContext.weekEventReg[9] & 0x80) && !(gSaveContext.weekEventReg[23] & 0x20)) {
+ ret = true;
+ }
+
+ return ret;
+}
+
+void func_8092D108(EnDns* this, GlobalContext* globalCtx) {
+ OPEN_DISPS(globalCtx->state.gfxCtx);
+
+ func_8012C28C(globalCtx->state.gfxCtx);
+
+ SysMatrix_SetStateRotationAndTranslation(this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z,
+ &this->actor.home.rot);
+ Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY);
+
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPDisplayList(POLY_OPA_DISP++, D_06002C48);
+
+ CLOSE_DISPS(globalCtx->state.gfxCtx);
+}
+
+void func_8092D1B8(EnDns* this, GlobalContext* globalCtx) {
+ Player* player = PLAYER;
+ s16 sp22 = this->actor.world.rot.y;
+
+ if (ENDNS_GET_4000(&this->actor)) {
+ func_8092CE38(this);
+ }
+
+ if (!ENDNS_GET_4000(&this->actor) || (this->unk_2D2 != 0)) {
+ if (!(gSaveContext.weekEventReg[23] & 0x20) && !(gSaveContext.eventInf[1] & 0x20) && func_8092CC68(globalCtx)) {
+ player->stateFlags1 |= 0x20;
+ this->unk_2C6 |= 0x100;
+ func_8013AED4(&this->unk_2C6, 4, 7);
+ play_sound(NA_SE_SY_FOUND);
+ gSaveContext.eventInf[1] |= 0x20;
+ this->unk_2F4 = func_8092CCEC;
+ func_8092C63C(this, 2);
+ this->actionFunc = EnDns_DoNothing;
+ } else if (gSaveContext.eventInf[1] & 0x40) {
+ func_8092CCEC(this, globalCtx);
+ func_8092C63C(this, 2);
+ this->actionFunc = func_8092D330;
+ }
+ Math_ApproachS(&this->actor.shape.rot.y, sp22, 3, 0x2AA8);
+ }
+}
+
+void EnDns_DoNothing(EnDns* this, GlobalContext* globalCtx) {
+}
+
+void func_8092D330(EnDns* this, GlobalContext* globalCtx) {
+ s32 pad;
+ Vec3f sp30 = D_801D15B0;
+ s16 temp = this->unk_2D6 - this->unk_2D4;
+
+ if (ABS_ALT(temp) < 0xC16) {
+ Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 3, 0x2AA8);
+ this->actor.world.rot.y = this->actor.shape.rot.y;
+ } else {
+ this->actor.world.pos.x = Math_SinS(this->unk_2D4) * this->unk_2EC;
+ this->actor.world.pos.z = Math_CosS(this->unk_2D4) * this->unk_2EC;
+ this->unk_2D4 += this->unk_2D8;
+ sp30.x = Math_SinS(this->unk_2D4) * this->unk_2EC;
+ sp30.z = Math_CosS(this->unk_2D4) * this->unk_2EC;
+ Math_ApproachS(&this->actor.shape.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &sp30), 3, 0x2AA8);
+ Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor);
+ }
+ if ((this->unk_2C6 & 0x100) && (DECR(this->unk_2D0) == 0)) {
+ this->unk_2C6 &= ~0x100;
+ globalCtx->nextEntranceIndex = 0x5010;
+ gSaveContext.unk_3F4A = 0;
+ globalCtx->sceneLoadFlag = 0x14;
+ globalCtx->unk_1887F = 3;
+ gSaveContext.nextTransition = 3;
+ }
+}
+
+void func_8092D4D8(EnDns* this, GlobalContext* globalCtx) {
+ s16 sp2E = this->actor.yawTowardsPlayer;
+
+ if (ENDNS_GET_4000(&this->actor) && (this->unk_2D2 == 0)) {
+ if (func_8092CE38(this)) {
+ func_8092C63C(this, 2);
+ }
+ } else if (func_8010BF58(&this->actor, globalCtx, this->unk_1E0, this->unk_2F4, &this->unk_1DC)) {
+ func_8013AED4(&this->unk_2C6, 3, 7);
+ this->unk_2F4 = NULL;
+ if (ENDNS_GET_4000(&this->actor)) {
+ if (!(gSaveContext.eventInf[1] & 0x20)) {
+ this->skelAnime.animCurrentFrame = this->unk_2F0;
+ this->actor.world.rot.y = this->unk_2DA;
+ func_8092C63C(this, 8);
+ }
+ this->unk_2CC = 0;
+ this->unk_2CE = 0;
+ this->unk_2C6 |= 0x10;
+ }
+ this->actionFunc = func_8092D1B8;
+ } else {
+ Math_ApproachS(&this->actor.shape.rot.y, sp2E, 3, 0x2AA8);
+ }
+}
+
+void func_8092D5E8(EnDns* this, GlobalContext* globalCtx) {
+ static s32 D_8092DE0C[] = { 0, 0, 4, 6 };
+ u32 temp_v0;
+ u32 temp_v1;
+
+ if (func_800EE29C(globalCtx, this->unk_2C8)) {
+ temp_v0 = func_800EE200(globalCtx, this->unk_2C8);
+ temp_v1 = globalCtx->csCtx.npcActions[temp_v0]->unk0;
+ if (this->unk_1D8 != (u8)temp_v1) {
+ func_8092C63C(this, D_8092DE0C[temp_v1]);
+ this->unk_1D8 = temp_v1;
+ }
+
+ if (((this->unk_2F8 == 4) || (this->unk_2F8 == 6)) &&
+ func_801378B8(&this->skelAnime, this->skelAnime.animFrameCount)) {
+ func_8092C63C(this, this->unk_2F8 + 1);
+ }
+
+ func_800EDF24(&this->actor, globalCtx, temp_v0);
+ }
+}
+
+void EnDns_Init(Actor* thisx, GlobalContext* globalCtx) {
+ EnDns* this = THIS;
+
+ if (!func_8092D068(this)) {
+ Actor_MarkForDeath(&this->actor);
+ return;
+ }
+
+ ActorShape_Init(&this->actor.shape, 0.0f, NULL, 18.0f);
+ SkelAnime_Init(globalCtx, &this->skelAnime, &D_06002DD8, NULL, this->jointTable, this->morphTable, 13);
+ this->unk_2F8 = -1;
+ func_8092C63C(this, 2);
+ Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
+ CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit);
+ Actor_SetScale(&this->actor, 0.01f);
+ this->actor.targetMode = 0;
+ this->actor.gravity = -0.8f;
+ this->unk_2D2 = 0;
+ this->unk_2C6 = 0;
+ func_8013AED4(&this->unk_2C6, 3, 7);
+ this->unk_2C6 |= (0x40 | 0x10);
+ this->unk_2C6 |= 0x200;
+ if (gSaveContext.weekEventReg[9] & 0x80) {
+ this->unk_2FC = 1;
+ } else {
+ this->unk_2FC = 0;
+ }
+ this->actionFunc = func_8092D1B8;
+ gSaveContext.eventInf[1] &= (u8)~0x20;
+ gSaveContext.eventInf[1] &= (u8)~0x40;
+}
+
+void EnDns_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+ EnDns* this = THIS;
+
+ Collider_DestroyCylinder(globalCtx, &this->collider);
+}
+
+void EnDns_Update(Actor* thisx, GlobalContext* globalCtx) {
+ EnDns* this = THIS;
+
+ if (!func_8092CAD0(this, globalCtx) && func_8092CB98(this, globalCtx)) {
+ func_8092D5E8(this, globalCtx);
+ SkelAnime_FrameUpdateMatrix(&this->skelAnime);
+ func_8092C5C0(this);
+ } else {
+ this->actionFunc(this, globalCtx);
+ SkelAnime_FrameUpdateMatrix(&this->skelAnime);
+ func_8092C934(this);
+ func_8092C86C(this, globalCtx);
+ Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, 12.0f, 0.0f, 4);
+ func_8013C964(&this->actor, globalCtx, 80.0f, 40.0f, 0, this->unk_2C6 & 7);
+ Actor_SetHeight(&this->actor, 34.0f);
+ func_8092C6FC(this, globalCtx);
+ func_8092C5C0(this);
+ }
+}
+
+s32 func_8092D954(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5) {
+ Vec3f sp74;
+ Vec3s sp6C;
+ MtxF sp2C;
+
+ SysMatrix_MultiplyVector3fByState(&D_801D15B0, &sp74);
+ SysMatrix_CopyCurrentState(&sp2C);
+ func_8018219C(&sp2C, &sp6C, 0);
+ *arg2 = sp74;
+
+ if (arg4 == 0) {
+ if (arg5 != 0) {
+ sp6C.z = arg0;
+ sp6C.y = arg1;
+ }
+ Math_SmoothStepToS(&arg3->x, sp6C.x, 3, 0x2AA8, 0xB6);
+ Math_SmoothStepToS(&arg3->y, sp6C.y, 3, 0x2AA8, 0xB6);
+ Math_SmoothStepToS(&arg3->z, sp6C.z, 3, 0x2AA8, 0xB6);
+ } else {
+ arg3->x = sp6C.x;
+ arg3->y = sp6C.y;
+ arg3->z = sp6C.z;
+ }
+
+ return 1;
+}
+
+s32 EnDns_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) {
+ EnDns* this = THIS;
+
+ this->unk_1E4[limbIndex] = *dList;
+ *dList = NULL;
+ return false;
+}
+
+void EnDns_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) {
+ EnDns* this = THIS;
+ s32 pad;
+ s32 phi_v1;
+ s32 phi_v0;
+
+ if (this->unk_2C6 & 0x10) {
+ phi_v1 = 1;
+ phi_v0 = 0;
+ } else {
+ phi_v1 = 0;
+ if (this->unk_2C6 & 0x20) {
+ phi_v0 = 1;
+ } else {
+ phi_v0 = 0;
+ }
+ }
+
+ if (limbIndex == 2) {
+ func_8092D954(this->unk_2CC, this->unk_2CE + this->actor.shape.rot.y, &this->unk_218, &this->unk_224, phi_v1,
+ phi_v0);
+ SysMatrix_InsertTranslation(this->unk_218.x, this->unk_218.y, this->unk_218.z, MTXMODE_NEW);
+ Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY);
+ Matrix_RotateY(this->unk_224.y, MTXMODE_APPLY);
+ SysMatrix_InsertXRotation_s(this->unk_224.z, MTXMODE_APPLY);
+ SysMatrix_InsertZRotation_s(this->unk_224.x, MTXMODE_APPLY);
+ }
+
+ OPEN_DISPS(globalCtx->state.gfxCtx);
+
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPDisplayList(POLY_OPA_DISP++, this->unk_1E4[limbIndex]);
+
+ CLOSE_DISPS(globalCtx->state.gfxCtx);
+}
+
+void EnDns_Draw(Actor* thisx, GlobalContext* globalCtx) {
+ static TexturePtr D_8092DE1C[] = { &D_060028E8, &D_06002968, &D_060029E8, &D_06002968 };
+ EnDns* this = THIS;
+
+ OPEN_DISPS(globalCtx->state.gfxCtx);
+
+ func_8012C28C(globalCtx->state.gfxCtx);
+
+ gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_8092DE1C[this->unk_2E0]));
+ gDPPipeSync(POLY_OPA_DISP++);
+
+ SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnDns_OverrideLimbDraw,
+ EnDns_PostLimbDraw, &this->actor);
+ func_8092D108(this, globalCtx);
+
+ CLOSE_DISPS(globalCtx->state.gfxCtx);
+}
diff --git a/src/overlays/actors/ovl_En_Dns/z_en_dns.h b/src/overlays/actors/ovl_En_Dns/z_en_dns.h
index a3ff0870d..598dfff3b 100644
--- a/src/overlays/actors/ovl_En_Dns/z_en_dns.h
+++ b/src/overlays/actors/ovl_En_Dns/z_en_dns.h
@@ -6,12 +6,54 @@
struct EnDns;
typedef void (*EnDnsActionFunc)(struct EnDns*, GlobalContext*);
+typedef s32 (*EnDnsFunc)(struct EnDns*, GlobalContext*);
+
+#define ENDNS_GET_7(thisx) ((thisx)->params & 7)
+#define ENDNS_GET_4000(thisx) ((thisx)->params & 0x4000)
+#define ENDNS_GET_8000(thisx) ((thisx)->params & 0x8000)
+
+enum {
+ /* 0x0 */ ENDNS_GET_7_0,
+ /* 0x1 */ ENDNS_GET_7_1,
+ /* 0x2 */ ENDNS_GET_7_2,
+ /* 0x3 */ ENDNS_GET_7_3,
+};
typedef struct EnDns {
- /* 0x0000 */ Actor actor;
- /* 0x0144 */ char unk_144[0x44];
- /* 0x0188 */ EnDnsActionFunc actionFunc;
- /* 0x018C */ char unk_18C[0x174];
+ /* 0x000 */ Actor actor;
+ /* 0x144 */ SkelAnime skelAnime;
+ /* 0x188 */ EnDnsActionFunc actionFunc;
+ /* 0x18C */ ColliderCylinder collider;
+ /* 0x1D8 */ u8 unk_1D8;
+ /* 0x1D9 */ UNK_TYPE1 unk_1D9[0x3];
+ /* 0x1DC */ s32 unk_1DC;
+ /* 0x1E0 */ s32* unk_1E0;
+ /* 0x1E4 */ Gfx* unk_1E4[13];
+ /* 0x218 */ Vec3f unk_218;
+ /* 0x224 */ Vec3s unk_224;
+ /* 0x22A */ Vec3s jointTable[13];
+ /* 0x278 */ Vec3s morphTable[13];
+ /* 0x2C6 */ u16 unk_2C6;
+ /* 0x2C8 */ u16 unk_2C8;
+ /* 0x2CA */ UNK_TYPE1 unk_2CA[0x2];
+ /* 0x2CC */ s16 unk_2CC;
+ /* 0x2CE */ s16 unk_2CE;
+ /* 0x2D0 */ s16 unk_2D0;
+ /* 0x2D2 */ s16 unk_2D2;
+ /* 0x2D4 */ s16 unk_2D4;
+ /* 0x2D6 */ s16 unk_2D6;
+ /* 0x2D8 */ s16 unk_2D8;
+ /* 0x2DA */ s16 unk_2DA;
+ /* 0x2DC */ s16 unk_2DC;
+ /* 0x2DE */ s16 unk_2DE;
+ /* 0x2E0 */ s16 unk_2E0;
+ /* 0x2E4 */ f32 unk_2E4;
+ /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x4];
+ /* 0x2EC */ f32 unk_2EC;
+ /* 0x2F0 */ f32 unk_2F0;
+ /* 0x2F4 */ EnDnsFunc unk_2F4;
+ /* 0x2F8 */ s32 unk_2F8;
+ /* 0x2FC */ s32 unk_2FC;
} EnDns; // size = 0x300
extern const ActorInit En_Dns_InitVars;