From 586a8828e5140aa80350c1685ddd9caa059e2ee6 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Tue, 22 Nov 2022 14:05:53 -0500 Subject: [PATCH 01/15] `z_en_Sw`: doc staring - docing fields and funcs - creating enums for Skultula types - macro for getting type from params. --- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 312 ++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 20 +- 3 files changed, 172 insertions(+), 162 deletions(-) diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 01bf4065715..75f865f8254 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -248,7 +248,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_801211D4[0].atTargetInit.x = actor->focus.pos.x; D_801211D4[0].atTargetInit.y = actor->focus.pos.y - 5.0f; D_801211D4[0].atTargetInit.z = actor->focus.pos.z; - spC0 = ((EnSw*)actor)->unk_364; + spC0 = ((EnSw*)actor)->normalVec; osSyncPrintf("%s(%d): xyz_t: %s (%f %f %f)\n", "../z_onepointdemo.c", 1671, "&cp", spC0.x, spC0.y, spC0.z); D_801211D4[0].eyeTargetInit.x = (actor->focus.pos.x + (120.0f * spC0.x)) - (Rand_ZeroOne() * 20.0f); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index dbdff8d3810..981abed6406 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -17,8 +17,8 @@ void func_80B0E728(EnSw* this, PlayState* play); void func_80B0DC7C(EnSw* this, PlayState* play); s32 func_80B0C0CC(EnSw* this, PlayState* play, s32); void func_80B0D3AC(EnSw* this, PlayState* play); -void func_80B0DB00(EnSw* this, PlayState* play); -void func_80B0D878(EnSw* this, PlayState* play); +void EnSw_Bounce(EnSw* this, PlayState* play); +void EnSw_DieGold(EnSw* this, PlayState* play); ActorInit En_Sw_InitVars = { ACTOR_EN_SW, @@ -72,7 +72,7 @@ void EnSw_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dst) { s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { Vec3f polyNormal; Vec3f sp38; - f32 sp34; + f32 dot; f32 temp_f0; s32 pad; @@ -80,9 +80,9 @@ s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { polyNormal.x = COLPOLY_GET_NORMAL(poly->normal.x); polyNormal.y = COLPOLY_GET_NORMAL(poly->normal.y); polyNormal.z = COLPOLY_GET_NORMAL(poly->normal.z); - sp34 = Math_FAcosF(DOTXYZ(polyNormal, this->unk_364)); - EnSw_CrossProduct(&this->unk_364, &polyNormal, &sp38); - Matrix_RotateAxis(sp34, &sp38, MTXMODE_NEW); + dot = Math_FAcosF(DOTXYZ(polyNormal, this->normalVec)); + EnSw_CrossProduct(&this->normalVec, &polyNormal, &sp38); + Matrix_RotateAxis(dot, &sp38, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &sp38); this->unk_370 = sp38; EnSw_CrossProduct(&this->unk_370, &polyNormal, &this->unk_37C); @@ -93,14 +93,14 @@ s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { this->unk_37C.x = this->unk_37C.x * (1.0f / temp_f0); this->unk_37C.y = this->unk_37C.y * (1.0f / temp_f0); this->unk_37C.z = this->unk_37C.z * (1.0f / temp_f0); - this->unk_364 = polyNormal; + this->normalVec = polyNormal; this->unk_3D8.xx = this->unk_370.x; this->unk_3D8.yx = this->unk_370.y; this->unk_3D8.zx = this->unk_370.z; this->unk_3D8.wx = 0.0f; - this->unk_3D8.xy = this->unk_364.x; - this->unk_3D8.yy = this->unk_364.y; - this->unk_3D8.zy = this->unk_364.z; + this->unk_3D8.xy = this->normalVec.x; + this->unk_3D8.yy = this->normalVec.y; + this->unk_3D8.zy = this->normalVec.z; this->unk_3D8.wy = 0.0f; this->unk_3D8.xz = this->unk_37C.x; this->unk_3D8.yz = this->unk_37C.y; @@ -114,54 +114,54 @@ s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { //! @bug: Does not return. } -CollisionPoly* func_80B0C020(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32* arg4) { - CollisionPoly* sp3C; +CollisionPoly* EnSw_GetPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posOut, s32* bgId) { + CollisionPoly* poly; s32 pad; - if (!BgCheck_EntityLineTest1(&play->colCtx, arg1, arg2, arg3, &sp3C, true, true, true, false, arg4)) { + if (!BgCheck_EntityLineTest1(&play->colCtx, posA, posB, posOut, &poly, true, true, true, false, bgId)) { return NULL; } - if (SurfaceType_GetWallFlags(&play->colCtx, sp3C, *arg4) & WALL_FLAG_CRAWLSPACE) { + if (SurfaceType_GetWallFlags(&play->colCtx, poly, *bgId) & WALL_FLAG_CRAWLSPACE) { return NULL; } - if (SurfaceType_IsIgnoredByProjectiles(&play->colCtx, sp3C, *arg4)) { + if (SurfaceType_IsIgnoredByProjectiles(&play->colCtx, poly, *bgId)) { return NULL; } - return sp3C; + return poly; } s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { CollisionPoly* temp_v0_2; CollisionPoly* temp_s1; Vec3f sp9C; - Vec3f sp90; - Vec3f sp84; - Vec3f sp78; + Vec3f posOut; + Vec3f posA; + Vec3f posB; s32 pad; - s32 sp70; + s32 bgId; s32 sp6C; s32 phi_s1; s32 sp64; sp64 = 0; this->unk_42C = 1; - sp84 = sp78 = this->actor.world.pos; - sp84.x += this->unk_364.x * 18.0f; - sp84.y += this->unk_364.y * 18.0f; - sp84.z += this->unk_364.z * 18.0f; - sp78.x -= this->unk_364.x * 18.0f; - sp78.y -= this->unk_364.y * 18.0f; - sp78.z -= this->unk_364.z * 18.0f; - temp_s1 = func_80B0C020(play, &sp84, &sp78, &sp90, &sp70); + posA = posB = this->actor.world.pos; + posA.x += this->normalVec.x * 18.0f; + posA.y += this->normalVec.y * 18.0f; + posA.z += this->normalVec.z * 18.0f; + posB.x -= this->normalVec.x * 18.0f; + posB.y -= this->normalVec.y * 18.0f; + posB.z -= this->normalVec.z * 18.0f; + temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); if ((temp_s1 != NULL) && (this->unk_360 == 0)) { - sp78.x = sp84.x + (this->unk_37C.x * 24); - sp78.y = sp84.y + (this->unk_37C.y * 24); - sp78.z = sp84.z + (this->unk_37C.z * 24); - temp_v0_2 = func_80B0C020(play, &sp84, &sp78, &sp9C, &sp6C); + posB.x = posA.x + (this->unk_37C.x * 24); + posB.y = posA.y + (this->unk_37C.y * 24); + posB.z = posA.z + (this->unk_37C.z * 24); + temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); if (temp_v0_2 != NULL) { if (arg2 == 1) { func_80B0BE20(this, temp_v0_2); @@ -172,28 +172,28 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { if (this->actor.floorPoly != temp_s1) { func_80B0BE20(this, temp_s1); } - this->actor.world.pos = sp90; - this->actor.floorBgId = sp70; + this->actor.world.pos = posOut; + this->actor.floorBgId = bgId; } sp64 = 1; } else { - sp84 = sp78; + posA = posB; for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { if (phi_s1 == 0) { - sp78.x = sp84.x - (this->unk_37C.x * 24.0f); - sp78.y = sp84.y - (this->unk_37C.y * 24.0f); + posB.x = posA.x - (this->unk_37C.x * 24.0f); + posB.y = posA.y - (this->unk_37C.y * 24.0f); if (0) {} - sp78.z = sp84.z - (this->unk_37C.z * 24.0f); + posB.z = posA.z - (this->unk_37C.z * 24.0f); } else if (phi_s1 == 1) { - sp78.x = sp84.x + (this->unk_370.x * 24.0f); - sp78.y = sp84.y + (this->unk_370.y * 24.0f); - sp78.z = sp84.z + (this->unk_370.z * 24.0f); + posB.x = posA.x + (this->unk_370.x * 24.0f); + posB.y = posA.y + (this->unk_370.y * 24.0f); + posB.z = posA.z + (this->unk_370.z * 24.0f); } else { - sp78.x = sp84.x - (this->unk_370.x * 24.0f); - sp78.y = sp84.y - (this->unk_370.y * 24.0f); - sp78.z = sp84.z - (this->unk_370.z * 24.0f); + posB.x = posA.x - (this->unk_370.x * 24.0f); + posB.y = posA.y - (this->unk_370.y * 24.0f); + posB.z = posA.z - (this->unk_370.z * 24.0f); } - temp_v0_2 = func_80B0C020(play, &sp84, &sp78, &sp9C, &sp6C); + temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); if (temp_v0_2 != NULL) { if (arg2 == 1) { func_80B0BE20(this, temp_v0_2); @@ -220,11 +220,11 @@ void EnSw_Init(Actor* thisx, PlayState* play) { s32 pad; if (thisx->params & 0x8000) { - phi_v0 = (((thisx->params - 0x8000) & 0xE000) >> 0xD) + 1; + phi_v0 = SW_GOLDTYPE((thisx->params - 0x8000)) + 1; thisx->params = (thisx->params & 0x1FFF) | (phi_v0 << 0xD); } - if (((thisx->params & 0xE000) >> 0xD) > 0) { + if (SW_GOLDTYPE(thisx->params) > SW_NORMALTYPE) { phi_v0 = ((thisx->params & 0x1F00) >> 8) - 1; thisx->params = (thisx->params & 0xE0FF) | (phi_v0 << 8); } @@ -243,7 +243,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); this->actor.scale.x = 0.02f; - if (((thisx->params & 0xE000) >> 0xD) == 0) { + if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { this->actor.world.rot.x = 0; this->actor.world.rot.z = 0; thisx->shape.rot = this->actor.world.rot; @@ -256,32 +256,32 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); this->unk_370.y = 0.0f; this->unk_370.z = Math_CosS(thisx->shape.rot.y + 0x4000); - this->unk_364.x = 0.0f; - this->unk_364.y = 1.0f; - this->unk_364.z = 0.0f; + this->normalVec.x = 0.0f; + this->normalVec.y = 1.0f; + this->normalVec.z = 0.0f; this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); func_80B0C0CC(this, play, 1); } - if (((thisx->params & 0xE000) >> 0xD) >= 3) { + if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - switch ((thisx->params & 0xE000) >> 0xD) { - case 3: - case 4: + switch (SW_GOLDTYPE(thisx->params)) { + case SW_GOLDTYPE_HIDDEN: + case SW_GOLDTYPE_HIDDEN2: this->unk_360 = 1; this->actor.velocity.y = 8.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = -1.0f; FALLTHROUGH; - case 2: + case SW_GOLDTYPE_NIGHT: this->actor.scale.x = 0.0f; FALLTHROUGH; - case 1: + case SW_GOLDTYPE_DEFAULT: this->collider.elements[0].info.toucher.damage *= 2; this->actor.naviEnemyId = NAVI_ENEMY_GOLD_SKULLTULA; this->actor.colChkInfo.health *= 2; @@ -293,16 +293,16 @@ void EnSw_Init(Actor* thisx, PlayState* play) { break; } - this->unk_38E = Rand_S16Offset(0xF, 0x1E); + this->unk_38E = Rand_S16Offset(15, 30); Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.home.pos = this->actor.world.pos; thisx->shape.rot = this->actor.world.rot; - if (((thisx->params & 0xE000) >> 0xD) >= 3) { - this->unk_38C = 0x28; + if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { + this->unk_38C = 40; this->unk_394 = 1; this->actionFunc = func_80B0D364; - } else if (((thisx->params & 0xE000) >> 0xD) == 0) { + } else if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { this->actionFunc = func_80B0E5E0; } else { this->actionFunc = func_80B0D590; @@ -315,10 +315,10 @@ void EnSw_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider); } -s32 func_80B0C9F0(EnSw* this, PlayState* play) { +s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { s32 phi_v1 = false; - if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && ((this->actor.params & 0xE000) >> 0xD) == 0 && + if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && SW_GOLDTYPE(this->actor.params) == SW_NORMALTYPE && play->actorCtx.unk_02 != 0) { this->actor.colChkInfo.damage = this->actor.colChkInfo.health; @@ -330,22 +330,22 @@ s32 func_80B0C9F0(EnSw* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; this->unk_392 = 0x10; Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->unk_392); - if (Actor_ApplyDamage(&this->actor) != 0) { + if (Actor_ApplyDamage(&this->actor) != SW_NORMALTYPE) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALTU_DAMAGE); return true; } Enemy_StartFinishingBlow(play, &this->actor); - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->skelAnime.playSpeed = 8.0f; if ((play->state.frames & 1) == 0) { - this->unk_420 = 0.1f; + this->rotateMag = 0.1f; } else { - this->unk_420 = -0.1f; + this->rotateMag = -0.1f; } this->unk_394 = 0xA; this->unk_38A = 1; - this->unk_420 *= 4.0f; - this->actionFunc = func_80B0D878; + this->rotateMag *= 4.0f; + this->actionFunc = EnSw_DieGold; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 0xFF; @@ -353,7 +353,7 @@ s32 func_80B0C9F0(EnSw* this, PlayState* play) { this->actor.shape.shadowScale = 16.0f; this->actor.gravity = -1.0f; this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = func_80B0DB00; + this->actionFunc = EnSw_Bounce; } Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_DEAD); @@ -369,7 +369,7 @@ s32 func_80B0C9F0(EnSw* this, PlayState* play) { } void func_80B0CBE8(EnSw* this, PlayState* play) { - if ((((this->actor.params & 0xE000) >> 0xD) > 0) && (this->actionFunc != func_80B0D590)) { + if ((SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != func_80B0D590)) { if (this->unk_392 != 0) { this->unk_392--; } @@ -386,11 +386,11 @@ void func_80B0CBE8(EnSw* this, PlayState* play) { } } -s32 func_80B0CCF4(EnSw* this, f32* arg1) { +s32 EnSw_GetRotate(EnSw* this, f32* angle) { CollisionPoly* floorPoly; f32 temp_f0; Vec3f floorPolyNormal; - MtxF sp2C; + MtxF rotMtxF; if (this->actor.floorPoly == NULL) { return false; @@ -400,10 +400,10 @@ s32 func_80B0CCF4(EnSw* this, f32* arg1) { floorPolyNormal.x = COLPOLY_GET_NORMAL(floorPoly->normal.x); floorPolyNormal.y = COLPOLY_GET_NORMAL(floorPoly->normal.y); floorPolyNormal.z = COLPOLY_GET_NORMAL(floorPoly->normal.z); - Matrix_RotateAxis(*arg1, &floorPolyNormal, MTXMODE_NEW); + Matrix_RotateAxis(*angle, &floorPolyNormal, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &floorPolyNormal); this->unk_370 = floorPolyNormal; - EnSw_CrossProduct(&this->unk_370, &this->unk_364, &this->unk_37C); + EnSw_CrossProduct(&this->unk_370, &this->normalVec, &this->unk_37C); temp_f0 = Math3D_Vec3fMagnitude(&this->unk_37C); if (temp_f0 < 0.001f) { return false; @@ -412,23 +412,23 @@ s32 func_80B0CCF4(EnSw* this, f32* arg1) { this->unk_37C.x *= temp_f0; this->unk_37C.y *= temp_f0; this->unk_37C.z *= temp_f0; - sp2C.xx = this->unk_370.x; - sp2C.yx = this->unk_370.y; - sp2C.zx = this->unk_370.z; - sp2C.wx = 0.0f; - sp2C.xy = this->unk_364.x; - sp2C.yy = this->unk_364.y; - sp2C.zy = this->unk_364.z; - sp2C.wy = 0.0f; - sp2C.xz = this->unk_37C.x; - sp2C.yz = this->unk_37C.y; - sp2C.zz = this->unk_37C.z; - sp2C.wz = 0.0f; - sp2C.xw = 0.0f; - sp2C.yw = 0.0f; - sp2C.zw = 0.0f; - sp2C.ww = 1.0f; - Matrix_MtxFToYXZRotS(&sp2C, &this->actor.world.rot, 0); + rotMtxF.xx = this->unk_370.x; + rotMtxF.yx = this->unk_370.y; + rotMtxF.zx = this->unk_370.z; + rotMtxF.wx = 0.0f; + rotMtxF.xy = this->normalVec.x; + rotMtxF.yy = this->normalVec.y; + rotMtxF.zy = this->normalVec.z; + rotMtxF.wy = 0.0f; + rotMtxF.xz = this->unk_37C.x; + rotMtxF.yz = this->unk_37C.y; + rotMtxF.zz = this->unk_37C.z; + rotMtxF.wz = 0.0f; + rotMtxF.xw = 0.0f; + rotMtxF.yw = 0.0f; + rotMtxF.zw = 0.0f; + rotMtxF.ww = 1.0f; + Matrix_MtxFToYXZRotS(&rotMtxF, &this->actor.world.rot, 0); return true; } @@ -437,13 +437,13 @@ void func_80B0CEA8(EnSw* this, PlayState* play) { Camera* activeCam = GET_ACTIVE_CAM(play); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) >= 380.0f)) { - Audio_PlayActorSfx2(&this->actor, ((this->actor.params & 0xE000) >> 0xD) > 0 ? NA_SE_EN_STALGOLD_ROLL - : NA_SE_EN_STALWALL_ROLL); + Audio_PlayActorSfx2(&this->actor, SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE + ? NA_SE_EN_STALGOLD_ROLL : NA_SE_EN_STALWALL_ROLL); } } } -void func_80B0CF44(EnSw* this, PlayState* play, s32 cnt) { +void EnSw_SpawnDust(EnSw* this, PlayState* play, s32 cnt) { Color_RGBA8 primColor = { 80, 80, 50, 255 }; Color_RGBA8 envColor = { 100, 100, 80, 0 }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; @@ -462,7 +462,7 @@ void func_80B0CF44(EnSw* this, PlayState* play, s32 cnt) { } } -void func_80B0D14C(EnSw* this, PlayState* play, s32 cnt) { +void EnSw_SpawnDust2(EnSw* this, PlayState* play, s32 cnt) { Color_RGBA8 primColor = { 80, 80, 50, 255 }; Color_RGBA8 envColor = { 100, 100, 80, 0 }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; @@ -482,7 +482,7 @@ void func_80B0D14C(EnSw* this, PlayState* play, s32 cnt) { } void func_80B0D364(EnSw* this, PlayState* play) { - if (((this->actor.params & 0xE000) >> 0xD) == 4) { + if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_HIDDEN2) { this->unk_38C = 0; this->actionFunc = func_80B0D3AC; } else { @@ -494,7 +494,7 @@ void func_80B0D364(EnSw* this, PlayState* play) { void func_80B0D3AC(EnSw* this, PlayState* play) { if (this->unk_38C != 0) { if ((this->unk_38C & 4) != 0) { - func_80B0CF44(this, play, 5); + EnSw_SpawnDust(this, play, 5); } this->unk_38C--; if (this->unk_38C == 0) { @@ -507,9 +507,9 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { Math_ApproachF(&this->actor.scale.x, 0.02f, 0.2f, 0.01f); Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.world.pos.x += this->unk_364.x * this->actor.velocity.y; - this->actor.world.pos.y += this->unk_364.y * this->actor.velocity.y; - this->actor.world.pos.z += this->unk_364.z * this->actor.velocity.y; + this->actor.world.pos.x += this->normalVec.x * this->actor.velocity.y; + this->actor.world.pos.y += this->normalVec.y * this->actor.velocity.y; + this->actor.world.pos.z += this->normalVec.z * this->actor.velocity.y; this->actor.world.pos.x += this->unk_37C.x * this->actor.speedXZ; this->actor.world.pos.y += this->unk_37C.y * this->actor.speedXZ; this->actor.world.pos.z += this->unk_37C.z * this->actor.speedXZ; @@ -522,7 +522,7 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { if (func_80B0C0CC(this, play, 1) == 1) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_M_GND); - func_80B0D14C(this, play, 8); + EnSw_SpawnDust2(this, play, 8); this->actor.scale.x = 0.02f; Actor_SetScale(&this->actor, 0.02f); this->actionFunc = func_80B0D590; @@ -533,9 +533,9 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { } void func_80B0D590(EnSw* this, PlayState* play) { - f32 sp2C; + f32 rotAngle; - if (((this->actor.params & 0xE000) >> 0xD) == 2) { + if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_NIGHT) { if (this->actor.scale.x < 0.0139999995f) { this->collider.elements[0].info.toucherFlags = TOUCH_NONE; this->collider.elements[0].info.bumperFlags = BUMP_NONE; @@ -556,12 +556,12 @@ void func_80B0D590(EnSw* this, PlayState* play) { this->unk_38E--; if (this->unk_38E == 0) { func_80B0CEA8(this, play); - this->unk_420 = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; + this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; this->unk_38A = 1; this->unk_38C = Rand_S16Offset(30, 60); - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->unk_38C *= 2; - this->unk_420 *= 2.0f; + this->rotateMag *= 2.0f; } } } else { @@ -570,7 +570,7 @@ void func_80B0D590(EnSw* this, PlayState* play) { this->unk_38E = Rand_S16Offset(15, 30); this->unk_38A = 0; this->skelAnime.playSpeed = 0.0f; - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->unk_38E /= 2; } } else if (this->unk_38A != 0) { @@ -580,24 +580,24 @@ void func_80B0D590(EnSw* this, PlayState* play) { if (this->skelAnime.playSpeed > 0.0f) { func_80B0CEA8(this, play); } - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->skelAnime.playSpeed *= 2.0f; } } else { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { this->unk_38A = 2; } - sp2C = 32768.0f / this->skelAnime.endFrame; - sp2C *= this->skelAnime.curFrame; - sp2C = Math_SinS(sp2C) * this->unk_420; - func_80B0CCF4(this, &sp2C); + rotAngle = 32768.0f / this->skelAnime.endFrame; + rotAngle *= this->skelAnime.curFrame; + rotAngle = Math_SinS(rotAngle) * this->rotateMag; + EnSw_GetRotate(this, &rotAngle); this->actor.shape.rot = this->actor.world.rot; } } } -void func_80B0D878(EnSw* this, PlayState* play) { - Actor* temp_v0; +void EnSw_DieGold(EnSw* this, PlayState* play) { + Actor* token; Vec3f pos; Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; f32 x; @@ -608,20 +608,20 @@ void func_80B0D878(EnSw* this, PlayState* play) { func_80B0CEA8(this, play); } - func_80B0CCF4(this, &this->unk_420); + EnSw_GetRotate(this, &this->rotateMag); this->actor.shape.rot = this->actor.world.rot; if ((this->unk_394 == 0) && (this->unk_392 == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - x = (this->unk_364.x * 10.0f); - y = (this->unk_364.y * 10.0f); - z = (this->unk_364.z * 10.0f); - temp_v0 = + x = (this->normalVec.x * 10.0f); + y = (this->normalVec.y * 10.0f); + z = (this->normalVec.z * 10.0f); + token = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SI, this->actor.world.pos.x + x, this->actor.world.pos.y + y, this->actor.world.pos.z + z, 0, 0, 0, this->actor.params); - if (temp_v0 != NULL) { - temp_v0->parent = NULL; + if (token != NULL) { + token->parent = NULL; } Actor_Kill(&this->actor); return; @@ -636,7 +636,7 @@ void func_80B0D878(EnSw* this, PlayState* play) { } } -void func_80B0DB00(EnSw* this, PlayState* play) { +void EnSw_Bounce(EnSw* this, PlayState* play) { Actor_MoveForward(&this->actor); this->actor.shape.rot.x += 0x1000; this->actor.shape.rot.z += 0x1000; @@ -679,12 +679,12 @@ void func_80B0DC7C(EnSw* this, PlayState* play) { } } -s16 func_80B0DE34(EnSw* this, Vec3f* arg1) { +s16 EnSw_GetRotateY(EnSw* this, Vec3f* target) { s16 pitch; s16 yaw; - yaw = Math_Vec3f_Yaw(&this->actor.world.pos, arg1) - this->actor.wallYaw; - pitch = Math_Vec3f_Pitch(&this->actor.world.pos, arg1) - 0x4000; + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, target) - this->actor.wallYaw; + pitch = Math_Vec3f_Pitch(&this->actor.world.pos, target) - 0x4000; return pitch * (yaw >= 0 ? -1 : 1); } @@ -698,7 +698,7 @@ s32 func_80B0DEA8(EnSw* this, PlayState* play, s32 arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; - } else if (ABS(func_80B0DE34(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { + } else if (ABS(EnSw_GetRotateY(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { return false; } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { return false; @@ -753,7 +753,7 @@ s32 func_80B0DFFC(EnSw* this, PlayState* play) { return sp4C; } -void func_80B0E314(EnSw* this, Vec3f arg1, f32 arg4) { +void func_80B0E314(EnSw* this, Vec3f arg1, f32 speedTarget) { f32 xDist; f32 yDist; f32 zDist; @@ -762,7 +762,7 @@ void func_80B0E314(EnSw* this, Vec3f arg1, f32 arg4) { f32 yDiff; f32 zDiff; - Math_SmoothStepToF(&this->actor.speedXZ, arg4, 0.3f, 100.0f, 0.1f); + Math_SmoothStepToF(&this->actor.speedXZ, speedTarget, 0.3f, 100.0f, 0.1f); xDiff = arg1.x - this->actor.world.pos.x; yDiff = arg1.y - this->actor.world.pos.y; zDiff = arg1.z - this->actor.world.pos.z; @@ -782,16 +782,16 @@ void func_80B0E314(EnSw* this, Vec3f arg1, f32 arg4) { this->actor.world.pos.z += zDist; } -s32 func_80B0E430(EnSw* this, f32 arg1, s16 arg2, s32 arg3, PlayState* play) { +s32 func_80B0E430(EnSw* this, f32 target, s16 step, s32 arg3, PlayState* play) { Camera* activeCam; f32 lastFrame = Animation_GetLastFrame(&object_st_Anim_000304); - if (DECR(this->unk_388) != 0) { + if (DECR(this->aniTimer) != 0) { Math_SmoothStepToF(&this->skelAnime.playSpeed, 0.0f, 0.6f, 1000.0f, 0.01f); return 0; } - Math_SmoothStepToF(&this->skelAnime.playSpeed, arg1, 0.6f, 1000.0f, 0.01f); + Math_SmoothStepToF(&this->skelAnime.playSpeed, target, 0.6f, 1000.0f, 0.01f); if ((arg3 == 1) && (lastFrame < (this->skelAnime.curFrame + this->skelAnime.playSpeed))) { return 0; @@ -800,16 +800,16 @@ s32 func_80B0E430(EnSw* this, f32 arg1, s16 arg2, s32 arg3, PlayState* play) { activeCam = GET_ACTIVE_CAM(play); if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) < 380.0f) { - if (DECR(this->unk_440) == 0) { + if (DECR(this->sfxTimer) == 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_ROLL); - this->unk_440 = 4; + this->sfxTimer = 4; } } else { - this->unk_440 = 0; + this->sfxTimer = 0; } - Math_SmoothStepToS(&this->actor.shape.rot.z, this->unk_444, 4, arg2, arg2); + Math_SmoothStepToS(&this->actor.shape.rot.z, this->rotZTarget, 4, step, step); this->actor.world.rot = this->actor.shape.rot; - if (this->actor.shape.rot.z == this->unk_444) { + if (this->actor.shape.rot.z == this->rotZTarget) { return 1; } return 0; @@ -819,11 +819,11 @@ void func_80B0E5E0(EnSw* this, PlayState* play) { s32 pad[2]; f32 rand; - if (func_80B0E430(this, 6.0f, 0x3E8, 1, play)) { + if (func_80B0E430(this, 6.0f, 1000, 1, play)) { rand = Rand_ZeroOne(); - this->unk_444 = - ((s16)(20000.0f * rand) + 0x2EE0) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + this->actor.world.rot.z; - this->unk_388 = Rand_S16Offset(10, 30); + this->rotZTarget = + ((s16)(20000.0f * rand) + 12000) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + this->actor.world.rot.z; + this->aniTimer = Rand_S16Offset(10, 30); } if ((DECR(this->unk_442) == 0) && (func_80B0DEA8(this, play, 1))) { @@ -841,23 +841,23 @@ void func_80B0E728(EnSw* this, PlayState* play) { if (func_80B0DEA8(this, play, 1)) { this->unk_448 = player->actor.world.pos; this->unk_448.y += 30.0f; - this->unk_444 = func_80B0DE34(this, &this->unk_448); - func_80B0E430(this, 6.0f, (u16)0xFA0, 0, play); + this->rotZTarget = EnSw_GetRotateY(this, &this->unk_448); + func_80B0E430(this, 6.0f, (u16)4000, 0, play); } else { this->actionFunc = func_80B0E5E0; } } else { if (!func_80B0DFFC(this, play)) { this->unk_442 = Rand_S16Offset(20, 10); - this->unk_444 = func_80B0DE34(this, &this->actor.home.pos); + this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); this->unk_448 = this->actor.home.pos; this->actionFunc = func_80B0E9BC; } else { func_80B0E314(this, this->unk_448, 8.0f); - if (DECR(this->unk_440) == 0) { + if (DECR(this->sfxTimer) == 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_DASH); - this->unk_440 = 4; + this->sfxTimer = 4; } if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 13.0f) || func_8002DDF4(play)) { @@ -872,7 +872,7 @@ void func_80B0E90C(EnSw* this, PlayState* play) { func_80B0E314(this, this->unk_448, 0.0f); if (this->actor.speedXZ == 0.0f) { - this->unk_444 = func_80B0DE34(this, &this->actor.home.pos); + this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); this->unk_448 = this->actor.home.pos; this->actionFunc = func_80B0E9BC; } @@ -881,7 +881,7 @@ void func_80B0E90C(EnSw* this, PlayState* play) { void func_80B0E9BC(EnSw* this, PlayState* play) { s32 pad; - if (func_80B0E430(this, 6.0f, 0x3E8, 0, play)) { + if (func_80B0E430(this, 6.0f, 1000, 0, play)) { func_80B0E314(this, this->unk_448, 2.0f); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 4.0f)) { this->actionFunc = func_80B0E5E0; @@ -893,7 +893,7 @@ void EnSw_Update(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; SkelAnime_Update(&this->skelAnime); - func_80B0C9F0(this, play); + EnSw_CheckDamage(this, play); this->actionFunc(this, play); func_80B0CBE8(this, play); } @@ -909,7 +909,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2084); - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { switch (limbIndex) { case 23: *dList = object_st_DL_004788; @@ -970,7 +970,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } -void func_80B0EDB8(PlayState* play, Color_RGBA8* arg1, s16 arg2, s16 arg3) { +void EnGs_SetFog(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { f32 temp_f2; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2181); @@ -981,12 +981,12 @@ void func_80B0EDB8(PlayState* play, Color_RGBA8* arg1, s16 arg2, s16 arg3) { temp_f2 = 11500; } - POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, arg1->r, arg1->g, arg1->b, arg1->a, 0, (s16)temp_f2); + POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, col->r, col->g, col->b, col->a, 0, (s16)temp_f2); CLOSE_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2197); } -void func_80B0EEA4(PlayState* play) { +void EnGs_ApplyFog(PlayState* play) { s32 pad; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2205); @@ -1000,20 +1000,20 @@ void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; Color_RGBA8 sp30 = { 184, 0, 228, 255 }; - if (((this->actor.params & 0xE000) >> 0xD) != 0) { + if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { Matrix_RotateX(DEG_TO_RAD(-80), MTXMODE_APPLY); if (this->actor.colChkInfo.health != 0) { Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); } func_8002EBCC(&this->actor, play, 0); } else if (this->actionFunc == func_80B0E728) { - func_80B0EDB8(play, &sp30, 0x14, 0x1E); + EnGs_SetFog(play, &sp30, 20, 30); } Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, EnSw_PostLimbDraw, this); if (this->actionFunc == func_80B0E728) { - func_80B0EEA4(play); + EnGs_ApplyFog(play); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index c766e9f9e98..30f31e44359 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -18,10 +18,10 @@ typedef struct EnSw { /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; /* 0x0360 */ u8 unk_360; - /* 0x0364 */ Vec3f unk_364; + /* 0x0364 */ Vec3f normalVec; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; - /* 0x0388 */ s16 unk_388; + /* 0x0388 */ s16 aniTimer; /* 0x038A */ s16 unk_38A; /* 0x038C */ s16 unk_38C; /* 0x038E */ s16 unk_38E; @@ -31,14 +31,14 @@ typedef struct EnSw { /* 0x0396 */ char unk_396[0x42]; /* 0x03D8 */ MtxF unk_3D8; /* 0x0418 */ char unk_418[8]; - /* 0x0420 */ f32 unk_420; + /* 0x0420 */ f32 rotateMag; /* 0x0424 */ char unk_424[0x8]; /* 0x042C */ u8 unk_42C; /* 0x0430 */ CollisionPoly* unk_430; /* 0x0434 */ Vec3f unk_434; - /* 0x0440 */ s16 unk_440; + /* 0x0440 */ s16 sfxTimer; /* 0x0442 */ s16 unk_442; - /* 0x0444 */ s16 unk_444; + /* 0x0444 */ s16 rotZTarget; /* 0x0446 */ s16 unk_446; /* 0x0448 */ Vec3f unk_448; /* 0x0454 */ Vec3f unk_454; @@ -49,4 +49,14 @@ typedef struct EnSw { /* 0x0490 */ char unk_490[0x48]; } EnSw; // size = 0x04D8 +#define SW_GOLDTYPE(params) ((params & 0xE000) >> 0xD) + +typedef enum { + SW_NORMALTYPE, // normal Skullwalltula + SW_GOLDTYPE_DEFAULT, // Normal Gold Skultula, found in dungeons + SW_GOLDTYPE_NIGHT, // nocturnal Gold Skultula, found outside + SW_GOLDTYPE_HIDDEN, + SW_GOLDTYPE_HIDDEN2, +} EnSwTypes; + #endif From 2b0c49ee3601ee533bb5f3c8f48924aa5645a8e8 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Fri, 25 Nov 2022 06:51:52 -0500 Subject: [PATCH 02/15] `z_en_sw`: More doc'ing --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 241 ++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 29 ++- 2 files changed, 139 insertions(+), 131 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 981abed6406..80436a00104 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -1,23 +1,30 @@ +/* + * File: z_en_sw.c + * Overlay: ovl_En_Sw + * Description: SkullWalltula and Gold Skulltula + */ + #include "z_en_sw.h" #include "assets/objects/object_st/object_st.h" + #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) void EnSw_Init(Actor* thisx, PlayState* play); void EnSw_Destroy(Actor* thisx, PlayState* play); void EnSw_Update(Actor* thisx, PlayState* play); void EnSw_Draw(Actor* thisx, PlayState* play); -s32 func_80B0DFFC(EnSw* this, PlayState* play); +s32 EnSW_LineTestWall(EnSw* this, PlayState* play); void func_80B0D364(EnSw* this, PlayState* play); -void func_80B0E5E0(EnSw* this, PlayState* play); +void EnSw_SetupNormal(EnSw* this, PlayState* play); void func_80B0D590(EnSw* this, PlayState* play); -void func_80B0E90C(EnSw* this, PlayState* play); -void func_80B0E9BC(EnSw* this, PlayState* play); -void func_80B0E728(EnSw* this, PlayState* play); -void func_80B0DC7C(EnSw* this, PlayState* play); +void EnSw_SetupGoHome(EnSw* this, PlayState* play); +void EnSw_GoHome(EnSw* this, PlayState* play); +void EnGs_Dash(EnSw* this, PlayState* play); +void EnSw_DieNormal(EnSw* this, PlayState* play); s32 func_80B0C0CC(EnSw* this, PlayState* play, s32); void func_80B0D3AC(EnSw* this, PlayState* play); -void EnSw_Bounce(EnSw* this, PlayState* play); +void EnSw_FallNormal(EnSw* this, PlayState* play); void EnSw_DieGold(EnSw* this, PlayState* play); ActorInit En_Sw_InitVars = { @@ -144,9 +151,9 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { s32 bgId; s32 sp6C; s32 phi_s1; - s32 sp64; + s32 ret; - sp64 = 0; + ret = 0; this->unk_42C = 1; posA = posB = this->actor.world.pos; posA.x += this->normalVec.x * 18.0f; @@ -157,7 +164,7 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { posB.z -= this->normalVec.z * 18.0f; temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); - if ((temp_s1 != NULL) && (this->unk_360 == 0)) { + if ((temp_s1 != NULL) && (this->goldHiddenBool == 0)) { posB.x = posA.x + (this->unk_37C.x * 24); posB.y = posA.y + (this->unk_37C.y * 24); posB.z = posA.z + (this->unk_37C.z * 24); @@ -175,7 +182,7 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { this->actor.world.pos = posOut; this->actor.floorBgId = bgId; } - sp64 = 1; + ret = 1; } else { posA = posB; for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { @@ -200,7 +207,7 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { this->actor.world.pos = sp9C; this->actor.floorBgId = sp6C; } - sp64 = 1; + ret = 1; break; } } @@ -210,7 +217,7 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 8, 0xFA0, 1); Math_SmoothStepToS(&this->actor.shape.rot.z, this->actor.world.rot.z, 8, 0xFA0, 1); - return sp64; + return ret; } void EnSw_Init(Actor* thisx, PlayState* play) { @@ -247,10 +254,10 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->actor.world.rot.x = 0; this->actor.world.rot.z = 0; thisx->shape.rot = this->actor.world.rot; - this->unk_484.y = this->actor.world.pos.y; - this->unk_484.x = this->actor.world.pos.x + (Math_SinS(this->actor.world.rot.y) * -60.0f); - this->unk_484.z = this->actor.world.pos.z + (Math_CosS(this->actor.world.rot.y) * -60.0f); - func_80B0DFFC(this, play); + this->walllCast.y = this->actor.world.pos.y; + this->walllCast.x = this->actor.world.pos.x + (Math_SinS(this->actor.world.rot.y) * -60.0f); + this->walllCast.z = this->actor.world.pos.z + (Math_CosS(this->actor.world.rot.y) * -60.0f); + EnSW_LineTestWall(this, play); this->actor.home.pos = this->actor.world.pos; } else { this->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); @@ -273,13 +280,14 @@ void EnSw_Init(Actor* thisx, PlayState* play) { switch (SW_GOLDTYPE(thisx->params)) { case SW_GOLDTYPE_HIDDEN: case SW_GOLDTYPE_HIDDEN2: - this->unk_360 = 1; + // they spring out of their hidding spot + this->goldHiddenBool = 1; this->actor.velocity.y = 8.0f; this->actor.speedXZ = 4.0f; this->actor.gravity = -1.0f; FALLTHROUGH; case SW_GOLDTYPE_NIGHT: - this->actor.scale.x = 0.0f; + this->actor.scale.x = 0.0f; // they expand at night FALLTHROUGH; case SW_GOLDTYPE_DEFAULT: this->collider.elements[0].info.toucher.damage *= 2; @@ -300,10 +308,10 @@ void EnSw_Init(Actor* thisx, PlayState* play) { if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { this->unk_38C = 40; - this->unk_394 = 1; + this->deathFlames = 1; this->actionFunc = func_80B0D364; } else if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { - this->actionFunc = func_80B0E5E0; + this->actionFunc = EnSw_SetupNormal; } else { this->actionFunc = func_80B0D590; } @@ -325,12 +333,12 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { phi_v1 = true; } - if (this->unk_392 == 0) { + if (this->painTimer == 0) { if ((this->collider.base.acFlags & AC_HIT) || phi_v1) { this->collider.base.acFlags &= ~AC_HIT; - this->unk_392 = 0x10; - Actor_SetColorFilter(&this->actor, 0x4000, 0xC8, 0, this->unk_392); - if (Actor_ApplyDamage(&this->actor) != SW_NORMALTYPE) { + this->painTimer = 0x10; + Actor_SetColorFilter(&this->actor, 0x4000, 200, 0, this->painTimer); + if (Actor_ApplyDamage(&this->actor) != 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALTU_DAMAGE); return true; } @@ -342,7 +350,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } else { this->rotateMag = -0.1f; } - this->unk_394 = 0xA; + this->deathFlames = 10; this->unk_38A = 1; this->rotateMag *= 4.0f; this->actionFunc = EnSw_DieGold; @@ -353,7 +361,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { this->actor.shape.shadowScale = 16.0f; this->actor.gravity = -1.0f; this->actor.flags &= ~ACTOR_FLAG_0; - this->actionFunc = EnSw_Bounce; + this->actionFunc = EnSw_FallNormal; } Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_DEAD); @@ -368,17 +376,17 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { return false; } -void func_80B0CBE8(EnSw* this, PlayState* play) { +void EnSw_SetCollider(EnSw* this, PlayState* play) { if ((SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != func_80B0D590)) { - if (this->unk_392 != 0) { - this->unk_392--; + if (this->painTimer != 0) { + this->painTimer--; } } else { if ((DECR(this->unk_390) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if ((DECR(this->unk_392) == 0) && (this->actor.colChkInfo.health != 0)) { + if ((DECR(this->painTimer) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } @@ -432,7 +440,7 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { return true; } -void func_80B0CEA8(EnSw* this, PlayState* play) { +void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { if (!(this->actor.scale.x < 0.0139999995f)) { Camera* activeCam = GET_ACTIVE_CAM(play); @@ -517,7 +525,7 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { this->actor.velocity.y = CLAMP_MIN(this->actor.velocity.y, this->actor.minVelocityY); if (this->actor.velocity.y < 0.0f) { - this->unk_360 = 0; + this->goldHiddenBool = 0; } if (func_80B0C0CC(this, play, 1) == 1) { @@ -535,6 +543,7 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { void func_80B0D590(EnSw* this, PlayState* play) { f32 rotAngle; + // Outdoor Gold Skulltula shrinks/expands based on time if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_NIGHT) { if (this->actor.scale.x < 0.0139999995f) { this->collider.elements[0].info.toucherFlags = TOUCH_NONE; @@ -555,7 +564,7 @@ void func_80B0D590(EnSw* this, PlayState* play) { if (this->unk_38E != 0) { this->unk_38E--; if (this->unk_38E == 0) { - func_80B0CEA8(this, play); + EnSw_PlaySfxRoll(this, play); this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; this->unk_38A = 1; this->unk_38C = Rand_S16Offset(30, 60); @@ -578,7 +587,7 @@ void func_80B0D590(EnSw* this, PlayState* play) { this->skelAnime.playSpeed = (this->unk_38A == 0) ? 4.0f : 0.0f; if (this->skelAnime.playSpeed > 0.0f) { - func_80B0CEA8(this, play); + EnSw_PlaySfxRoll(this, play); } if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->skelAnime.playSpeed *= 2.0f; @@ -605,13 +614,13 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { f32 z; if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - func_80B0CEA8(this, play); + EnSw_PlaySfxRoll(this, play); } EnSw_GetRotate(this, &this->rotateMag); this->actor.shape.rot = this->actor.world.rot; - if ((this->unk_394 == 0) && (this->unk_392 == 0)) { + if ((this->deathFlames == 0) && (this->painTimer == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); x = (this->normalVec.x * 10.0f); @@ -627,7 +636,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { return; } - if ((this->unk_392 == 0) && (DECR(this->unk_394) != 0)) { + if ((this->painTimer == 0) && (DECR(this->deathFlames) != 0)) { pos = this->actor.world.pos; pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); pos.x += (Rand_ZeroOne() - 0.5f) * 32.0f; @@ -636,7 +645,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { } } -void EnSw_Bounce(EnSw* this, PlayState* play) { +void EnSw_FallNormal(EnSw* this, PlayState* play) { Actor_MoveForward(&this->actor); this->actor.shape.rot.x += 0x1000; this->actor.shape.rot.z += 0x1000; @@ -651,8 +660,8 @@ void EnSw_Bounce(EnSw* this, PlayState* play) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; if (this->unk_38A == 0) { - this->actionFunc = func_80B0DC7C; - this->unk_394 = 10; + this->actionFunc = EnSw_DieNormal; + this->deathFlames = 10; } else { this->actor.velocity.y = ((this->unk_38A--) * 8.0f) * 0.5f; } @@ -662,11 +671,11 @@ void EnSw_Bounce(EnSw* this, PlayState* play) { } } -void func_80B0DC7C(EnSw* this, PlayState* play) { +void EnSw_DieNormal(EnSw* this, PlayState* play) { Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; Vec3f pos = { 0.0f, 0.0f, 0.0f }; - if (DECR(this->unk_394) != 0) { + if (DECR(this->deathFlames) != 0) { pos.y = ((Rand_ZeroOne() - 0.5f) * 6.0f) + (this->actor.world.pos.y + 10.0f); pos.x = ((Rand_ZeroOne() - 0.5f) * 32.0f) + this->actor.world.pos.x; pos.z = ((Rand_ZeroOne() - 0.5f) * 32.0f) + this->actor.world.pos.z; @@ -688,7 +697,7 @@ s16 EnSw_GetRotateY(EnSw* this, Vec3f* target) { return pitch * (yaw >= 0 ? -1 : 1); } -s32 func_80B0DEA8(EnSw* this, PlayState* play, s32 arg2) { +s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { Player* player = GET_PLAYER(play); CollisionPoly* sp58; s32 sp54; @@ -710,50 +719,50 @@ s32 func_80B0DEA8(EnSw* this, PlayState* play, s32 arg2) { } } -s32 func_80B0DFFC(EnSw* this, PlayState* play) { +s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { s32 pad; - CollisionPoly* sp60; - s32 sp5C; - Vec3f sp50; - s32 sp4C = true; + CollisionPoly* poly; + s32 bgId; + Vec3f posResult; + s32 ret = true; if (this->collider.base.ocFlags1 & OC1_HIT) { this->collider.base.acFlags &= ~AC_HIT; - sp4C = false; + ret = false; } else if (((play->state.frames % 4) == 0) && - !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_454, &sp50, &sp60, true, - false, false, true, &sp5C)) { - sp4C = false; + !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast0, &posResult, &poly, true, + false, false, true, &bgId)) { + ret = false; } else if (((play->state.frames % 4) == 1) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_460, &sp50, &sp60, true, false, - false, true, &sp5C)) { - sp4C = false; + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast1, &posResult, &poly, true, false, + false, true, &bgId)) { + ret = false; } else if (((play->state.frames % 4) == 2) && - !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_46C, &sp50, &sp60, true, - false, false, true, &sp5C)) { + !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast2, &posResult, &poly, true, + false, false, true, &bgId)) { if (0) {} - sp4C = false; + ret = false; } else if (((play->state.frames % 4) == 3) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_478, &sp50, &sp60, true, false, - false, true, &sp5C)) { - sp4C = false; + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast3, &posResult, &poly, true, false, + false, true, &bgId)) { + ret = false; } - if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->unk_484, &sp50, &this->unk_430, true, - false, false, true, &sp5C)) { - this->actor.wallYaw = RAD_TO_BINANG(Math_FAtan2F(this->unk_430->normal.x, this->unk_430->normal.z)); - this->actor.world.pos = sp50; + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->walllCast, &posResult, &this->wallPoly, true, + false, false, true, &bgId)) { + this->actor.wallYaw = RAD_TO_BINANG(Math_FAtan2F(this->wallPoly->normal.x, this->wallPoly->normal.z)); + this->actor.world.pos = posResult; this->actor.world.pos.x += 6.0f * Math_SinS(this->actor.world.rot.y); this->actor.world.pos.z += 6.0f * Math_CosS(this->actor.world.rot.y); - this->unk_434 = sp50; + this->unk_434 = posResult; this->unk_434.x += Math_SinS(this->actor.world.rot.y); this->unk_434.z += Math_CosS(this->actor.world.rot.y); } - return sp4C; + return ret; } -void func_80B0E314(EnSw* this, Vec3f arg1, f32 speedTarget) { +void EnGs_Move(EnSw* this, Vec3f targetPos, f32 speedTarget) { f32 xDist; f32 yDist; f32 zDist; @@ -763,9 +772,9 @@ void func_80B0E314(EnSw* this, Vec3f arg1, f32 speedTarget) { f32 zDiff; Math_SmoothStepToF(&this->actor.speedXZ, speedTarget, 0.3f, 100.0f, 0.1f); - xDiff = arg1.x - this->actor.world.pos.x; - yDiff = arg1.y - this->actor.world.pos.y; - zDiff = arg1.z - this->actor.world.pos.z; + xDiff = targetPos.x - this->actor.world.pos.x; + yDiff = targetPos.y - this->actor.world.pos.y; + zDiff = targetPos.z - this->actor.world.pos.z; dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); if (dist == 0.0f) { xDist = yDist = zDist = 0.0f; @@ -782,7 +791,7 @@ void func_80B0E314(EnSw* this, Vec3f arg1, f32 speedTarget) { this->actor.world.pos.z += zDist; } -s32 func_80B0E430(EnSw* this, f32 target, s16 step, s32 arg3, PlayState* play) { +s32 EnSw_SetCrawlAnimation(EnSw* this, f32 target, s16 step, s32 arg3, PlayState* play) { Camera* activeCam; f32 lastFrame = Animation_GetLastFrame(&object_st_Anim_000304); @@ -815,76 +824,76 @@ s32 func_80B0E430(EnSw* this, f32 target, s16 step, s32 arg3, PlayState* play) { return 0; } -void func_80B0E5E0(EnSw* this, PlayState* play) { +void EnSw_SetupNormal(EnSw* this, PlayState* play) { s32 pad[2]; f32 rand; - if (func_80B0E430(this, 6.0f, 1000, 1, play)) { + if (EnSw_SetCrawlAnimation(this, 6.0f, 1000, 1, play)) { rand = Rand_ZeroOne(); this->rotZTarget = ((s16)(20000.0f * rand) + 12000) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + this->actor.world.rot.z; this->aniTimer = Rand_S16Offset(10, 30); } - if ((DECR(this->unk_442) == 0) && (func_80B0DEA8(this, play, 1))) { + if ((DECR(this->dashTimer) == 0) && (EnSW_CanDashPlayer(this, play, 1))) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_LAUGH); - this->unk_442 = 20; - this->actionFunc = func_80B0E728; + this->dashTimer = 20; + this->actionFunc = EnGs_Dash; } } -void func_80B0E728(EnSw* this, PlayState* play) { +void EnGs_Dash(EnSw* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - if (DECR(this->unk_442) != 0) { - if (func_80B0DEA8(this, play, 1)) { - this->unk_448 = player->actor.world.pos; - this->unk_448.y += 30.0f; - this->rotZTarget = EnSw_GetRotateY(this, &this->unk_448); - func_80B0E430(this, 6.0f, (u16)4000, 0, play); + if (DECR(this->dashTimer) != 0) { + if (EnSW_CanDashPlayer(this, play, 1)) { + this->targetPos = player->actor.world.pos; + this->targetPos.y += 30.0f; + this->rotZTarget = EnSw_GetRotateY(this, &this->targetPos); + EnSw_SetCrawlAnimation(this, 6.0f, (u16)4000, 0, play); } else { - this->actionFunc = func_80B0E5E0; + this->actionFunc = EnSw_SetupNormal; } } else { - if (!func_80B0DFFC(this, play)) { - this->unk_442 = Rand_S16Offset(20, 10); + if (!EnSW_LineTestWall(this, play)) { + this->dashTimer = Rand_S16Offset(20, 10); this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); - this->unk_448 = this->actor.home.pos; - this->actionFunc = func_80B0E9BC; + this->targetPos = this->actor.home.pos; + this->actionFunc = EnSw_GoHome; } else { - func_80B0E314(this, this->unk_448, 8.0f); + EnGs_Move(this, this->targetPos, 8.0f); if (DECR(this->sfxTimer) == 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_DASH); this->sfxTimer = 4; } - if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 13.0f) || func_8002DDF4(play)) { - this->actionFunc = func_80B0E90C; + if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->targetPos) > 13.0f) || func_8002DDF4(play)) { + this->actionFunc = EnSw_SetupGoHome; } } } } -void func_80B0E90C(EnSw* this, PlayState* play) { +void EnSw_SetupGoHome(EnSw* this, PlayState* play) { s32 pad; - func_80B0E314(this, this->unk_448, 0.0f); + EnGs_Move(this, this->targetPos, 0.0f); if (this->actor.speedXZ == 0.0f) { this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); - this->unk_448 = this->actor.home.pos; - this->actionFunc = func_80B0E9BC; + this->targetPos = this->actor.home.pos; + this->actionFunc = EnSw_GoHome; } } -void func_80B0E9BC(EnSw* this, PlayState* play) { +void EnSw_GoHome(EnSw* this, PlayState* play) { s32 pad; - if (func_80B0E430(this, 6.0f, 1000, 0, play)) { - func_80B0E314(this, this->unk_448, 2.0f); - if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->unk_448) > 4.0f)) { - this->actionFunc = func_80B0E5E0; + if (EnSw_SetCrawlAnimation(this, 6.0f, 1000, 0, play)) { + EnGs_Move(this, this->targetPos, 2.0f); + if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->targetPos) > 4.0f)) { + this->actionFunc = EnSw_SetupNormal; } } } @@ -895,7 +904,7 @@ void EnSw_Update(Actor* thisx, PlayState* play) { SkelAnime_Update(&this->skelAnime); EnSw_CheckDamage(this, play); this->actionFunc(this, play); - func_80B0CBE8(this, play); + EnSw_SetCollider(this, play); } s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { @@ -945,11 +954,11 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } if (limbIndex == 1) { - Matrix_MultVec3f(&sp7C, &this->unk_454); - Matrix_MultVec3f(&sp70, &this->unk_460); - Matrix_MultVec3f(&sp64, &this->unk_46C); - Matrix_MultVec3f(&sp58, &this->unk_478); - Matrix_MultVec3f(&sp4C, &this->unk_484); + Matrix_MultVec3f(&sp7C, &this->lineCast0); + Matrix_MultVec3f(&sp70, &this->lineCast1); + Matrix_MultVec3f(&sp64, &this->lineCast2); + Matrix_MultVec3f(&sp58, &this->lineCast3); + Matrix_MultVec3f(&sp4C, &this->walllCast); } if (limbIndex == 5) { @@ -957,7 +966,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } if (limbIndex == 4) { - gDPSetEnvColor(POLY_OPA_DISP++, this->unk_1F4.r, this->unk_1F4.g, this->unk_1F4.b, 0); + gDPSetEnvColor(POLY_OPA_DISP++, this->limb4Col.r, this->limb4Col.g, this->limb4Col.b, 0); } Collider_UpdateSpheres(limbIndex, &this->collider); @@ -970,7 +979,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } -void EnGs_SetFog(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { +void EnGs_SetTint(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { f32 temp_f2; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2181); @@ -986,7 +995,7 @@ void EnGs_SetFog(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { CLOSE_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2197); } -void EnGs_ApplyFog(PlayState* play) { +void EnGs_ApplyTint(PlayState* play) { s32 pad; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2205); @@ -998,7 +1007,7 @@ void EnGs_ApplyFog(PlayState* play) { void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; - Color_RGBA8 sp30 = { 184, 0, 228, 255 }; + Color_RGBA8 col = { 184, 0, 228, 255 }; if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { Matrix_RotateX(DEG_TO_RAD(-80), MTXMODE_APPLY); @@ -1006,14 +1015,14 @@ void EnSw_Draw(Actor* thisx, PlayState* play) { Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); } func_8002EBCC(&this->actor, play, 0); - } else if (this->actionFunc == func_80B0E728) { - EnGs_SetFog(play, &sp30, 20, 30); + } else if (this->actionFunc == EnGs_Dash) { + EnGs_SetTint(play, &col, 20, 30); } Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, EnSw_PostLimbDraw, this); - if (this->actionFunc == func_80B0E728) { - EnGs_ApplyFog(play); + if (this->actionFunc == EnGs_Dash) { + EnGs_ApplyTint(play); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 30f31e44359..23c9365b180 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -14,10 +14,10 @@ typedef struct EnSw { /* 0x0190 */ EnSwActionFunc actionFunc; /* 0x0194 */ ColliderJntSph collider; /* 0x01B4 */ ColliderJntSphElement sphs[1]; - /* 0x01F4 */ Color_RGBA8 unk_1F4; + /* 0x01F4 */ Color_RGBA8 limb4Col; // never set past black. /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; - /* 0x0360 */ u8 unk_360; + /* 0x0360 */ u8 goldHiddenBool; /* 0x0364 */ Vec3f normalVec; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; @@ -26,26 +26,25 @@ typedef struct EnSw { /* 0x038C */ s16 unk_38C; /* 0x038E */ s16 unk_38E; /* 0x0390 */ s16 unk_390; - /* 0x0392 */ s16 unk_392; - /* 0x0394 */ s16 unk_394; + /* 0x0392 */ s16 painTimer; + /* 0x0394 */ s16 deathFlames; /* 0x0396 */ char unk_396[0x42]; /* 0x03D8 */ MtxF unk_3D8; /* 0x0418 */ char unk_418[8]; /* 0x0420 */ f32 rotateMag; /* 0x0424 */ char unk_424[0x8]; /* 0x042C */ u8 unk_42C; - /* 0x0430 */ CollisionPoly* unk_430; + /* 0x0430 */ CollisionPoly* wallPoly; /* 0x0434 */ Vec3f unk_434; /* 0x0440 */ s16 sfxTimer; - /* 0x0442 */ s16 unk_442; + /* 0x0442 */ s16 dashTimer; /* 0x0444 */ s16 rotZTarget; - /* 0x0446 */ s16 unk_446; - /* 0x0448 */ Vec3f unk_448; - /* 0x0454 */ Vec3f unk_454; - /* 0x0460 */ Vec3f unk_460; - /* 0x046C */ Vec3f unk_46C; - /* 0x0478 */ Vec3f unk_478; - /* 0x0484 */ Vec3f unk_484; + /* 0x0448 */ Vec3f targetPos; + /* 0x0454 */ Vec3f lineCast0; // used for line tests of walls/player + /* 0x0460 */ Vec3f lineCast1; + /* 0x046C */ Vec3f lineCast2; + /* 0x0478 */ Vec3f lineCast3; + /* 0x0484 */ Vec3f walllCast; /* 0x0490 */ char unk_490[0x48]; } EnSw; // size = 0x04D8 @@ -55,8 +54,8 @@ typedef enum { SW_NORMALTYPE, // normal Skullwalltula SW_GOLDTYPE_DEFAULT, // Normal Gold Skultula, found in dungeons SW_GOLDTYPE_NIGHT, // nocturnal Gold Skultula, found outside - SW_GOLDTYPE_HIDDEN, - SW_GOLDTYPE_HIDDEN2, + SW_GOLDTYPE_HIDDEN, // found by using incects on soil patches + SW_GOLDTYPE_HIDDEN2, // found by hitting trees. } EnSwTypes; #endif From 48b6d7436b6212f8b30d9b4c9b84d116bef7e5c4 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Fri, 16 Dec 2022 19:01:15 -0500 Subject: [PATCH 03/15] `z_en_sw`: update id'd most fields and funcs --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 148 ++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 14 +-- 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 1e440af6512..0509c3ba135 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -15,15 +15,15 @@ void EnSw_Destroy(Actor* thisx, PlayState* play); void EnSw_Update(Actor* thisx, PlayState* play); void EnSw_Draw(Actor* thisx, PlayState* play); s32 EnSW_LineTestWall(EnSw* this, PlayState* play); -void func_80B0D364(EnSw* this, PlayState* play); +void EnSw_SetupGoldHidden(EnSw* this, PlayState* play); void EnSw_SetupNormal(EnSw* this, PlayState* play); -void func_80B0D590(EnSw* this, PlayState* play); +void EnSw_Crawl(EnSw* this, PlayState* play); void EnSw_SetupGoHome(EnSw* this, PlayState* play); void EnSw_GoHome(EnSw* this, PlayState* play); void EnGs_Dash(EnSw* this, PlayState* play); void EnSw_DieNormal(EnSw* this, PlayState* play); -s32 func_80B0C0CC(EnSw* this, PlayState* play, s32); -void func_80B0D3AC(EnSw* this, PlayState* play); +s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32); +void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play); void EnSw_FallNormal(EnSw* this, PlayState* play); void EnSw_DieGold(EnSw* this, PlayState* play); @@ -76,11 +76,11 @@ void EnSw_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dst) { dst->z = (a->x * b->y) - (a->y * b->x); } -s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { +s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { Vec3f polyNormal; Vec3f sp38; f32 dot; - f32 temp_f0; + f32 length; s32 pad; this->actor.floorPoly = poly; @@ -93,13 +93,13 @@ s32 func_80B0BE20(EnSw* this, CollisionPoly* poly) { Matrix_MultVec3f(&this->unk_370, &sp38); this->unk_370 = sp38; EnSw_CrossProduct(&this->unk_370, &polyNormal, &this->unk_37C); - temp_f0 = Math3D_Vec3fMagnitude(&this->unk_37C); - if (temp_f0 < 0.001f) { + length = Math3D_Vec3fMagnitude(&this->unk_37C); + if (length < 0.001f) { return 0; } - this->unk_37C.x = this->unk_37C.x * (1.0f / temp_f0); - this->unk_37C.y = this->unk_37C.y * (1.0f / temp_f0); - this->unk_37C.z = this->unk_37C.z * (1.0f / temp_f0); + this->unk_37C.x = this->unk_37C.x * (1.0f / length); + this->unk_37C.y = this->unk_37C.y * (1.0f / length); + this->unk_37C.z = this->unk_37C.z * (1.0f / length); this->normalVec = polyNormal; this->unk_3D8.xx = this->unk_370.x; this->unk_3D8.yx = this->unk_370.y; @@ -140,7 +140,7 @@ CollisionPoly* EnSw_GetPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* po return poly; } -s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { +s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { CollisionPoly* temp_v0_2; CollisionPoly* temp_s1; Vec3f sp9C; @@ -171,13 +171,13 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); if (temp_v0_2 != NULL) { if (arg2 == 1) { - func_80B0BE20(this, temp_v0_2); + EnSw_ClingToWall(this, temp_v0_2); this->actor.world.pos = sp9C; this->actor.floorBgId = sp6C; } } else { if (this->actor.floorPoly != temp_s1) { - func_80B0BE20(this, temp_s1); + EnSw_ClingToWall(this, temp_s1); } this->actor.world.pos = posOut; this->actor.floorBgId = bgId; @@ -203,7 +203,7 @@ s32 func_80B0C0CC(EnSw* this, PlayState* play, s32 arg2) { temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); if (temp_v0_2 != NULL) { if (arg2 == 1) { - func_80B0BE20(this, temp_v0_2); + EnSw_ClingToWall(this, temp_v0_2); this->actor.world.pos = sp9C; this->actor.floorBgId = sp6C; } @@ -269,7 +269,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); - func_80B0C0CC(this, play, 1); + EnSw_GoldClingToWall(this, play, 1); } if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { @@ -301,19 +301,19 @@ void EnSw_Init(Actor* thisx, PlayState* play) { break; } - this->unk_38E = Rand_S16Offset(15, 30); + this->crawlTimer = Rand_S16Offset(15, 30); Actor_SetScale(&this->actor, this->actor.scale.x); this->actor.home.pos = this->actor.world.pos; thisx->shape.rot = this->actor.world.rot; if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { - this->unk_38C = 40; + this->waitTimer = 40; this->deathFlames = 1; - this->actionFunc = func_80B0D364; + this->actionFunc = EnSw_SetupGoldHidden; } else if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { this->actionFunc = EnSw_SetupNormal; } else { - this->actionFunc = func_80B0D590; + this->actionFunc = EnSw_Crawl; } } @@ -333,11 +333,11 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { phi_v1 = true; } - if (this->painTimer == 0) { + if (this->painTimer1 == 0) { if ((this->collider.base.acFlags & AC_HIT) || phi_v1) { this->collider.base.acFlags &= ~AC_HIT; - this->painTimer = 0x10; - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->painTimer); + this->painTimer1 = 0x10; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->painTimer1); if (Actor_ApplyDamage(&this->actor) != 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALTU_DAMAGE); return true; @@ -351,13 +351,13 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { this->rotateMag = -0.1f; } this->deathFlames = 10; - this->unk_38A = 1; + this->animationSpeed = 1; this->rotateMag *= 4.0f; this->actionFunc = EnSw_DieGold; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 0xFF; - this->unk_38A = 2; + this->animationSpeed = 2; this->actor.shape.shadowScale = 16.0f; this->actor.gravity = -1.0f; this->actor.flags &= ~ACTOR_FLAG_0; @@ -369,24 +369,24 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } } - if ((this->unk_390 == 0) && (this->collider.base.atFlags & AT_HIT)) { - this->unk_390 = 30; + if ((this->painTimer0 == 0) && (this->collider.base.atFlags & AT_HIT)) { + this->painTimer0 = 30; } return false; } void EnSw_SetCollider(EnSw* this, PlayState* play) { - if ((SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != func_80B0D590)) { - if (this->painTimer != 0) { - this->painTimer--; + if ((SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != EnSw_Crawl)) { + if (this->painTimer1 != 0) { + this->painTimer1--; } } else { - if ((DECR(this->unk_390) == 0) && (this->actor.colChkInfo.health != 0)) { + if ((DECR(this->painTimer0) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if ((DECR(this->painTimer) == 0) && (this->actor.colChkInfo.health != 0)) { + if ((DECR(this->painTimer1) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } @@ -396,7 +396,7 @@ void EnSw_SetCollider(EnSw* this, PlayState* play) { s32 EnSw_GetRotate(EnSw* this, f32* angle) { CollisionPoly* floorPoly; - f32 temp_f0; + f32 length; Vec3f floorPolyNormal; MtxF rotMtxF; @@ -412,14 +412,14 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { Matrix_MultVec3f(&this->unk_370, &floorPolyNormal); this->unk_370 = floorPolyNormal; EnSw_CrossProduct(&this->unk_370, &this->normalVec, &this->unk_37C); - temp_f0 = Math3D_Vec3fMagnitude(&this->unk_37C); - if (temp_f0 < 0.001f) { + length = Math3D_Vec3fMagnitude(&this->unk_37C); + if (length < 0.001f) { return false; } - temp_f0 = 1.0f / temp_f0; - this->unk_37C.x *= temp_f0; - this->unk_37C.y *= temp_f0; - this->unk_37C.z *= temp_f0; + length = 1.0f / length; + this->unk_37C.x *= length; + this->unk_37C.y *= length; + this->unk_37C.z *= length; rotMtxF.xx = this->unk_370.x; rotMtxF.yx = this->unk_370.y; rotMtxF.zx = this->unk_370.z; @@ -489,23 +489,23 @@ void EnSw_SpawnDust2(EnSw* this, PlayState* play, s32 cnt) { } } -void func_80B0D364(EnSw* this, PlayState* play) { +void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_HIDDEN2) { - this->unk_38C = 0; - this->actionFunc = func_80B0D3AC; + this->waitTimer = 0; + this->actionFunc = EnSw_GoldHiddenReveal; } else { - this->unk_38C = 10; - this->actionFunc = func_80B0D3AC; + this->waitTimer = 10; + this->actionFunc = EnSw_GoldHiddenReveal; } } -void func_80B0D3AC(EnSw* this, PlayState* play) { - if (this->unk_38C != 0) { - if ((this->unk_38C & 4) != 0) { +void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { + if (this->waitTimer != 0) { + if ((this->waitTimer & 4) != 0) { EnSw_SpawnDust(this, play, 5); } - this->unk_38C--; - if (this->unk_38C == 0) { + this->waitTimer--; + if (this->waitTimer == 0) { SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_STALGOLD_UP_CRY); SfxSource_PlaySfxAtFixedWorldPos(play, &this->actor.world.pos, 40, NA_SE_EN_DODO_M_UP); } else { @@ -528,19 +528,19 @@ void func_80B0D3AC(EnSw* this, PlayState* play) { this->goldHiddenBool = 0; } - if (func_80B0C0CC(this, play, 1) == 1) { + if (EnSw_GoldClingToWall(this, play, 1) == 1) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_M_GND); EnSw_SpawnDust2(this, play, 8); this->actor.scale.x = 0.02f; Actor_SetScale(&this->actor, 0.02f); - this->actionFunc = func_80B0D590; + this->actionFunc = EnSw_Crawl; this->actor.velocity.y = 0.0f; this->actor.speedXZ = 0.0f; this->actor.gravity = 0.0f; } } -void func_80B0D590(EnSw* this, PlayState* play) { +void EnSw_Crawl(EnSw* this, PlayState* play) { f32 rotAngle; // Outdoor Gold Skulltula shrinks/expands based on time @@ -561,30 +561,30 @@ void func_80B0D590(EnSw* this, PlayState* play) { Actor_SetScale(&this->actor, this->actor.scale.x); } - if (this->unk_38E != 0) { - this->unk_38E--; - if (this->unk_38E == 0) { + if (this->crawlTimer != 0) { + this->crawlTimer--; + if (this->crawlTimer == 0) { EnSw_PlaySfxRoll(this, play); this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; - this->unk_38A = 1; - this->unk_38C = Rand_S16Offset(30, 60); + this->animationSpeed = 1; + this->waitTimer = Rand_S16Offset(30, 60); if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { - this->unk_38C *= 2; + this->waitTimer *= 2; this->rotateMag *= 2.0f; } } } else { - this->unk_38C--; - if (this->unk_38C == 0) { - this->unk_38E = Rand_S16Offset(15, 30); - this->unk_38A = 0; + this->waitTimer--; + if (this->waitTimer == 0) { + this->crawlTimer = Rand_S16Offset(15, 30); + this->animationSpeed = 0; this->skelAnime.playSpeed = 0.0f; if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { - this->unk_38E /= 2; + this->crawlTimer /= 2; } - } else if (this->unk_38A != 0) { - this->unk_38A--; - this->skelAnime.playSpeed = (this->unk_38A == 0) ? 4.0f : 0.0f; + } else if (this->animationSpeed != 0) { + this->animationSpeed--; + this->skelAnime.playSpeed = (this->animationSpeed == 0) ? 4.0f : 0.0f; if (this->skelAnime.playSpeed > 0.0f) { EnSw_PlaySfxRoll(this, play); @@ -594,7 +594,7 @@ void func_80B0D590(EnSw* this, PlayState* play) { } } else { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - this->unk_38A = 2; + this->animationSpeed = 2; } rotAngle = 32768.0f / this->skelAnime.endFrame; rotAngle *= this->skelAnime.curFrame; @@ -620,7 +620,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { EnSw_GetRotate(this, &this->rotateMag); this->actor.shape.rot = this->actor.world.rot; - if ((this->deathFlames == 0) && (this->painTimer == 0)) { + if ((this->deathFlames == 0) && (this->painTimer1 == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); x = (this->normalVec.x * 10.0f); @@ -636,7 +636,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { return; } - if ((this->painTimer == 0) && (DECR(this->deathFlames) != 0)) { + if ((this->painTimer1 == 0) && (DECR(this->deathFlames) != 0)) { pos = this->actor.world.pos; pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); pos.x += (Rand_ZeroOne() - 0.5f) * 32.0f; @@ -659,11 +659,11 @@ void EnSw_FallNormal(EnSw* this, PlayState* play) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - if (this->unk_38A == 0) { + if (this->animationSpeed == 0) { this->actionFunc = EnSw_DieNormal; this->deathFlames = 10; } else { - this->actor.velocity.y = ((this->unk_38A--) * 8.0f) * 0.5f; + this->actor.velocity.y = ((this->animationSpeed--) * 8.0f) * 0.5f; } Audio_PlayActorSfx2(&this->actor, NA_SE_EN_DODO_M_GND); @@ -919,7 +919,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2084); if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { - switch (limbIndex) { + switch (limbIndex) { // replace with Gold Skulltula body parts. case 23: *dList = object_st_DL_004788; break; @@ -953,7 +953,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } } - if (limbIndex == 1) { + if (limbIndex == 1) { // eyes? Matrix_MultVec3f(&sp7C, &this->lineCast0); Matrix_MultVec3f(&sp70, &this->lineCast1); Matrix_MultVec3f(&sp64, &this->lineCast2); @@ -965,7 +965,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Matrix_MultVec3f(&sp3C, &this->actor.focus.pos); } - if (limbIndex == 4) { + if (limbIndex == 4) { // head? gDPSetEnvColor(POLY_OPA_DISP++, this->limb4Col.r, this->limb4Col.g, this->limb4Col.b, 0); } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 23c9365b180..cbdb2848d2d 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -17,16 +17,16 @@ typedef struct EnSw { /* 0x01F4 */ Color_RGBA8 limb4Col; // never set past black. /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; - /* 0x0360 */ u8 goldHiddenBool; + /* 0x0360 */ u8 goldHiddenBool; // set when revealed, unset when landing. /* 0x0364 */ Vec3f normalVec; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; /* 0x0388 */ s16 aniTimer; - /* 0x038A */ s16 unk_38A; - /* 0x038C */ s16 unk_38C; - /* 0x038E */ s16 unk_38E; - /* 0x0390 */ s16 unk_390; - /* 0x0392 */ s16 painTimer; + /* 0x038A */ s16 animationSpeed; + /* 0x038C */ s16 waitTimer; + /* 0x038E */ s16 crawlTimer; + /* 0x0390 */ s16 painTimer0; + /* 0x0392 */ s16 painTimer1; /* 0x0394 */ s16 deathFlames; /* 0x0396 */ char unk_396[0x42]; /* 0x03D8 */ MtxF unk_3D8; @@ -35,7 +35,7 @@ typedef struct EnSw { /* 0x0424 */ char unk_424[0x8]; /* 0x042C */ u8 unk_42C; /* 0x0430 */ CollisionPoly* wallPoly; - /* 0x0434 */ Vec3f unk_434; + /* 0x0434 */ Vec3f unk_434; // set during EnSW_LineTestWall, never read. /* 0x0440 */ s16 sfxTimer; /* 0x0442 */ s16 dashTimer; /* 0x0444 */ s16 rotZTarget; From 4c3892538170e93ce046d1d6ee14340080a57bc7 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sun, 18 Dec 2022 21:09:18 -0500 Subject: [PATCH 04/15] `z_en_sw`: changes based on feedback --- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 134 ++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 8 +- 3 files changed, 73 insertions(+), 71 deletions(-) diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index d73f370cedf..197f98340a3 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -248,7 +248,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_801211D4[0].atTargetInit.x = actor->focus.pos.x; D_801211D4[0].atTargetInit.y = actor->focus.pos.y - 5.0f; D_801211D4[0].atTargetInit.z = actor->focus.pos.z; - spC0 = ((EnSw*)actor)->normalVec; + spC0 = ((EnSw*)actor)->wallPolyNormal; osSyncPrintf("%s(%d): xyz_t: %s (%f %f %f)\n", "../z_onepointdemo.c", 1671, "&cp", spC0.x, spC0.y, spC0.z); D_801211D4[0].eyeTargetInit.x = (actor->focus.pos.x + (120.0f * spC0.x)) - (Rand_ZeroOne() * 20.0f); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 0509c3ba135..716aeac4b55 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -20,7 +20,7 @@ void EnSw_SetupNormal(EnSw* this, PlayState* play); void EnSw_Crawl(EnSw* this, PlayState* play); void EnSw_SetupGoHome(EnSw* this, PlayState* play); void EnSw_GoHome(EnSw* this, PlayState* play); -void EnGs_Dash(EnSw* this, PlayState* play); +void EnSw_Dash(EnSw* this, PlayState* play); void EnSw_DieNormal(EnSw* this, PlayState* play); s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32); void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play); @@ -87,8 +87,8 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { polyNormal.x = COLPOLY_GET_NORMAL(poly->normal.x); polyNormal.y = COLPOLY_GET_NORMAL(poly->normal.y); polyNormal.z = COLPOLY_GET_NORMAL(poly->normal.z); - dot = Math_FAcosF(DOTXYZ(polyNormal, this->normalVec)); - EnSw_CrossProduct(&this->normalVec, &polyNormal, &sp38); + dot = Math_FAcosF(DOTXYZ(polyNormal, this->wallPolyNormal)); + EnSw_CrossProduct(&this->wallPolyNormal, &polyNormal, &sp38); Matrix_RotateAxis(dot, &sp38, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &sp38); this->unk_370 = sp38; @@ -97,17 +97,17 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { if (length < 0.001f) { return 0; } - this->unk_37C.x = this->unk_37C.x * (1.0f / length); - this->unk_37C.y = this->unk_37C.y * (1.0f / length); - this->unk_37C.z = this->unk_37C.z * (1.0f / length); - this->normalVec = polyNormal; + this->unk_37C.x *= (1.0f / length); + this->unk_37C.y *= (1.0f / length); + this->unk_37C.z *= (1.0f / length); + this->wallPolyNormal = polyNormal; this->unk_3D8.xx = this->unk_370.x; this->unk_3D8.yx = this->unk_370.y; this->unk_3D8.zx = this->unk_370.z; this->unk_3D8.wx = 0.0f; - this->unk_3D8.xy = this->normalVec.x; - this->unk_3D8.yy = this->normalVec.y; - this->unk_3D8.zy = this->normalVec.z; + this->unk_3D8.xy = this->wallPolyNormal.x; + this->unk_3D8.yy = this->wallPolyNormal.y; + this->unk_3D8.zy = this->wallPolyNormal.z; this->unk_3D8.wy = 0.0f; this->unk_3D8.xz = this->unk_37C.x; this->unk_3D8.yz = this->unk_37C.y; @@ -156,12 +156,12 @@ s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { ret = 0; this->unk_42C = 1; posA = posB = this->actor.world.pos; - posA.x += this->normalVec.x * 18.0f; - posA.y += this->normalVec.y * 18.0f; - posA.z += this->normalVec.z * 18.0f; - posB.x -= this->normalVec.x * 18.0f; - posB.y -= this->normalVec.y * 18.0f; - posB.z -= this->normalVec.z * 18.0f; + posA.x += this->wallPolyNormal.x * 18.0f; + posA.y += this->wallPolyNormal.y * 18.0f; + posA.z += this->wallPolyNormal.z * 18.0f; + posB.x -= this->wallPolyNormal.x * 18.0f; + posB.y -= this->wallPolyNormal.y * 18.0f; + posB.z -= this->wallPolyNormal.z * 18.0f; temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); if ((temp_s1 != NULL) && (this->goldHiddenBool == 0)) { @@ -227,11 +227,11 @@ void EnSw_Init(Actor* thisx, PlayState* play) { s32 pad; if (thisx->params & 0x8000) { - phi_v0 = SW_GOLDTYPE((thisx->params - 0x8000)) + 1; + phi_v0 = ENSW_GET_GOLDTYPE((thisx->params - 0x8000)) + 1; thisx->params = (thisx->params & 0x1FFF) | (phi_v0 << 0xD); } - if (SW_GOLDTYPE(thisx->params) > SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(thisx->params) > SW_NORMALTYPE) { phi_v0 = ((thisx->params & 0x1F00) >> 8) - 1; thisx->params = (thisx->params & 0xE0FF) | (phi_v0 << 8); } @@ -250,7 +250,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); this->actor.scale.x = 0.02f; - if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { this->actor.world.rot.x = 0; this->actor.world.rot.z = 0; thisx->shape.rot = this->actor.world.rot; @@ -263,23 +263,23 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); this->unk_370.y = 0.0f; this->unk_370.z = Math_CosS(thisx->shape.rot.y + 0x4000); - this->normalVec.x = 0.0f; - this->normalVec.y = 1.0f; - this->normalVec.z = 0.0f; + this->wallPolyNormal.x = 0.0f; + this->wallPolyNormal.y = 1.0f; + this->wallPolyNormal.z = 0.0f; this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); EnSw_GoldClingToWall(this, play, 1); } - if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { + if (ENSW_GET_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN_SOIL) { Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - switch (SW_GOLDTYPE(thisx->params)) { - case SW_GOLDTYPE_HIDDEN: - case SW_GOLDTYPE_HIDDEN2: + switch (ENSW_GET_GOLDTYPE(thisx->params)) { + case SW_GOLDTYPE_HIDDEN_SOIL: + case SW_GOLDTYPE_HIDDEN_TREE: // they spring out of their hidding spot this->goldHiddenBool = 1; this->actor.velocity.y = 8.0f; @@ -295,10 +295,12 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.health *= 2; this->actor.flags &= ~ACTOR_FLAG_0; break; + default: Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); this->actor.naviEnemyId = NAVI_ENEMY_SKULLWALLTULA; break; + } this->crawlTimer = Rand_S16Offset(15, 30); @@ -306,11 +308,11 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->actor.home.pos = this->actor.world.pos; thisx->shape.rot = this->actor.world.rot; - if (SW_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN) { + if (ENSW_GET_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN_SOIL) { this->waitTimer = 40; this->deathFlames = 1; this->actionFunc = EnSw_SetupGoldHidden; - } else if (SW_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { + } else if (ENSW_GET_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { this->actionFunc = EnSw_SetupNormal; } else { this->actionFunc = EnSw_Crawl; @@ -326,7 +328,7 @@ void EnSw_Destroy(Actor* thisx, PlayState* play) { s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { s32 phi_v1 = false; - if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && SW_GOLDTYPE(this->actor.params) == SW_NORMALTYPE && + if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && ENSW_GET_GOLDTYPE(this->actor.params) == SW_NORMALTYPE && play->actorCtx.unk_02 != 0) { this->actor.colChkInfo.damage = this->actor.colChkInfo.health; @@ -343,7 +345,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { return true; } Enemy_StartFinishingBlow(play, &this->actor); - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->skelAnime.playSpeed = 8.0f; if ((play->state.frames & 1) == 0) { this->rotateMag = 0.1f; @@ -377,7 +379,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } void EnSw_SetCollider(EnSw* this, PlayState* play) { - if ((SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != EnSw_Crawl)) { + if ((ENSW_GET_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != EnSw_Crawl)) { if (this->painTimer1 != 0) { this->painTimer1--; } @@ -411,7 +413,7 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { Matrix_RotateAxis(*angle, &floorPolyNormal, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &floorPolyNormal); this->unk_370 = floorPolyNormal; - EnSw_CrossProduct(&this->unk_370, &this->normalVec, &this->unk_37C); + EnSw_CrossProduct(&this->unk_370, &this->wallPolyNormal, &this->unk_37C); length = Math3D_Vec3fMagnitude(&this->unk_37C); if (length < 0.001f) { return false; @@ -424,9 +426,9 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { rotMtxF.yx = this->unk_370.y; rotMtxF.zx = this->unk_370.z; rotMtxF.wx = 0.0f; - rotMtxF.xy = this->normalVec.x; - rotMtxF.yy = this->normalVec.y; - rotMtxF.zy = this->normalVec.z; + rotMtxF.xy = this->wallPolyNormal.x; + rotMtxF.yy = this->wallPolyNormal.y; + rotMtxF.zy = this->wallPolyNormal.z; rotMtxF.wy = 0.0f; rotMtxF.xz = this->unk_37C.x; rotMtxF.yz = this->unk_37C.y; @@ -445,7 +447,7 @@ void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { Camera* activeCam = GET_ACTIVE_CAM(play); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) >= 380.0f)) { - Audio_PlayActorSfx2(&this->actor, SW_GOLDTYPE(this->actor.params) > SW_NORMALTYPE + Audio_PlayActorSfx2(&this->actor, ENSW_GET_GOLDTYPE(this->actor.params) > SW_NORMALTYPE ? NA_SE_EN_STALGOLD_ROLL : NA_SE_EN_STALWALL_ROLL); } } @@ -490,7 +492,7 @@ void EnSw_SpawnDust2(EnSw* this, PlayState* play, s32 cnt) { } void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { - if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_HIDDEN2) { + if (ENSW_GET_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_HIDDEN_TREE) { this->waitTimer = 0; this->actionFunc = EnSw_GoldHiddenReveal; } else { @@ -515,9 +517,9 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { Math_ApproachF(&this->actor.scale.x, 0.02f, 0.2f, 0.01f); Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.world.pos.x += this->normalVec.x * this->actor.velocity.y; - this->actor.world.pos.y += this->normalVec.y * this->actor.velocity.y; - this->actor.world.pos.z += this->normalVec.z * this->actor.velocity.y; + this->actor.world.pos.x += this->wallPolyNormal.x * this->actor.velocity.y; + this->actor.world.pos.y += this->wallPolyNormal.y * this->actor.velocity.y; + this->actor.world.pos.z += this->wallPolyNormal.z * this->actor.velocity.y; this->actor.world.pos.x += this->unk_37C.x * this->actor.speedXZ; this->actor.world.pos.y += this->unk_37C.y * this->actor.speedXZ; this->actor.world.pos.z += this->unk_37C.z * this->actor.speedXZ; @@ -544,7 +546,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { f32 rotAngle; // Outdoor Gold Skulltula shrinks/expands based on time - if (SW_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_NIGHT) { + if (ENSW_GET_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_NIGHT) { if (this->actor.scale.x < 0.0139999995f) { this->collider.elements[0].info.toucherFlags = TOUCH_NONE; this->collider.elements[0].info.bumperFlags = BUMP_NONE; @@ -568,7 +570,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; this->animationSpeed = 1; this->waitTimer = Rand_S16Offset(30, 60); - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->waitTimer *= 2; this->rotateMag *= 2.0f; } @@ -579,7 +581,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { this->crawlTimer = Rand_S16Offset(15, 30); this->animationSpeed = 0; this->skelAnime.playSpeed = 0.0f; - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->crawlTimer /= 2; } } else if (this->animationSpeed != 0) { @@ -589,7 +591,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { if (this->skelAnime.playSpeed > 0.0f) { EnSw_PlaySfxRoll(this, play); } - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { this->skelAnime.playSpeed *= 2.0f; } } else { @@ -623,9 +625,9 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { if ((this->deathFlames == 0) && (this->painTimer1 == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - x = (this->normalVec.x * 10.0f); - y = (this->normalVec.y * 10.0f); - z = (this->normalVec.z * 10.0f); + x = (this->wallPolyNormal.x * 10.0f); + y = (this->wallPolyNormal.y * 10.0f); + z = (this->wallPolyNormal.z * 10.0f); token = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SI, this->actor.world.pos.x + x, this->actor.world.pos.y + y, this->actor.world.pos.z + z, 0, 0, 0, this->actor.params); @@ -688,7 +690,7 @@ void EnSw_DieNormal(EnSw* this, PlayState* play) { } } -s16 EnSw_GetRotateY(EnSw* this, Vec3f* target) { +s16 EnSw_GetTargetPitch(EnSw* this, Vec3f* target) { s16 pitch; s16 yaw; @@ -707,7 +709,7 @@ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; - } else if (ABS(EnSw_GetRotateY(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { + } else if (ABS(EnSw_GetTargetPitch(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { return false; } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { return false; @@ -762,7 +764,7 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { return ret; } -void EnGs_Move(EnSw* this, Vec3f targetPos, f32 speedTarget) { +void EnSw_Move(EnSw* this, Vec3f targetPos, f32 speedTarget) { f32 xDist; f32 yDist; f32 zDist; @@ -838,11 +840,11 @@ void EnSw_SetupNormal(EnSw* this, PlayState* play) { if ((DECR(this->dashTimer) == 0) && (EnSW_CanDashPlayer(this, play, 1))) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_LAUGH); this->dashTimer = 20; - this->actionFunc = EnGs_Dash; + this->actionFunc = EnSw_Dash; } } -void EnGs_Dash(EnSw* this, PlayState* play) { +void EnSw_Dash(EnSw* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; @@ -850,7 +852,7 @@ void EnGs_Dash(EnSw* this, PlayState* play) { if (EnSW_CanDashPlayer(this, play, 1)) { this->targetPos = player->actor.world.pos; this->targetPos.y += 30.0f; - this->rotZTarget = EnSw_GetRotateY(this, &this->targetPos); + this->rotZTarget = EnSw_GetTargetPitch(this, &this->targetPos); EnSw_SetCrawlAnimation(this, 6.0f, (u16)4000, 0, play); } else { this->actionFunc = EnSw_SetupNormal; @@ -858,11 +860,11 @@ void EnGs_Dash(EnSw* this, PlayState* play) { } else { if (!EnSW_LineTestWall(this, play)) { this->dashTimer = Rand_S16Offset(20, 10); - this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); + this->rotZTarget = EnSw_GetTargetPitch(this, &this->actor.home.pos); this->targetPos = this->actor.home.pos; this->actionFunc = EnSw_GoHome; } else { - EnGs_Move(this, this->targetPos, 8.0f); + EnSw_Move(this, this->targetPos, 8.0f); if (DECR(this->sfxTimer) == 0) { Audio_PlayActorSfx2(&this->actor, NA_SE_EN_STALWALL_DASH); @@ -879,9 +881,9 @@ void EnGs_Dash(EnSw* this, PlayState* play) { void EnSw_SetupGoHome(EnSw* this, PlayState* play) { s32 pad; - EnGs_Move(this, this->targetPos, 0.0f); + EnSw_Move(this, this->targetPos, 0.0f); if (this->actor.speedXZ == 0.0f) { - this->rotZTarget = EnSw_GetRotateY(this, &this->actor.home.pos); + this->rotZTarget = EnSw_GetTargetPitch(this, &this->actor.home.pos); this->targetPos = this->actor.home.pos; this->actionFunc = EnSw_GoHome; } @@ -891,7 +893,7 @@ void EnSw_GoHome(EnSw* this, PlayState* play) { s32 pad; if (EnSw_SetCrawlAnimation(this, 6.0f, 1000, 0, play)) { - EnGs_Move(this, this->targetPos, 2.0f); + EnSw_Move(this, this->targetPos, 2.0f); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &this->targetPos) > 4.0f)) { this->actionFunc = EnSw_SetupNormal; } @@ -918,7 +920,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2084); - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { switch (limbIndex) { // replace with Gold Skulltula body parts. case 23: *dList = object_st_DL_004788; @@ -979,7 +981,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } -void EnGs_SetTint(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { +void EnSw_SetFog(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { f32 temp_f2; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2181); @@ -995,7 +997,7 @@ void EnGs_SetTint(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { CLOSE_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2197); } -void EnGs_ApplyTint(PlayState* play) { +void EnSw_RestoreFog(PlayState* play) { s32 pad; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2205); @@ -1009,20 +1011,20 @@ void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; Color_RGBA8 col = { 184, 0, 228, 255 }; - if (SW_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { Matrix_RotateX(DEG_TO_RAD(-80), MTXMODE_APPLY); if (this->actor.colChkInfo.health != 0) { Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); } func_8002EBCC(&this->actor, play, 0); - } else if (this->actionFunc == EnGs_Dash) { - EnGs_SetTint(play, &col, 20, 30); + } else if (this->actionFunc == EnSw_Dash) { + EnSw_SetFog(play, &col, 20, 30); } Gfx_SetupDL_25Opa(play->state.gfxCtx); SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnSw_OverrideLimbDraw, EnSw_PostLimbDraw, this); - if (this->actionFunc == EnGs_Dash) { - EnGs_ApplyTint(play); + if (this->actionFunc == EnSw_Dash) { + EnSw_RestoreFog(play); } } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index cbdb2848d2d..a10f781e9af 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -18,7 +18,7 @@ typedef struct EnSw { /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; /* 0x0360 */ u8 goldHiddenBool; // set when revealed, unset when landing. - /* 0x0364 */ Vec3f normalVec; + /* 0x0364 */ Vec3f wallPolyNormal; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; /* 0x0388 */ s16 aniTimer; @@ -48,14 +48,14 @@ typedef struct EnSw { /* 0x0490 */ char unk_490[0x48]; } EnSw; // size = 0x04D8 -#define SW_GOLDTYPE(params) ((params & 0xE000) >> 0xD) +#define ENSW_GET_GOLDTYPE(params) ((params & 0xE000) >> 0xD) typedef enum { SW_NORMALTYPE, // normal Skullwalltula SW_GOLDTYPE_DEFAULT, // Normal Gold Skultula, found in dungeons SW_GOLDTYPE_NIGHT, // nocturnal Gold Skultula, found outside - SW_GOLDTYPE_HIDDEN, // found by using incects on soil patches - SW_GOLDTYPE_HIDDEN2, // found by hitting trees. + SW_GOLDTYPE_HIDDEN_SOIL, // found by using bugs on soil patches + SW_GOLDTYPE_HIDDEN_TREE, // found by hitting trees. } EnSwTypes; #endif From f980bda6698513a61e8a78208c8a930ee5225810 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Tue, 3 Jan 2023 04:17:31 -0500 Subject: [PATCH 05/15] `z_en_sw`: changes based on feedback. --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 163 ++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 32 ++--- 2 files changed, 100 insertions(+), 95 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index fb90e1fcf0f..bb8da4c0d26 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -22,7 +22,7 @@ void EnSw_SetupGoHome(EnSw* this, PlayState* play); void EnSw_GoHome(EnSw* this, PlayState* play); void EnSw_Dash(EnSw* this, PlayState* play); void EnSw_DieNormal(EnSw* this, PlayState* play); -s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32); +s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32); void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play); void EnSw_FallNormal(EnSw* this, PlayState* play); void EnSw_DieGold(EnSw* this, PlayState* play); @@ -140,7 +140,7 @@ CollisionPoly* EnSw_GetPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* po return poly; } -s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { +s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { CollisionPoly* temp_v0_2; CollisionPoly* temp_s1; Vec3f sp9C; @@ -153,7 +153,7 @@ s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { s32 phi_s1; s32 ret; - ret = 0; + ret = false; this->unk_42C = 1; posA = posB = this->actor.world.pos; posA.x += this->wallPolyNormal.x * 18.0f; @@ -164,7 +164,7 @@ s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { posB.z -= this->wallPolyNormal.z * 18.0f; temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); - if ((temp_s1 != NULL) && (this->goldHiddenBool == 0)) { + if ((temp_s1 != NULL) && (this->goldIsHidden == false)) { posB.x = posA.x + (this->unk_37C.x * 24); posB.y = posA.y + (this->unk_37C.y * 24); posB.z = posA.z + (this->unk_37C.z * 24); @@ -182,7 +182,7 @@ s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { this->actor.world.pos = posOut; this->actor.floorBgId = bgId; } - ret = 1; + ret = true; } else { posA = posB; for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { @@ -207,7 +207,7 @@ s32 EnSw_GoldClingToWall(EnSw* this, PlayState* play, s32 arg2) { this->actor.world.pos = sp9C; this->actor.floorBgId = sp6C; } - ret = 1; + ret = true; break; } } @@ -227,11 +227,13 @@ void EnSw_Init(Actor* thisx, PlayState* play) { s32 pad; if (thisx->params & 0x8000) { - phi_v0 = ENSW_GET_GOLDTYPE((thisx->params - 0x8000)) + 1; + // special case of "Gold Type" macro + phi_v0 = (((thisx->params - 0x8000) & 0xE000) >> 0xD) + 1; thisx->params = (thisx->params & 0x1FFF) | (phi_v0 << 0xD); } - if (ENSW_GET_GOLDTYPE(thisx->params) > SW_NORMALTYPE) { + if (ENSW_GET_TYPE(thisx) > SW_TYPE_NORMAL) { + // shift the token ID phi_v0 = ((thisx->params & 0x1F00) >> 8) - 1; thisx->params = (thisx->params & 0xE0FF) | (phi_v0 << 8); } @@ -250,13 +252,13 @@ void EnSw_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0xE), &D_80B0F074); this->actor.scale.x = 0.02f; - if (ENSW_GET_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { + if (ENSW_GET_TYPE(thisx) == SW_TYPE_NORMAL) { this->actor.world.rot.x = 0; this->actor.world.rot.z = 0; thisx->shape.rot = this->actor.world.rot; - this->walllCast.y = this->actor.world.pos.y; - this->walllCast.x = this->actor.world.pos.x + (Math_SinS(this->actor.world.rot.y) * -60.0f); - this->walllCast.z = this->actor.world.pos.z + (Math_CosS(this->actor.world.rot.y) * -60.0f); + this->wallCast.y = this->actor.world.pos.y; + this->wallCast.x = this->actor.world.pos.x + (Math_SinS(this->actor.world.rot.y) * -60.0f); + this->wallCast.z = this->actor.world.pos.z + (Math_CosS(this->actor.world.rot.y) * -60.0f); EnSW_LineTestWall(this, play); this->actor.home.pos = this->actor.world.pos; } else { @@ -269,27 +271,27 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); - EnSw_GoldClingToWall(this, play, 1); + EnSw_MoveGold(this, play, 1); } - if (ENSW_GET_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN_SOIL) { + if (ENSW_GET_TYPE(thisx) >= SW_TYPE_GOLD_HIDDEN_SOIL) { Audio_PlaySfxGeneral(NA_SE_SY_CORRECT_CHIME, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - switch (ENSW_GET_GOLDTYPE(thisx->params)) { - case SW_GOLDTYPE_HIDDEN_SOIL: - case SW_GOLDTYPE_HIDDEN_TREE: + switch (ENSW_GET_TYPE(thisx)) { + case SW_TYPE_GOLD_HIDDEN_SOIL: + case SW_TYPE_GOLD_HIDDEN_TREE: // they spring out of their hidding spot - this->goldHiddenBool = 1; + this->goldIsHidden = true; this->actor.velocity.y = 8.0f; this->actor.speed = 4.0f; this->actor.gravity = -1.0f; FALLTHROUGH; - case SW_GOLDTYPE_NIGHT: + case SW_TYPE_GOLD_NIGHT: this->actor.scale.x = 0.0f; // they expand at night FALLTHROUGH; - case SW_GOLDTYPE_DEFAULT: + case SW_TYPE_GOLD_DEFAULT: this->collider.elements[0].info.toucher.damage *= 2; this->actor.naviEnemyId = NAVI_ENEMY_GOLD_SKULLTULA; this->actor.colChkInfo.health *= 2; @@ -308,11 +310,11 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->actor.home.pos = this->actor.world.pos; thisx->shape.rot = this->actor.world.rot; - if (ENSW_GET_GOLDTYPE(thisx->params) >= SW_GOLDTYPE_HIDDEN_SOIL) { + if (ENSW_GET_TYPE(thisx) >= SW_TYPE_GOLD_HIDDEN_SOIL) { this->waitTimer = 40; this->deathFlames = 1; this->actionFunc = EnSw_SetupGoldHidden; - } else if (ENSW_GET_GOLDTYPE(thisx->params) == SW_NORMALTYPE) { + } else if (ENSW_GET_TYPE(thisx) == SW_TYPE_NORMAL) { this->actionFunc = EnSw_SetupNormal; } else { this->actionFunc = EnSw_Crawl; @@ -328,24 +330,24 @@ void EnSw_Destroy(Actor* thisx, PlayState* play) { s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { s32 phi_v1 = false; - if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && ENSW_GET_GOLDTYPE(this->actor.params) == SW_NORMALTYPE && + if (this->actor.xyzDistToPlayerSq < SQ(400.0f) && ENSW_GET_TYPE_EN(this) == SW_TYPE_NORMAL && play->actorCtx.unk_02 != 0) { this->actor.colChkInfo.damage = this->actor.colChkInfo.health; phi_v1 = true; } - if (this->painTimer1 == 0) { + if (this->painTimer == 0) { if ((this->collider.base.acFlags & AC_HIT) || phi_v1) { this->collider.base.acFlags &= ~AC_HIT; - this->painTimer1 = 0x10; - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->painTimer1); + this->painTimer = 0x10; + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->painTimer); if (Actor_ApplyDamage(&this->actor) != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_DAMAGE); return true; } Enemy_StartFinishingBlow(play, &this->actor); - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->skelAnime.playSpeed = 8.0f; if ((play->state.frames & 1) == 0) { this->rotateMag = 0.1f; @@ -353,13 +355,13 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { this->rotateMag = -0.1f; } this->deathFlames = 10; - this->animationSpeed = 1; + this->animSpeed = 1; this->rotateMag *= 4.0f; this->actionFunc = EnSw_DieGold; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 0xFF; - this->animationSpeed = 2; + this->animSpeed = 2; this->actor.shape.shadowScale = 16.0f; this->actor.gravity = -1.0f; this->actor.flags &= ~ACTOR_FLAG_0; @@ -371,24 +373,24 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } } - if ((this->painTimer0 == 0) && (this->collider.base.atFlags & AT_HIT)) { - this->painTimer0 = 30; + if ((this->attackTimer == 0) && (this->collider.base.atFlags & AT_HIT)) { + this->attackTimer = 30; } return false; } void EnSw_SetCollider(EnSw* this, PlayState* play) { - if ((ENSW_GET_GOLDTYPE(this->actor.params) > SW_NORMALTYPE) && (this->actionFunc != EnSw_Crawl)) { - if (this->painTimer1 != 0) { - this->painTimer1--; + if ((ENSW_GET_TYPE_EN(this) > SW_TYPE_NORMAL) && (this->actionFunc != EnSw_Crawl)) { + if (this->painTimer != 0) { + this->painTimer--; } } else { - if ((DECR(this->painTimer0) == 0) && (this->actor.colChkInfo.health != 0)) { + if ((DECR(this->attackTimer) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); } - if ((DECR(this->painTimer1) == 0) && (this->actor.colChkInfo.health != 0)) { + if ((DECR(this->painTimer) == 0) && (this->actor.colChkInfo.health != 0)) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } @@ -443,11 +445,11 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { } void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { - if (!(this->actor.scale.x < 0.0139999995f)) { + if (!(this->actor.scale.x < (140.0f * 0.0001f))) { Camera* activeCam = GET_ACTIVE_CAM(play); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) >= 380.0f)) { - Actor_PlaySfx(&this->actor, ENSW_GET_GOLDTYPE(this->actor.params) > SW_NORMALTYPE + Actor_PlaySfx(&this->actor, ENSW_GET_TYPE_EN(this) > SW_TYPE_NORMAL ? NA_SE_EN_STALGOLD_ROLL : NA_SE_EN_STALWALL_ROLL); } } @@ -472,7 +474,7 @@ void EnSw_SpawnDust(EnSw* this, PlayState* play, s32 cnt) { } } -void EnSw_SpawnDust2(EnSw* this, PlayState* play, s32 cnt) { +void EnSw_SpawnDustBig(EnSw* this, PlayState* play, s32 cnt) { Color_RGBA8 primColor = { 80, 80, 50, 255 }; Color_RGBA8 envColor = { 100, 100, 80, 0 }; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; @@ -492,7 +494,7 @@ void EnSw_SpawnDust2(EnSw* this, PlayState* play, s32 cnt) { } void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { - if (ENSW_GET_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_HIDDEN_TREE) { + if (ENSW_GET_TYPE_EN(this) == SW_TYPE_GOLD_HIDDEN_TREE) { this->waitTimer = 0; this->actionFunc = EnSw_GoldHiddenReveal; } else { @@ -528,12 +530,12 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { this->actor.velocity.y = CLAMP_MIN(this->actor.velocity.y, this->actor.minVelocityY); if (this->actor.velocity.y < 0.0f) { - this->goldHiddenBool = 0; + this->goldIsHidden = false; } - if (EnSw_GoldClingToWall(this, play, 1) == 1) { + if (EnSw_MoveGold(this, play, 1) == true) { Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND); - EnSw_SpawnDust2(this, play, 8); + EnSw_SpawnDustBig(this, play, 8); this->actor.scale.x = 0.02f; Actor_SetScale(&this->actor, 0.02f); this->actionFunc = EnSw_Crawl; @@ -547,14 +549,14 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { f32 rotAngle; // Outdoor Gold Skulltula shrinks/expands based on time - if (ENSW_GET_GOLDTYPE(this->actor.params) == SW_GOLDTYPE_NIGHT) { - if (this->actor.scale.x < 0.0139999995f) { + if (ENSW_GET_TYPE_EN(this) == SW_TYPE_GOLD_NIGHT) { + if (this->actor.scale.x < (140.0f * 0.0001f)) { this->collider.elements[0].info.toucherFlags = TOUCH_NONE; this->collider.elements[0].info.bumperFlags = BUMP_NONE; this->collider.elements[0].info.ocElemFlags = OCELEM_NONE; } - if (this->actor.scale.x >= 0.0139999995f) { + if (this->actor.scale.x >= (140.0f * 0.0001f)) { this->collider.elements[0].info.toucherFlags = TOUCH_ON; this->collider.elements[0].info.bumperFlags = BUMP_ON; this->collider.elements[0].info.ocElemFlags = OCELEM_ON; @@ -569,9 +571,9 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { if (this->crawlTimer == 0) { EnSw_PlaySfxRoll(this, play); this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; - this->animationSpeed = 1; + this->animSpeed = 1; this->waitTimer = Rand_S16Offset(30, 60); - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->waitTimer *= 2; this->rotateMag *= 2.0f; } @@ -580,24 +582,24 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { this->waitTimer--; if (this->waitTimer == 0) { this->crawlTimer = Rand_S16Offset(15, 30); - this->animationSpeed = 0; + this->animSpeed = 0; this->skelAnime.playSpeed = 0.0f; - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->crawlTimer /= 2; } - } else if (this->animationSpeed != 0) { - this->animationSpeed--; - this->skelAnime.playSpeed = (this->animationSpeed == 0) ? 4.0f : 0.0f; + } else if (this->animSpeed != 0) { + this->animSpeed--; + this->skelAnime.playSpeed = (this->animSpeed == 0) ? 4.0f : 0.0f; if (this->skelAnime.playSpeed > 0.0f) { EnSw_PlaySfxRoll(this, play); } - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->skelAnime.playSpeed *= 2.0f; } } else { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - this->animationSpeed = 2; + this->animSpeed = 2; } rotAngle = 32768.0f / this->skelAnime.endFrame; rotAngle *= this->skelAnime.curFrame; @@ -623,7 +625,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { EnSw_GetRotate(this, &this->rotateMag); this->actor.shape.rot = this->actor.world.rot; - if ((this->deathFlames == 0) && (this->painTimer1 == 0)) { + if ((this->deathFlames == 0) && (this->painTimer == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); x = (this->wallPolyNormal.x * 10.0f); @@ -639,7 +641,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { return; } - if ((this->painTimer1 == 0) && (DECR(this->deathFlames) != 0)) { + if ((this->painTimer == 0) && (DECR(this->deathFlames) != 0)) { pos = this->actor.world.pos; pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); pos.x += (Rand_ZeroOne() - 0.5f) * 32.0f; @@ -662,11 +664,12 @@ void EnSw_FallNormal(EnSw* this, PlayState* play) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - if (this->animationSpeed == 0) { + if (this->animSpeed == 0) { this->actionFunc = EnSw_DieNormal; this->deathFlames = 10; } else { - this->actor.velocity.y = ((this->animationSpeed--) * 8.0f) * 0.5f; + this->actor.velocity.y = (this->animSpeed * 8.0f) * 0.5f; + this->animSpeed--; } Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND); @@ -702,9 +705,9 @@ s16 EnSw_GetTargetPitch(EnSw* this, Vec3f* target) { s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { Player* player = GET_PLAYER(play); - CollisionPoly* sp58; - s32 sp54; - Vec3f sp48; + CollisionPoly* poly; + s32 bgId; + Vec3f pos; if (!(player->stateFlags1 & PLAYER_STATE1_21) && arg2) { return false; @@ -714,8 +717,8 @@ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { return false; } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { return false; - } else if (!BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &player->actor.world.pos, &sp48, &sp58, - true, false, false, true, &sp54)) { + } else if (!BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &player->actor.world.pos, &pos, &poly, + true, false, false, true, &bgId)) { return true; } else { return false; @@ -751,7 +754,7 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { ret = false; } - if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->walllCast, &posResult, &this->wallPoly, true, + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->wallCast, &posResult, &this->wallPoly, true, false, false, true, &bgId)) { this->actor.wallYaw = RAD_TO_BINANG(Math_FAtan2F(this->wallPoly->normal.x, this->wallPoly->normal.z)); this->actor.world.pos = posResult; @@ -798,7 +801,7 @@ s32 EnSw_SetCrawlAnimation(EnSw* this, f32 target, s16 step, s32 arg3, PlayState Camera* activeCam; f32 lastFrame = Animation_GetLastFrame(&object_st_Anim_000304); - if (DECR(this->aniTimer) != 0) { + if (DECR(this->animTimer) != 0) { Math_SmoothStepToF(&this->skelAnime.playSpeed, 0.0f, 0.6f, 1000.0f, 0.01f); return 0; } @@ -835,7 +838,7 @@ void EnSw_SetupNormal(EnSw* this, PlayState* play) { rand = Rand_ZeroOne(); this->rotZTarget = ((s16)(20000.0f * rand) + 12000) * (Rand_ZeroOne() >= 0.5f ? 1.0f : -1.0f) + this->actor.world.rot.z; - this->aniTimer = Rand_S16Offset(10, 30); + this->animTimer = Rand_S16Offset(10, 30); } if ((DECR(this->dashTimer) == 0) && (EnSW_CanDashPlayer(this, play, 1))) { @@ -854,7 +857,7 @@ void EnSw_Dash(EnSw* this, PlayState* play) { this->targetPos = player->actor.world.pos; this->targetPos.y += 30.0f; this->rotZTarget = EnSw_GetTargetPitch(this, &this->targetPos); - EnSw_SetCrawlAnimation(this, 6.0f, (u16)4000, 0, play); + EnSw_SetCrawlAnimation(this, 6.0f, 4000, 0, play); } else { this->actionFunc = EnSw_SetupNormal; } @@ -920,7 +923,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2084); - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { switch (limbIndex) { // replace with Gold Skulltula body parts. case 23: *dList = object_st_DL_004788; @@ -960,7 +963,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Matrix_MultVec3f(&sp70, &this->lineCast1); Matrix_MultVec3f(&sp64, &this->lineCast2); Matrix_MultVec3f(&sp58, &this->lineCast3); - Matrix_MultVec3f(&sp4C, &this->walllCast); + Matrix_MultVec3f(&sp4C, &this->wallCast); } if (limbIndex == 5) { @@ -968,7 +971,7 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } if (limbIndex == 4) { // head? - gDPSetEnvColor(POLY_OPA_DISP++, this->limb4Col.r, this->limb4Col.g, this->limb4Col.b, 0); + gDPSetEnvColor(POLY_OPA_DISP++, this->limb4Color.r, this->limb4Color.g, this->limb4Color.b, 0); } Collider_UpdateSpheres(limbIndex, &this->collider); @@ -981,18 +984,18 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } -void EnSw_SetFog(PlayState* play, Color_RGBA8* col, s16 arg2, s16 arg3) { - f32 temp_f2; +void EnSw_SetFog(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { + f32 far; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2181); - temp_f2 = (11500.0f / arg3) * (arg3 - arg2); + far = (11500.0f / arg3) * (arg3 - arg2); - if (0.0f == temp_f2) { - temp_f2 = 11500; + if (0.0f == far) { + far = 11500; } - POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, col->r, col->g, col->b, col->a, 0, (s16)temp_f2); + POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP, color->r, color->g, color->b, color->a, 0, (s16)far); CLOSE_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2197); } @@ -1009,16 +1012,16 @@ void EnSw_RestoreFog(PlayState* play) { void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; - Color_RGBA8 col = { 184, 0, 228, 255 }; + Color_RGBA8 color = { 184, 0, 228, 255 }; - if (ENSW_GET_GOLDTYPE(this->actor.params) != SW_NORMALTYPE) { + if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { Matrix_RotateX(DEG_TO_RAD(-80), MTXMODE_APPLY); if (this->actor.colChkInfo.health != 0) { Matrix_Translate(0.0f, 0.0f, 200.0f, MTXMODE_APPLY); } func_8002EBCC(&this->actor, play, 0); } else if (this->actionFunc == EnSw_Dash) { - EnSw_SetFog(play, &col, 20, 30); + EnSw_SetFog(play, &color, 20, 30); } Gfx_SetupDL_25Opa(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index a10f781e9af..43c8d832563 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -14,26 +14,26 @@ typedef struct EnSw { /* 0x0190 */ EnSwActionFunc actionFunc; /* 0x0194 */ ColliderJntSph collider; /* 0x01B4 */ ColliderJntSphElement sphs[1]; - /* 0x01F4 */ Color_RGBA8 limb4Col; // never set past black. + /* 0x01F4 */ Color_RGBA8 limb4Color; // never set past black. /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; - /* 0x0360 */ u8 goldHiddenBool; // set when revealed, unset when landing. + /* 0x0360 */ u8 goldIsHidden; // set when revealed, unset when landing. /* 0x0364 */ Vec3f wallPolyNormal; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; - /* 0x0388 */ s16 aniTimer; - /* 0x038A */ s16 animationSpeed; + /* 0x0388 */ s16 animTimer; + /* 0x038A */ s16 animSpeed; /* 0x038C */ s16 waitTimer; /* 0x038E */ s16 crawlTimer; - /* 0x0390 */ s16 painTimer0; - /* 0x0392 */ s16 painTimer1; + /* 0x0390 */ s16 attackTimer; + /* 0x0392 */ s16 painTimer; /* 0x0394 */ s16 deathFlames; /* 0x0396 */ char unk_396[0x42]; /* 0x03D8 */ MtxF unk_3D8; /* 0x0418 */ char unk_418[8]; /* 0x0420 */ f32 rotateMag; /* 0x0424 */ char unk_424[0x8]; - /* 0x042C */ u8 unk_42C; + /* 0x042C */ u8 unk_42C; // set during EnSw_MoveGold, rever read. /* 0x0430 */ CollisionPoly* wallPoly; /* 0x0434 */ Vec3f unk_434; // set during EnSW_LineTestWall, never read. /* 0x0440 */ s16 sfxTimer; @@ -44,18 +44,20 @@ typedef struct EnSw { /* 0x0460 */ Vec3f lineCast1; /* 0x046C */ Vec3f lineCast2; /* 0x0478 */ Vec3f lineCast3; - /* 0x0484 */ Vec3f walllCast; + /* 0x0484 */ Vec3f wallCast; /* 0x0490 */ char unk_490[0x48]; } EnSw; // size = 0x04D8 -#define ENSW_GET_GOLDTYPE(params) ((params & 0xE000) >> 0xD) +#define ENSW_GET_TYPE(thisx) ((thisx->params & 0xE000) >> 0xD) +// version of the macro used for the whole entity struct. +#define ENSW_GET_TYPE_EN(this) ((this->actor.params & 0xE000) >> 0xD) typedef enum { - SW_NORMALTYPE, // normal Skullwalltula - SW_GOLDTYPE_DEFAULT, // Normal Gold Skultula, found in dungeons - SW_GOLDTYPE_NIGHT, // nocturnal Gold Skultula, found outside - SW_GOLDTYPE_HIDDEN_SOIL, // found by using bugs on soil patches - SW_GOLDTYPE_HIDDEN_TREE, // found by hitting trees. -} EnSwTypes; + SW_TYPE_NORMAL, // normal Skullwalltula + SW_TYPE_GOLD_DEFAULT, // normal Gold Skultula, found in dungeons + SW_TYPE_GOLD_NIGHT, // nocturnal Gold Skultula, found outside + SW_TYPE_GOLD_HIDDEN_SOIL, // found by using bugs on soil patches + SW_TYPE_GOLD_HIDDEN_TREE, // found by hitting trees. +} EnSwType; #endif From cbb5d5714cfa1fcdec646c59e54823bb70105931 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sat, 21 Jan 2023 15:16:17 -0500 Subject: [PATCH 06/15] `En_Sw`: wallpolynormal -> surfaceNormal --- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 50 ++++++++++++------------- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 9101601968d..adc4c093ea3 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -261,7 +261,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_801211D4[0].atTargetInit.x = actor->focus.pos.x; D_801211D4[0].atTargetInit.y = actor->focus.pos.y - 5.0f; D_801211D4[0].atTargetInit.z = actor->focus.pos.z; - spC0 = ((EnSw*)actor)->wallPolyNormal; + spC0 = ((EnSw*)actor)->surfaceNormal; osSyncPrintf("%s(%d): xyz_t: %s (%f %f %f)\n", "../z_onepointdemo.c", 1671, "&cp", spC0.x, spC0.y, spC0.z); D_801211D4[0].eyeTargetInit.x = (actor->focus.pos.x + (120.0f * spC0.x)) - (Rand_ZeroOne() * 20.0f); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index bb8da4c0d26..b1f8f488763 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -87,8 +87,8 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { polyNormal.x = COLPOLY_GET_NORMAL(poly->normal.x); polyNormal.y = COLPOLY_GET_NORMAL(poly->normal.y); polyNormal.z = COLPOLY_GET_NORMAL(poly->normal.z); - dot = Math_FAcosF(DOTXYZ(polyNormal, this->wallPolyNormal)); - EnSw_CrossProduct(&this->wallPolyNormal, &polyNormal, &sp38); + dot = Math_FAcosF(DOTXYZ(polyNormal, this->surfaceNormal)); + EnSw_CrossProduct(&this->surfaceNormal, &polyNormal, &sp38); Matrix_RotateAxis(dot, &sp38, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &sp38); this->unk_370 = sp38; @@ -100,14 +100,14 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { this->unk_37C.x *= (1.0f / length); this->unk_37C.y *= (1.0f / length); this->unk_37C.z *= (1.0f / length); - this->wallPolyNormal = polyNormal; + this->surfaceNormal = polyNormal; this->unk_3D8.xx = this->unk_370.x; this->unk_3D8.yx = this->unk_370.y; this->unk_3D8.zx = this->unk_370.z; this->unk_3D8.wx = 0.0f; - this->unk_3D8.xy = this->wallPolyNormal.x; - this->unk_3D8.yy = this->wallPolyNormal.y; - this->unk_3D8.zy = this->wallPolyNormal.z; + this->unk_3D8.xy = this->surfaceNormal.x; + this->unk_3D8.yy = this->surfaceNormal.y; + this->unk_3D8.zy = this->surfaceNormal.z; this->unk_3D8.wy = 0.0f; this->unk_3D8.xz = this->unk_37C.x; this->unk_3D8.yz = this->unk_37C.y; @@ -156,12 +156,12 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { ret = false; this->unk_42C = 1; posA = posB = this->actor.world.pos; - posA.x += this->wallPolyNormal.x * 18.0f; - posA.y += this->wallPolyNormal.y * 18.0f; - posA.z += this->wallPolyNormal.z * 18.0f; - posB.x -= this->wallPolyNormal.x * 18.0f; - posB.y -= this->wallPolyNormal.y * 18.0f; - posB.z -= this->wallPolyNormal.z * 18.0f; + posA.x += this->surfaceNormal.x * 18.0f; + posA.y += this->surfaceNormal.y * 18.0f; + posA.z += this->surfaceNormal.z * 18.0f; + posB.x -= this->surfaceNormal.x * 18.0f; + posB.y -= this->surfaceNormal.y * 18.0f; + posB.z -= this->surfaceNormal.z * 18.0f; temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); if ((temp_s1 != NULL) && (this->goldIsHidden == false)) { @@ -265,9 +265,9 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_370.x = Math_SinS(thisx->shape.rot.y + 0x4000); this->unk_370.y = 0.0f; this->unk_370.z = Math_CosS(thisx->shape.rot.y + 0x4000); - this->wallPolyNormal.x = 0.0f; - this->wallPolyNormal.y = 1.0f; - this->wallPolyNormal.z = 0.0f; + this->surfaceNormal.x = 0.0f; + this->surfaceNormal.y = 1.0f; + this->surfaceNormal.z = 0.0f; this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); @@ -415,7 +415,7 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { Matrix_RotateAxis(*angle, &floorPolyNormal, MTXMODE_NEW); Matrix_MultVec3f(&this->unk_370, &floorPolyNormal); this->unk_370 = floorPolyNormal; - EnSw_CrossProduct(&this->unk_370, &this->wallPolyNormal, &this->unk_37C); + EnSw_CrossProduct(&this->unk_370, &this->surfaceNormal, &this->unk_37C); length = Math3D_Vec3fMagnitude(&this->unk_37C); if (length < 0.001f) { return false; @@ -428,9 +428,9 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { rotMtxF.yx = this->unk_370.y; rotMtxF.zx = this->unk_370.z; rotMtxF.wx = 0.0f; - rotMtxF.xy = this->wallPolyNormal.x; - rotMtxF.yy = this->wallPolyNormal.y; - rotMtxF.zy = this->wallPolyNormal.z; + rotMtxF.xy = this->surfaceNormal.x; + rotMtxF.yy = this->surfaceNormal.y; + rotMtxF.zy = this->surfaceNormal.z; rotMtxF.wy = 0.0f; rotMtxF.xz = this->unk_37C.x; rotMtxF.yz = this->unk_37C.y; @@ -520,9 +520,9 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { Math_ApproachF(&this->actor.scale.x, 0.02f, 0.2f, 0.01f); Actor_SetScale(&this->actor, this->actor.scale.x); - this->actor.world.pos.x += this->wallPolyNormal.x * this->actor.velocity.y; - this->actor.world.pos.y += this->wallPolyNormal.y * this->actor.velocity.y; - this->actor.world.pos.z += this->wallPolyNormal.z * this->actor.velocity.y; + this->actor.world.pos.x += this->surfaceNormal.x * this->actor.velocity.y; + this->actor.world.pos.y += this->surfaceNormal.y * this->actor.velocity.y; + this->actor.world.pos.z += this->surfaceNormal.z * this->actor.velocity.y; this->actor.world.pos.x += this->unk_37C.x * this->actor.speed; this->actor.world.pos.y += this->unk_37C.y * this->actor.speed; this->actor.world.pos.z += this->unk_37C.z * this->actor.speed; @@ -628,9 +628,9 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { if ((this->deathFlames == 0) && (this->painTimer == 0)) { Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - x = (this->wallPolyNormal.x * 10.0f); - y = (this->wallPolyNormal.y * 10.0f); - z = (this->wallPolyNormal.z * 10.0f); + x = (this->surfaceNormal.x * 10.0f); + y = (this->surfaceNormal.y * 10.0f); + z = (this->surfaceNormal.z * 10.0f); token = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SI, this->actor.world.pos.x + x, this->actor.world.pos.y + y, this->actor.world.pos.z + z, 0, 0, 0, this->actor.params); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 43c8d832563..7fb84be30d3 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -18,7 +18,7 @@ typedef struct EnSw { /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; /* 0x0360 */ u8 goldIsHidden; // set when revealed, unset when landing. - /* 0x0364 */ Vec3f wallPolyNormal; + /* 0x0364 */ Vec3f surfaceNormal; /* 0x0370 */ Vec3f unk_370; /* 0x037C */ Vec3f unk_37C; /* 0x0388 */ s16 animTimer; From f89c2560a544839492583fbf9803150ce62ec651 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Mon, 3 Jul 2023 18:16:22 -0400 Subject: [PATCH 07/15] `z_en_sw`: better clarified fields, added more comments better name for "gold Jumping" bool, matrix used in some rotate calculation, and ends of Skullwalltula's eyesight. --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 86 +++++++++++++------------ src/overlays/actors/ovl_En_Sw/z_en_sw.h | 23 +++---- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index b1f8f488763..2144e88bcfb 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -101,23 +101,23 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { this->unk_37C.y *= (1.0f / length); this->unk_37C.z *= (1.0f / length); this->surfaceNormal = polyNormal; - this->unk_3D8.xx = this->unk_370.x; - this->unk_3D8.yx = this->unk_370.y; - this->unk_3D8.zx = this->unk_370.z; - this->unk_3D8.wx = 0.0f; - this->unk_3D8.xy = this->surfaceNormal.x; - this->unk_3D8.yy = this->surfaceNormal.y; - this->unk_3D8.zy = this->surfaceNormal.z; - this->unk_3D8.wy = 0.0f; - this->unk_3D8.xz = this->unk_37C.x; - this->unk_3D8.yz = this->unk_37C.y; - this->unk_3D8.zz = this->unk_37C.z; - this->unk_3D8.wz = 0.0f; - this->unk_3D8.xw = 0.0f; - this->unk_3D8.yw = 0.0f; - this->unk_3D8.zw = 0.0f; - this->unk_3D8.ww = 1.0f; - Matrix_MtxFToYXZRotS(&this->unk_3D8, &this->actor.world.rot, 0); + this->rotMtxF.xx = this->unk_370.x; + this->rotMtxF.yx = this->unk_370.y; + this->rotMtxF.zx = this->unk_370.z; + this->rotMtxF.wx = 0.0f; + this->rotMtxF.xy = this->surfaceNormal.x; + this->rotMtxF.yy = this->surfaceNormal.y; + this->rotMtxF.zy = this->surfaceNormal.z; + this->rotMtxF.wy = 0.0f; + this->rotMtxF.xz = this->unk_37C.x; + this->rotMtxF.yz = this->unk_37C.y; + this->rotMtxF.zz = this->unk_37C.z; + this->rotMtxF.wz = 0.0f; + this->rotMtxF.xw = 0.0f; + this->rotMtxF.yw = 0.0f; + this->rotMtxF.zw = 0.0f; + this->rotMtxF.ww = 1.0f; + Matrix_MtxFToYXZRotS(&this->rotMtxF, &this->actor.world.rot, 0); //! @bug: Does not return. } @@ -164,7 +164,7 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { posB.z -= this->surfaceNormal.z * 18.0f; temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); - if ((temp_s1 != NULL) && (this->goldIsHidden == false)) { + if ((temp_s1 != NULL) && (this->goldInAir == false)) { posB.x = posA.x + (this->unk_37C.x * 24); posB.y = posA.y + (this->unk_37C.y * 24); posB.z = posA.z + (this->unk_37C.z * 24); @@ -283,7 +283,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { case SW_TYPE_GOLD_HIDDEN_SOIL: case SW_TYPE_GOLD_HIDDEN_TREE: // they spring out of their hidding spot - this->goldIsHidden = true; + this->goldInAir = true; this->actor.velocity.y = 8.0f; this->actor.speed = 4.0f; this->actor.gravity = -1.0f; @@ -348,6 +348,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } Enemy_StartFinishingBlow(play, &this->actor); if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { + // Gold Skultula spins in place as it dies. this->skelAnime.playSpeed = 8.0f; if ((play->state.frames & 1) == 0) { this->rotateMag = 0.1f; @@ -359,6 +360,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { this->rotateMag *= 4.0f; this->actionFunc = EnSw_DieGold; } else { + // Skulwalltula detaches from surface before dying. this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 0xFF; this->animSpeed = 2; @@ -530,7 +532,7 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { this->actor.velocity.y = CLAMP_MIN(this->actor.velocity.y, this->actor.minVelocityY); if (this->actor.velocity.y < 0.0f) { - this->goldIsHidden = false; + this->goldInAir = false; } if (EnSw_MoveGold(this, play, 1) == true) { @@ -709,14 +711,18 @@ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { s32 bgId; Vec3f pos; + // Check if Link is in climbing state. if (!(player->stateFlags1 & PLAYER_STATE1_21) && arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; + // check Link's Angle } else if (ABS(EnSw_GetTargetPitch(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { return false; + // is Link in dash range? } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { return false; + // are there no obstructions? } else if (!BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &player->actor.world.pos, &pos, &poly, true, false, false, true, &bgId)) { return true; @@ -736,20 +742,20 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { this->collider.base.acFlags &= ~AC_HIT; ret = false; } else if (((play->state.frames % 4) == 0) && - !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast0, &posResult, &poly, true, + !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine0, &posResult, &poly, true, false, false, true, &bgId)) { ret = false; } else if (((play->state.frames % 4) == 1) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast1, &posResult, &poly, true, false, + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine1, &posResult, &poly, true, false, false, true, &bgId)) { ret = false; } else if (((play->state.frames % 4) == 2) && - !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast2, &posResult, &poly, true, + !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine2, &posResult, &poly, true, false, false, true, &bgId)) { if (0) {} ret = false; } else if (((play->state.frames % 4) == 3) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->lineCast3, &posResult, &poly, true, false, + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine3, &posResult, &poly, true, false, false, true, &bgId)) { ret = false; } @@ -913,13 +919,13 @@ void EnSw_Update(Actor* thisx, PlayState* play) { } s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - Vec3f sp7C = { 1400.0f, -2600.0f, -800.0f }; - Vec3f sp70 = { 1400.0f, -1600.0f, 0.0f }; - Vec3f sp64 = { -1400.0f, -2600.0f, -800.0f }; - Vec3f sp58 = { -1400.0f, -1600.0f, 0.0f }; - Vec3f sp4C = { 0.0, 0.0f, -600.0f }; + Vec3f sightPos0 = { 1400.0f, -2600.0f, -800.0f }; + Vec3f sightPos1 = { 1400.0f, -1600.0f, 0.0f }; + Vec3f sightPos2 = { -1400.0f, -2600.0f, -800.0f }; + Vec3f sightPos3 = { -1400.0f, -1600.0f, 0.0f }; + Vec3f bottomPos = { 0.0, 0.0f, -600.0f }; EnSw* this = (EnSw*)thisx; - Vec3f sp3C = { 0.0f, 0.0f, 0.0f }; + Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2084); @@ -958,16 +964,16 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po } } - if (limbIndex == 1) { // eyes? - Matrix_MultVec3f(&sp7C, &this->lineCast0); - Matrix_MultVec3f(&sp70, &this->lineCast1); - Matrix_MultVec3f(&sp64, &this->lineCast2); - Matrix_MultVec3f(&sp58, &this->lineCast3); - Matrix_MultVec3f(&sp4C, &this->wallCast); + if (limbIndex == 1) { // calculate eyelines. + Matrix_MultVec3f(&sightPos0, &this->eyeLine0); + Matrix_MultVec3f(&sightPos1, &this->eyeLine1); + Matrix_MultVec3f(&sightPos2, &this->eyeLine2); + Matrix_MultVec3f(&sightPos3, &this->eyeLine3); + Matrix_MultVec3f(&bottomPos, &this->wallCast); } if (limbIndex == 5) { - Matrix_MultVec3f(&sp3C, &this->actor.focus.pos); + Matrix_MultVec3f(&zeroVec, &this->actor.focus.pos); } if (limbIndex == 4) { // head? @@ -984,12 +990,12 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } -void EnSw_SetFog(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { +void EnSw_SetFog(PlayState* play, Color_RGBA8* color, s16 distA, s16 distB) { f32 far; OPEN_DISPS(play->state.gfxCtx, "../z_en_sw.c", 2181); - far = (11500.0f / arg3) * (arg3 - arg2); + far = (11500.0f / distB) * (distB - distA); if (0.0f == far) { far = 11500; @@ -1012,7 +1018,7 @@ void EnSw_RestoreFog(PlayState* play) { void EnSw_Draw(Actor* thisx, PlayState* play) { EnSw* this = (EnSw*)thisx; - Color_RGBA8 color = { 184, 0, 228, 255 }; + Color_RGBA8 color = { 184, 0, 228, 255 }; // violet tint when dashing. if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { Matrix_RotateX(DEG_TO_RAD(-80), MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 7fb84be30d3..d328eba3f7b 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -17,10 +17,10 @@ typedef struct EnSw { /* 0x01F4 */ Color_RGBA8 limb4Color; // never set past black. /* 0x01F8 */ Vec3s jointTable[30]; /* 0x02AC */ Vec3s morphTable[30]; - /* 0x0360 */ u8 goldIsHidden; // set when revealed, unset when landing. - /* 0x0364 */ Vec3f surfaceNormal; - /* 0x0370 */ Vec3f unk_370; - /* 0x037C */ Vec3f unk_37C; + /* 0x0360 */ u8 goldInAir; // set when revealed, unset when landing. + /* 0x0364 */ Vec3f surfaceNormal; // normal of wall/floor/ceiling it's on. + /* 0x0370 */ Vec3f unk_370; // used for rotate calculation + /* 0x037C */ Vec3f unk_37C; // used for rotate calculation /* 0x0388 */ s16 animTimer; /* 0x038A */ s16 animSpeed; /* 0x038C */ s16 waitTimer; @@ -28,8 +28,8 @@ typedef struct EnSw { /* 0x0390 */ s16 attackTimer; /* 0x0392 */ s16 painTimer; /* 0x0394 */ s16 deathFlames; - /* 0x0396 */ char unk_396[0x42]; - /* 0x03D8 */ MtxF unk_3D8; + /* 0x0396 */ char unk_396[0x42]; //another Mtx(F)? + /* 0x03D8 */ MtxF rotMtxF; /* 0x0418 */ char unk_418[8]; /* 0x0420 */ f32 rotateMag; /* 0x0424 */ char unk_424[0x8]; @@ -40,20 +40,21 @@ typedef struct EnSw { /* 0x0442 */ s16 dashTimer; /* 0x0444 */ s16 rotZTarget; /* 0x0448 */ Vec3f targetPos; - /* 0x0454 */ Vec3f lineCast0; // used for line tests of walls/player - /* 0x0460 */ Vec3f lineCast1; - /* 0x046C */ Vec3f lineCast2; - /* 0x0478 */ Vec3f lineCast3; + /* 0x0454 */ Vec3f eyeLine0; // used for line tests of walls/player + /* 0x0460 */ Vec3f eyeLine1; + /* 0x046C */ Vec3f eyeLine2; + /* 0x0478 */ Vec3f eyeLine3; /* 0x0484 */ Vec3f wallCast; /* 0x0490 */ char unk_490[0x48]; } EnSw; // size = 0x04D8 +// Skullwalltula type stored in last 3 bits of params. #define ENSW_GET_TYPE(thisx) ((thisx->params & 0xE000) >> 0xD) // version of the macro used for the whole entity struct. #define ENSW_GET_TYPE_EN(this) ((this->actor.params & 0xE000) >> 0xD) typedef enum { - SW_TYPE_NORMAL, // normal Skullwalltula + SW_TYPE_NORMAL, // normal Skull(wall)tula SW_TYPE_GOLD_DEFAULT, // normal Gold Skultula, found in dungeons SW_TYPE_GOLD_NIGHT, // nocturnal Gold Skultula, found outside SW_TYPE_GOLD_HIDDEN_SOIL, // found by using bugs on soil patches From 5d6ae221fd42289bf724968fac9fa675804ce610 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Tue, 29 Aug 2023 15:38:30 -0400 Subject: [PATCH 08/15] `animSpeed -> animVar` --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 31 +++++++++++++++---------- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 2144e88bcfb..9cccaab53f4 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -356,14 +356,14 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { this->rotateMag = -0.1f; } this->deathFlames = 10; - this->animSpeed = 1; + this->animVar = 1; this->rotateMag *= 4.0f; this->actionFunc = EnSw_DieGold; } else { // Skulwalltula detaches from surface before dying. this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.shape.shadowAlpha = 0xFF; - this->animSpeed = 2; + this->animVar = 2; this->actor.shape.shadowScale = 16.0f; this->actor.gravity = -1.0f; this->actor.flags &= ~ACTOR_FLAG_0; @@ -499,7 +499,7 @@ void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { if (ENSW_GET_TYPE_EN(this) == SW_TYPE_GOLD_HIDDEN_TREE) { this->waitTimer = 0; this->actionFunc = EnSw_GoldHiddenReveal; - } else { + } else { // slight delay for Gold Skulltula in soil. this->waitTimer = 10; this->actionFunc = EnSw_GoldHiddenReveal; } @@ -573,7 +573,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { if (this->crawlTimer == 0) { EnSw_PlaySfxRoll(this, play); this->rotateMag = ((play->state.frames % 2) == 0) ? 0.1f : -0.1f; - this->animSpeed = 1; + this->animVar = 1; this->waitTimer = Rand_S16Offset(30, 60); if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->waitTimer *= 2; @@ -584,24 +584,25 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { this->waitTimer--; if (this->waitTimer == 0) { this->crawlTimer = Rand_S16Offset(15, 30); - this->animSpeed = 0; + this->animVar = 0; this->skelAnime.playSpeed = 0.0f; if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->crawlTimer /= 2; } - } else if (this->animSpeed != 0) { - this->animSpeed--; - this->skelAnime.playSpeed = (this->animSpeed == 0) ? 4.0f : 0.0f; + } else if (this->animVar != 0) { + this->animVar--; + this->skelAnime.playSpeed = (this->animVar == 0) ? 4.0f : 0.0f; if (this->skelAnime.playSpeed > 0.0f) { EnSw_PlaySfxRoll(this, play); } + // Gold Skulltulas move faster if (ENSW_GET_TYPE_EN(this) != SW_TYPE_NORMAL) { this->skelAnime.playSpeed *= 2.0f; } } else { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) == 1) { - this->animSpeed = 2; + this->animVar = 2; } rotAngle = 32768.0f / this->skelAnime.endFrame; rotAngle *= this->skelAnime.curFrame; @@ -628,6 +629,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { this->actor.shape.rot = this->actor.world.rot; if ((this->deathFlames == 0) && (this->painTimer == 0)) { + // spawn token 10 units from surface normal. Audio_PlaySfxGeneral(NA_SE_SY_KINSTA_MARK_APPEAR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); x = (this->surfaceNormal.x * 10.0f); @@ -643,6 +645,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { return; } + // spawn death flames if ((this->painTimer == 0) && (DECR(this->deathFlames) != 0)) { pos = this->actor.world.pos; pos.y += 10.0f + ((Rand_ZeroOne() - 0.5f) * 6.0f); @@ -659,6 +662,7 @@ void EnSw_FallNormal(EnSw* this, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 20.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2); if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(0.0f <= this->actor.velocity.y)) { + // kill if out-of-bounds. if (this->actor.floorHeight <= BGCHECK_Y_MIN || this->actor.floorHeight >= 32000.0f) { Actor_Kill(&this->actor); return; @@ -666,12 +670,14 @@ void EnSw_FallNormal(EnSw* this, PlayState* play) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - if (this->animSpeed == 0) { + if (this->animVar == 0) { + // start death flames if stopped bouncing this->actionFunc = EnSw_DieNormal; this->deathFlames = 10; } else { - this->actor.velocity.y = (this->animSpeed * 8.0f) * 0.5f; - this->animSpeed--; + // another bounce + this->actor.velocity.y = (this->animVar * 8.0f) * 0.5f; + this->animVar--; } Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND); @@ -741,6 +747,7 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { this->collider.base.acFlags &= ~AC_HIT; ret = false; + // rotates through the 4 "eyes" each frame. } else if (((play->state.frames % 4) == 0) && !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine0, &posResult, &poly, true, false, false, true, &bgId)) { diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index d328eba3f7b..6a8ac064fb0 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -22,7 +22,7 @@ typedef struct EnSw { /* 0x0370 */ Vec3f unk_370; // used for rotate calculation /* 0x037C */ Vec3f unk_37C; // used for rotate calculation /* 0x0388 */ s16 animTimer; - /* 0x038A */ s16 animSpeed; + /* 0x038A */ s16 animVar; // used to determine crawl and "death bounce" animations. /* 0x038C */ s16 waitTimer; /* 0x038E */ s16 crawlTimer; /* 0x0390 */ s16 attackTimer; @@ -35,7 +35,7 @@ typedef struct EnSw { /* 0x0424 */ char unk_424[0x8]; /* 0x042C */ u8 unk_42C; // set during EnSw_MoveGold, rever read. /* 0x0430 */ CollisionPoly* wallPoly; - /* 0x0434 */ Vec3f unk_434; // set during EnSW_LineTestWall, never read. + /* 0x0434 */ Vec3f unk_434; // set during EnSW_LineTestWall, never read. another target pos? /* 0x0440 */ s16 sfxTimer; /* 0x0442 */ s16 dashTimer; /* 0x0444 */ s16 rotZTarget; From 8766d6f99be6c09abdd1a7b16bc8c001101d4c84 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sun, 26 Nov 2023 16:02:31 -0500 Subject: [PATCH 09/15] Update z_en_sw.c merge fix? --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index c45795b965a..90e7d500578 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -210,7 +210,7 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { this->actor.world.pos = sp9C; this->actor.floorBgId = sp6C; } - sp64 = 1; + ret = true; break; } } From 626b926f3ebabae55e9df7500197da9a6c93e022 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sun, 26 Nov 2023 16:11:27 -0500 Subject: [PATCH 10/15] Update z_en_sw.c match fix? --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 90e7d500578..58def74f5fe 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -190,7 +190,6 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { if (phi_s1 == 0) { posB.x = posA.x - (this->unk_37C.x * 24.0f); posB.y = posA.y - (this->unk_37C.y * 24.0f); - if (0) {} posB.z = posA.z - (this->unk_37C.z * 24.0f); } else if (phi_s1 == 1) { posB.x = posA.x + (this->unk_370.x * 24.0f); From d7eff2a96c8a37532ccb31d226ba711c797177f6 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sun, 26 Nov 2023 18:50:49 -0500 Subject: [PATCH 11/15] `En_Sw`: named vars, added more comments --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 106 ++++++++++++++---------- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 2 +- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 58def74f5fe..9ef4255439f 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -76,6 +76,8 @@ void EnSw_CrossProduct(Vec3f* a, Vec3f* b, Vec3f* dst) { dst->z = (a->x * b->y) - (a->y * b->x); } +/* adjusts rotation of (this) to (poly). returns false if failed, +nothing(bug) if successful.*/ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { Vec3f polyNormal; Vec3f sp38; @@ -118,10 +120,11 @@ s32 EnSw_ClingToWall(EnSw* this, CollisionPoly* poly) { this->rotMtxF.zw = 0.0f; this->rotMtxF.ww = 1.0f; Matrix_MtxFToYXZRotS(&this->rotMtxF, &this->actor.world.rot, 0); - //! @bug: Does not return. } +/*returns a wall for the spider to cling to in range of (posA) and (PosB). +returns NULL if none are available*/ CollisionPoly* EnSw_GetPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* posOut, s32* bgId) { CollisionPoly* poly; s32 pad; @@ -140,22 +143,23 @@ CollisionPoly* EnSw_GetPoly(PlayState* play, Vec3f* posA, Vec3f* posB, Vec3f* po return poly; } - -s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { - CollisionPoly* temp_v0_2; - CollisionPoly* temp_s1; - Vec3f sp9C; +/*Moves position of Gold Skulltula based on normal. will change +surface poly if (ChangePoly) is true. returns true if successfully moved.*/ +s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 changePoly) { + CollisionPoly* newPoly; + CollisionPoly* poly0; + Vec3f newPos; Vec3f posOut; Vec3f posA; Vec3f posB; s32 pad; s32 bgId; - s32 sp6C; - s32 phi_s1; + s32 newBgId; + s32 i; s32 ret; ret = false; - this->unk_42C = 1; + this->moveGoldBool = true; posA = posB = this->actor.world.pos; posA.x += this->surfaceNormal.x * 18.0f; posA.y += this->surfaceNormal.y * 18.0f; @@ -163,35 +167,36 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { posB.x -= this->surfaceNormal.x * 18.0f; posB.y -= this->surfaceNormal.y * 18.0f; posB.z -= this->surfaceNormal.z * 18.0f; - temp_s1 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); - - if ((temp_s1 != NULL) && (this->goldInAir == false)) { + poly0 = EnSw_GetPoly(play, &posA, &posB, &posOut, &bgId); + // move spider if poly avalable and not jumping/falling from hidding spot + if ((poly0 != NULL) && (this->goldInAir == false)) { posB.x = posA.x + (this->unk_37C.x * 24); posB.y = posA.y + (this->unk_37C.y * 24); posB.z = posA.z + (this->unk_37C.z * 24); - temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); - if (temp_v0_2 != NULL) { - if (arg2 == 1) { - EnSw_ClingToWall(this, temp_v0_2); - this->actor.world.pos = sp9C; - this->actor.floorBgId = sp6C; + newPoly = EnSw_GetPoly(play, &posA, &posB, &newPos, &newBgId); + if (newPoly != NULL) { + if (changePoly == true) { + EnSw_ClingToWall(this, newPoly); + this->actor.world.pos = newPos; + this->actor.floorBgId = newBgId; } } else { - if (this->actor.floorPoly != temp_s1) { - EnSw_ClingToWall(this, temp_s1); + if (this->actor.floorPoly != poly0) { + EnSw_ClingToWall(this, poly0); } this->actor.world.pos = posOut; this->actor.floorBgId = bgId; } ret = true; } else { + // find a new poly based on 3 24-unit line casts posA = posB; - for (phi_s1 = 0; phi_s1 < 3; phi_s1++) { - if (phi_s1 == 0) { + for (i = 0; i < 3; i++) { + if (i == 0) { posB.x = posA.x - (this->unk_37C.x * 24.0f); posB.y = posA.y - (this->unk_37C.y * 24.0f); posB.z = posA.z - (this->unk_37C.z * 24.0f); - } else if (phi_s1 == 1) { + } else if (i == 1) { posB.x = posA.x + (this->unk_370.x * 24.0f); posB.y = posA.y + (this->unk_370.y * 24.0f); posB.z = posA.z + (this->unk_370.z * 24.0f); @@ -200,14 +205,14 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 arg2) { posB.y = posA.y - (this->unk_370.y * 24.0f); posB.z = posA.z - (this->unk_370.z * 24.0f); } - temp_v0_2 = EnSw_GetPoly(play, &posA, &posB, &sp9C, &sp6C); - if (temp_v0_2 == NULL) { + newPoly = EnSw_GetPoly(play, &posA, &posB, &newPos, &newBgId); + if (newPoly == NULL) { continue; } - if (arg2 == 1) { - EnSw_ClingToWall(this, temp_v0_2); - this->actor.world.pos = sp9C; - this->actor.floorBgId = sp6C; + if (changePoly == true) { + EnSw_ClingToWall(this, newPoly); + this->actor.world.pos = newPos; + this->actor.floorBgId = newBgId; } ret = true; break; @@ -272,7 +277,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->unk_37C.x = Math_SinS(thisx->shape.rot.y); this->unk_37C.y = 0.0f; this->unk_37C.z = Math_CosS(thisx->shape.rot.y); - EnSw_MoveGold(this, play, 1); + EnSw_MoveGold(this, play, true); } if (ENSW_GET_TYPE(thisx) >= SW_TYPE_GOLD_HIDDEN_SOIL) { @@ -293,6 +298,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { this->actor.scale.x = 0.0f; // they expand at night FALLTHROUGH; case SW_TYPE_GOLD_DEFAULT: + // Gold Skulltulas have double health and damage this->collider.elements[0].info.toucher.damage *= 2; this->actor.naviEnemyId = NAVI_ENEMY_GOLD_SKULLTULA; this->actor.colChkInfo.health *= 2; @@ -400,7 +406,7 @@ void EnSw_SetCollider(EnSw* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } - +/*Adjust rotation of (this) by (angle). returns true on success*/ s32 EnSw_GetRotate(EnSw* this, f32* angle) { CollisionPoly* floorPoly; f32 length; @@ -446,7 +452,8 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { Matrix_MtxFToYXZRotS(&rotMtxF, &this->actor.world.rot, 0); return true; } - +/*Play the Skulltula's "roll" sound if in range +(and in outdoor Gold's case, not "sleeping")*/ void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { if (!(this->actor.scale.x < (140.0f * 0.0001f))) { Camera* activeCam = GET_ACTIVE_CAM(play); @@ -457,7 +464,8 @@ void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { } } } - +/*Spawn (cnt) Dust particles when a Gold Skulltula is revealed +from a tree or soil plot*/ void EnSw_SpawnDust(EnSw* this, PlayState* play, s32 cnt) { Color_RGBA8 primColor = { 80, 80, 50, 255 }; Color_RGBA8 envColor = { 100, 100, 80, 0 }; @@ -476,7 +484,8 @@ void EnSw_SpawnDust(EnSw* this, PlayState* play, s32 cnt) { func_8002836C(play, &pos, &velocity, &accel, &primColor, &envColor, 20, 30, 12); } } - +/*Spawn (cnt) Dust particles when a Gold Skulltula has landed +from a tree or soil plot*/ void EnSw_SpawnDustBig(EnSw* this, PlayState* play, s32 cnt) { Color_RGBA8 primColor = { 80, 80, 50, 255 }; Color_RGBA8 envColor = { 100, 100, 80, 0 }; @@ -495,7 +504,8 @@ void EnSw_SpawnDustBig(EnSw* this, PlayState* play, s32 cnt) { func_8002836C(play, &pos, &velocity, &accel, &primColor, &envColor, 20, 40, 10); } } - +/*detrimes if a delay should be added for based on if (this) is +a Gold Skulltula hidden in a tree or soil patch*/ void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { if (ENSW_GET_TYPE_EN(this) == SW_TYPE_GOLD_HIDDEN_TREE) { this->waitTimer = 0; @@ -506,6 +516,7 @@ void EnSw_SetupGoldHidden(EnSw* this, PlayState* play) { } } +/*Animation for Gold Skulltula coming from tree or soil patch.*/ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { if (this->waitTimer != 0) { if ((this->waitTimer & 4) != 0) { @@ -536,7 +547,7 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { this->goldInAir = false; } - if (EnSw_MoveGold(this, play, 1) == true) { + if (EnSw_MoveGold(this, play, true) == true) { Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_M_GND); EnSw_SpawnDustBig(this, play, 8); this->actor.scale.x = 0.02f; @@ -548,6 +559,7 @@ void EnSw_GoldHiddenReveal(EnSw* this, PlayState* play) { } } +/*Skulltula crawling in place*/ void EnSw_Crawl(EnSw* this, PlayState* play) { f32 rotAngle; @@ -614,6 +626,7 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { } } +/*Death behavior for Gold Skulltula*/ void EnSw_DieGold(EnSw* this, PlayState* play) { Actor* token; Vec3f pos; @@ -656,6 +669,7 @@ void EnSw_DieGold(EnSw* this, PlayState* play) { } } +/*Part of death animation for Skullwalltula*/ void EnSw_FallNormal(EnSw* this, PlayState* play) { Actor_MoveXZGravity(&this->actor); this->actor.shape.rot.x += 0x1000; @@ -686,6 +700,7 @@ void EnSw_FallNormal(EnSw* this, PlayState* play) { } } +/*Second part of death animation for SkullWalltula*/ void EnSw_DieNormal(EnSw* this, PlayState* play) { Vec3f velAndAccel = { 0.0f, 0.5f, 0.0f }; Vec3f pos = { 0.0f, 0.0f, 0.0f }; @@ -712,19 +727,21 @@ s16 EnSw_GetTargetPitch(EnSw* this, Vec3f* target) { return pitch * (yaw >= 0 ? -1 : 1); } +/*used by Skullwalltula to determine if link can be rammed. +(arg2) will be checked alongside 2 player state flags (asscociated w/ climbing?)*/ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { Player* player = GET_PLAYER(play); CollisionPoly* poly; s32 bgId; Vec3f pos; - // Check if Link is in climbing state. + // Check if Link is in climbing state(?) if (!(player->stateFlags1 & PLAYER_STATE1_21) && arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; // check Link's Angle - } else if (ABS(EnSw_GetTargetPitch(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 0x1FC2) { + } else if (ABS(EnSw_GetTargetPitch(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 8130) { return false; // is Link in dash range? } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { @@ -737,7 +754,8 @@ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { return false; } } - +/*Skullwalltula uses to Linetest walls visible from its "eyes" +and detect/adjust bottom position.*/ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { s32 pad; CollisionPoly* poly; @@ -781,7 +799,8 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { return ret; } - +/*Used by Skullwalltulas to move to (targetPos) at a top speed of (speedTarget) +While dashing or retreating*/ void EnSw_Move(EnSw* this, Vec3f targetPos, f32 speedTarget) { f32 xDist; f32 yDist; @@ -894,7 +913,7 @@ void EnSw_Dash(EnSw* this, PlayState* play) { } } } - +/*after dashing, a Skullwalltula will retreat to its spawn point*/ void EnSw_SetupGoHome(EnSw* this, PlayState* play) { s32 pad; @@ -905,7 +924,7 @@ void EnSw_SetupGoHome(EnSw* this, PlayState* play) { this->actionFunc = EnSw_GoHome; } } - +/*Skullwalltula: return to spawn point then reset behavior.*/ void EnSw_GoHome(EnSw* this, PlayState* play) { s32 pad; @@ -997,7 +1016,8 @@ s32 EnSw_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnSw_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { } - +/*Give Skullwalltula a tint of (color) from (distA) to (distB) +while dashing / preparing to dash*/ void EnSw_SetFog(PlayState* play, Color_RGBA8* color, s16 distA, s16 distB) { f32 far; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index 6a8ac064fb0..68326e1043a 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -33,7 +33,7 @@ typedef struct EnSw { /* 0x0418 */ char unk_418[8]; /* 0x0420 */ f32 rotateMag; /* 0x0424 */ char unk_424[0x8]; - /* 0x042C */ u8 unk_42C; // set during EnSw_MoveGold, rever read. + /* 0x042C */ u8 moveGoldBool; // set during EnSw_MoveGold, rever read. /* 0x0430 */ CollisionPoly* wallPoly; /* 0x0434 */ Vec3f unk_434; // set during EnSW_LineTestWall, never read. another target pos? /* 0x0440 */ s16 sfxTimer; From 904282e35937161fe8ba521c9b58ea24af043197 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sat, 27 Jan 2024 18:22:15 -0500 Subject: [PATCH 12/15] Update z_en_sw.c merge fix --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 9ef4255439f..d6d919cd5e7 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -299,7 +299,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { FALLTHROUGH; case SW_TYPE_GOLD_DEFAULT: // Gold Skulltulas have double health and damage - this->collider.elements[0].info.toucher.damage *= 2; + this->collider.elements[0].base.toucher.damage *= 2; this->actor.naviEnemyId = NAVI_ENEMY_GOLD_SKULLTULA; this->actor.colChkInfo.health *= 2; this->actor.flags &= ~ACTOR_FLAG_0; @@ -566,15 +566,15 @@ void EnSw_Crawl(EnSw* this, PlayState* play) { // Outdoor Gold Skulltula shrinks/expands based on time if (ENSW_GET_TYPE_EN(this) == SW_TYPE_GOLD_NIGHT) { if (this->actor.scale.x < (140.0f * 0.0001f)) { - this->collider.elements[0].info.toucherFlags = TOUCH_NONE; - this->collider.elements[0].info.bumperFlags = BUMP_NONE; - this->collider.elements[0].info.ocElemFlags = OCELEM_NONE; + this->collider.elements[0].base.toucherFlags = TOUCH_NONE; + this->collider.elements[0].base.bumperFlags = BUMP_NONE; + this->collider.elements[0].base.ocElemFlags = OCELEM_NONE; } if (this->actor.scale.x >= (140.0f * 0.0001f)) { - this->collider.elements[0].info.toucherFlags = TOUCH_ON; - this->collider.elements[0].info.bumperFlags = BUMP_ON; - this->collider.elements[0].info.ocElemFlags = OCELEM_ON; + this->collider.elements[0].base.toucherFlags = TOUCH_ON; + this->collider.elements[0].base.bumperFlags = BUMP_ON; + this->collider.elements[0].base.ocElemFlags = OCELEM_ON; } Math_ApproachF(&this->actor.scale.x, !IS_DAY ? 0.02f : 0.0f, 0.2f, 0.01f); From c6d6964f15270f0ae114f6054f57787ae7c5dbe5 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Sun, 28 Apr 2024 17:27:41 -0400 Subject: [PATCH 13/15] Formatting --- src/code/z_onepointdemo.c | 2 +- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 37 ++++++++++++------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 25ccc8076a9..a3e11111381 100644 --- a/src/code/z_onepointdemo.c +++ b/src/code/z_onepointdemo.c @@ -1074,7 +1074,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* act D_801211D4[0].atTargetInit.y = actor->focus.pos.y - 5.0f; D_801211D4[0].atTargetInit.z = actor->focus.pos.z; spC0 = ((EnSw*)actor)->surfaceNormal; - PRINTF("%s(%d): xyz_t: %s (%f %f %f)\n", "../z_onepointdemo.c", 1671, "&cp", spC0.x, spC0.y,spC0.z); + PRINTF("%s(%d): xyz_t: %s (%f %f %f)\n", "../z_onepointdemo.c", 1671, "&cp", spC0.x, spC0.y, spC0.z); D_801211D4[0].eyeTargetInit.x = (actor->focus.pos.x + (120.0f * spC0.x)) - (Rand_ZeroOne() * 20.0f); D_801211D4[0].eyeTargetInit.y = actor->focus.pos.y + (120.0f * spC0.y) + 20.0f; D_801211D4[0].eyeTargetInit.z = (actor->focus.pos.z + (120.0f * spC0.z)) - (Rand_ZeroOne() * 20.0f); diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 44765199b44..8e2cb398b67 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -7,7 +7,6 @@ #include "z_en_sw.h" #include "assets/objects/object_st/object_st.h" - #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) void EnSw_Init(Actor* thisx, PlayState* play); @@ -210,9 +209,9 @@ s32 EnSw_MoveGold(EnSw* this, PlayState* play, s32 changePoly) { continue; } if (changePoly == true) { - EnSw_ClingToWall(this, newPoly); - this->actor.world.pos = newPos; - this->actor.floorBgId = newBgId; + EnSw_ClingToWall(this, newPoly); + this->actor.world.pos = newPos; + this->actor.floorBgId = newBgId; } ret = true; break; @@ -309,7 +308,6 @@ void EnSw_Init(Actor* thisx, PlayState* play) { Actor_ChangeCategory(play, &play->actorCtx, &this->actor, ACTORCAT_ENEMY); this->actor.naviEnemyId = NAVI_ENEMY_SKULLWALLTULA; break; - } this->crawlTimer = Rand_S16Offset(15, 30); @@ -348,7 +346,8 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { if ((this->collider.base.acFlags & AC_HIT) || phi_v1) { this->collider.base.acFlags &= ~AC_HIT; this->painTimer = 0x10; - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, this->painTimer); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 200, COLORFILTER_BUFFLAG_OPA, + this->painTimer); if (Actor_ApplyDamage(&this->actor) != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_STALTU_DAMAGE); return true; @@ -452,15 +451,15 @@ s32 EnSw_GetRotate(EnSw* this, f32* angle) { Matrix_MtxFToYXZRotS(&rotMtxF, &this->actor.world.rot, 0); return true; } -/*Play the Skulltula's "roll" sound if in range +/*Play the Skulltula's "roll" sound if in range (and in outdoor Gold's case, not "sleeping")*/ void EnSw_PlaySfxRoll(EnSw* this, PlayState* play) { if (!(this->actor.scale.x < (140.0f * 0.0001f))) { Camera* activeCam = GET_ACTIVE_CAM(play); if (!(Math_Vec3f_DistXYZ(&this->actor.world.pos, &activeCam->eye) >= 380.0f)) { - Actor_PlaySfx(&this->actor, ENSW_GET_TYPE_EN(this) > SW_TYPE_NORMAL - ? NA_SE_EN_STALGOLD_ROLL : NA_SE_EN_STALWALL_ROLL); + Actor_PlaySfx(&this->actor, + ENSW_GET_TYPE_EN(this) > SW_TYPE_NORMAL ? NA_SE_EN_STALGOLD_ROLL : NA_SE_EN_STALWALL_ROLL); } } } @@ -740,13 +739,13 @@ s32 EnSW_CanDashPlayer(EnSw* this, PlayState* play, s32 arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; - // check Link's Angle + // check Link's Angle } else if (ABS(EnSw_GetTargetPitch(this, &player->actor.world.pos) - this->actor.shape.rot.z) >= 8130) { return false; - // is Link in dash range? + // is Link in dash range? } else if (Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.world.pos) >= 130.0f) { return false; - // are there no obstructions? + // are there no obstructions? } else if (!BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &player->actor.world.pos, &pos, &poly, true, false, false, true, &bgId)) { return true; @@ -766,14 +765,14 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { if (this->collider.base.ocFlags1 & OC1_HIT) { this->collider.base.acFlags &= ~AC_HIT; ret = false; - // rotates through the 4 "eyes" each frame. + // rotates through the 4 "eyes" each frame. } else if (((play->state.frames % 4) == 0) && !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine0, &posResult, &poly, true, false, false, true, &bgId)) { ret = false; } else if (((play->state.frames % 4) == 1) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine1, &posResult, &poly, true, false, - false, true, &bgId)) { + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine1, &posResult, &poly, true, + false, false, true, &bgId)) { ret = false; } else if (((play->state.frames % 4) == 2) && !BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine2, &posResult, &poly, true, @@ -781,13 +780,13 @@ s32 EnSW_LineTestWall(EnSw* this, PlayState* play) { if (0) {} ret = false; } else if (((play->state.frames % 4) == 3) && - BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine3, &posResult, &poly, true, false, - false, true, &bgId)) { + BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->eyeLine3, &posResult, &poly, true, + false, false, true, &bgId)) { ret = false; } - if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->wallCast, &posResult, &this->wallPoly, true, - false, false, true, &bgId)) { + if (BgCheck_EntityLineTest1(&play->colCtx, &this->actor.world.pos, &this->wallCast, &posResult, &this->wallPoly, + true, false, false, true, &bgId)) { this->actor.wallYaw = RAD_TO_BINANG(Math_FAtan2F(this->wallPoly->normal.x, this->wallPoly->normal.z)); this->actor.world.pos = posResult; this->actor.world.pos.x += 6.0f * Math_SinS(this->actor.world.rot.y); From 79b02f8f7ce3d0a7f9ccc4375fb7bc8c2dc7b463 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Tue, 17 Sep 2024 12:17:12 -0400 Subject: [PATCH 14/15] Update z_en_sw.c --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 1f16695b56c..9265bbb2927 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -231,7 +231,7 @@ void EnSw_Init(Actor* thisx, PlayState* play) { Vec3f sp4C = { 0.0f, 0.0f, 0.0f }; s32 pad; - if (PARAMS_GET_NOSHIFT(thisx->params, 15, 1)) {} + if (PARAMS_GET_NOSHIFT(thisx->params, 15, 1)) { phi_v0 = PARAMS_GET_S(thisx->params - 0x8000, 13, 3) + 1; thisx->params = PARAMS_GET_S(thisx->params, 0, 13) | (phi_v0 << 0xD); } From cbc7ec8d04f260539503d8dd1e3c60d7d2340f16 Mon Sep 17 00:00:00 2001 From: blackgamma7 Date: Tue, 17 Sep 2024 12:34:56 -0400 Subject: [PATCH 15/15] Update z_en_sw.c ran fomat.py --- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 5ca654bae0d..393ea468390 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -384,7 +384,7 @@ s32 EnSw_CheckDamage(EnSw* this, PlayState* play) { } return false; -} +} void EnSw_SetCollider(EnSw* this, PlayState* play) { if ((ENSW_GET_TYPE_EN(this) > SW_TYPE_NORMAL) && (this->actionFunc != EnSw_Crawl)) {