diff --git a/include/functions.h b/include/functions.h index 18fc730880..028b0dc488 100644 --- a/include/functions.h +++ b/include/functions.h @@ -629,7 +629,7 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f // void EffectSsGSpk_SpawnRandColor(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); // void EffectSsGSpk_SpawnSmall(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, - s16 alpha, s16 fadeDelay, s16 arg8, s32 life); + s16 alpha, s16 fadeDelay, s16 life, s32 arg9); void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale); void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life); diff --git a/include/variables.h b/include/variables.h index 9452578312..d5bbe17ac0 100644 --- a/include/variables.h +++ b/include/variables.h @@ -1414,7 +1414,7 @@ extern MtxF sMtxFClear; // extern UNK_TYPE1 D_801C5D20; // extern UNK_TYPE1 D_801C5D60; // extern UNK_TYPE1 D_801C5D80; -// extern UNK_TYPE1 D_801C5DB0; +extern Vec3f D_801C5DB0; // extern UNK_TYPE1 D_801C5DD0; // extern UNK_TYPE1 D_801C5DE0; // extern UNK_TYPE1 D_801C5DF0; diff --git a/include/z64effect.h b/include/z64effect.h index 9bb4f1ea2a..f84ae9c9ac 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -91,12 +91,19 @@ typedef struct { } EffBlureInit1; // size = 0x1A0 typedef struct { - /* 0x00 */ UNK_TYPE1 pad0[0x8]; - /* 0x08 */ Color_RGBA8 unk8; - /* 0x0C */ Color_RGBA8 unkC; - /* 0x10 */ Color_RGBA8 unk10; - /* 0x14 */ Color_RGBA8 unk14; - /* 0x18 */ UNK_TYPE1 pad18[0xC]; + /* 0x00 */ s32 calcMode; + /* 0x04 */ u16 flags; + /* 0x06 */ s16 addAngleChange; + /* 0x08 */ u8 p1StartColor[4]; + /* 0x0C */ u8 p2StartColor[4]; + /* 0x10 */ u8 p1EndColor[4]; + /* 0x14 */ u8 p2EndColor[4]; + /* 0x18 */ u8 elemDuration; + /* 0x19 */ u8 unkFlag; + /* 0x1A */ u8 drawMode; // 0: simple; 1: simple with alt colors; 2+: smooth + /* 0x1B */ u8 mode4Param; + /* 0x1C */ Color_RGBA8 altPrimColor; // used with drawMode 1 + /* 0x20 */ Color_RGBA8 altEnvColor; // used with drawMode 1 } EffBlureInit2; // size = 0x24 typedef struct { diff --git a/spec b/spec index 2668615840..4e2b6841c5 100644 --- a/spec +++ b/spec @@ -844,8 +844,7 @@ beginseg name "ovl_En_Dodongo" compress include "build/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.o" - include "build/data/ovl_En_Dodongo/ovl_En_Dodongo.data.o" - include "build/data/ovl_En_Dodongo/ovl_En_Dodongo.reloc.o" + include "build/src/overlays/actors/ovl_En_Dodongo/ovl_En_Dodongo_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h index 4fb546a2c4..723d254cb4 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.h @@ -9,7 +9,9 @@ typedef void (*EnBombfActionFunc)(struct EnBombf*, GlobalContext*); typedef struct EnBombf { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0xB0]; + /* 0x0144 */ char unk_144[0xAC]; + /* 0x01F0 */ s16 timer; + /* 0x01F2 */ char unk_1F2[0x2]; /* 0x01F4 */ EnBombfActionFunc actionFunc; /* 0x01F8 */ char unk_1F8[0x10]; } EnBombf; // size = 0x208 diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 1673ae7274..a71f415191 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -279,10 +279,17 @@ static InitChainEntry sInitChain[] = { void EnDinofos_Init(Actor* thisx, GlobalContext* globalCtx) { static s32 D_8089E364 = 0; static EffBlureInit2 D_8089E368 = { - { 0, 0, 0, 0, 0, 8, 0, 0 }, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, - { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, { 8, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + 0, + 8, + 0, + { 255, 255, 255, 255 }, + { 255, 255, 255, 64 }, + { 255, 255, 255, 0 }, + { 255, 255, 255, 0 }, + 8, 0, 2, 0, + { 0, 0, 0, 0 }, + { 0, 0, 0, 0 }, }; - EnDinofos* this = THIS; s32 i; ColliderJntSphElementDim* dim; @@ -1433,7 +1440,6 @@ void func_8089DC84(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* static s8 D_8089E3B0[] = { -1, -1, 0, -1, 1, 2, -1, 3, 4, -1, 5, 6, -1, 7, 8, -1, 9, 10, -1, 11, -1, }; - EnDinofos* this = THIS; Vec3f sp80; Vec3f sp74; diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index 94b474c45a..7c49e0ce0f 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -1,4 +1,12 @@ +/* + * File: z_en_dodongo.c + * Overlay: ovl_En_Dodongo + * Description: Dodongo + */ + #include "z_en_dodongo.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Bombf/z_en_bombf.h" #define FLAGS 0x00000405 @@ -9,7 +17,33 @@ void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx); void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_808773C4(EnDodongo* this); +void func_80877424(EnDodongo* this, GlobalContext* globalCtx); +void func_80877494(EnDodongo* this); +void func_80877500(EnDodongo* this, GlobalContext* globalCtx); +void func_808777A8(EnDodongo* this); +void func_8087784C(EnDodongo* this, GlobalContext* globalCtx); +void func_80877D50(EnDodongo* this); +void func_80877D90(EnDodongo* this, GlobalContext* globalCtx); +void func_80877E60(EnDodongo* this, GlobalContext* globalCtx); +void func_80878354(EnDodongo* this); +void func_80878424(EnDodongo* this, GlobalContext* globalCtx); +void func_808785B0(EnDodongo* this, GlobalContext* globalCtx); +void func_8087864C(EnDodongo* this); +void func_808786C8(EnDodongo* this, GlobalContext* globalCtx); +void func_80878724(EnDodongo* this); +void func_808787B0(EnDodongo* this, GlobalContext* globalCtx); + +extern AnimationHeader D_060013C4; +extern AnimationHeader D_06001A44; +extern AnimationHeader D_060028F0; +extern AnimationHeader D_06003088; +extern AnimationHeader D_06003B14; +extern AnimationHeader D_060042C4; +extern AnimationHeader D_06004C20; +extern SkeletonHeader D_06008318; +extern AnimationHeader D_06008B1C; + const ActorInit En_Dodongo_InitVars = { ACTOR_EN_DODONGO, ACTORCAT_ENEMY, @@ -22,86 +56,195 @@ const ActorInit En_Dodongo_InitVars = { (ActorFunc)EnDodongo_Draw, }; -// static ColliderJntSphElementInit sJntSphElementsInit[10] = { -static ColliderJntSphElementInit D_808790D0[10] = { +static ColliderJntSphElementInit sJntSphElementsInit1[10] = { { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800CB019, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800CB019, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 7, { { 500, 0, 0 }, 27 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800CB019, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800CB019, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 21, { { -200, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800CB019, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800CB019, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 28, { { -200, 0, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800CB019, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800CB019, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 22, { { 400, -400, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x800CB019, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x800CB019, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 29, { { 400, -400, 0 }, 20 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 16, { { 1000, 0, 0 }, 28 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 14, { { -300, 300, 0 }, 17 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 14, { { 800, 100, 0 }, 15 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 13, { { 600, 0, 0 }, 12 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 13, { { 1500, 0, 0 }, 12 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80879238 = { - { COLTYPE_HIT0, AT_NONE | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 10, D_808790D0, // sJntSphElementsInit, -}; - -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80879248 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_HARD | AC_TYPE_PLAYER, OC1_NONE, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - 3, D_808790D0, // sJntSphElementsInit, -}; - -// static ColliderJntSphElementInit sJntSphElementsInit[3] = { -static ColliderJntSphElementInit D_80879258[3] = { +static ColliderJntSphInit sJntSphInit1 = { { - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + COLTYPE_HIT0, + AT_NONE | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 10, + sJntSphElementsInit1, +}; + +static ColliderJntSphInit sJntSphInit2 = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_HARD | AC_TYPE_PLAYER, + OC1_NONE, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + 3, + sJntSphElementsInit1, +}; + +static ColliderJntSphElementInit sJntSphElementsInit2[3] = { + { + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 2, { { 0, -10, 10 }, 25 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 2, { { 0, -5, 50 }, 37 }, 100 }, }, { - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x10 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_NONE, }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x10 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, { 2, { { 0, 0, 90 }, 50 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_808792C4 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_NONE, OC2_NONE, COLSHAPE_JNTSPH, }, - 3, D_80879258, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit3 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_NONE, + OC2_NONE, + COLSHAPE_JNTSPH, + }, + 3, + sJntSphElementsInit2, }; -// static DamageTable sDamageTable = { -static DamageTable D_808792D4 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x1), /* Deku Stick */ DMG_ENTRY(1, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -136,97 +279,837 @@ static DamageTable D_808792D4 = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808792F4 = { 3, 100, 100, 80 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 100, 100, 80 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808792FC[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 13, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 1400, ICHAIN_STOP), }; -#endif +void EnDodongo_Init(Actor* thisx, GlobalContext* globalCtx) { + static EffBlureInit2 D_80879308 = { + 2, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 8, + 0, 0, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, + }; + EnDodongo* this = THIS; + s32 i; -extern ColliderJntSphElementInit D_808790D0[10]; -extern ColliderJntSphInit D_80879238; -extern ColliderJntSphInit D_80879248; -extern ColliderJntSphElementInit D_80879258[3]; -extern ColliderJntSphInit D_808792C4; -extern DamageTable D_808792D4; -extern CollisionCheckInfoInit D_808792F4; -extern InitChainEntry D_808792FC[]; + Actor_ProcessInitChain(&this->actor, sInitChain); + this->unk_32C.r = 255; + this->unk_32C.g = 255; + this->unk_32C.a = 200; + this->unk_330.r = 255; + this->unk_330.g = 10; + this->unk_330.a = 200; + Math_Vec3f_Copy(&this->unk_314, &D_801C5DB0); + ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 48.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_06008318, &D_06004C20, this->jointTable, this->morphTable, 31); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetJntSph(globalCtx, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); + Collider_InitAndSetJntSph(globalCtx, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); + Collider_InitAndSetJntSph(globalCtx, &this->collider3, &this->actor, &sJntSphInit3, this->collider3Elements); -extern UNK_TYPE D_060013C4; -extern UNK_TYPE D_06001A44; -extern UNK_TYPE D_060028F0; -extern UNK_TYPE D_06003088; -extern UNK_TYPE D_060042C4; -extern UNK_TYPE D_06004C20; -extern UNK_TYPE D_06008B1C; + for (i = 0; i < ARRAY_COUNT(this->collider2Elements); i++) { + this->collider2.elements[i].info.elemType = ELEMTYPE_UNK2; + this->collider2.elements[i].info.bumper.dmgFlags = 0x77C34FE6; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/EnDodongo_Init.s") + Effect_Add(globalCtx, &this->unk_338, 2, 0, 0, &D_80879308); + if (this->actor.params == 0) { + Actor_SetScale(&this->actor, 3.0f / 160.0f); + this->unk_334 = 1.0f; + } else { + Actor_SetScale(&this->actor, 3.0f / 80.0f); + this->actor.colChkInfo.health = 12; + this->unk_334 = 2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/EnDodongo_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->collider1Elements); i++) { + this->collider1.elements[i].dim.modelSphere.radius *= 2; + this->collider1.elements[i].info.toucher.damage *= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876930.s") + for (i = 0; i < ARRAY_COUNT(this->collider2Elements); i++) { + this->collider2.elements[i].dim.modelSphere.radius *= 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876B08.s") + for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { + this->collider3.elements[i].dim.modelSphere.radius *= 2; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876BD0.s") + func_808773C4(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876CAC.s") +void EnDodongo_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnDodongo* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876D28.s") + Effect_Destroy(globalCtx, this->unk_338); + Collider_DestroyJntSph(globalCtx, &this->collider2); + Collider_DestroyJntSph(globalCtx, &this->collider3); + Collider_DestroyJntSph(globalCtx, &this->collider1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80876DC4.s") +void func_80876930(EnDodongo* this, GlobalContext* globalCtx, Vec3f* arg2) { + static Color_RGBA8 D_8087932C = { 250, 250, 250, 255 }; + static Color_RGBA8 D_80879330 = { 180, 180, 180, 255 }; + static Color_RGBA8 D_80879334 = { 170, 130, 90, 255 }; + static Color_RGBA8 D_80879338 = { 100, 60, 20, 255 }; + static Vec3f D_8087933C = { 0.0f, 0.3f, 0.0f }; + s32 i; + Vec3f sp88; + s32 pad2; + Color_RGBA8* sp80; + Color_RGBA8* sp7C; + s32 pad; + s16 temp1; + s16 temp2; + f32 temp3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_8087721C.s") + if (func_800C9BB8(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 14) { + sp80 = &D_8087932C; + sp7C = &D_80879330; + } else { + sp80 = &D_80879334; + sp7C = &D_80879338; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877278.s") + temp1 = this->unk_334 * 300.0f; + temp2 = this->unk_334 * 15.0f; + temp3 = this->unk_334 * 30.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_808773C4.s") + for (i = 0; i < 3; i++) { + sp88.x = randPlusMinusPoint5Scaled(temp3) + arg2->x; + sp88.y = Rand_ZeroFloat(5.0f) + this->actor.floorHeight; + sp88.z = randPlusMinusPoint5Scaled(temp3) + arg2->z; + D_8087933C.x = randPlusMinusPoint5Scaled(2.0f); + D_8087933C.z = randPlusMinusPoint5Scaled(2.0f); + func_800B0DE0(globalCtx, &sp88, &D_801D15B0, &D_8087933C, sp80, sp7C, temp1, temp2); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877424.s") +void func_80876B08(EnDodongo* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + s16 yDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877494.s") + if (ABS_ALT(yDiff) < 0x4000) { + if (!(player->stateFlags1 & 0x00800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + func_808777A8(this); + } else { + func_80877494(this); + } + } else if (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK) { + func_80878354(this); + } else { + func_80877494(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877500.s") +void func_80876BD0(EnDodongo* this, GlobalContext* globalCtx, s32 arg2) { + if (this->actor.colChkInfo.damageEffect == 2) { + this->unk_300 = 0; + this->unk_340 = 0.75f; + this->unk_33C = 4.0f; + } else if (this->actor.colChkInfo.damageEffect == 4) { + this->unk_300 = 20; + this->unk_340 = 0.75f; + this->unk_33C = 4.0f; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider1.elements[arg2].info.bumper.hitPos.x, + this->collider1.elements[arg2].info.bumper.hitPos.y, + this->collider1.elements[arg2].info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_808777A8.s") +void func_80876CAC(EnDodongo* this) { + this->unk_300 = 10; + this->collider1.base.colType = COLTYPE_HIT3; + this->unk_340 = 0.75f; + this->unk_344 = 1.125f; + this->unk_33C = 1.0f; + this->timer = 80; + this->actor.flags &= ~0x400; + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_8087784C.s") +void func_80876D28(EnDodongo* this, GlobalContext* globalCtx) { + if (this->unk_300 == 10) { + this->timer = 0; + this->actor.colorFilterTimer = 0; + this->unk_300 = 0; + this->collider1.base.colType = COLTYPE_HIT0; + this->unk_33C = 0.0f; + func_800BF7CC(globalCtx, &this->actor, &this->unk_348[0], 9, 2, this->unk_334 * 0.3f, this->unk_334 * 0.2f); + this->actor.flags |= 0x400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877D50.s") +void func_80876DC4(EnDodongo* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f sp80; + Vec3f sp74; + Vec3f sp68; + s16 sp66; + s16 sp64; + s16 sp62; + f32 temp_f22; + f32 temp_f20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877D90.s") + Math_Vec3f_Copy(&sp68, &this->unk_348[0]); + sp66 = (Rand_Next() >> 0x12) + this->actor.shape.rot.y; + temp_f20 = Math_CosS(sp66); + temp_f22 = Math_SinS(sp66); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877DE0.s") + if (this->unk_32C.r > 30) { + this->unk_32C.r -= 16; + this->unk_32C.g += -16; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80877E60.s") + if (this->unk_32C.b < 30) { + this->unk_32C.b += 5; + this->unk_32C.a += 8; + this->unk_330.a += 8; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878354.s") + if (this->unk_330.r != 0) { + this->unk_330.r -= 15; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878424.s") + if (this->unk_330.g != 0) { + this->unk_330.g--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878594.s") + sp80.x = temp_f22 * 3.5f * this->unk_334; + sp80.y = this->unk_330.r * 0.02f * this->unk_334; + sp80.z = temp_f20 * 3.5f * this->unk_334; + sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; + sp74.y = this->unk_334 * 0.3f; + sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; + sp64 = this->unk_334 * 100.0f; + sp62 = this->unk_334 * 25.0f; + func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_808785B0.s") + sp66 = ((u32)Rand_Next() >> 0x13) + this->actor.shape.rot.y; + temp_f20 = Math_CosS(sp66); + temp_f22 = Math_SinS(sp66); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_8087864C.s") + sp68.x -= (temp_f20 * 6.0f) * this->unk_334; + sp68.z += (temp_f22 * 6.0f) * this->unk_334; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_808786C8.s") + sp80.x = -temp_f20 * 3.5f * this->unk_334; + sp80.z = temp_f22 * 3.5f * this->unk_334; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878724.s") + sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * temp_f20 * this->unk_334; + sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f22 * this->unk_334; + func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_808787B0.s") + sp68.x = this->unk_348[0].x + (temp_f20 * 6.0f * this->unk_334); + sp68.z = this->unk_348[0].z - (temp_f22 * 6.0f * this->unk_334); + sp80.x *= -1.0f; + sp80.z = sp80.z * -1.0f; + sp74.x = (Rand_ZeroFloat(0.1f) + 0.15f) * -temp_f20 * this->unk_334; + sp74.z = (Rand_ZeroFloat(0.1f) + 0.15f) * temp_f22 * this->unk_334; + func_800B0EB0(globalCtx, &sp68, &sp80, &sp74, &this->unk_32C, &this->unk_330, sp64, sp62, 0x14); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878910.s") +s32 func_8087721C(EnDodongo* this) { + if ((this->actionFunc == func_8087784C) && (this->skelAnime.animCurrentFrame >= 29.0f) && + (this->skelAnime.animCurrentFrame <= 43.0f)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/EnDodongo_Update.s") +s32 func_80877278(EnDodongo* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Vec3f sp44; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878E44.s") + // Bugfix from OoT + while (explosive != NULL) { + if (!explosive->params && (explosive->parent == NULL) && (explosive->update != NULL) && + (explosive != player->unk_388) && + (((explosive->id == ACTOR_EN_BOM) && (((EnBom*)explosive)->timer > 0)) || + ((explosive->id == ACTOR_EN_BOMBF) && (((EnBombf*)explosive)->timer > 0)))) { + Math_Vec3f_Diff(&explosive->world.pos, &this->unk_308, &sp44); + if ((fabsf(sp44.x) < 20.0f) && (fabsf(sp44.y) < 10.0f) && (fabsf(sp44.z) < 20.0f)) { + this->actor.child = explosive; + explosive->freezeTimer = 30000; // 25 minutes + return true; + } + } + explosive = explosive->next; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/func_80878EB4.s") +void func_808773C4(EnDodongo* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06004C20, -4.0f); + this->actor.speedXZ = 0.0f; + this->timer = Rand_S16Offset(30, 50); + this->actionFunc = func_80877424; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Dodongo/EnDodongo_Draw.s") +void func_80877424(EnDodongo* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + if (func_801378B8(&this->skelAnime, 0.0f)) { + func_80877494(this); + } + } +} + +void func_80877494(EnDodongo* this) { + SkelAnime_ChangeAnimTransitionRepeat(&this->skelAnime, &D_06008B1C, -4.0f); + this->actor.speedXZ = this->unk_334 * 1.5f; + this->timer = Rand_S16Offset(50, 70); + this->actionFunc = func_80877500; +} + +void func_80877500(EnDodongo* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + Vec3f sp30; + s16 temp_v1; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (func_801378B8(&this->skelAnime, 19.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + sp30.x = this->collider1Elements[2].dim.worldSphere.center.x; + sp30.y = this->collider1Elements[2].dim.worldSphere.center.y; + sp30.z = this->collider1Elements[2].dim.worldSphere.center.z; + func_80876930(this, globalCtx, &sp30); + } else if (func_801378B8(&this->skelAnime, 39.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_WALK); + sp30.x = this->collider1Elements[1].dim.worldSphere.center.x; + sp30.y = this->collider1Elements[1].dim.worldSphere.center.y; + sp30.z = this->collider1Elements[1].dim.worldSphere.center.z; + func_80876930(this, globalCtx, &sp30); + } + + if ((Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < 400.0f) && + (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + Math_ScaledStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0x1F4); + if (this->actor.xzDistToPlayer < (100.0f * this->unk_334)) { + if ((ABS_ALT(temp_v1) < 0x1388) && (this->actor.yDistToPlayer < 60.0f) && + !(player->stateFlags1 & 0x800000)) { + func_808777A8(this); + } + } + } else { + if ((Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 150.0f) || + (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK)) { + Math_ScaledStepToS(&this->actor.world.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x1F4); + } + + this->timer--; + if (this->timer == 0) { + if (Rand_ZeroOne() > 0.7f) { + this->timer = Rand_S16Offset(50, 70); + } else { + func_808773C4(this); + } + } + } + + this->actor.shape.rot.y = this->actor.world.rot.y; +} + +void func_808777A8(EnDodongo* this) { + s32 i; + Sphere16* sph; + + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060028F0, -4.0f); + this->actor.speedXZ = 0.0f; + + for (i = 0; i < ARRAY_COUNT(this->collider3Elements); i++) { + sph = &this->collider3.elements[i].dim.worldSphere; + + sph->center.x = this->unk_348[0].x; + sph->center.y = this->unk_348[0].y; + sph->center.z = this->unk_348[0].z; + sph->radius = 0; + } + + this->actionFunc = func_8087784C; +} + +void func_8087784C(EnDodongo* this, GlobalContext* globalCtx) { + static Vec3f D_80879348 = { 0.0f, 0.9f, 0.0f }; + static Vec3f D_80879354 = { 0.0f, 0.0f, 0.0f }; + s16 frame; + ColliderJntSphElement* element; + s32 i; + s32 end; + f32 temp_f2; + f32 temp_f12; + + if (func_801378B8(&this->skelAnime, 24.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_CRY); + } + + if (func_8087721C(this)) { + func_800B9010(&this->actor, NA_SE_EN_DODO_J_FIRE - SFX_FLAG); + frame = this->skelAnime.animCurrentFrame - 29.0f; + end = frame >> 1; + if (end > 3) { + end = 3; + } + + element = &this->collider3.elements[0]; + temp_f2 = Math_SinS(this->actor.shape.rot.y) * this->unk_334; + temp_f12 = Math_CosS(this->actor.shape.rot.y) * this->unk_334; + + for (i = 0; i < end; i++, element++) { + element->dim.worldSphere.center.x = this->unk_348[0].x + (element->dim.modelSphere.center.z * temp_f2); + element->dim.worldSphere.center.y = + this->unk_348[0].y + (element->dim.modelSphere.center.y * this->unk_334); + element->dim.worldSphere.center.z = this->unk_348[0].z + (element->dim.modelSphere.center.z * temp_f12); + element->dim.worldSphere.radius = element->dim.modelSphere.radius; + } + + D_80879354.y = this->unk_334 * -4.5f; + D_80879348.x = 2.5f * temp_f2; + D_80879348.y = this->unk_334 * 1.4f; + D_80879348.z = 2.5f * temp_f12; + EffectSsDFire_Spawn(globalCtx, &this->unk_348[0], &D_80879354, &D_80879348, this->unk_334 * 100.0f, + this->unk_334 * 35.0f, 0xFF - (frame * 10), 5, 0, 8); + } else if ((this->skelAnime.animCurrentFrame >= 2.0f) && (this->skelAnime.animCurrentFrame <= 20.0f)) { + func_800B9010(&this->actor, NA_SE_EN_DODO_J_BREATH - SFX_FLAG); + } + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + func_80877D50(this); + } +} + +void func_80877D50(EnDodongo* this) { + SkelAnime_ChangeAnimDefaultStop(&this->skelAnime, &D_06003088); + this->actionFunc = func_80877D90; +} + +void func_80877D90(EnDodongo* this, GlobalContext* globalCtx) { + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + func_808773C4(this); + this->timer = Rand_S16Offset(10, 20); + } +} + +void func_80877DE0(EnDodongo* this) { + SkelAnime_ChangeAnim(&this->skelAnime, &D_060028F0, -1.0f, 35.0f, 0.0f, 2, -4.0f); + this->actor.flags |= 0x10; + this->timer = 25; + this->actionFunc = func_80877E60; + this->actor.speedXZ = 0.0f; +} + +void func_80877E60(EnDodongo* this, GlobalContext* globalCtx) { + static Vec3f D_80879360 = { 0.0f, 0.6f, 0.0f }; + static Color_RGBA8 D_8087936C = { 255, 255, 255, 255 }; + Vec3f sp84; + Vec3f sp78; + s16 i; + Actor* explosive = globalCtx->actorCtx.actorList[ACTORCAT_EXPLOSIVES].first; + Vec3f sp64; + s32 pad; + s16 sp5E; + s16 sp5C; + + while (explosive != NULL) { + if (explosive == this->actor.child) { + break; + } + explosive = explosive->next; + } + + if (explosive == NULL) { + this->actor.child = NULL; + } + + if (this->actor.child != NULL) { + Math_Vec3f_Copy(&this->actor.child->world.pos, &this->unk_308); + this->actor.child->freezeTimer = 30000; // 25 minutes + } + + if (func_801378B8(&this->skelAnime, 28.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_EAT); + if (this->actor.child != NULL) { + Actor_MarkForDeath(this->actor.child); + this->actor.child = NULL; + } + this->actor.flags &= ~0x10; + } else if (this->skelAnime.animPlaybackSpeed > -0.5f) { + this->timer--; + if (this->timer == 10) { + for (i = 10; i >= 0; i--) { + sp84.x = randPlusMinusPoint5Scaled(10.0f); + sp84.y = randPlusMinusPoint5Scaled(10.0f); + sp84.z = randPlusMinusPoint5Scaled(10.0f); + sp78.x = sp84.x * -0.1f; + sp78.y = sp84.y * -0.1f; + sp78.z = sp84.z * -0.1f; + sp64.x = this->collider1Elements[0].dim.worldSphere.center.x + sp84.x; + sp64.y = this->collider1Elements[0].dim.worldSphere.center.y + sp84.y; + sp64.z = this->collider1Elements[0].dim.worldSphere.center.z + sp84.z; + func_800B0EB0(globalCtx, &sp64, &sp84, &sp78, &this->unk_32C, &this->unk_330, this->unk_334 * 400.0f, + this->unk_334 * 10.0f, 10); + } + + Audio_PlayActorSound2(&this->actor, NA_SE_IT_BOMB_EXPLOSION); + if (this->actor.colChkInfo.health <= 4) { + this->actor.colChkInfo.health = 0; + func_800BBA88(globalCtx, &this->actor); + } else { + this->actor.colChkInfo.health -= 4; + } + func_800BCB70(&this->actor, 0x4000, 0x78, 0, 8); + } + } else if (func_801378B8(&this->skelAnime, 24.0f)) { + this->timer--; + this->skelAnime.animPlaybackSpeed = 0.0f; + } + + if (this->skelAnime.animCurrentFrame <= 27.0f) { + if ((this->skelAnime.animCurrentFrame <= 25.0f) && (this->timer < 11)) { + func_80876DC4(this, globalCtx); + } else { + sp5E = this->unk_334 * 50.0f; + sp5C = this->unk_334 * 5.0f; + Math_Vec3f_Copy(&sp64, &this->unk_348[0]); + func_800B0DE0(globalCtx, &sp64, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + sp64.x -= Math_CosS(this->actor.shape.rot.y) * 6.0f * this->unk_334; + sp64.z += Math_SinS(this->actor.shape.rot.y) * 6.0f * this->unk_334; + func_800B0DE0(globalCtx, &sp64, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + sp64.x = (2.0f * this->unk_348[0].x) - sp64.x; + sp64.z = (2.0f * this->unk_348[0].z) - sp64.z; + func_800B0DE0(globalCtx, &sp64, &D_801D15B0, &D_80879360, &D_8087936C, &D_8087936C, sp5E, sp5C); + } + } + + this->unk_314.z = Math_SinS((this->actor.colorFilterTimer * 0x1000) >> 1) + 1.0f; + this->unk_314.x = Math_SinS(this->actor.colorFilterTimer * 0x1000) + 1.0f; + this->unk_314.y = this->unk_314.z; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if (this->timer == 0) { + if (this->actor.colChkInfo.health == 0) { + func_80878724(this); + } else { + func_8087864C(this); + } + this->unk_304 = 1; + } +} + +void func_80878354(EnDodongo* this) { + s32 pad; + AnimationHeader* sp18; + s16 yDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; + + this->unk_306 = (0xFFFF - ABS_ALT(yDiff)) / 15; + + if (yDiff >= 0) { + sp18 = &D_060042C4; + this->unk_306 = -this->unk_306; + } else { + sp18 = &D_06003B14; + } + + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_TAIL); + SkelAnime_ChangeAnimPlaybackStop(&this->skelAnime, sp18, 2.0f); + this->timer = 0; + this->collider1.base.atFlags |= AT_ON; + this->unk_304 = -1; + this->actionFunc = func_80878424; +} + +void func_80878424(EnDodongo* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + Vec3f sp20; + + this->timer++; + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) { + this->collider1.base.atFlags &= ~AT_ON; + func_808777A8(this); + } else { + func_80877494(this); + } + return; + } + + this->actor.world.rot.y += this->unk_306; + this->actor.shape.rot.y = this->actor.world.rot.y; + sp20.x = this->collider1Elements[1].dim.worldSphere.center.x; + sp20.y = this->collider1Elements[1].dim.worldSphere.center.y; + sp20.z = this->collider1Elements[1].dim.worldSphere.center.z; + func_80876930(this, globalCtx, &sp20); + sp20.x = this->collider1Elements[2].dim.worldSphere.center.x; + sp20.y = this->collider1Elements[2].dim.worldSphere.center.y; + sp20.z = this->collider1Elements[2].dim.worldSphere.center.z; + func_80876930(this, globalCtx, &sp20); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + this->actor.flags |= 0x1000000; +} + +void func_80878594(EnDodongo* this) { + this->actionFunc = func_808785B0; + this->actor.speedXZ = 0.0f; +} + +void func_808785B0(EnDodongo* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + func_80876D28(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + func_80878724(this); + } else if (this->actor.xzDistToPlayer > 100.0f * this->unk_334) { + func_80877494(this); + } else { + func_80876B08(this, globalCtx); + } + } +} + +void func_8087864C(EnDodongo* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_06001A44, -4.0f); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DAMAGE); + this->timer = 0; + this->unk_304 = 0; + this->actor.speedXZ = 0.0f; + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + this->actionFunc = func_808786C8; +} + +void func_808786C8(EnDodongo* this, GlobalContext* globalCtx) { + if (this->unk_304 == 1) { + func_80876DC4(this, globalCtx); + } + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + func_80876B08(this, globalCtx); + } +} + +void func_80878724(EnDodongo* this) { + SkelAnime_ChangeAnimTransitionStop(&this->skelAnime, &D_060013C4, -8.0f); + this->timer = 0; + this->unk_304 = 0; + Audio_PlayActorSound2(&this->actor, NA_SE_EN_DODO_J_DEAD); + this->actor.flags &= ~1; + this->actor.speedXZ = 0.0f; + func_800BCB70(&this->actor, 0x4000, 0xFF, 0, 8); + this->actionFunc = func_808787B0; +} + +void func_808787B0(EnDodongo* this, GlobalContext* globalCtx) { + s32 pad; + + if (this->skelAnime.animCurrentFrame < 35.0f) { + if (this->unk_304 != 0) { + func_80876DC4(this, globalCtx); + } + } else if (this->actor.colorFilterTimer == 0) { + func_800BCB70(&this->actor, 0x4000, 0x78, 0, 4); + } + + if (SkelAnime_FrameUpdateMatrix(&this->skelAnime)) { + if (this->timer == 0) { + EnBom* bomb = (EnBom*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + if (bomb != NULL) { + bomb->timer = 0; + } + this->timer = 8; + } + } else if (func_801378B8(&this->skelAnime, 52.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } + + if (this->timer != 0) { + this->timer--; + if (this->timer == 0) { + if (this->actor.params == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + } else { + Item_DropCollectible(globalCtx, &this->actor.world.pos, ITEM00_RUPEE_PURPLE); + } + Actor_MarkForDeath(&this->actor); + } + } +} + +void EnDodongo_UpdateDamage(EnDodongo* this, GlobalContext* globalCtx) { + Vec3f sp3C; + s32 i; + + if (this->collider2.base.acFlags & AC_HIT) { + this->collider2.base.acFlags &= ~AC_HIT; + this->collider1.base.acFlags &= ~AC_HIT; + + for (i = 0; i < ARRAY_COUNT(this->collider2Elements); i++) { + if (this->collider2.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if ((i != ARRAY_COUNT(this->collider2Elements)) && + ((this->unk_300 != 10) || !(this->collider2.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + func_80876D28(this, globalCtx); + Math_Vec3s_ToVec3f(&sp3C, &this->collider2.elements[i].info.bumper.hitPos); + if (this->actor.colChkInfo.damageEffect == 0xF) { + CollisionCheck_BlueBlood(globalCtx, NULL, &sp3C); + EffectSsHitMark_SpawnFixedScale(globalCtx, 0, &sp3C); + } else if (this->actor.colChkInfo.damageEffect != 14) { + EffectSsHitMark_SpawnFixedScale(globalCtx, 3, &sp3C); + CollisionCheck_SpawnShieldParticlesMetalSound(globalCtx, &sp3C, &this->actor.projectedPos); + } + } + } else if (this->collider1.base.acFlags & AC_HIT) { + this->collider2.base.acFlags &= ~AC_HIT; + this->collider1.base.acFlags &= ~AC_HIT; + func_800BE2B8(&this->actor, &this->collider1); + + for (i = 0; i < ARRAY_COUNT(this->collider1Elements); i++) { + if (this->collider1.elements[i].info.bumperFlags & BUMP_HIT) { + break; + } + } + + if ((i != ARRAY_COUNT(this->collider1Elements)) && + ((this->unk_300 != 10) || !(this->collider1.elements[i].info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + func_80876D28(this, globalCtx); + if (this->actor.colChkInfo.damageEffect != 0xF) { + if (!func_800BE22C(&this->actor)) { + func_800BBA88(globalCtx, &this->actor); + if (this->actor.colChkInfo.damageEffect == 3) { + func_80876CAC(this); + this->timer = 3; + this->collider1.base.acFlags &= ~AC_ON; + this->collider2.base.acFlags &= ~AC_ON; + func_80878594(this); + } else { + func_80876BD0(this, globalCtx, i); + func_80878724(this); + } + } else if (this->actor.colChkInfo.damageEffect == 1) { + this->timer = 40; + func_800BCB70(&this->actor, 0, 0xFF, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + func_80878594(this); + } else if (this->actor.colChkInfo.damageEffect == 5) { + this->timer = 40; + func_800BCB70(&this->actor, 0, 0xFF, 0, 40); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->unk_300 = 30; + this->unk_340 = 0.75f; + this->unk_33C = 2.0f; + func_80878594(this); + } else if (this->actor.colChkInfo.damageEffect == 3) { + func_80876CAC(this); + func_80878594(this); + } else { + func_80876BD0(this, globalCtx, i); + func_8087864C(this); + } + } + } + } +} + +void EnDodongo_Update(Actor* thisx, GlobalContext* globalCtx2) { + EnDodongo* this = THIS; + GlobalContext* globalCtx = globalCtx2; + + EnDodongo_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 75.0f, 60.0f, 70.0f, 0x1D); + if (this->actor.bgCheckFlags & 2) { + Audio_PlayActorSound2(&this->actor, NA_SE_EN_GERUDOFT_DOWN); + } + + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if (this->actionFunc != func_808787B0) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider2.base); + if ((this->actionFunc != func_808786C8) && (this->actionFunc != func_80877E60)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider1.base); + if ((this->actionFunc != func_8087784C) && func_80877278(this, globalCtx)) { + func_80877DE0(this); + } + } + } + + if (func_8087721C(this)) { + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider3.base); + } + + if (this->unk_33C > 0.0f) { + if (this->unk_300 != 10) { + Math_StepToF(&this->unk_33C, 0.0f, 0.05f); + this->unk_340 = (this->unk_33C + 1.0f) * 0.375f; + this->unk_340 = (this->unk_340 > 0.75f) ? 0.75f : this->unk_340; + } else if (!Math_StepToF(&this->unk_344, 0.75f, 0.01875f)) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } +} + +s32 EnDodongo_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnDodongo* this = THIS; + + if (limbIndex == 1) { + pos->z += 1000.0f; + } else if ((limbIndex == 15) || (limbIndex == 16)) { + Matrix_Scale(this->unk_314.x, this->unk_314.y, this->unk_314.z, MTXMODE_APPLY); + } + + return false; +} + +void EnDodongo_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f D_80879370 = { 1800.0f, 1200.0f, 0.0f }; + static Vec3f D_8087937C = { 1500.0f, 300.0f, 0.0f }; + static s8 D_80879388[] = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, + -1, -1, -1, -1, -1, 5, 6, -1, -1, -1, -1, -1, 7, 8, -1, 0, + }; + EnDodongo* this = THIS; + + Collider_UpdateSpheres(limbIndex, &this->collider1); + Collider_UpdateSpheres(limbIndex, &this->collider2); + if (D_80879388[limbIndex] != -1) { + SysMatrix_GetStateTranslation(&this->unk_348[D_80879388[limbIndex]]); + } + + if (limbIndex == 7) { + SysMatrix_MultiplyVector3fByState(&D_80879370, &this->unk_308); + SysMatrix_MultiplyVector3fByState(&D_8087937C, &this->unk_348[0]); + SysMatrix_GetStateTranslation(&this->actor.focus.pos); + SysMatrix_GetStateTranslationAndScaledY(-200.0f, &this->unk_348[1]); + } else if (limbIndex == 13) { + SysMatrix_GetStateTranslationAndScaledX(1600.0f, &this->unk_320); + } + + if ((limbIndex == 30) && (this->actionFunc == func_80878424) && (this->timer != this->unk_304)) { + func_800A81F0(Effect_GetParams(this->unk_338), &this->unk_320, &this->unk_348[4]); + this->unk_304 = this->timer; + } +} + +void EnDodongo_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnDodongo* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnDodongo_OverrideLimbDraw, + EnDodongo_PostLimbDraw, &this->actor); + func_800BE680(globalCtx, &this->actor, this->unk_348, ARRAY_COUNT(this->unk_348), this->unk_340 * this->unk_334, + this->unk_344 * this->unk_334, this->unk_33C, this->unk_300); +} diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h index 67a5e1993a..4a7fe8e9d8 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.h @@ -8,10 +8,32 @@ struct EnDodongo; typedef void (*EnDodongoActionFunc)(struct EnDodongo*, GlobalContext*); typedef struct EnDodongo { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1B8]; - /* 0x02FC */ EnDodongoActionFunc actionFunc; - /* 0x0300 */ char unk_300[0x514]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[31]; + /* 0x242 */ Vec3s morphTable[31]; + /* 0x2FC */ EnDodongoActionFunc actionFunc; + /* 0x300 */ u8 unk_300; + /* 0x302 */ s16 timer; + /* 0x304 */ s16 unk_304; + /* 0x306 */ s16 unk_306; + /* 0x308 */ Vec3f unk_308; + /* 0x314 */ Vec3f unk_314; + /* 0x320 */ Vec3f unk_320; + /* 0x32C */ Color_RGBA8 unk_32C; + /* 0x330 */ Color_RGBA8 unk_330; + /* 0x334 */ f32 unk_334; + /* 0x338 */ s32 unk_338; + /* 0x33C */ f32 unk_33C; + /* 0x340 */ f32 unk_340; + /* 0x344 */ f32 unk_344; + /* 0x348 */ Vec3f unk_348[9]; + /* 0x3B4 */ ColliderJntSph collider1; + /* 0x3D4 */ ColliderJntSphElement collider1Elements[10]; + /* 0x654 */ ColliderJntSph collider2; + /* 0x674 */ ColliderJntSphElement collider2Elements[3]; + /* 0x734 */ ColliderJntSph collider3; + /* 0x754 */ ColliderJntSphElement collider3Elements[3]; } EnDodongo; // size = 0x814 extern const ActorInit En_Dodongo_InitVars;