diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 3959be087..41634e383 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -35,7 +35,7 @@ void func_80A83FBC(Actor* thisx, PlayState* play); void func_80A84088(Actor* thisx, PlayState* play); void func_80A84338(Actor* thisx, PlayState* play); -static s32 D_80A849D0[0xC0]; +static Vec3f D_80A849D0[0x40]; const ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, @@ -220,22 +220,22 @@ void func_80A8164C(Vec3f* arg0) { matrix->mf[3][2] = arg0->z; } -void func_80A81684(ObjMineUnkStruct* arg0) { +void func_80A81684(ObjMineMtxF3* arg0) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = arg0->unk_00.x; - matrix->mf[0][1] = arg0->unk_00.y; - matrix->mf[0][2] = arg0->unk_00.z; + matrix->mf[0][0] = arg0->x.x; + matrix->mf[0][1] = arg0->x.y; + matrix->mf[0][2] = arg0->x.z; matrix->mf[0][3] = 0.0f; - matrix->mf[1][0] = arg0->unk_0C.x; - matrix->mf[1][1] = arg0->unk_0C.y; - matrix->mf[1][2] = arg0->unk_0C.z; + matrix->mf[1][0] = arg0->y.x; + matrix->mf[1][1] = arg0->y.y; + matrix->mf[1][2] = arg0->y.z; matrix->mf[1][3] = 0.0f; - matrix->mf[2][0] = arg0->unk_18.x; - matrix->mf[2][1] = arg0->unk_18.y; - matrix->mf[2][2] = arg0->unk_18.z; + matrix->mf[2][0] = arg0->z.x; + matrix->mf[2][1] = arg0->z.y; + matrix->mf[2][2] = arg0->z.z; matrix->mf[2][3] = 0.0f; matrix->mf[3][0] = 0.0f; @@ -278,24 +278,24 @@ void func_80A81818(ObjMine* this) { void func_80A81868(ObjMine* this, s32 arg1) { s32 i; - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct* ptr = &this->chain1; ObjMineUnkStruct3* unkStruct; f32 arg = arg1; f32 temp_f12 = this->actor.home.rot.z * 5.0f; - ptr->unk_00.x = 1.0f; - ptr->unk_0C.y = 1.0f; - ptr->unk_18.z = 1.0f; + ptr->unk_00.x.x = 1.0f; + ptr->unk_00.y.y = 1.0f; + ptr->unk_00.z.z = 1.0f; ptr->unk_24.y = 1.0f; if (arg1 > 0) { - ptr->unk_40 = -sqrtf(0.001984f / arg); - ptr->unk_44 = (0.00031746097f * arg) + 0.95f; + ptr->unk_40 = -sqrtf(0.001984f / arg); // approx 1/504 = 1/8 * 1/63 + ptr->unk_44 = (0.00031746097f * arg) + 0.95f; // approx 1/3150 = 1/50 * 1/63 } ptr->unk_58 = 0.0002f; - for (i = 0, unkStruct = &ptr->unk_60[0]; i < arg1; i++, unkStruct++) { + for (i = 0, unkStruct = ptr->unk_60; i < arg1; i++, unkStruct++) { unkStruct->unk_00 = 0x4000; } @@ -315,27 +315,27 @@ void func_80A819A4(ObjMine* this, s32 arg1) { } void func_80A81A00(ObjMine* this) { - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineUnkStruct* ptr = &this->chain1; Vec3f sp28; sp28.x = -ptr->unk_30; sp28.y = 1.0f; sp28.z = -ptr->unk_34; - func_80A8120C(&sp28, &ptr->unk_0C); - Math3D_CrossProduct(&D_80A845C4, &ptr->unk_0C, &sp28); - func_80A8120C(&sp28, &ptr->unk_18); - Math3D_CrossProduct(&ptr->unk_0C, &ptr->unk_18, &sp28); - func_80A8120C(&sp28, &ptr->unk_00); + func_80A8120C(&sp28, &ptr->unk_00.y); + Math3D_CrossProduct(&D_80A845C4, &ptr->unk_00.y, &sp28); + func_80A8120C(&sp28, &ptr->unk_00.z); + Math3D_CrossProduct(&ptr->unk_00.y, &ptr->unk_00.z, &sp28); + func_80A8120C(&sp28, &ptr->unk_00.x); } void func_80A81AA4(ObjMine* this) { s32 params = this->actor.params & 0x3F; f32 temp_f0 = -((params * 12.0f) + 10.0f); - this->actor.world.pos.x = (this->unk_1B8.unk_0C.x * temp_f0) + this->actor.home.pos.x; - this->actor.world.pos.y = (this->unk_1B8.unk_0C.y * temp_f0) + this->actor.home.pos.y; - this->actor.world.pos.z = (this->unk_1B8.unk_0C.z * temp_f0) + this->actor.home.pos.z; + this->actor.world.pos.x = (this->chain1.unk_00.y.x * temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->chain1.unk_00.y.y * temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->chain1.unk_00.y.z * temp_f0) + this->actor.home.pos.z; } void func_80A81B14(ObjMine* this) { @@ -344,34 +344,34 @@ void func_80A81B14(ObjMine* this) { f32 x = this->actor.world.pos.x - this->actor.home.pos.x; f32 z = this->actor.world.pos.z - this->actor.home.pos.z; - this->unk_1B8.unk_30 = x * temp_f0; - this->unk_1B8.unk_34 = z * temp_f0; + this->chain1.unk_30 = x * temp_f0; + this->chain1.unk_34 = z * temp_f0; } void func_80A81B7C(ObjMine* this, s32 arg1) { - ObjMineUnkStruct* ptr = &this->unk_1B8; + ObjMineTestStruct2* ptr = &this->chain2; ObjMineUnkStruct2* unkStruct; s32 i; f32 sp58 = this->actor.home.rot.z * 5.0f; f32 temp_f24; f32 temp_f26; - ptr->unk_00.x = 0.9f; - ptr->unk_18.y = 0.003f; + ptr->unk_00 = 0.9f; + ptr->unk_1C = 0.003f; - *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; - ptr->unk_24.x = -0.0002f; + ptr->unk_20 = Rand_Next() >> 0x13; + ptr->unk_24 = -0.0002f; ptr->unk_30 = -0.0002f; - temp_f26 = ptr->unk_18.y * 6.0f; + temp_f26 = ptr->unk_1C * 6.0f; temp_f24 = this->actor.home.pos.y; - unkStruct = (ObjMineUnkStruct2*)&ptr->unk_44; + unkStruct = ptr->unk_44; for (i = 0; i < arg1; i++, unkStruct++) { temp_f24 += 12.0f; - unkStruct->unk_00.x = 1.0f; - unkStruct->unk_0C.y = 1.0f; - unkStruct->unk_18.z = 1.0f; + unkStruct->unk_00.x.x = 1.0f; + unkStruct->unk_00.y.y = 1.0f; + unkStruct->unk_00.z.z = 1.0f; unkStruct->unk_24.x = this->actor.home.pos.x; unkStruct->unk_24.y = temp_f24; unkStruct->unk_24.z = this->actor.home.pos.z; @@ -380,12 +380,12 @@ void func_80A81B7C(ObjMine* this, s32 arg1) { unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; } - ptr->unk_24.y = temp_f24; - ptr->unk_24.z = temp_f24 * 0.97f; - temp_f24 = temp_f24 - 18.0f; + ptr->unk_28 = temp_f24; + ptr->unk_2C = temp_f24 * 0.97f; + temp_f24 -= 18.0f; - if (ptr->unk_24.z < temp_f24) { - ptr->unk_24.z = temp_f24; + if (ptr->unk_2C < temp_f24) { + ptr->unk_2C = temp_f24; } if (sp58 < 0.0f) { @@ -405,22 +405,24 @@ void func_80A81D70(ObjMine* this, s32 arg1) { } void func_80A81DEC(ObjMine* this) { - s32 pad[2]; + ObjMineTestStruct2* ptr = &this->chain2; + s32 pad; s32 temp_v0 = this->actor.params & 0x3F; - NextUnkStruct* temp_v1 = &((NextUnkStruct*)&this->unk_1B8)[temp_v0]; + if (temp_v0 == 0) { this->actor.world.pos.y = (this->actor.home.pos.y + 12.0f) + 10.0f; } else { + ObjMineUnkStruct2* ptr2 = &ptr->unk_44[temp_v0 - 1]; Vec3f sp1C; - Math_Vec3f_ScaleAndStore(&temp_v1->unk_08, 10.0f, &sp1C); - Math_Vec3f_Sum(&temp_v1->unk_20, &sp1C, &this->actor.world.pos); + Math_Vec3f_ScaleAndStore(&ptr2->unk_00.y, 10.0f, &sp1C); + Math_Vec3f_Sum(&ptr2->unk_24, &sp1C, &this->actor.world.pos); } } void func_80A81E7C(ObjMine* this, PlayState* play) { - ObjMineUnkStruct* temp_v1 = &this->unk_1B8; + ObjMineTestStruct2* temp_v1 = &this->chain2; s32 pad; Vec3f sp7C; Vec3f sp70; @@ -432,47 +434,122 @@ void func_80A81E7C(ObjMine* this, PlayState* play) { f32 sp40; f32 sp3C; - *(s8*)(&temp_v1->unk_40) = 0; - if (temp_v1->unk_34 > -0.000001f) { - if (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, - this->actor.world.pos.x, this->actor.world.pos.z)) { - sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; - sp58.y = 0.0f; - sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { - sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); - sp70.y = this->actor.world.pos.y; - sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); - sp7C.x = this->actor.home.pos.x; - sp7C.y = this->actor.world.pos.y; - sp7C.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { - *(s8*)(&temp_v1->unk_40) = 1; - temp_v1->unk_38 = sp4C.x * -0.2f; - temp_v1->unk_3C = sp4C.z * -0.2f; - } + temp_v1->unk_40 = 0; + if ((-0.000001f < temp_v1->unk_34) && (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + this->actor.world.pos.x, this->actor.world.pos.z))) { + sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; + sp58.y = 0.0f; + sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; + if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { + sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + sp70.y = this->actor.world.pos.y; + sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp7C.x = this->actor.home.pos.x; + sp7C.y = this->actor.world.pos.y; + sp7C.z = this->actor.home.pos.z; + if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { + temp_v1->unk_40 = 1; + temp_v1->unk_38 = sp4C.x * -0.2f; + temp_v1->unk_3C = sp4C.z * -0.2f; } } } } +#ifdef NON_MATCHING +void func_80A81FFC(ObjMine *this) { + s32 i; + ObjMineTestStruct2 *temp_s1 = &this->chain2; + ObjMineUnkStruct2 *var_s0; + s32 temp_s6 = this->actor.params & 0x3F; + s16 var_s3 = 0; + f32 temp_fs2 = 1.0f / (f32) temp_s6; + Vec3f sp90; + f32 temp_fs0 = (temp_s1->unk_44[temp_s6 - 1].unk_24.y - temp_s1->unk_2C) * temp_s1->unk_30; + f32 temp_ft4; + + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + Math_Vec3f_Copy(&D_80A849D0[i], &var_s0->unk_3C); + if (var_s0->unk_24.y <= this->actor.home.pos.y) { + var_s0->unk_3C.y = temp_s1->unk_30 * -96.0f; + } else if (temp_fs0 > 0.0f) { + var_s0->unk_3C.y = (i + 1) * temp_fs2 * (temp_fs0 / 0.3f); + } else { + var_s0->unk_3C.y = temp_fs0; + } + var_s0->unk_3C.x = (var_s0->unk_24.x - this->actor.home.pos.x) * temp_s1->unk_24; + var_s0->unk_3C.z = (var_s0->unk_24.z - this->actor.home.pos.z) * temp_s1->unk_24; + var_s0->unk_3C.x += temp_s1->unk_14 * Math_SinS(var_s3); + var_s0->unk_3C.y += temp_s1->unk_18; + var_s0->unk_3C.z += temp_s1->unk_14 * Math_CosS(var_s3); + var_s3 += temp_s1->unk_20; + } + if (temp_s1->unk_10 > 0.0001f) { + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + temp_ft4 = SQ((temp_s6 - i) * temp_fs2); + var_s0->unk_3C.x += temp_s1->unk_04.x * temp_ft4; + var_s0->unk_3C.y += temp_s1->unk_04.y * temp_ft4; + var_s0->unk_3C.z += temp_s1->unk_04.z * temp_ft4; + } + } + if (temp_s1->unk_40) { + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + var_s0->unk_3C.x += temp_s1->unk_38; + var_s0->unk_3C.z += temp_s1->unk_3C; + } + } + + for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + Math_Vec3f_Copy(&sp90, &gZeroVec3f); + if(i - 2 >= 0) { + sp90.x += D_80A849D0[i - 2].x * 0.075f; + sp90.y += D_80A849D0[i - 2].y * 0.075f; + sp90.z += D_80A849D0[i - 2].z * 0.075f; + } + if(i - 1 >= 0) { + sp90.x += D_80A849D0[i - 1].x * 0.15f; + sp90.y += D_80A849D0[i - 1].y * 0.15f; + sp90.z += D_80A849D0[i - 1].z * 0.15f; + } + sp90.x += D_80A849D0[i].x * 0.3f; + sp90.y += D_80A849D0[i].y * 0.3f; + sp90.z += D_80A849D0[i].z * 0.3f; + if(i + 1 < temp_s6) { + sp90.x += D_80A849D0[i + 1].x * 0.15f; + sp90.y += D_80A849D0[i + 1].y * 0.15f; + sp90.z += D_80A849D0[i + 1].z * 0.15f; + } + if(i + 2 < temp_s6) { + sp90.x += D_80A849D0[i + 2].x * 0.075f; + sp90.y += D_80A849D0[i + 2].y * 0.075f; + sp90.z += D_80A849D0[i + 2].z * 0.075f; + } + var_s0->unk_3C.x += sp90.x; + var_s0->unk_3C.y += sp90.y; + var_s0->unk_3C.z += sp90.z; + } + +} +#else +void func_80A81FFC(ObjMine* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") +#endif void func_80A828A8(ObjMine* this) { - s32 pad; + s32 i; Vec3f spE0; Vec3f spD4; Vec3f spC8; s32 spC4 = this->actor.params & 0x3F; - s32 i = 0; + ObjMineTestStruct2* sp70 = &this->chain2; + ObjMineUnkStruct2* temp_s0; + Vec3f* phi_s3; s32 phi_s5; - Vec3f* phi_s3 = NULL; - ObjMineUnkStruct* sp70 = &this->unk_1B8; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Vec3f sp84; - ObjMineUnkStruct2* temp_s0 = (ObjMineUnkStruct2*)&sp70->unk_44; + s32 pad; f32 sp7C; f32 sp78; @@ -480,12 +557,12 @@ void func_80A828A8(ObjMine* this) { sp84.y = this->actor.home.pos.y + 6.0f; sp84.z = this->actor.home.pos.z; - for (; i < spC4; i++, temp_s0++) { + for (i = 0, phi_s3 = NULL, temp_s0 = sp70->unk_44; i < spC4; i++, phi_s3 = &temp_s0->unk_00.x, temp_s0++) { phi_s5 = false; temp_s0->unk_30.x += temp_s0->unk_3C.x; temp_s0->unk_30.y += temp_s0->unk_3C.y; temp_s0->unk_30.z += temp_s0->unk_3C.z; - Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00.x); + Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00); Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); temp_s0->unk_24.x += temp_s0->unk_30.x; temp_s0->unk_24.y += temp_s0->unk_30.y; @@ -498,7 +575,7 @@ void func_80A828A8(ObjMine* this) { Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { - Math_Vec3f_Copy(&spD4, &temp_s0->unk_0C); + Math_Vec3f_Copy(&spD4, &temp_s0->unk_00.y); func_80A81714(&spD4, &sp9C, 0.10471976f); Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); @@ -512,33 +589,29 @@ void func_80A828A8(ObjMine* this) { } if (phi_s5) { - Math_Vec3f_Copy(&temp_s0->unk_00, &spC8); - Math_Vec3f_Copy(&temp_s0->unk_0C, &spD4); - Math_Vec3f_Copy(&temp_s0->unk_18, &spE0); + Math_Vec3f_Copy(&temp_s0->unk_00.x, &spC8); + Math_Vec3f_Copy(&temp_s0->unk_00.y, &spD4); + Math_Vec3f_Copy(&temp_s0->unk_00.z, &spE0); } else { sp7C = 4.0f; } if (sp7C >= 6.0f) { - temp_s0->unk_24.x = (temp_s0->unk_0C.x * 6.0f) + sp84.x; - temp_s0->unk_24.y = (temp_s0->unk_0C.y * 6.0f) + sp84.y; - temp_s0->unk_24.z = (temp_s0->unk_0C.z * 6.0f) + sp84.z; + temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * 6.0f); + temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * 6.0f); + temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * 6.0f); } else { - temp_s0->unk_24.x = (temp_s0->unk_0C.x * sp7C) + sp84.x; - temp_s0->unk_24.y = (temp_s0->unk_0C.y * sp7C) + sp84.y; - temp_s0->unk_24.z = (temp_s0->unk_0C.z * sp7C) + sp84.z; + temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * sp7C); + temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * sp7C); + temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * sp7C); } - sp84.x = temp_s0->unk_24.x + (temp_s0->unk_0C.x * 6.0f); - sp84.y = temp_s0->unk_24.y + (temp_s0->unk_0C.y * 6.0f); - sp84.z = temp_s0->unk_24.z + (temp_s0->unk_0C.z * 6.0f); - - phi_s3 = &temp_s0->unk_00; + sp84.x = temp_s0->unk_24.x + (temp_s0->unk_00.y.x * 6.0f); + sp84.y = temp_s0->unk_24.y + (temp_s0->unk_00.y.y * 6.0f); + sp84.z = temp_s0->unk_24.z + (temp_s0->unk_00.y.z * 6.0f); } } -void func_80A81FFC(ObjMine* this); - void func_80A82C28(ObjMine* this, PlayState* play) { func_80A81E7C(this, play); func_80A81FFC(this); @@ -707,121 +780,118 @@ void func_80A832BC(ObjMine* this) { void func_80A832D0(ObjMine* this, PlayState* play) { s32 pad; s32 spA0 = this->actor.params & 0x3F; - ObjMineUnkStruct* unkStruct = &this->unk_1B8; + ObjMineUnkStruct* unkStruct = &this->chain1; + ObjMineUnkStruct3* temp; + s32 i; + f32 sp90; + f32 sp8C; + f32 sp88; + s16 sp86; + s16 sp84; + s32 pad2; + s32 pad3; - Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_0C); + Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_00.y); if (func_80A8140C(this)) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - ObjMineUnkStruct3* temp; - s32 i; - f32 sp90; - f32 sp8C; - f32 sp88; - s16 sp86; - s16 sp84; - s32 pad2; - s32 pad3; + return; + } - if (this->collider.base.acFlags & AC_HIT) { - this->collider.base.acFlags &= ~AC_HIT; - unkStruct->unk_48 = 0.04f; - func_80A8146C(this, &unkStruct->unk_4C, &sp84); - sp8C = Math_SinS(sp84) * 150.0f; - sp88 = sp8C; - sp8C = -(sp8C / spA0); + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + unkStruct->unk_48 = 0.04f; + func_80A8146C(this, &unkStruct->unk_4C, &sp84); + sp88 = sp8C = Math_SinS(sp84) * 150.0f; + sp8C = -(sp8C / spA0); - for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { - temp->unk_02 += (s16)sp88; - temp->unk_02 = CLAMP(temp->unk_02, -800, 800); - sp88 -= sp8C; - } + for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { + temp->unk_02 += (s16)sp88; + temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + sp88 -= sp8C; } + } - if (unkStruct->unk_48 > 0.0001f) { - sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; - sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; - Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); - } - - if ((Rand_Next() >> 0x1B) == 0) { - unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; - unkStruct->unk_54 = Rand_Next() >> 0x10; - } - - sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; - sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + if (unkStruct->unk_48 > 0.0001f) { + sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; + sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; unkStruct->unk_38 += sp90; unkStruct->unk_3C += sp8C; - - unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; - unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; - - unkStruct->unk_38 *= unkStruct->unk_44; - unkStruct->unk_3C *= unkStruct->unk_44; - - unkStruct->unk_30 += unkStruct->unk_38; - unkStruct->unk_34 += unkStruct->unk_3C; - - unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); - unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); - - func_80A81A00(this); - func_80A81AA4(this); - - if ((unkStruct->unk_5C > -0.000001f) && - (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, - this->actor.home.pos.x, this->actor.home.pos.z))) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); - - if (this->actor.bgCheckFlags & 8) { - if (this->actor.wallPoly != NULL) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - f32 sp44; - - sp4C.x = unkStruct->unk_38; - sp4C.y = 0.0f; - sp4C.z = unkStruct->unk_3C; - if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { - sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); - sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - func_80179F64(&sp70, &sp58, &sp64); - sp48 *= 0.5f; - unkStruct->unk_38 = sp64.x * sp48; - unkStruct->unk_3C = sp64.z * sp48; - } else { - unkStruct->unk_38 *= -0.1f; - unkStruct->unk_3C *= -0.1f; - } - func_80A81B14(this); - func_80A81A00(this); - func_80A81AA4(this); - } - } - } - - for (i = 0, temp = &unkStruct->unk_60[0]; i < spA0; i++, temp++) { - sp86 = temp->unk_00 - 0x4000; - sp88 = ((Rand_ZeroOne() * 30.0f) - 15.0f) + (temp->unk_02 + (sp86 * -0.05f)); - sp88 *= 0.995f; - temp->unk_02 = sp88; - temp->unk_00 += temp->unk_02; - } - - func_800B4AEC(play, &this->actor, 0.0f); - func_80A81818(this); - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); } + + if ((Rand_Next() >> 0x1B) == 0) { + unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; + unkStruct->unk_54 = Rand_Next() >> 0x10; + } + + sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; + sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; + unkStruct->unk_38 += sp90; + unkStruct->unk_3C += sp8C; + + unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; + unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; + + unkStruct->unk_38 *= unkStruct->unk_44; + unkStruct->unk_3C *= unkStruct->unk_44; + + unkStruct->unk_30 += unkStruct->unk_38; + unkStruct->unk_34 += unkStruct->unk_3C; + + unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); + unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); + + func_80A81A00(this); + func_80A81AA4(this); + + if ((unkStruct->unk_5C > -0.000001f) && + (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, + this->actor.home.pos.x, this->actor.home.pos.z))) { + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = unkStruct->unk_38; + sp4C.y = 0.0f; + sp4C.z = unkStruct->unk_3C; + if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + func_80179F64(&sp70, &sp58, &sp64); + sp48 *= 0.5f; + unkStruct->unk_38 = sp64.x * sp48; + unkStruct->unk_3C = sp64.z * sp48; + } else { + unkStruct->unk_38 *= -0.1f; + unkStruct->unk_3C *= -0.1f; + } + func_80A81B14(this); + func_80A81A00(this); + func_80A81AA4(this); + } + } + + for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { + sp86 = temp->unk_00 - 0x4000; + sp88 = temp->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); + sp88 *= 0.995f; + temp->unk_02 = sp88; + temp->unk_00 += temp->unk_02; + } + + func_800B4AEC(play, &this->actor, 0.0f); + func_80A81818(this); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_80A83A74(ObjMine* this) { @@ -833,10 +903,11 @@ void func_80A83A88(ObjMine* this, PlayState* play) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + return; } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } void func_80A83B14(ObjMine* this) { @@ -844,8 +915,7 @@ void func_80A83B14(ObjMine* this) { } void func_80A83B28(ObjMine* this, PlayState* play) { - ObjMineUnkStruct* ptr; - s16 rand; + ObjMineTestStruct2* ptr = &this->chain2; if (func_80A8140C(this)) { func_80A81384(this, play); @@ -854,27 +924,27 @@ void func_80A83B28(ObjMine* this, PlayState* play) { return; } - ptr = &this->unk_1B8; if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80A81544(this, (Vec3f*)&ptr->unk_00.y); - ptr->unk_0C.y = 7.0f; - Math_Vec3f_Scale((Vec3f*)&ptr->unk_00.y, 7.0f); + func_80A81544(this, &ptr->unk_04); + ptr->unk_10 = 7.0f; + Math_Vec3f_Scale(&ptr->unk_04, 7.0f); } - if (ptr->unk_0C.y > 0.0001f) { - ptr->unk_0C.y = Math_Vec3f_StepTo((Vec3f*)&ptr->unk_00.y, &gZeroVec3f, 2.8f); + if (ptr->unk_10 > 0.0001f) { + ptr->unk_10 = Math_Vec3f_StepTo( &ptr->unk_04, &gZeroVec3f, 2.8f); } - ptr->unk_00.x = 0.9f; - ptr->unk_24.x = -0.0002f; + ptr->unk_00 = 0.9f; + ptr->unk_24 = -0.0002f; ptr->unk_30 = -0.0002f; - ptr->unk_18.y = 0.003f; + ptr->unk_1C = 0.003f; if ((Rand_Next() >> 0x1B) == 0) { - rand = Rand_Next() >> 0x10; - ptr->unk_0C.z = Math_SinS(rand) * 1.8f * ptr->unk_18.y; - ptr->unk_18.x = Math_CosS(rand) * 0.2f * ptr->unk_18.y; - *(s16*)((u8*)ptr + 0x20) = Rand_Next() >> 0x13; + s16 rand = Rand_Next() >> 0x10; + + ptr->unk_14 = Math_SinS(rand) * 1.8f * ptr->unk_1C; + ptr->unk_18 = Math_CosS(rand) * 0.2f * ptr->unk_1C; + ptr->unk_20 = Rand_Next() >> 0x13; } func_80A82C28(this, play); @@ -893,10 +963,12 @@ void func_80A83D00(ObjMine* this, PlayState* play) { func_80A81384(this, play); func_80A81640(this); func_80A83214(this); - } else { - CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + return; } + + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + } void ObjMine_Update(Actor* thisx, PlayState* play) { @@ -966,11 +1038,11 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { } void func_80A84088(Actor* thisx, PlayState* play) { + s32 pad; ObjMine* this = THIS; s32 temp_s5 = this->actor.params & 0x3F; ObjMineUnkStruct3* temp; - ObjMineUnkStruct* ptr = &this->unk_1B8; - s32 pad; + ObjMineUnkStruct* ptr = &this->chain1; s32 i; Vec3f sp94; Vec3f sp88; @@ -985,16 +1057,16 @@ void func_80A84088(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - func_80A81684(ptr); + func_80A81684(&ptr->unk_00); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); if (temp_s5 != 0) { - Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -6.0f, &sp88); + Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -6.0f, &sp88); sp94.x = this->actor.home.pos.x - sp88.x; sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; sp94.z = this->actor.home.pos.z - sp88.z; - Math_Vec3f_ScaleAndStore(&ptr->unk_0C, -12.0f, &sp88); + Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -12.0f, &sp88); - for (i = 0, temp = &ptr->unk_60[0]; i < temp_s5; i++, temp++) { + for (i = 0, temp = ptr->unk_60; i < temp_s5; i++, temp++) { Matrix_RotateYS(temp->unk_00, MTXMODE_APPLY); sp94.x += sp88.x; sp94.y += sp88.y; @@ -1022,12 +1094,13 @@ void func_80A84088(Actor* thisx, PlayState* play) { } void func_80A84338(Actor* thisx, PlayState* play) { + s32 pad1; ObjMine* this = THIS; s32 temp_s7 = this->actor.params & 0x3F; + ObjMineTestStruct2* pad2 = &this->chain2; s32 i; Gfx* gfx; ObjMineUnkStruct2* temp; - s32 pad[2]; func_800B8050(&this->actor, play, 1); @@ -1038,8 +1111,8 @@ void func_80A84338(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - for (i = 0, temp = (ObjMineUnkStruct2*)((u8*)this + 0x1FC); i < temp_s7; i++, temp++) { - func_80A81684((ObjMineUnkStruct*)temp); + for (i = 0, temp = pad2->unk_44; i < temp_s7; i++, temp++) { + func_80A81684(&temp->unk_00); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); if ((i & 1) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index be5f1bb58..ac4fb0182 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,26 +7,22 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); -// definitely fake typedef struct { - char unk_00[0x8]; - Vec3f unk_08; - char unk_14[0xC]; - Vec3f unk_20; - char unk_2C[0x1C]; -} NextUnkStruct; // size = 0x48 + Vec3f x; + Vec3f y; + Vec3f z; + // Vec3f w; +} ObjMineMtxF3; -// maybe fake typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; } ObjMineUnkStruct3; typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ Vec3f unk_0C; - /* 0x18 */ Vec3f unk_18; - ///* 0x24 */ char unk_24[0x3C]; + /* 0x00 */ ObjMineMtxF3 unk_00; + // /* 0x0C */ Vec3f unk_0C; + // /* 0x18 */ Vec3f unk_18; /* 0x24 */ Vec3f unk_24; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; @@ -45,18 +41,33 @@ typedef struct { // probably fake typedef struct { - /* 0x00 */ Vec3f unk_00; - /* 0x0c */ Vec3f unk_0C; - ///* 0x10 */ f32 unk_10; - ///* 0x14 */ char unk_14[0x4]; - /* 0x18 */ Vec3f unk_18; - ///* 0x1C */ char unk_1C[0x4]; - ///* 0x20 */ f32 unk_20; + /* 0x00 */ ObjMineMtxF3 unk_00; + // /* 0x0c */ Vec3f unk_0C; + // /* 0x18 */ Vec3f unk_18; /* 0x24 */ Vec3f unk_24; /* 0x30 */ Vec3f unk_30; /* 0x3C */ Vec3f unk_3C; } ObjMineUnkStruct2; // size = 0x48??? +typedef struct { + f32 unk_00; + Vec3f unk_04; + f32 unk_10; + f32 unk_14; + f32 unk_18; + f32 unk_1C; + s16 unk_20; + f32 unk_24; + f32 unk_28; + f32 unk_2C; + f32 unk_30; + f32 unk_34; + f32 unk_38; + f32 unk_3C; + s8 unk_40; + ObjMineUnkStruct2 unk_44[0x3F]; +} ObjMineTestStruct2; + typedef struct ObjMine { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderJntSph collider; @@ -66,8 +77,8 @@ typedef struct ObjMine { /* 0x01AC */ s32 unk_1AC; /* 0x01B0 */ s32 unk_1B0; /* 0x01B4 */ Vec3s* unk_1B4; - /* 0x01B8 */ ObjMineUnkStruct unk_1B8; // array?? - /* 0x021C */ char unk_21C[0x1198]; + // ObjMineTestStruct2 chain2; + union { ObjMineTestStruct2 chain2; ObjMineUnkStruct chain1;}; } ObjMine; // size = 0x13B4 extern const ActorInit Obj_Mine_InitVars;