diff --git a/assets/xml/objects/object_wallmaster.xml b/assets/xml/objects/object_wallmaster.xml index d6ab1aa02e..fba2bc2460 100644 --- a/assets/xml/objects/object_wallmaster.xml +++ b/assets/xml/objects/object_wallmaster.xml @@ -1,63 +1,75 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 3ba626c71e..bbf6420cc5 100644 --- a/spec +++ b/spec @@ -800,8 +800,7 @@ beginseg name "ovl_En_Wallmas" compress include "build/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.data.o" - include "build/data/ovl_En_Wallmas/ovl_En_Wallmas.reloc.o" + include "build/src/overlays/actors/ovl_En_Wallmas/ovl_En_Wallmas_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index ce5928004e..489d464413 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -5,7 +5,6 @@ */ #include "z_en_floormas.h" -#include "objects/object_wallmaster/object_wallmaster.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_400) @@ -154,8 +153,8 @@ void EnFloormas_Init(Actor* thisx, GlobalContext* globalCtx2) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 50.0f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_wallmaster_Skel_008FB0, &object_wallmaster_Anim_009DB0, - this->jointTable, this->morphTable, 25); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -259,7 +258,7 @@ void func_808D0A48(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0B08(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0B50; } @@ -278,7 +277,7 @@ void func_808D0B50(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0C14(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_00A054, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterStandUpAnim, -3.0f); this->actionFunc = func_808D0C58; } @@ -296,7 +295,7 @@ void func_808D0C58(EnFloormas* this, GlobalContext* globalCtx) { void func_808D0CE4(EnFloormas* this) { if (this->actionFunc != func_808D0F80) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 1.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 1.5f); } else { this->skelAnime.playSpeed = 1.5f; } @@ -334,7 +333,7 @@ void func_808D0D70(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D0ECC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009244); + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D0F14; } @@ -373,10 +372,10 @@ void func_808D108C(EnFloormas* this) { this->actor.speedXZ = 0.0f; if (sp36 > 0) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_002158, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gFloormasterTurnAnim, -3.0f); } else { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_002158, -1.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_002158.common), 0.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gFloormasterTurnAnim, -1.0f, Animation_GetLastFrame(&gFloormasterTurnAnim), + 0.0f, ANIMMODE_ONCE, -3.0f); } if (this->actor.scale.x > 0.009f) { @@ -418,8 +417,8 @@ void func_808D11BC(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1380(EnFloormas* this, GlobalContext* globalCtx) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_009520, 3.0f, 0.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_009520.common), 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterHoverAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterHoverAnim), + ANIMMODE_ONCE, -3.0f); this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; func_808D08D0(this); @@ -492,7 +491,7 @@ void func_808D1650(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1740(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, 42.0f, 2, 5.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, 42.0f, ANIMMODE_ONCE, 5.0f); if ((this->actor.speedXZ < 0.0f) || (this->actionFunc != func_808D1650)) { this->unk_18E = 30; } else { @@ -538,7 +537,7 @@ void func_808D17EC(EnFloormas* this, GlobalContext* globalCtx) { if ((this->unk_18E == 0) && (sp24 != 0)) { if (this->skelAnime.endFrame < 45.0f) { - this->skelAnime.endFrame = Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common); + this->skelAnime.endFrame = Animation_GetLastFrame(&gWallmasterJumpAnim); } else if (this->actor.params == ENFLOORMAS_GET_7FFF_40) { func_808D2700(this); } else { @@ -569,8 +568,8 @@ void func_808D19D4(EnFloormas* this) { this->actor.shape.rot.y = parent->shape.rot.y + 0x5555; this->actor.world.pos = parent->world.pos; this->actor.params = ENFLOORMAS_GET_7FFF_10; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 41.0f, - Animation_GetLastFrame(&object_wallmaster_Anim_0019CC.common), 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, 0.0f); this->collider.dim.radius = sCylinderInit.dim.radius * 0.6f; this->collider.dim.height = sCylinderInit.dim.height * 0.6f; this->actor.flags &= ~ACTOR_FLAG_400; @@ -596,7 +595,7 @@ void func_808D1B44(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1BCC(EnFloormas* this) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1C1C; } @@ -623,7 +622,7 @@ void func_808D1C1C(EnFloormas* this, GlobalContext* globalCtx) { void func_808D1D0C(EnFloormas* this) { if (this->actionFunc != func_808D1C1C) { - Animation_PlayLoopSetSpeed(&this->skelAnime, &object_wallmaster_Anim_0041F4, 4.5f); + Animation_PlayLoopSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 4.5f); } this->actor.speedXZ = 5.0f; this->actionFunc = func_808D1D6C; @@ -686,7 +685,7 @@ void func_808D1F7C(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D1FD4(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D2040; } @@ -716,7 +715,7 @@ void func_808D217C(EnFloormas* this, Player* player) { Vec3f* ptr; u8 playerForm; - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 1.0f, 36.0f, 45.0f, 2, -3.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 36.0f, 45.0f, ANIMMODE_ONCE, -3.0f); this->actor.flags &= ~ACTOR_FLAG_1; this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; @@ -772,7 +771,7 @@ void func_808D22C8(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2484(EnFloormas* this) { - Animation_Change(&this->skelAnime, &object_wallmaster_Anim_0019CC, 2.0f, 0.0f, 41.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 2.0f, 0.0f, 41.0f, ANIMMODE_ONCE, 0.0f); this->actor.speedXZ = 0.0f; this->actionFunc = func_808D24F0; } @@ -816,7 +815,7 @@ void func_808D24F0(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2700(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; this->unk_194 = 1500; this->actor.params = ENFLOORMAS_GET_7FFF_40; @@ -881,10 +880,10 @@ void func_808D2764(EnFloormas* this, GlobalContext* globalCtx) { this->actor.colChkInfo.health = sColChkInfoInit.health; func_808D0C14(this); } else if (this->unk_18E == 0) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_0039B0); + Animation_PlayOnce(&this->skelAnime, &gFloormasterTapFingerAnim); this->unk_18E = 1; } else { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_009DB0); + Animation_PlayOnce(&this->skelAnime, &gWallmasterIdleAnim); this->unk_18E = 0; } } @@ -924,7 +923,7 @@ void func_808D2AF4(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2B18(EnFloormas* this) { - Animation_MorphToPlayOnce(&this->skelAnime, &object_wallmaster_Anim_000590, -3.0f); + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); func_800BE504(&this->actor, &this->collider); Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); this->actor.speedXZ = 5.0f; @@ -967,7 +966,7 @@ void func_808D2C08(EnFloormas* this, GlobalContext* globalCtx) { } void func_808D2CDC(EnFloormas* this) { - Animation_PlayOnce(&this->skelAnime, &object_wallmaster_Anim_000EA4); + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); this->actor.speedXZ = 0.0f; this->actor.velocity.y = 0.0f; this->actor.world.rot.y = this->actor.shape.rot.y; @@ -1151,9 +1150,10 @@ s32 EnFloormas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** d Actor* thisx, Gfx** gfx) { EnFloormas* this = THIS; - if (limbIndex == 1) { + if (limbIndex == WALLMASTER_LIMB_ROOT) { pos->z += this->unk_192; } + return false; } @@ -1165,13 +1165,10 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_GetStateTranslation(&this->limbPos[D_808D393C[limbIndex]]); } - if (limbIndex == 19) { + if (limbIndex == WALLMASTER_LIMB_WRIST) { Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); - return; - } - - if (limbIndex == 2) { + } else if (limbIndex == WALLMASTER_LIMB_HAND) { Matrix_StatePush(); Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); Matrix_InsertYRotation_f(M_PI / 3, MTXMODE_APPLY); @@ -1179,7 +1176,7 @@ void EnFloormas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, object_wallmaster_DL_008688); + gSPDisplayList((*gfx)++, gWallmasterLittleFingerDL); Matrix_StatePop(); } diff --git a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h index 7cf52edc33..5c33ba8863 100644 --- a/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h +++ b/src/overlays/actors/ovl_En_Floormas/z_en_floormas.h @@ -2,6 +2,7 @@ #define Z_EN_FLOORMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" struct EnFloormas; @@ -26,8 +27,8 @@ typedef struct EnFloormas { /* 0x0190 */ s16 unk_190; /* 0x0192 */ s16 unk_192; /* 0x0194 */ s16 unk_194; - /* 0x0196 */ Vec3s jointTable[25]; - /* 0x022C */ Vec3s morphTable[25]; + /* 0x0196 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x022C */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; /* 0x02C4 */ f32 drawDmgEffAlpha; /* 0x02C8 */ f32 drawDmgEffScale; /* 0x02CC */ f32 drawDmgEffFrozenSteamScale; diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 39f1e4f956..6bb60f174e 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -186,10 +186,10 @@ void EnPr2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } if (this->actor.parent != NULL) { - Actor* parent = this->actor.parent; + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; - if ((parent->update != NULL) && (((EnEncount1*)parent)->unk_14E > 0)) { - ((EnEncount1*)parent)->unk_14E--; + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; } } } diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 0bdb51729a..1b88d692b2 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -5,6 +5,8 @@ */ #include "z_en_wallmas.h" +#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" +#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_4 | ACTOR_FLAG_10 | ACTOR_FLAG_400) @@ -15,22 +17,32 @@ void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx); void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80874BE4(EnWallmas* this, GlobalContext* globalCtx); -void func_80874DE8(EnWallmas* this, GlobalContext* globalCtx); -void func_80874FD8(EnWallmas* this, GlobalContext* globalCtx); -void func_80875054(EnWallmas* this, GlobalContext* globalCtx); -void func_80875108(EnWallmas* this, GlobalContext* globalCtx); -void func_8087520C(EnWallmas* this, GlobalContext* globalCtx); -void func_808752CC(EnWallmas* this, GlobalContext* globalCtx); -void func_80875484(EnWallmas* this, GlobalContext* globalCtx); -void func_8087556C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875638(EnWallmas* this, GlobalContext* globalCtx); -void func_8087571C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875910(EnWallmas* this, GlobalContext* globalCtx); -void func_8087596C(EnWallmas* this, GlobalContext* globalCtx); -void func_80875A0C(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupStand(EnWallmas* this); +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupWalk(EnWallmas* this); +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupJumpToCeiling(EnWallmas* this); +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupReturnToCeiling(EnWallmas* this); +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupCooldown(EnWallmas* this); +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this); +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx); +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx); -#if 0 const ActorInit En_Wallmas_InitVars = { ACTOR_EN_WALLMAS, ACTORCAT_ENEMY, @@ -43,147 +55,704 @@ const ActorInit En_Wallmas_InitVars = { (ActorFunc)EnWallmas_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80876360 = { - { COLTYPE_HIT0, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, 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_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 30, 40, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_8087638C = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(1, 0x0), - /* Hookshot */ DMG_ENTRY(0, 0xF), - /* Goron punch */ DMG_ENTRY(1, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x3), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ WALLMASTER_DMGEFF_NONE, + /* 0x1 */ WALLMASTER_DMGEFF_STUN, + /* 0x2 */ WALLMASTER_DMGEFF_FIRE_ARROW, + /* 0x3 */ WALLMASTER_DMGEFF_ICE_ARROW, + /* 0x4 */ WALLMASTER_DMGEFF_LIGHT_ARROW, + /* 0x5 */ WALLMASTER_DMGEFF_ZORA_MAGIC, + /* 0xF */ WALLMASTER_DMGEFF_HOOKSHOT = 0xF +} EnWallmasDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(0, WALLMASTER_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_FIRE_ARROW), + /* Ice arrow */ DMG_ENTRY(1, WALLMASTER_DMGEFF_ICE_ARROW), + /* Light arrow */ DMG_ENTRY(2, WALLMASTER_DMGEFF_LIGHT_ARROW), + /* Goron spikes */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, WALLMASTER_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, WALLMASTER_DMGEFF_ZORA_MAGIC), + /* Normal shield */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, WALLMASTER_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, WALLMASTER_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_808763AC = { 3, 30, 40, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 3, 30, 40, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_808763B4[] = { +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 48, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 5500, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1500, ICHAIN_STOP), }; -#endif +static f32 sYOffsetPerForm[] = { 50.0f, 55.0f, 50.0f, 20.0f, 30.0f }; -extern ColliderCylinderInit D_80876360; -extern DamageTable D_8087638C; -extern CollisionCheckInfoInit D_808763AC; -extern InitChainEntry D_808763B4[]; +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the limbPos array. An index of -1 indicates that the limb is not part + * of the limbPos array. + */ +static s8 sLimbIndexToLimbPosIndex[] = { + -1, -1, -1, -1, 0, -1, -1, 1, -1, 2, -1, -1, 3, -1, 4, -1, -1, 5, -1, -1, -1, 6, 7, -1, 8, +}; -extern UNK_TYPE D_06000590; -extern UNK_TYPE D_06000EA4; -extern UNK_TYPE D_060019CC; -extern UNK_TYPE D_0600299C; -extern UNK_TYPE D_060041F4; -extern UNK_TYPE D_06008688; -extern UNK_TYPE D_06009244; -extern UNK_TYPE D_06009520; -extern UNK_TYPE D_06009DB0; -extern UNK_TYPE D_0600A054; +void EnWallmas_Init(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Init.s") + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.5f); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gWallmasterSkel, &gWallmasterIdleAnim, this->jointTable, + this->morphTable, WALLMASTER_LIMB_MAX); + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Destroy.s") + this->switchFlag = WALLMASTER_GET_SWITCH_FLAG(thisx); + this->actor.params &= 0xFF; + this->detectionRadius = this->actor.shape.rot.x * 40.0f * 0.1f; + this->actor.shape.rot.x = 0; + this->actor.world.rot.x = 0; + if (this->detectionRadius <= 0.0f) { + this->detectionRadius = 200.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874A88.s") + Actor_SetFocus(&this->actor, 25.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B04.s") + if (WALLMASTER_IS_FROZEN(&this->actor)) { + Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, this->actor.world.rot.x, + (this->actor.world.rot.y + 0x5900), this->actor.world.rot.z, 0xFF50); + this->actor.params &= ~0x80; + EnWallmas_SetupReturnToCeiling(this); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874B88.s") + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + Actor_MarkForDeath(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874BE4.s") + EnWallmas_ProximityOrSwitchInit(this); + } else if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + EnWallmas_ProximityOrSwitchInit(this); + } else { + EnWallmas_TimerInit(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874D1C.s") +void EnWallmas_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874DE8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874F14.s") + if (this->actor.parent != NULL) { + EnEncount1* encount1 = (EnEncount1*)this->actor.parent; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80874FD8.s") + if ((encount1->actor.update != NULL) && (encount1->unk_14E > 0)) { + encount1->unk_14E--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875014.s") +void EnWallmas_Freeze(EnWallmas* this) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffFrozenSteamScale = 0.82500005f; + this->drawDmgEffAlpha = 1.0f; + this->collider.base.colType = 3; + this->timer = 80; + this->actor.flags &= ~ACTOR_FLAG_400; + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 80); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875054.s") +void EnWallmas_ThawIfFrozen(EnWallmas* this, GlobalContext* globalCtx) { + if (this->drawDmgEffType == ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + this->collider.base.colType = 0; + this->drawDmgEffAlpha = 0.0f; + Actor_SpawnIceEffects(globalCtx, &this->actor, this->limbPos, 11, 2, 0.3f, 0.2f); + this->actor.flags |= ACTOR_FLAG_400; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808750B8.s") +void EnWallmas_TimerInit(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875108.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_20; + this->timer = 130; + this->actor.velocity.y = 0.0f; + this->actor.world.pos.y = player->actor.world.pos.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.draw = EnWallmas_Draw; + this->actionFunc = EnWallmas_WaitToDrop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808751C4.s") +void EnWallmas_WaitToDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f* playerPos = &player->actor.world.pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087520C.s") + this->actor.world.pos = *playerPos; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.floorPoly = player->actor.floorPoly; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875248.s") + if (this->timer != 0) { + this->timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808752CC.s") + if ((player->stateFlags1 & 0x08100000) || (player->stateFlags2 & 0x80) || (player->unk_B5E > 0) || + (player->actor.freezeTimer > 0) || !(player->actor.bgCheckFlags & 1) || + ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) && + (Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos) > (120.f + this->detectionRadius)))) { + func_801A75E8(NA_SE_EN_FALL_AIM); + this->timer = 130; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808753F0.s") + if (this->timer == 80) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_AIM); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875484.s") + if (this->timer == 0) { + EnWallmas_SetupDrop(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875518.s") +void EnWallmas_SetupDrop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087556C.s") + Animation_Change(&this->skelAnime, &gWallmasterLungeAnim, 0.0f, 20.0f, + Animation_GetLastFrame(&gWallmasterLungeAnim), ANIMMODE_ONCE, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808755A8.s") + this->yTarget = player->actor.world.pos.y; + this->actor.world.pos.y = player->actor.world.pos.y + 300.0f; + this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actor.floorHeight = player->actor.floorHeight; + this->actor.flags |= ACTOR_FLAG_1; + this->actor.flags &= ~ACTOR_FLAG_20; + this->actionFunc = EnWallmas_Drop; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875638.s") +void EnWallmas_Drop(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808756AC.s") + if ((player->stateFlags2 & 0x80) || (player->actor.freezeTimer > 0)) { + EnWallmas_SetupReturnToCeiling(this); + } else if (!Play_InCsMode(globalCtx) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + (this->actor.xzDistToPlayer < 30.0f) && (this->actor.playerHeightRel < -5.0f) && + (-(f32)(player->cylinder.dim.height + 10) < this->actor.playerHeightRel)) { + EnWallmas_SetupTakePlayer(this, globalCtx); + } else if (this->actor.world.pos.y <= this->yTarget) { + this->actor.world.pos.y = this->yTarget; + this->actor.velocity.y = 0.0f; + EnWallmas_SetupLand(this, globalCtx); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087571C.s") +void EnWallmas_SetupLand(EnWallmas* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 1.0f, 41.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808758C8.s") + Actor_SpawnFloorDustRing(globalCtx, &this->actor, &this->actor.world.pos, 15.0f, 6, 20.0f, 300, 100, true); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_LAND); + this->actionFunc = EnWallmas_Land; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875910.s") +void EnWallmas_Land(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupStand(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_8087596C.s") +void EnWallmas_SetupStand(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStandUpAnim); + this->actionFunc = EnWallmas_Stand; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808759B8.s") +void EnWallmas_Stand(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupWalk(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A0C.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875A74.s") +void EnWallmas_SetupWalk(EnWallmas* this) { + Animation_PlayOnceSetSpeed(&this->skelAnime, &gWallmasterWalkAnim, 3.0f); + this->actor.speedXZ = 3.0f; + this->actionFunc = EnWallmas_Walk; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Update.s") +void EnWallmas_Walk(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupJumpToCeiling(this); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80875F04.s") + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 0xB6); + this->actor.world.rot.y = this->actor.shape.rot.y; + if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 12.0f) || + Animation_OnFrame(&this->skelAnime, 24.0f) || Animation_OnFrame(&this->skelAnime, 36.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_WALK); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_808760A4.s") +void EnWallmas_SetupJumpToCeiling(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterStopWalkAnim); + this->actor.speedXZ = 0.0f; + this->actionFunc = EnWallmas_JumpToCeiling; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/func_80876118.s") +void EnWallmas_JumpToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Wallmas/EnWallmas_Draw.s") +void EnWallmas_SetupReturnToCeiling(EnWallmas* this) { + this->timer = 0; + this->actor.speedXZ = 0.0f; + Animation_Change(&this->skelAnime, &gWallmasterJumpAnim, 3.0f, 0.0f, Animation_GetLastFrame(&gWallmasterJumpAnim), + ANIMMODE_ONCE, -3.0f); + this->actionFunc = EnWallmas_ReturnToCeiling; +} + +void EnWallmas_ReturnToCeiling(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + SkelAnime_Update(&this->skelAnime); + if (this->skelAnime.curFrame > 20.0f) { + this->actor.world.pos.y += 30.0f; + this->timer += 9; + this->actor.flags &= ~ACTOR_FLAG_2000; + } + + if (Animation_OnFrame(&this->skelAnime, 20.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + if (this->actor.playerHeightRel < -900.0f) { + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_FLAG) { + Actor_MarkForDeath(&this->actor); + return; + } + + if ((WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_TIMER_ONLY) || + (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius)) { + EnWallmas_TimerInit(this, globalCtx); + } else { + EnWallmas_ProximityOrSwitchInit(this); + } + } +} + +void EnWallmas_SetupDamage(EnWallmas* this, s32 arg1) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterDamageAnim, -3.0f); + + if (arg1) { + func_800BE504(&this->actor, &this->collider); + } + + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->actor.speedXZ = 5.0f; + this->actor.velocity.y = 10.0f; + this->actionFunc = EnWallmas_Damage; +} + +void EnWallmas_Damage(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDie(this, globalCtx); + } else { + EnWallmas_SetupCooldown(this); + } + } + + if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_EYEGOLE_ATTACK); + } + + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.2f); +} + +void EnWallmas_SetupCooldown(EnWallmas* this) { + Animation_PlayOnce(&this->skelAnime, &gWallmasterRecoverFromDamageAnim); + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->actionFunc = EnWallmas_Cooldown; +} + +void EnWallmas_Cooldown(EnWallmas* this, GlobalContext* globalCtx) { + if (SkelAnime_Update(&this->skelAnime)) { + EnWallmas_SetupReturnToCeiling(this); + } +} + +void EnWallmas_SetupDie(EnWallmas* this, GlobalContext* globalCtx) { + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + func_800B3030(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, 250, -10, 2); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 11, NA_SE_EN_EXTINCT); + this->actionFunc = EnWallmas_Die; +} + +void EnWallmas_Die(EnWallmas* this, GlobalContext* globalCtx) { + if (Math_StepToF(&this->actor.scale.x, 0.0f, 0.0015f)) { + Actor_SetScale(&this->actor, 0.01f); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x90); + Actor_MarkForDeath(&this->actor); + } + + this->actor.scale.z = this->actor.scale.x; + this->actor.scale.y = this->actor.scale.x; +} + +void EnWallmas_SetupTakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Animation_MorphToPlayOnce(&this->skelAnime, &gWallmasterHoverAnim, -5.0f); + this->timer = -30; + this->actionFunc = EnWallmas_TakePlayer; + this->actor.speedXZ = 0.0f; + this->actor.velocity.y = 0.0f; + this->yTarget = this->actor.playerHeightRel; + func_800B724C(globalCtx, &this->actor, 18); +} + +void EnWallmas_TakePlayer(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Animation_OnFrame(&this->skelAnime, 1.0f)) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_DAMAGE_S); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_CATCH); + } + + if (SkelAnime_Update(&this->skelAnime)) { + player->actor.world.pos.x = this->actor.world.pos.x; + player->actor.world.pos.z = this->actor.world.pos.z; + + if (this->timer < 0) { + this->actor.world.pos.y += 2.0f; + } else { + this->actor.world.pos.y += 10.0f; + } + + player->actor.world.pos.y = this->actor.world.pos.y - sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)]; + if (this->timer == -30) { + func_800B8E58(player, player->ageProperties->unk_92 + NA_SE_VO_LI_TAKEN_AWAY); + } + + if (this->timer == 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_UP); + } + + this->timer += 2; + } else { + Math_StepToF(&this->actor.world.pos.y, + sYOffsetPerForm[((void)0, gSaveContext.save.playerForm)] + player->actor.world.pos.y, 5.0f); + } + + Math_StepToF(&this->actor.world.pos.x, player->actor.world.pos.x, 3.0f); + Math_StepToF(&this->actor.world.pos.z, player->actor.world.pos.z, 3.0f); + + if (this->timer == 30) { + play_sound(NA_SE_OC_ABYSS); + func_80169FDC(&globalCtx->state); + } +} + +void EnWallmas_ProximityOrSwitchInit(EnWallmas* this) { + this->timer = 0; + this->actor.draw = NULL; + this->actor.flags &= ~ACTOR_FLAG_1; + if (WALLMASTER_GET_TYPE(&this->actor) == WALLMASTER_TYPE_PROXIMITY) { + this->actionFunc = EnWallmas_WaitForProximity; + } else { + this->actionFunc = EnWallmas_WaitForSwitchFlag; + } +} + +void EnWallmas_WaitForProximity(EnWallmas* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->detectionRadius) { + EnWallmas_TimerInit(this, globalCtx); + } +} + +void EnWallmas_WaitForSwitchFlag(EnWallmas* this, GlobalContext* globalCtx) { + if (Flags_GetSwitch(globalCtx, this->switchFlag)) { + EnWallmas_TimerInit(this, globalCtx); + this->timer = 81; + } +} + +void EnWallmas_SetupStun(EnWallmas* this) { + this->actor.speedXZ = 0.0f; + if (this->actor.velocity.y > 0.0f) { + this->actor.velocity.y = 0.0f; + } + + func_800BE504(&this->actor, &this->collider); + this->actionFunc = EnWallmas_Stun; +} + +void EnWallmas_Stun(EnWallmas* this, GlobalContext* globalCtx) { + if (this->timer != 0) { + this->timer--; + } + + if (this->timer == 0) { + EnWallmas_ThawIfFrozen(this, globalCtx); + if (this->actor.colChkInfo.health == 0) { + EnWallmas_SetupDamage(this, false); + } else { + this->actor.world.rot.y = this->actor.shape.rot.y; + EnWallmas_SetupReturnToCeiling(this); + } + } +} + +void EnWallmas_UpdateDamage(EnWallmas* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + + if ((this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) || + (!(this->collider.info.acHitInfo->toucher.dmgFlags & 0xDB0B3))) { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_DAIOCTA_REVERSE); + this->actor.flags &= ~ACTOR_FLAG_1; + } else if (this->actor.colChkInfo.damage != 0) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_FALL_DAMAGE); + } + + EnWallmas_ThawIfFrozen(this, globalCtx); + + if (this->actor.colChkInfo.damageEffect != WALLMASTER_DMGEFF_HOOKSHOT) { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ICE_ARROW) { + EnWallmas_Freeze(this); + if (this->actor.colChkInfo.health == 0) { + this->timer = 3; + this->collider.base.acFlags &= ~AC_ON; + } + + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_STUN) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnWallmas_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_ZORA_MAGIC) { + this->timer = 40; + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_MEDIUM; + EnWallmas_SetupStun(this); + } else { + if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_FIRE_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; + } else if (this->actor.colChkInfo.damageEffect == WALLMASTER_DMGEFF_LIGHT_ARROW) { + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffScale = 0.55f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, + this->collider.info.bumper.hitPos.x, this->collider.info.bumper.hitPos.y, + this->collider.info.bumper.hitPos.z, 0, 0, 0, CLEAR_TAG_LARGE_LIGHT_RAYS); + } + + EnWallmas_SetupDamage(this, true); + } + } + } + } +} + +void EnWallmas_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnWallmas* this = THIS; + + EnWallmas_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_WaitForProximity) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + if ((this->actionFunc != EnWallmas_ReturnToCeiling) && (this->actionFunc != EnWallmas_TakePlayer)) { + Actor_MoveWithGravity(&this->actor); + } + + if (this->actionFunc != EnWallmas_Drop) { + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 25.0f, 0.0f, 0x1DU); + } + + if ((this->actionFunc != EnWallmas_Die) && (this->actionFunc != EnWallmas_Drop)) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + if ((this->actionFunc != EnWallmas_Damage) && (this->actor.bgCheckFlags & 1) && + (this->actor.freezeTimer == 0)) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + } + + Actor_SetFocus(&this->actor, 25.0f); + + if (this->drawDmgEffAlpha > 0.0f) { + if (this->drawDmgEffType != ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } else if (Math_StepToF(&this->drawDmgEffFrozenSteamScale, 0.55f, 0.01375f) == 0) { + func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG); + } + } + } +} + +void EnWallmas_DrawShadow(EnWallmas* this, GlobalContext* globalCtx) { + s32 pad; + f32 xzScale; + MtxF mf; + Gfx* gfx; + + if ((this->actor.floorPoly != NULL) && ((this->timer < 81) || (this->actionFunc == EnWallmas_Stun))) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + gSPDisplayList(&gfx[0], &sSetupDL[6 * 44]); + gDPSetPrimColor(&gfx[1], 0, 0, 0, 0, 0, 255); + func_800C0094(this->actor.floorPoly, this->actor.world.pos.x, this->actor.floorHeight, this->actor.world.pos.z, + &mf); + Matrix_InsertMatrix(&mf, MTXMODE_NEW); + + if ((this->actionFunc != EnWallmas_WaitToDrop) && (this->actionFunc != EnWallmas_ReturnToCeiling) && + (this->actionFunc != EnWallmas_TakePlayer) && (this->actionFunc != EnWallmas_WaitForSwitchFlag)) { + xzScale = this->actor.scale.x * 50.0f; + } else { + xzScale = CLAMP_MAX(80 - this->timer, 80) * 0.00625f; + } + + Matrix_Scale(xzScale, 1.0f, xzScale, MTXMODE_APPLY); + gSPMatrix(&gfx[2], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[3], gCircleShadowDL); + + POLY_OPA_DISP = &gfx[4]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +s32 EnWallmas_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnWallmas* this = THIS; + + if (limbIndex == WALLMASTER_LIMB_ROOT) { + if (this->actionFunc != EnWallmas_TakePlayer) { + pos->z -= 1600.0f; + } else { + pos->z -= (1600.0f * (this->skelAnime.endFrame - this->skelAnime.curFrame)) / this->skelAnime.endFrame; + } + } + + return false; +} + +void EnWallmas_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnWallmas* this = THIS; + Gfx* gfx; + + if (sLimbIndexToLimbPosIndex[limbIndex] != -1) { + Matrix_GetStateTranslation(&this->limbPos[sLimbIndexToLimbPosIndex[limbIndex]]); + } + + if (limbIndex == WALLMASTER_LIMB_WRIST) { + Matrix_GetStateTranslationAndScaledX(1000.0f, &this->limbPos[9]); + Matrix_GetStateTranslationAndScaledX(-1000.0f, &this->limbPos[10]); + } else if (limbIndex == WALLMASTER_LIMB_HAND) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + Matrix_StatePush(); + Matrix_InsertTranslation(1600.0f, -700.0f, -1700.0f, MTXMODE_APPLY); + Matrix_RotateY(0x2AAA, MTXMODE_APPLY); + Matrix_InsertZRotation_s(0xAAA, MTXMODE_APPLY); + Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY); + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], gWallmasterLittleFingerDL); + + POLY_OPA_DISP = &gfx[2]; + + Matrix_StatePop(); + + CLOSE_DISPS(globalCtx->state.gfxCtx); + } +} + +void EnWallmas_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnWallmas* this = THIS; + + if (this->actionFunc != EnWallmas_WaitToDrop) { + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, EnWallmas_OverrideLimbDraw, EnWallmas_PostLimbDraw, + &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->limbPos, ARRAY_COUNT(this->limbPos), + this->drawDmgEffScale, this->drawDmgEffFrozenSteamScale, this->drawDmgEffAlpha, + this->drawDmgEffType); + } + + if (this->actor.colorFilterTimer != 0) { + func_800AE5A0(globalCtx); + } + + EnWallmas_DrawShadow(this, globalCtx); +} diff --git a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h index 1bd6fbe837..06d4d24d15 100644 --- a/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h +++ b/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.h @@ -2,16 +2,54 @@ #define Z_EN_WALLMAS_H #include "global.h" +#include "objects/object_wallmaster/object_wallmaster.h" + +#define WALLMASTER_GET_TYPE(thisx) ((thisx)->params) +#define WALLMASTER_GET_SWITCH_FLAG(thisx) (((thisx)->params >> 8) & 0xFF) +#define WALLMASTER_IS_FROZEN(thisx) ((thisx)->params & 0x80) + +/** + * This type determines under what conditions the Wallmaster will drop from the ceiling. + * - WALLMASTER_TYPE_TIMER_ONLY: These Wallmasters don't check for anything to determine + * whether or not to drop; they just set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_PROXIMITY: These Wallmasters ensure that the player in within a certain + * distance of their current position (as dictated by detectionRadius); once the player + * enters that range, they set a 130-frame timer and drop once it reaches 0. + * - WALLMASTER_TYPE_FLAG: These Wallmasters wait for a certain switch flag to be activated, + * as specified in their params. Once this switch is activated, they set an 81-frame timer + * and drop once it reaches 0. + * + * While in the "waiting to drop" state, all Wallmaster variations can be forced to reset the + * timer to 130 frames if the player enters certain states (e.g., if the player is no longer + * touching the ground). Additionally, WALLMASTER_TYPE_PROXIMITY-type Wallmasters will reset + * the timer to 130 frames if the player strays too far from the Wallmaster's current position. + */ +typedef enum { + /* 0x00 */ WALLMASTER_TYPE_TIMER_ONLY, + /* 0x01 */ WALLMASTER_TYPE_PROXIMITY, + /* 0x02 */ WALLMASTER_TYPE_FLAG +} WallmasterType; struct EnWallmas; typedef void (*EnWallmasActionFunc)(struct EnWallmas*, GlobalContext*); typedef struct EnWallmas { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x44]; - /* 0x0188 */ EnWallmasActionFunc actionFunc; - /* 0x018C */ char unk_18C[0x218]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ EnWallmasActionFunc actionFunc; + /* 0x18C */ u8 drawDmgEffType; + /* 0x18E */ s16 timer; + /* 0x190 */ s16 switchFlag; + /* 0x192 */ Vec3s jointTable[WALLMASTER_LIMB_MAX]; + /* 0x228 */ Vec3s morphTable[WALLMASTER_LIMB_MAX]; + /* 0x2C0 */ f32 yTarget; + /* 0x2C4 */ f32 detectionRadius; + /* 0x2C8 */ f32 drawDmgEffAlpha; + /* 0x2CC */ f32 drawDmgEffScale; + /* 0x2D0 */ f32 drawDmgEffFrozenSteamScale; + /* 0x2D4 */ Vec3f limbPos[11]; + /* 0x358 */ ColliderCylinder collider; } EnWallmas; // size = 0x3A4 extern const ActorInit En_Wallmas_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0ac959c7a1..72fadfea59 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -5108,40 +5108,40 @@ 0x80872BC0:("func_80872BC0",), 0x80874810:("EnWallmas_Init",), 0x80874A28:("EnWallmas_Destroy",), - 0x80874A88:("func_80874A88",), - 0x80874B04:("func_80874B04",), - 0x80874B88:("func_80874B88",), - 0x80874BE4:("func_80874BE4",), - 0x80874D1C:("func_80874D1C",), - 0x80874DE8:("func_80874DE8",), - 0x80874F14:("func_80874F14",), - 0x80874FD8:("func_80874FD8",), - 0x80875014:("func_80875014",), - 0x80875054:("func_80875054",), - 0x808750B8:("func_808750B8",), - 0x80875108:("func_80875108",), - 0x808751C4:("func_808751C4",), - 0x8087520C:("func_8087520C",), - 0x80875248:("func_80875248",), - 0x808752CC:("func_808752CC",), - 0x808753F0:("func_808753F0",), - 0x80875484:("func_80875484",), - 0x80875518:("func_80875518",), - 0x8087556C:("func_8087556C",), - 0x808755A8:("func_808755A8",), - 0x80875638:("func_80875638",), - 0x808756AC:("func_808756AC",), - 0x8087571C:("func_8087571C",), - 0x808758C8:("func_808758C8",), - 0x80875910:("func_80875910",), - 0x8087596C:("func_8087596C",), - 0x808759B8:("func_808759B8",), - 0x80875A0C:("func_80875A0C",), - 0x80875A74:("func_80875A74",), + 0x80874A88:("EnWallmas_Freeze",), + 0x80874B04:("EnWallmas_ThawIfFrozen",), + 0x80874B88:("EnWallmas_TimerInit",), + 0x80874BE4:("EnWallmas_WaitToDrop",), + 0x80874D1C:("EnWallmas_SetupDrop",), + 0x80874DE8:("EnWallmas_Drop",), + 0x80874F14:("EnWallmas_SetupLand",), + 0x80874FD8:("EnWallmas_Land",), + 0x80875014:("EnWallmas_SetupStand",), + 0x80875054:("EnWallmas_Stand",), + 0x808750B8:("EnWallmas_SetupWalk",), + 0x80875108:("EnWallmas_Walk",), + 0x808751C4:("EnWallmas_SetupJumpToCeiling",), + 0x8087520C:("EnWallmas_JumpToCeiling",), + 0x80875248:("EnWallmas_SetupReturnToCeiling",), + 0x808752CC:("EnWallmas_ReturnToCeiling",), + 0x808753F0:("EnWallmas_SetupDamage",), + 0x80875484:("EnWallmas_Damage",), + 0x80875518:("EnWallmas_SetupCooldown",), + 0x8087556C:("EnWallmas_Cooldown",), + 0x808755A8:("EnWallmas_SetupDie",), + 0x80875638:("EnWallmas_Die",), + 0x808756AC:("EnWallmas_SetupTakePlayer",), + 0x8087571C:("EnWallmas_TakePlayer",), + 0x808758C8:("EnWallmas_ProximityOrSwitchInit",), + 0x80875910:("EnWallmas_WaitForProximity",), + 0x8087596C:("EnWallmas_WaitForSwitchFlag",), + 0x808759B8:("EnWallmas_SetupStun",), + 0x80875A0C:("EnWallmas_Stun",), + 0x80875A74:("EnWallmas_Update",), 0x80875CF4:("EnWallmas_Update",), - 0x80875F04:("func_80875F04",), - 0x808760A4:("func_808760A4",), - 0x80876118:("func_80876118",), + 0x80875F04:("EnWallmas_DrawShadow",), + 0x808760A4:("EnWallmas_OverrideLimbDraw",), + 0x80876118:("EnWallmas_PostLimbDraw",), 0x80876268:("EnWallmas_Draw",), 0x80876670:("EnDodongo_Init",), 0x808768D0:("EnDodongo_Destroy",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 2cce52fbae..4fac6bb9e8 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -5801,10 +5801,7 @@ 0x808763AC:("D_808763AC","UNK_TYPE1","",0x1), 0x808763B4:("D_808763B4","UNK_TYPE1","",0x1), 0x808763C0:("D_808763C0","UNK_TYPE1","",0x1), - 0x808763D4:("D_808763D4","UNK_TYPE1","",0x1), - 0x808763D6:("D_808763D6","UNK_TYPE1","",0x1), - 0x808763E6:("D_808763E6","UNK_TYPE1","",0x1), - 0x808763E7:("D_808763E7","UNK_TYPE1","",0x1), + 0x808763D4:("D_808763D4","s8","[25]",0x25), 0x808763F0:("D_808763F0","f32","",0x4), 0x808763F4:("D_808763F4","f32","",0x4), 0x808763F8:("D_808763F8","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 4807cfc119..28008293b5 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1591,20 +1591,6 @@ D_0601A830 = 0x0601A830; D_060014C8 = 0x060014C8; D_06001C38 = 0x06001C38; -// ovl_En_Wallmas - -D_06000590 = 0x06000590; -D_06000EA4 = 0x06000EA4; -D_060019CC = 0x060019CC; -D_0600299C = 0x0600299C; -D_060041F4 = 0x060041F4; -D_06008688 = 0x06008688; -D_06008FB0 = 0x06008FB0; -D_06009244 = 0x06009244; -D_06009520 = 0x06009520; -D_06009DB0 = 0x06009DB0; -D_0600A054 = 0x0600A054; - // ovl_En_Wdhand D_060000F4 = 0x060000F4;