diff --git a/configure.py b/configure.py index 5c51c7ae6..f6d9e870f 100755 --- a/configure.py +++ b/configure.py @@ -409,7 +409,7 @@ config.libs = [ "progress_category": "game", "host": True, "objects": [ - Object(NonMatching, "c/c_damagereaction.cpp"), + Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "c/c_damagereaction.cpp"), Object(Matching, "c/c_dylink.cpp"), ], }, diff --git a/src/c/c_damagereaction.cpp b/src/c/c_damagereaction.cpp index 517e95b73..5e59d4ac8 100644 --- a/src/c/c_damagereaction.cpp +++ b/src/c/c_damagereaction.cpp @@ -3,6 +3,7 @@ // Translation Unit: c_damagereaction.o // +#include "d/dolzel.h" // IWYU pragma: keep #include "c/c_damagereaction.h" #include "d/d_com_inf_game.h" #include "d/actor/d_a_sea.h" @@ -477,7 +478,7 @@ void enemy_fire(enemyfire* ef) { ef->mSph.Set(fire_at_sph_src); ef->mSph.SetStts(&ef->mStts); } -#if VERSION == VERSION_DEMO +#if VERSION <= VERSION_JPN else { ef->mLight.mPower = 0.0f; } @@ -572,7 +573,7 @@ void enemy_fire(enemyfire* ef) { if (ef->mFireTimer == 0) { ef->mMode = 0; // Not on fire -#if VERSION > VERSION_DEMO +#if VERSION > VERSION_JPN dKy_plight_cut(&ef->mLight); #endif ef->mSph.SetC(non_pos); @@ -722,7 +723,7 @@ int dr_joint_bg_check(damagereaction* dr) { dr->m1F0[i].y = G_CM3D_F_INF; } - if((u32)i <= 2 || i == 3) { + if(i == 0 || i == 1 || i == 2 || i == 3) { if(dr->m1F0[i].y == G_CM3D_F_INF) { dr->m3D0[i] = 2; } @@ -745,11 +746,11 @@ int dr_joint_bg_check(damagereaction* dr) { f32 diffY = dr->m100[0xE].y - dr->m100[0xA].y; f32 diffZ = dr->m100[0xE].z - dr->m100[0xA].z; temp.z = std::sqrtf(diffX * diffX + diffY * diffY + diffZ * diffZ); - s16 angle = cM_atan2s(diffX, diffZ); - s16 i = 0; - for(; i >= -0x4000; i -= 0x400) { - mDoMtx_YrotS(*calc_mtx, angle); - mDoMtx_XrotM(*calc_mtx, i); + s16 angleY = cM_atan2s(diffX, diffZ); + s16 angleX = 0; + for(; angleX >= -0x4000; angleX -= 0x400) { + cMtx_YrotS(*calc_mtx, angleY); + cMtx_XrotM(*calc_mtx, angleX); MtxPosition(&temp, &temp2); temp2.x = temp2.x + dr->m100[0xA].x; temp2.y = temp2.y + dr->m100[0xA].y; @@ -760,8 +761,8 @@ int dr_joint_bg_check(damagereaction* dr) { } } - if(i != 0) { - dr->m440 = i + 0x400; + if(angleX != 0) { + dr->m440 = angleX + 0x400; dr->m408 = 2; } else { @@ -790,11 +791,11 @@ int dr_joint_bg_check(damagereaction* dr) { diffY = dr->m100[0xF].y - dr->m100[0xB].y; diffZ = dr->m100[0xF].z - dr->m100[0xB].z; temp.z = std::sqrtf(diffX * diffX + diffY * diffY + diffZ * diffZ); - angle = cM_atan2s(diffX, diffZ); - i = 0; - for(; i >= -0x4000; i -= 0x400) { - mDoMtx_YrotS(*calc_mtx, angle); - mDoMtx_XrotM(*calc_mtx, i); + angleY = cM_atan2s(diffX, diffZ); + angleX = 0; + for(; angleX >= -0x4000; angleX -= 0x400) { + cMtx_YrotS(*calc_mtx, angleY); + cMtx_XrotM(*calc_mtx, angleX); MtxPosition(&temp, &temp2); temp2.x = temp2.x + dr->m100[0xB].x; temp2.y = temp2.y + dr->m100[0xB].y; @@ -805,8 +806,8 @@ int dr_joint_bg_check(damagereaction* dr) { } } - if(i != 0) { - dr->m442 = i + 0x400; + if(angleX != 0) { + dr->m442 = angleX + 0x400; dr->m40C = 2; } else { @@ -828,11 +829,11 @@ int dr_joint_bg_check(damagereaction* dr) { diffY = dr->m100[0x10].y - dr->m100[0x8].y; diffZ = dr->m100[0x10].z - dr->m100[0x8].z; temp.z = std::sqrtf(diffX * diffX + diffY * diffY + diffZ * diffZ); - angle = cM_atan2s(diffX, diffZ); - i = 0; - for(; i >= -0x4000; i -= 0x400) { - mDoMtx_YrotS(*calc_mtx, angle); - mDoMtx_XrotM(*calc_mtx, i); + angleY = cM_atan2s(diffX, diffZ); + angleX = 0; + for(; angleX >= -0x4000; angleX -= 0x400) { + cMtx_YrotS(*calc_mtx, angleY); + cMtx_XrotM(*calc_mtx, angleX); MtxPosition(&temp, &temp2); temp2.x = temp2.x + dr->m100[0x8].x; temp2.y = temp2.y + dr->m100[0x8].y; @@ -843,8 +844,8 @@ int dr_joint_bg_check(damagereaction* dr) { } } - if(i != 0) { - dr->m444 = i + 0x400; + if(angleX != 0) { + dr->m444 = angleX + 0x400; dr->m410 = 2; } else { @@ -861,11 +862,11 @@ int dr_joint_bg_check(damagereaction* dr) { diffY = dr->m100[0x11].y - dr->m100[0x9].y; diffZ = dr->m100[0x11].z - dr->m100[0x9].z; temp.z = std::sqrtf(diffX * diffX + diffY * diffY + diffZ * diffZ); - angle = cM_atan2s(diffX, diffZ); - i = 0; - for(; i >= -0x4000; i -= 0x400) { - mDoMtx_YrotS(*calc_mtx, angle); - mDoMtx_XrotM(*calc_mtx, i); + angleY = cM_atan2s(diffX, diffZ); + angleX = 0; + for(; angleX >= -0x4000; angleX -= 0x400) { + cMtx_YrotS(*calc_mtx, angleY); + cMtx_XrotM(*calc_mtx, angleX); MtxPosition(&temp, &temp2); temp2.x = temp2.x + dr->m100[0x9].x; temp2.y = temp2.y + dr->m100[0x9].y; @@ -876,8 +877,8 @@ int dr_joint_bg_check(damagereaction* dr) { } } - if(i != 0) { - dr->m446 = i + 0x400; + if(angleX != 0) { + dr->m446 = angleX + 0x400; dr->m414 = 2; } else { @@ -894,13 +895,13 @@ int dr_joint_bg_check(damagereaction* dr) { diffY = dr->m100[0x12].y - dr->m100[0xC].y; diffZ = dr->m100[0x12].z - dr->m100[0xC].z; temp.z = std::sqrtf(diffX * diffX + diffY * diffY + diffZ * diffZ); - angle = cM_atan2s(diffX, diffZ); + angleY = cM_atan2s(diffX, diffZ); if(REG0_S(4) == 0) { - i = 0; - for(; i >= -0x4000; i -= 0x400) { - mDoMtx_YrotS(*calc_mtx, angle); - mDoMtx_XrotM(*calc_mtx, i); + angleX = 0; + for(; angleX >= -0x4000; angleX -= 0x400) { + cMtx_YrotS(*calc_mtx, angleY); + cMtx_XrotM(*calc_mtx, angleX); MtxPosition(&temp, &temp2); temp2.x = temp2.x + dr->m100[0xC].x; temp2.y = temp2.y + dr->m100[0xC].y; @@ -911,8 +912,8 @@ int dr_joint_bg_check(damagereaction* dr) { } } - if(i != 0) { - dr->m448 = i + 0x400; + if(angleX != 0) { + dr->m448 = angleX + 0x400; dr->m418 = 2; } else { @@ -944,14 +945,16 @@ int kado_check(damagereaction* dr) { int result = 0; - mDoMtx_YrotS(*calc_mtx, dr->m482); - mDoMtx_XrotM(*calc_mtx, dr->m480); + cMtx_YrotS(*calc_mtx, dr->m482); + cMtx_XrotM(*calc_mtx, dr->m480); for(int i = 0; i < 2; i++) { cXyz temp1; cXyz start = dr->mpEnemy->current.pos; start.y += REG14_F(0) + 100.0f; - temp1.set(REG14_F(1), REG14_F(2), REG14_F(3) + -70.0f); + temp1.x = REG14_F(1); + temp1.y = REG14_F(2); + temp1.z = REG14_F(3) + -70.0f; cXyz temp2; MtxPosition(&temp1, &temp2); start += temp2; @@ -981,7 +984,7 @@ s16 hang_ang_get(damagereaction* dr) { cXyz temp = dr->m7A0 - dr->mpEnemy->current.pos; - mDoMtx_YrotS(*calc_mtx, cM_atan2s(temp.x, temp.z)); + cMtx_YrotS(*calc_mtx, cM_atan2s(temp.x, temp.z)); cXyz temp3; temp.set(0.0f, 0.0f, -100.0f); MtxPosition(&temp, &temp3); @@ -1094,7 +1097,7 @@ int dr_damage_set(damagereaction* dr) { temp2.x = 0.0f; temp2.y = 0.0f; temp2.z = dr->m478; - mDoMtx_YrotS(*calc_mtx, dr->m482); + cMtx_YrotS(*calc_mtx, dr->m482); MtxPosition(&temp2, &temp4); dr->mpEnemy->speed.x = temp4.x; dr->mpEnemy->speed.z = temp4.z; @@ -1194,7 +1197,7 @@ int dr_damage_set(damagereaction* dr) { if(dr->m7B6 == 0 && test_sw == 0) { if(dr->m4C8[0] == 0) { - mDoMtx_YrotS(*calc_mtx, cM_atan2s(-dr->m42C.x, -dr->m42C.z)); + cMtx_YrotS(*calc_mtx, cM_atan2s(-dr->m42C.x, -dr->m42C.z)); temp2.x = 0.0f; temp2.y = 0.0f; temp2.z = dr->m4D4; @@ -1282,7 +1285,7 @@ int dr_damage_set(damagereaction* dr) { } temp2.y = 0.0f; temp2.z = dr->m478 * 0.5f; - mDoMtx_YrotS(*calc_mtx, dr->m482); + cMtx_YrotS(*calc_mtx, dr->m482); MtxPosition(&temp2, &temp4); dr->mpEnemy->speed.x = temp4.x; dr->mpEnemy->speed.z = temp4.z; @@ -1384,7 +1387,7 @@ int dr_damage_set(damagereaction* dr) { } temp2.y = 0.0f; temp2.z = dr->m478 * 0.75f; - mDoMtx_YrotS(*calc_mtx, dr->m482); + cMtx_YrotS(*calc_mtx, dr->m482); MtxPosition(&temp2, &temp4); dr->mpEnemy->speed.x = temp4.x; dr->mpEnemy->speed.z = temp4.z; @@ -1455,12 +1458,14 @@ void dr_damage_anime(damagereaction* dr) { dr->m010[i].x = dr->m010[i].y = dr->m010[i].z = 0; } + fopAc_ac_c* player = dComIfGp_getPlayer(0); + s16 maxSpeed; if(dr->m47C != 0 || test_sw != 0) { maxSpeed = 0x3000; - s16 temp7 = dr->m482 + 0x8000 - dr->mpEnemy->current.angle.y; - f32 temp = temp7; + f32 temp = (s16)(dr->m482 + 0x8000 - dr->mpEnemy->current.angle.y); + f32 zero = 0.0f; f32 temp2 = temp; if(temp2 > 5000.0f) { temp2 = 5000.0f; @@ -1468,11 +1473,10 @@ void dr_damage_anime(damagereaction* dr) { if(temp2 < -22000.0f) { temp2 = -22000.0f; } - dr->m010[8].y = temp2 * 0.4f + 8192.0f; - dr->m010[4].z = -temp2 * 0.4f - 8192.0f; - f32 temp_8192 = 8192.0f; - dr->m010[8].z = temp_8192; - dr->m010[4].y = temp_8192; + dr->m010[8].y = 0.4f * temp2 + 8192.0f; + dr->m010[4].z = 0.4f * -temp2 - 8192.0f; + dr->m010[8].z = 0.4f * zero + 8192.0f; + dr->m010[4].y = 0.4f * zero + 8192.0f; f32 temp3 = temp; if(temp3 > 22000.0f) { @@ -1481,11 +1485,10 @@ void dr_damage_anime(damagereaction* dr) { if(temp3 < -5000.0f) { temp3 = -5000.0f; } - dr->m010[9].y = temp3 * 0.4f - 8192.0f; - dr->m010[5].z = temp3 * 0.4f - 8192.0f; - f32 zero = 0.0f; - dr->m010[9].z = temp_8192; - dr->m010[5].y = -zero * 0.4f - temp_8192; + dr->m010[9].y = 0.4f * temp3 - 8192.0f; + dr->m010[5].z = 0.4f * temp3 - 8192.0f; + dr->m010[9].z = 0.4f * zero + 8192.0f; + dr->m010[5].y = 0.4f * -zero - 8192.0f; f32 temp4 = temp; if(temp4 > 20000.0f) { @@ -1494,10 +1497,10 @@ void dr_damage_anime(damagereaction* dr) { if(temp4 < -20000.0f) { temp4 = -20000.0f; } - dr->m010[0xC].x = temp4 * 0.2f; - dr->m010[0x13].x = temp4 * 0.2f; - dr->m010[0xC].z = -zero * 0.2f; - dr->m010[0x13].z = -zero * 0.2f; + dr->m010[0x0C].x = 0.2f * temp4; + dr->m010[0x13].x = 0.2f * temp4; + dr->m010[0x0C].z = 0.2f * -zero; + dr->m010[0x13].z = 0.2f * -zero; f32 temp5 = temp; if(temp5 > 7000.0f) { @@ -1559,7 +1562,7 @@ void dr_damage_anime(damagereaction* dr) { cxyz_temp.x = 0.0f; cxyz_temp.y = 0.0f; cxyz_temp.z = dr->m470; - mDoMtx_YrotS(*calc_mtx, angle - dr->mpEnemy->current.angle.y); + cMtx_YrotS(*calc_mtx, angle - dr->mpEnemy->current.angle.y); MtxPosition(&cxyz_temp, &cxyz_temp2); if(dr->mEnemyType == damagereaction::TYPE_BOKOBLIN) { @@ -1588,6 +1591,7 @@ void dr_damage_anime(damagereaction* dr) { maxSpeed = 0x3000; } else if(dr->m710 != 0 || dr->m49E != 0) { + f32 f31 = 0.5f; maxSpeed = 0x800; s16 temp; @@ -1640,8 +1644,8 @@ void dr_damage_anime(damagereaction* dr) { } else { dr->m010[0xD].y -= temp2; - dr->m010[0xC].y -= temp2 / 2.0f; - dr->m010[0xC].x = dr->m010[0xC].y + temp2 / 2.0f; + dr->m010[0xC].y -= temp2 * f31; + dr->m010[0xC].x = dr->m010[0xC].y + temp2 * f31; dr->m010[0xD].z += temp; } } @@ -1686,7 +1690,7 @@ void dr_damage_anime(damagereaction* dr) { cxyz_temp.x = dr->m48C.z; cxyz_temp.y = 0.0f; cxyz_temp.z = dr->m48C.x; - mDoMtx_YrotS(*calc_mtx, dr->mpEnemy->current.angle.y); + cMtx_YrotS(*calc_mtx, dr->mpEnemy->current.angle.y); MtxPosition(&cxyz_temp, &cxyz_temp2); cLib_addCalcAngleS2(&dr->m492, cxyz_temp2.x, 4, 0x100); cLib_addCalcAngleS2(&dr->m494, cxyz_temp2.z, 4, 0x100); @@ -1864,17 +1868,17 @@ void dr_damage_anime(damagereaction* dr) { /* 80022460-800225D0 .text dr_matrix_set__FP14damagereaction */ void dr_matrix_set(damagereaction* dr) { MtxTrans(dr->mpEnemy->current.pos.x + dr->m458.x, dr->mpEnemy->current.pos.y + dr->m458.y, dr->mpEnemy->current.pos.z + dr->m458.z, false); - mDoMtx_XrotM(*calc_mtx, dr->m48C.x); - mDoMtx_ZrotM(*calc_mtx, dr->m48C.z); + cMtx_XrotM(*calc_mtx, dr->m48C.x); + cMtx_ZrotM(*calc_mtx, dr->m48C.z); MtxTrans(-dr->m44C.x, -dr->m44C.y, -dr->m44C.z, true); - mDoMtx_YrotM(*calc_mtx, dr->m482); - mDoMtx_XrotM(*calc_mtx, dr->m480); - mDoMtx_YrotM(*calc_mtx, dr->m484); - mDoMtx_YrotM(*calc_mtx, -dr->m482); + cMtx_YrotM(*calc_mtx, dr->m482); + cMtx_XrotM(*calc_mtx, dr->m480); + cMtx_YrotM(*calc_mtx, dr->m484); + cMtx_YrotM(*calc_mtx, -dr->m482); MtxTrans(dr->m44C.x, dr->m44C.y, dr->m44C.z, true); - mDoMtx_YrotM(*calc_mtx, dr->mpEnemy->shape_angle.y); - mDoMtx_XrotM(*calc_mtx, dr->mpEnemy->shape_angle.x); - mDoMtx_ZrotM(*calc_mtx, dr->mpEnemy->shape_angle.z); + cMtx_YrotM(*calc_mtx, dr->mpEnemy->shape_angle.y); + cMtx_XrotM(*calc_mtx, dr->mpEnemy->shape_angle.x); + cMtx_ZrotM(*calc_mtx, dr->mpEnemy->shape_angle.z); MtxTrans(0.0f, dr->m468, dr->m46C, true); cXyz temp(0.0f, 0.0f, 10000.0f);