From 2a75abb376c6d890a1620765e7c0a026896f21bf Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Thu, 2 Apr 2026 18:52:28 -0400 Subject: [PATCH] Use composition for d_a_ks --- include/d/actor/d_a_ks.h | 4 +- src/d/actor/d_a_cc.cpp | 2 +- src/d/actor/d_a_ks.cpp | 372 +++++++++++++++++++++------------------ 3 files changed, 199 insertions(+), 179 deletions(-) diff --git a/include/d/actor/d_a_ks.h b/include/d/actor/d_a_ks.h index bdf3a89a2..7ecfeb8d1 100644 --- a/include/d/actor/d_a_ks.h +++ b/include/d/actor/d_a_ks.h @@ -4,8 +4,8 @@ #include "f_op/f_op_actor.h" #include "c/c_damagereaction.h" -class ks_class : public fopEn_enemy_c { -public: +struct ks_class { + /* 0x000 */ fopEn_enemy_c actor; /* 0x2AC */ request_of_phase_process_class mPhs; /* 0x2B4 */ mDoExt_McaMorf* mpBodyMorf; /* 0x2B8 */ mDoExt_McaMorf* mpEyeMorf; diff --git a/src/d/actor/d_a_cc.cpp b/src/d/actor/d_a_cc.cpp index c3cd4e348..a0028881f 100644 --- a/src/d/actor/d_a_cc.cpp +++ b/src/d/actor/d_a_cc.cpp @@ -1772,7 +1772,7 @@ void action_noboru(cc_class* i_this) { /* 00004CAC-0000561C .text action_up_check__FP8cc_class */ void action_up_check(cc_class* i_this) { - fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; + fopAc_ac_c* a_this = (fopAc_ac_c*)&i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); s16 bVar4 = 0; diff --git a/src/d/actor/d_a_ks.cpp b/src/d/actor/d_a_ks.cpp index fe494144a..f6f0e09f7 100644 --- a/src/d/actor/d_a_ks.cpp +++ b/src/d/actor/d_a_ks.cpp @@ -22,10 +22,12 @@ static int GORON_COUNT = 0; /* 00000078-000002CC .text draw_SUB__FP8ks_class */ void draw_SUB(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + J3DModel* pBodyModel = i_this->mpBodyMorf->getModel(); J3DModel* pEyeModel = i_this->mpEyeMorf->getModel(); - cXyz local_24 = dComIfGp_getCamera(0)->mLookat.mEye - i_this->current.pos; + cXyz local_24 = dComIfGp_getCamera(0)->mLookat.mEye - actor->current.pos; int iVar3 = cM_atan2s(local_24.x, local_24.z); int iVar4 = (s16)-cM_atan2s(local_24.y, std::sqrtf(SQUARE(local_24.x) + SQUARE(local_24.z))); @@ -35,11 +37,11 @@ void draw_SUB(ks_class* i_this) { fVar1 = i_this->m304; } - mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y + fVar1, i_this->current.pos.z); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y + fVar1, actor->current.pos.z); mDoMtx_stack_c::YrotM(iVar3); mDoMtx_stack_c::XrotM(iVar4); - mDoMtx_stack_c::ZrotM(i_this->shape_angle.z + i_this->m2FA); + mDoMtx_stack_c::ZrotM(actor->shape_angle.z + i_this->m2FA); cXyz local_18; local_18.setall(1.0f); @@ -48,15 +50,15 @@ void draw_SUB(ks_class* i_this) { mDoMtx_stack_c::scaleM(1.0f,1.0f,1.0f); - mDoMtx_stack_c::ZrotM(i_this->shape_angle.z - i_this->m2FA); + mDoMtx_stack_c::ZrotM(actor->shape_angle.z - i_this->m2FA); pBodyModel->setBaseTRMtx(mDoMtx_stack_c::get()); - mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y + fVar1, i_this->current.pos.z); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y + fVar1, actor->current.pos.z); - mDoMtx_stack_c::YrotM(i_this->shape_angle.y); - mDoMtx_stack_c::XrotM(i_this->shape_angle.x); - mDoMtx_stack_c::ZrotM(i_this->shape_angle.z); + mDoMtx_stack_c::YrotM(actor->shape_angle.y); + mDoMtx_stack_c::XrotM(actor->shape_angle.x); + mDoMtx_stack_c::ZrotM(actor->shape_angle.z); mDoMtx_stack_c::scaleM(local_18); @@ -67,10 +69,10 @@ void draw_SUB(ks_class* i_this) { /* 000002CC-00000568 .text daKS_Draw__FP8ks_class */ static BOOL daKS_Draw(ks_class* i_this) { - fopAc_ac_c* actor = i_this; + fopAc_ac_c* actor = &i_this->actor; #if VERSION > VERSION_DEMO - cXyz local_24 = i_this->current.pos - dComIfGp_getCamera(0)->mLookat.mEye; + cXyz local_24 = actor->current.pos - dComIfGp_getCamera(0)->mLookat.mEye; if (local_24.abs() < REG0_F(10) + 100.0f) { return TRUE; } @@ -79,7 +81,7 @@ static BOOL daKS_Draw(ks_class* i_this) { J3DModel* pBodyModel = i_this->mpBodyMorf->getModel(); J3DModel* pEyeModel = i_this->mpEyeMorf->getModel(); - cXyz local_18 = i_this->current.pos; + cXyz local_18 = actor->current.pos; local_18.y += 40.0f; dSnap_RegistFig(DSNAP_TYPE_KS, actor, 1.0f, 1.0f, 1.0f); @@ -94,8 +96,8 @@ static BOOL daKS_Draw(ks_class* i_this) { i_this->m2CD = 0; - g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->current.pos, &i_this->tevStr); - g_env_light.setLightTevColorType(pBodyModel, &i_this->tevStr); + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->actor.current.pos, &i_this->actor.tevStr); + g_env_light.setLightTevColorType(pBodyModel, &i_this->actor.tevStr); i_this->mpBodyBrkAnm->entry(pBodyModel->getModelData()); i_this->mpBodyBrkAnm->setFrame(i_this->m320); @@ -104,7 +106,7 @@ static BOOL daKS_Draw(ks_class* i_this) { i_this->mpBodyBrkAnm->remove(pBodyModel->getModelData()); - g_env_light.setLightTevColorType(pEyeModel, &i_this->tevStr); + g_env_light.setLightTevColorType(pEyeModel, &i_this->actor.tevStr); i_this->mpEyeBtkAnm->entry(pEyeModel->getModelData()); i_this->mpEyeBtkAnm->setFrame(i_this->m302); @@ -122,42 +124,43 @@ static BOOL daKS_Draw(ks_class* i_this) { /* 00000568-0000074C .text naraku_check__FP8ks_class */ void naraku_check(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; cXyz local_24; cXyz local_18; if (i_this->mAcch.GetGroundH() != -G_CM3D_F_INF && dComIfG_Bgsp()->ChkPolySafe(i_this->mAcch.m_gnd) && dComIfG_Bgsp()->GetGroundCode(i_this->mAcch.m_gnd) == 4) { i_this->m2D3++; - if (i_this->current.pos.y < -500.0f || i_this->m2D3 > 0x32) { - i_this->speedF = 0.0; - i_this->speed.setall(0.0f); - i_this->gravity = 0.0f; + if (actor->current.pos.y < -500.0f || i_this->m2D3 > 0x32) { + actor->speedF = 0.0; + actor->speed.setall(0.0f); + actor->gravity = 0.0f; - fopAcM_delete(i_this); + fopAcM_delete(actor); return; } } - if (i_this->mAcch.ChkWaterIn() && i_this->current.pos.y < i_this->mAcch.m_wtr.GetHeight() + 20.0f) { + if (i_this->mAcch.ChkWaterIn() && actor->current.pos.y < i_this->mAcch.m_wtr.GetHeight() + 20.0f) { if (!i_this->m2CF) { - local_24 = i_this->current.pos; + local_24 = actor->current.pos; i_this->m2CF = 1; local_18.setall(0.5f); i_this->m52C.remove(); - dComIfGp_particle_setShipTail(dPa_name::ID_AK_JN_HAMON00, &i_this->current.pos, NULL, &local_18, 0xFF, &i_this->m52C); + dComIfGp_particle_setShipTail(dPa_name::ID_AK_JN_HAMON00, &actor->current.pos, NULL, &local_18, 0xFF, &i_this->m52C); i_this->m52C.setRate(0.0f); } - cLib_addCalc2(&i_this->current.pos.y, i_this->mAcch.m_wtr.GetHeight() + 20.0f, 1.0f, 10.0); + cLib_addCalc2(&actor->current.pos.y, i_this->mAcch.m_wtr.GetHeight() + 20.0f, 1.0f, 10.0); - i_this->gravity = 0.0f; - i_this->speed.y = 0.0f; + actor->gravity = 0.0f; + actor->speed.y = 0.0f; } - else if (i_this->m2CF && (i_this->mAcch.ChkGroundHit() || i_this->current.pos.y > i_this->mAcch.m_wtr.GetHeight() + 100.0f)) { + else if (i_this->m2CF && (i_this->mAcch.ChkGroundHit() || actor->current.pos.y > i_this->mAcch.m_wtr.GetHeight() + 100.0f)) { i_this->m2CF = 0; i_this->m52C.remove(); @@ -166,13 +169,15 @@ void naraku_check(ks_class* i_this) { /* 0000074C-00000788 .text tyaku_check__FP8ks_class */ BOOL tyaku_check(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + if (i_this->mAcch.ChkGroundHit()) { return TRUE; } if (i_this->mAcch.ChkWaterIn()) { - i_this->speed.y = 0.0f; - i_this->gravity = 0.0f; + actor->speed.y = 0.0f; + actor->gravity = 0.0f; return TRUE; } @@ -216,16 +221,17 @@ void gm_birth_delet(ks_class* i_this) { /* 000008F4-00000A98 .text shock_damage_check__FP8ks_class */ BOOL shock_damage_check(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; daPy_lk_c* link = daPy_getPlayerLinkActorClass(); if (link->checkHammerQuake()) { cXyz mSwordTopPos = link->getSwordTopPos(); - mSwordTopPos.x -= i_this->current.pos.x; - mSwordTopPos.y -= i_this->current.pos.y; - mSwordTopPos.z -= i_this->current.pos.z; + mSwordTopPos.x -= actor->current.pos.x; + mSwordTopPos.y -= actor->current.pos.y; + mSwordTopPos.z -= actor->current.pos.z; - float distXZ = std::sqrtf(SQUARE(mSwordTopPos.x) + SQUARE(mSwordTopPos.z)); + f32 distXZ = std::sqrtf(SQUARE(mSwordTopPos.x) + SQUARE(mSwordTopPos.z)); if (distXZ < 200.0f) { if (std::sqrtf(SQUARE(mSwordTopPos.y)) < 40.0f) { @@ -241,8 +247,8 @@ BOOL shock_damage_check(ks_class* i_this) { /* 00000A98-00000DE8 .text body_atari_check__FP8ks_class */ BOOL body_atari_check(ks_class* i_this) { + fopAc_ac_c* actor = (fopAc_ac_c*)&i_this->actor; daPy_py_c* player = daPy_getPlayerActorClass(); - fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; cXyz mTgHitPos; cXyz mParticleScale; @@ -259,13 +265,13 @@ BOOL body_atari_check(ks_class* i_this) { return FALSE; } - a_this->current.angle.y = fopAcM_searchPlayerAngleY(a_this) + 0x8000; + actor->current.angle.y = fopAcM_searchPlayerAngleY(actor) + 0x8000; i_this->mAction = 3; switch (mTgHitObj->GetAtType()) { case AT_TYPE_WIND: { - a_this->current.angle.y = cM_atan2s(a_this->current.pos.x - mTgHitPos.x, a_this->current.pos.z - mTgHitPos.z); + actor->current.angle.y = cM_atan2s(actor->current.pos.x - mTgHitPos.x, actor->current.pos.z - mTgHitPos.z); i_this->mAction = 2; i_this->mMode = 20; @@ -276,7 +282,7 @@ BOOL body_atari_check(ks_class* i_this) { case AT_TYPE_UNK8: { i_this->mMode = 32; - a_this->health = 0; + actor->health = 0; i_this->mMode = 30; @@ -287,7 +293,7 @@ BOOL body_atari_check(ks_class* i_this) { if (i_this->mMode != 43 || i_this->m2CE) { dScnPly_ply_c::setPauseTimer(2); #if VERSION > VERSION_DEMO - a_this->stealItemBitNo = 1; + actor->stealItemBitNo = 1; #endif } @@ -298,16 +304,16 @@ BOOL body_atari_check(ks_class* i_this) { } case AT_TYPE_SKULL_HAMMER: { if (player->getCutType() == 0x12 || player->getCutType() == 0x13) { - a_this->speedF = 0.0f; - a_this->gravity = 0.0f; - a_this->speed.setall(0.0f); + actor->speedF = 0.0f; + actor->gravity = 0.0f; + actor->speed.setall(0.0f); - a_this->health = 0; + actor->health = 0; dScnPly_ply_c::setPauseTimer(2); #if VERSION > VERSION_DEMO - a_this->stealItemBitNo = 1; + actor->stealItemBitNo = 1; #endif i_this->mMode = 32; @@ -351,7 +357,7 @@ BOOL body_atari_check(ks_class* i_this) { } } - a_this->health = 0; + actor->health = 0; i_this->mMode = 30; @@ -364,6 +370,8 @@ BOOL body_atari_check(ks_class* i_this) { /* 00000DE8-00000EBC .text speed_keisan__FP8ks_classs */ void speed_keisan(ks_class* i_this, short i_speed) { + fopAc_ac_c* actor = &i_this->actor; + cMtx_YrotS(*calc_mtx, i_speed); s16 sVar1 = i_this->m30C * cM_ssin(i_this->m2F0[0]); @@ -376,19 +384,20 @@ void speed_keisan(ks_class* i_this, short i_speed) { cXyz local_8; MtxPosition(&local_14, &local_8); - i_this->current.pos.x += local_8.x; - i_this->current.pos.z += local_8.z; + actor->current.pos.x += local_8.x; + actor->current.pos.z += local_8.z; } /* 00000EBC-00001314 .text action_dousa_move__FP8ks_class */ void action_dousa_move(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; daPy_lk_c* link = daPy_getPlayerLinkActorClass(); switch (i_this->mMode) { case 0: i_this->m30C = 0.0f; - i_this->gravity = -3.0f; + actor->gravity = -3.0f; for (int i = 0; i < 5; i++) { i_this->m2F0[i] = 0; @@ -397,39 +406,39 @@ void action_dousa_move(ks_class* i_this) { i_this->mMode++; // Fall-through case 1: - cLib_addCalcAngleS2(&i_this->shape_angle.z, 0, 1, 0x1000); + cLib_addCalcAngleS2(&actor->shape_angle.z, 0, 1, 0x1000); - if (fopAcM_searchPlayerDistance(i_this) > 10000.0f) { + if (fopAcM_searchPlayerDistance(actor) > 10000.0f) { break; } - if (i_this->shape_angle.z > 0x100) { + if (actor->shape_angle.z > 0x100) { return; } - i_this->shape_angle.z = 0; + actor->shape_angle.z = 0; - fopAcM_seStart(i_this, JA_SE_CM_KS_MOVE, 0); + fopAcM_seStart(actor, JA_SE_CM_KS_MOVE, 0); if (tyaku_check(i_this) != 0) { - i_this->gravity = -3.0f; + actor->gravity = -3.0f; - i_this->speed.y = 1.0f; - i_this->speed.y += cM_rndF(5.0f); + actor->speed.y = 1.0f; + actor->speed.y += cM_rndF(5.0f); } - i_this->current.angle.y = i_this->m2FC + fopAcM_searchPlayerAngleY(i_this); + actor->current.angle.y = i_this->m2FC + fopAcM_searchPlayerAngleY(actor); i_this->mMode++; // Fall-through case 2: if (i_this->mAcch.ChkGroundHit()) { - i_this->current.angle.y = i_this->m2FC + fopAcM_searchPlayerAngleY(i_this); + actor->current.angle.y = i_this->m2FC + fopAcM_searchPlayerAngleY(actor); } if (KUTTUKU_ALL_COUNT >= 0 && KUTTUKU_ALL_COUNT < 0x14 && (link->getSpeedF() > 12.0f || HEAVY_IN) && - fopAcM_searchPlayerDistance(i_this) < 500.0f && + fopAcM_searchPlayerDistance(actor) < 500.0f && !dComIfGp_checkPlayerStatus0(0, daPyStts0_SWIM_e) && tyaku_check(i_this)) { @@ -440,56 +449,56 @@ void action_dousa_move(ks_class* i_this) { } if (link->getSpeedF() <= 12.0f || dComIfGp_checkPlayerStatus0(0, daPyStts0_SWIM_e)) { - cLib_addCalc0(&i_this->speedF, 0.3f, cM_rndF(1.0f) + 0.3f); + cLib_addCalc0(&actor->speedF, 0.3f, cM_rndF(1.0f) + 0.3f); - cLib_addCalcAngleS2(&i_this->shape_angle.z, 0, 1, 0x1000); + cLib_addCalcAngleS2(&actor->shape_angle.z, 0, 1, 0x1000); i_this->m2FC = 0; break; } if (i_this->m2FC == 0) { - i_this->m2FC = (fopAcM_GetID(i_this) & 0xf) * cM_rndFX(512.0f); + i_this->m2FC = (fopAcM_GetID(actor) & 0xf) * cM_rndFX(512.0f); } - i_this->shape_angle.z = cM_rndFX(2000.0f); + actor->shape_angle.z = cM_rndFX(2000.0f); - speed_keisan(i_this, i_this->current.angle.y); + speed_keisan(i_this, actor->current.angle.y); - i_this->speedF = 12.0f; + actor->speedF = 12.0f; i_this->m2F0[0] += 1000; i_this->m30C = 10.0f; if (tyaku_check(i_this)) { - fopAcM_seStart(i_this, JA_SE_CM_KS_MOVE, 0); + fopAcM_seStart(actor, JA_SE_CM_KS_MOVE, 0); - i_this->gravity = -3.0f; + actor->gravity = -3.0f; - i_this->speed.y = 1.0f; - i_this->speed.y += cM_rndF(5.0f); + actor->speed.y = 1.0f; + actor->speed.y += cM_rndF(5.0f); } break; case 3: - if (fopAcM_searchPlayerDistance(i_this) < 500.0f) { - i_this->current.angle.y = fopAcM_searchPlayerAngleY(i_this); + if (fopAcM_searchPlayerDistance(actor) < 500.0f) { + actor->current.angle.y = fopAcM_searchPlayerAngleY(actor); } break; } if (i_this->mMode == 2 || i_this->mMode == 3) { - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->current.angle.y, 1, 0x1000); + cLib_addCalcAngleS2(&actor->shape_angle.y, actor->current.angle.y, 1, 0x1000); } if (body_atari_check(i_this) != 0) { - fopAcM_seStart(i_this, JA_SE_LK_LAST_HIT, 0); + fopAcM_seStart(actor, JA_SE_LK_LAST_HIT, 0); } } /* 00001314-00001630 .text action_kougeki_move__FP8ks_class */ void action_kougeki_move(ks_class* i_this) { - fopAc_ac_c* actor = i_this; + fopAc_ac_c* actor = &i_this->actor; cXyz head_top_pos = daPy_getPlayerActorClass()->getHeadTopPos(); i_this->m31C = 20.0f; @@ -574,6 +583,8 @@ void action_kougeki_move(ks_class* i_this) { /* 00001630-00001874 .text action_kaze_move__FP8ks_class */ void action_kaze_move(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + switch (i_this->mMode) { case 20: { for (int i = 0; i < 5; i++) { @@ -582,13 +593,13 @@ void action_kaze_move(ks_class* i_this) { i_this->m2E8[1] = 0x32; - fopAcM_monsSeStart(i_this, JA_SE_CV_KS_BLOW, 0); + fopAcM_monsSeStart(actor, JA_SE_CV_KS_BLOW, 0); - i_this->m310 = i_this->current.pos.y; + i_this->m310 = actor->current.pos.y; i_this->m30C = 0.0f; - i_this->speedF = cM_rndF(15.0f) + 10.0f; + actor->speedF = cM_rndF(15.0f) + 10.0f; i_this->m314 = cM_rndF(15.0f) + 10.0f; i_this->m308 = 0.0f; @@ -597,26 +608,26 @@ void action_kaze_move(ks_class* i_this) { // Fall-through } case 21: { - cLib_addCalc2(&i_this->speed.y, i_this->m314, 0.8f, i_this->m308); + cLib_addCalc2(&actor->speed.y, i_this->m314, 0.8f, i_this->m308); cLib_addCalc2(&i_this->m308, 5.0f, 1.0f, 0.5f); - if (i_this->m310 + 200.0f < i_this->current.pos.y || i_this->m2E8[1] == 0) { + if (i_this->m310 + 200.0f < actor->current.pos.y || i_this->m2E8[1] == 0) { i_this->mMode++; } break; } case 22: { - cLib_addCalc2(&i_this->gravity, -1.0f, 0.3f, 0.5f); + cLib_addCalc2(&actor->gravity, -1.0f, 0.3f, 0.5f); - if (i_this->speed.y < -2.0f) { - i_this->speed.y = -2.0f; + if (actor->speed.y < -2.0f) { + actor->speed.y = -2.0f; } - cLib_addCalc0(&i_this->speedF, 0.5f, 2.0f); + cLib_addCalc0(&actor->speedF, 0.5f, 2.0f); - speed_keisan(i_this, i_this->shape_angle.y); + speed_keisan(i_this, actor->shape_angle.y); i_this->m2F0[0] += 3000; @@ -631,10 +642,10 @@ void action_kaze_move(ks_class* i_this) { } } - i_this->shape_angle.z += 0x500; + actor->shape_angle.z += 0x500; if (body_atari_check(i_this)) { - fopAcM_seStart(i_this, JA_SE_LK_LAST_HIT, 0); + fopAcM_seStart(actor, JA_SE_LK_LAST_HIT, 0); } } @@ -642,9 +653,9 @@ static u8 item_tbl[4] = {0xA, 0xB, 0xC, 0xA}; /* 00001874-00001A14 .text dead_eff_set__FP8ks_classP4cXyz */ void dead_eff_set(ks_class* i_this, cXyz* i_pos) { - fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; + fopAc_ac_c* actor = (fopAc_ac_c*)i_this; u8 drop_type; - if (!strcmp(dComIfGp_getStartStageName(), "GanonK") && (i_this->stealItemBitNo != 0)) { + if (!strcmp(dComIfGp_getStartStageName(), "GanonK") && (actor->stealItemBitNo != 0)) { if (dComIfGs_getLife() <= 8) { drop_type = daDisItem_HEART_e; } @@ -666,21 +677,22 @@ void dead_eff_set(ks_class* i_this, cXyz* i_pos) { drop_type = daDisItem_NONE13_e; } - fopAcM_createDisappear(i_this, i_pos, 3, drop_type, 0xff); + fopAcM_createDisappear(actor, i_pos, 3, drop_type, 0xff); } else { - fopAcM_seStart(i_this, JA_SE_CM_KS_DIE, 0); + fopAcM_seStart(actor, JA_SE_CM_KS_DIE, 0); dComIfGp_particle_setSimple(dPa_name::ID_IT_SN_O_KUROBOU_SIBOU00, i_pos); gm_birth_delet(i_this); } - fopAcM_delete(a_this); + fopAcM_delete(actor); } /* 00001A14-00001C5C .text action_dead_move__FP8ks_class */ void action_dead_move(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; cXyz local_28; switch (i_this->mMode) { @@ -693,11 +705,11 @@ void action_dead_move(ks_class* i_this) { i_this->mSph.ClrCoSet(); i_this->mSph.ClrTgHit(); - fopAcM_monsSeStart(i_this, JA_SE_CV_KS_DAMAGE, 0); + fopAcM_monsSeStart(actor, JA_SE_CV_KS_DAMAGE, 0); - i_this->speedF = cM_rndF(5.0f) + 15.0f; - i_this->gravity = -3.0f; - i_this->speed.y = cM_rndF(5.0f) + 20.0f; + actor->speedF = cM_rndF(5.0f) + 15.0f; + actor->gravity = -3.0f; + actor->speed.y = cM_rndF(5.0f) + 20.0f; i_this->mMode++; @@ -708,23 +720,23 @@ void action_dead_move(ks_class* i_this) { // Fall-through } case 31: { - i_this->shape_angle.z += i_this->m2F0[1]; + actor->shape_angle.z += i_this->m2F0[1]; if (tyaku_check(i_this)) { - i_this->gravity = -3.0f; - i_this->speedF *= 0.5f; + actor->gravity = -3.0f; + actor->speedF *= 0.5f; switch (i_this->m2F0[0]) { case 0: - i_this->speed.y = 13.0f; + actor->speed.y = 13.0f; i_this->m2F0[0]++; break; case 1: - i_this->speed.y = 7.0f; + actor->speed.y = 7.0f; i_this->m2F0[0]++; break; case 2: - local_28 = i_this->current.pos; + local_28 = actor->current.pos; local_28.y += 20.0f; dead_eff_set(i_this, &local_28); break; @@ -733,7 +745,7 @@ void action_dead_move(ks_class* i_this) { break; } case 32: { - local_28 = i_this->current.pos; + local_28 = actor->current.pos; local_28.y += 45.0f; dead_eff_set(i_this, &local_28); break; @@ -766,7 +778,7 @@ u32 pl_harituki_joint_dt[20] = { /* 00001C5C-000026DC .text action_omoi__FP8ks_class */ void action_omoi(ks_class* i_this) { - fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; + fopAc_ac_c* actor = (fopAc_ac_c*)i_this; cXyz local_1c; cXyz local_10; @@ -781,14 +793,14 @@ void action_omoi(ks_class* i_this) { case 40: { i_this->m52C.remove(); - a_this->speedF = 0.0f; - a_this->gravity = 0.0f; - a_this->speed.setall(0.0f); + actor->speedF = 0.0f; + actor->gravity = 0.0f; + actor->speed.setall(0.0f); if (GORON_COUNT != 0 || KUTTUKU_ALL_COUNT >= 0x14) { i_this->m528 = 0; - fopAcM_OffStatus(a_this, fopAcStts_UNK4000_e); + fopAcM_OffStatus(actor, fopAcStts_UNK4000_e); i_this->mMode = 42; @@ -830,21 +842,21 @@ void action_omoi(ks_class* i_this) { i_this->m2E8[1] = 0; i_this->m2E8[2] = 0; - fopAcM_OnStatus(a_this, fopAcStts_UNK4000_e); + fopAcM_OnStatus(actor, fopAcStts_UNK4000_e); - fopAcM_setStageLayer(a_this); + fopAcM_setStageLayer(actor); i_this->mMode++; // Fall-through } case 0x29: { - fopAcM_SetRoomNo(a_this, fopAcM_GetRoomNo(mpCurPlayerActor)); + fopAcM_SetRoomNo(actor, fopAcM_GetRoomNo(mpCurPlayerActor)); - if (!(fopAcM_GetID(a_this) & 1)) { - a_this->shape_angle.y += i_this->m2FE * 0.25f; + if (!(fopAcM_GetID(actor) & 1)) { + actor->shape_angle.y += i_this->m2FE * 0.25f; } else { - a_this->shape_angle.y -= i_this->m2FE * 0.25f; + actor->shape_angle.y -= i_this->m2FE * 0.25f; } if (i_this->m528) { @@ -878,9 +890,9 @@ void action_omoi(ks_class* i_this) { if (std::sqrtf(SQUARE(mpCurPlayerActor->speed.x) + SQUARE(mpCurPlayerActor->speed.y) + SQUARE(mpCurPlayerActor->speed.z)) < REG12_F(17) + 8.0f) { local_1c.setall(REG12_F(18) + 8.0f); - f32 x = a_this->current.pos.x - local_10.x; - f32 y = a_this->current.pos.y - local_10.y; - f32 z = a_this->current.pos.z - local_10.z; + f32 x = actor->current.pos.x - local_10.x; + f32 y = actor->current.pos.y - local_10.y; + f32 z = actor->current.pos.z - local_10.z; if (std::sqrtf(x * x + y * y + z * z) < 2.0f && i_this->m2E8[1] == 0) { i_this->m2E8[1] = cM_rndF(10.0f) + 10.0f; @@ -923,9 +935,9 @@ void action_omoi(ks_class* i_this) { local_1c.setall(100.0f); } - cLib_addCalc2(&a_this->current.pos.x, local_10.x, 1.0f, local_1c.x); - cLib_addCalc2(&a_this->current.pos.y, local_10.y, 1.0f, local_1c.y); - cLib_addCalc2(&a_this->current.pos.z, local_10.z, 1.0f, local_1c.z); + cLib_addCalc2(&actor->current.pos.x, local_10.x, 1.0f, local_1c.x); + cLib_addCalc2(&actor->current.pos.y, local_10.y, 1.0f, local_1c.y); + cLib_addCalc2(&actor->current.pos.z, local_10.z, 1.0f, local_1c.z); if (link->checkFrontRollCrash() || link->getCutType() == 8 || link->getCutType() == 9 || dComIfGp_checkPlayerStatus0(0, daPyStts0_SWIM_e)) { i_this->mSph.OnCoSetBit(); @@ -1032,19 +1044,19 @@ void action_omoi(ks_class* i_this) { } case 42: { if (i_this->m528) { - fopAcM_OffStatus(a_this, fopAcStts_UNK4000_e); + fopAcM_OffStatus(actor, fopAcStts_UNK4000_e); - fopAcM_setRoomLayer(a_this, fopAcM_GetRoomNo(a_this)); + fopAcM_setRoomLayer(actor, fopAcM_GetRoomNo(actor)); i_this->m528 = 0; } - i_this->current.angle.y = fopAcM_searchPlayerAngleY(a_this) + 0x8000; - i_this->current.angle.y += (s16)cM_rndFX(16384.0f); + actor->current.angle.y = fopAcM_searchPlayerAngleY(actor) + 0x8000; + actor->current.angle.y += (s16)cM_rndFX(16384.0f); - i_this->speedF = 15.0f; - i_this->gravity = -3.0f; - i_this->speed.y = 26.0f; + actor->speedF = 15.0f; + actor->gravity = -3.0f; + actor->speed.y = 26.0f; i_this->mMode++; // Fall-through @@ -1064,36 +1076,39 @@ void action_omoi(ks_class* i_this) { } if (i_this->mMode == 43 && body_atari_check(i_this) && i_this->m2CE) { - fopAcM_seStart(a_this, JA_SE_LK_LAST_HIT, 0); + fopAcM_seStart(actor, JA_SE_LK_LAST_HIT, 0); i_this->m2CE = 0; } } /* 000026DC-000027A0 .text tsubo_search__FPvPv */ -BOOL tsubo_search(void* param_1, void* param_2) { - ks_class* i_ks1 = (ks_class*)param_1; - ks_class* i_ks2 = (ks_class*)param_2; - - if (fopAc_IsActor(i_ks1) && (fopAcM_GetName(i_ks1) == 0x1cb) && - std::fabsf(i_ks1->current.pos.x - i_ks2->current.pos.x) < 20.0f && - std::fabsf(i_ks1->current.pos.y - i_ks2->current.pos.y) < 20.0f && - std::fabsf(i_ks1->current.pos.z - i_ks2->current.pos.z) < 20.0f) { - i_ks2->mKsID = fopAcM_GetID(i_ks1); +void* tsubo_search(void* param_1, void* i_data) { + ks_class* i_this = (ks_class*)i_data; + fopAc_ac_c* actor = &i_this->actor; + if (fopAc_IsActor(param_1) && (fopAcM_GetName(param_1) == PROC_TSUBO)) { + fopAc_ac_c* tsubo_actor = (fopAc_ac_c*)param_1; + + if (std::fabsf(tsubo_actor->current.pos.x - actor->current.pos.x) < 20.0f && + std::fabsf(tsubo_actor->current.pos.y - actor->current.pos.y) < 20.0f && + std::fabsf(tsubo_actor->current.pos.z - actor->current.pos.z) < 20.0f) + { + i_this->mKsID = fopAcM_GetID(tsubo_actor); + } } - return FALSE; + return NULL; } /* 000027A0-00002A40 .text action_tubo_search__FP8ks_class */ void action_tubo_search(ks_class* i_this) { - fopAc_ac_c* a_this = (fopAc_ac_c*)i_this; + fopAc_ac_c* actor = (fopAc_ac_c*)i_this; switch (i_this->mMode) { case 50: { i_this->mKsID = fpcM_ERROR_PROCESS_ID_e; - fpcEx_Search((fpcLyIt_JudgeFunc)tsubo_search, a_this); + fpcEx_Search(tsubo_search, actor); if (i_this->mKsID == fpcM_ERROR_PROCESS_ID_e) { - fopAcM_delete(a_this); + fopAcM_delete(actor); } else { i_this->mMode++; @@ -1105,13 +1120,13 @@ void action_tubo_search(ks_class* i_this) { fopAc_ac_c* mpCurrActor = (fopAc_ac_c*)fopAcM_SearchByID(i_this->mKsID); if (mpCurrActor) { - a_this->current.pos = mpCurrActor->current.pos; + actor->current.pos = mpCurrActor->current.pos; if (!i_this->m318) { return; } - if (fopAcM_searchPlayerDistance(a_this) > i_this->m318) { + if (fopAcM_searchPlayerDistance(actor) > i_this->m318) { return; } } @@ -1129,7 +1144,7 @@ void action_tubo_search(ks_class* i_this) { i_this->mSph.OnAtHitBit(); - i_this->mSph.SetC(i_this->current.pos); + i_this->mSph.SetC(actor->current.pos); i_this->mSph.SetR(i_this->m31C); dComIfG_Ccsp()->Set(&i_this->mSph); @@ -1139,7 +1154,7 @@ void action_tubo_search(ks_class* i_this) { break; } case 52: { - i_this->mSph.SetC(a_this->current.pos); + i_this->mSph.SetC(actor->current.pos); i_this->mSph.SetR(i_this->m31C); dComIfG_Ccsp()->Set(&i_this->mSph); @@ -1149,7 +1164,7 @@ void action_tubo_search(ks_class* i_this) { } for (int i = 0; i < i_this->m2C9; i++) { - cXyz local_24 = a_this->current.pos; + cXyz local_24 = actor->current.pos; local_24.y += cM_rndF(40.0f); if (i != 0) { @@ -1157,13 +1172,13 @@ void action_tubo_search(ks_class* i_this) { local_24.z += cM_rndFX(40.0f); } - a_this->shape_angle = a_this->current.angle; - a_this->shape_angle.x = 0; + actor->shape_angle = actor->current.angle; + actor->shape_angle.x = 0; - fopAcM_create(PROC_KS, 3, &local_24, fopAcM_GetRoomNo(a_this), &a_this->shape_angle, &a_this->scale, 0); + fopAcM_create(PROC_KS, 3, &local_24, fopAcM_GetRoomNo(actor), &actor->shape_angle, &actor->scale, 0); } - fopAcM_delete(a_this); + fopAcM_delete(actor); break; } } @@ -1171,25 +1186,26 @@ void action_tubo_search(ks_class* i_this) { /* 00002A40-00002BC4 .text action_kb_birth_check__FP8ks_class */ void action_kb_birth_check(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; switch (i_this->mMode) { case 60: { - i_this->current.pos.y += REG8_F(13) + 30.0f; - i_this->current.angle.y = cM_rndFX(32767.0f); + actor->current.pos.y += REG8_F(13) + 30.0f; + actor->current.angle.y = cM_rndFX(32767.0f); - i_this->speedF = REG8_F(8) + 4.0f + cM_rndF(REG8_F(9) + 4.0f); - i_this->speed.y = REG8_F(10) + 20.0f + cM_rndF(REG8_F(11) + 5.0f); - i_this->gravity = -(REG8_F(12) + 2.0f); + actor->speedF = REG8_F(8) + 4.0f + cM_rndF(REG8_F(9) + 4.0f); + actor->speed.y = REG8_F(10) + 20.0f + cM_rndF(REG8_F(11) + 5.0f); + actor->gravity = -(REG8_F(12) + 2.0f); i_this->mMode++; // Fall-through } case 61: { - if (i_this->speed.y <= 0.0f && (i_this->mAcch.ChkGroundHit() || i_this->mAcch.GetGroundH() + (REG8_F(19) + 10.0f) > i_this->current.pos.y )) { - fopAcM_OffStatus(i_this, fopAcStts_UNK4000_e); + if (actor->speed.y <= 0.0f && (i_this->mAcch.ChkGroundHit() || i_this->mAcch.GetGroundH() + (REG8_F(19) + 10.0f) > actor->current.pos.y )) { + fopAcM_OffStatus(actor, fopAcStts_UNK4000_e); - i_this->speedF = 0.0f; - i_this->gravity = 0.0f; - i_this->speed.setall(0.0f); + actor->speedF = 0.0f; + actor->gravity = 0.0f; + actor->speed.setall(0.0f); i_this->mAction = 0; i_this->mMode = 0; @@ -1201,19 +1217,23 @@ void action_kb_birth_check(ks_class* i_this) { /* 00002BC4-00002C54 .text BG_check__FP8ks_class */ void BG_check(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + i_this->mAcchCir.SetWall(30.0f, 30.0f); - i_this->current.pos.y -= i_this->m304; - i_this->old.pos.y -= i_this->m304; + actor->current.pos.y -= i_this->m304; + actor->old.pos.y -= i_this->m304; i_this->mAcch.CrrPos(*dComIfG_Bgsp()); - i_this->current.pos.y += i_this->m304; - i_this->old.pos.y += i_this->m304; + actor->current.pos.y += i_this->m304; + actor->old.pos.y += i_this->m304; } /* 00002C54-00003054 .text daKS_Execute__FP8ks_class */ -static BOOL daKS_Execute(ks_class* i_this) { +static BOOL daKS_Execute(ks_class* i_this) { + fopAc_ac_c* actor = &i_this->actor; + if (enemy_ice(&i_this->mEnemyIce)) { i_this->mpBodyMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); i_this->mpEyeMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); @@ -1306,41 +1326,41 @@ static BOOL daKS_Execute(ks_class* i_this) { i_this->m302 = 1; } - cMtx_YrotS(*calc_mtx, i_this->current.angle.y); + cMtx_YrotS(*calc_mtx, actor->current.angle.y); cXyz local_18; local_18.x = 0.0f; local_18.y = 0.0f; - local_18.z = i_this->speedF; + local_18.z = actor->speedF; cXyz local_c; MtxPosition(&local_18, &local_c); - i_this->speed.x = local_c.x; - i_this->speed.z = local_c.z; + actor->speed.x = local_c.x; + actor->speed.z = local_c.z; if (i_this->mMode != 41 && !i_this->mAcch.ChkGroundHit() && !i_this->mAcch.ChkWaterIn()) { - i_this->speed.y += i_this->gravity; + actor->speed.y += actor->gravity; - if (i_this->speed.y < -20.0f) { - i_this->speed.y = -20.0f; + if (actor->speed.y < -20.0f) { + actor->speed.y = -20.0f; } } - i_this->eyePos = i_this->current.pos; + actor->eyePos = actor->current.pos; - i_this->attention_info.position = i_this->eyePos; + actor->attention_info.position = actor->eyePos; - i_this->mSph.SetC(i_this->current.pos); + i_this->mSph.SetC(actor->current.pos); i_this->mSph.SetR(i_this->m31C); dComIfG_Ccsp()->Set(&i_this->mSph); if (i_this->mSph.ChkCoSet() && (i_this->mAction == 0 || i_this->mAction == 2)) { - fopAcM_posMove(i_this, i_this->mStts.GetCCMoveP()); + fopAcM_posMove(actor, i_this->mStts.GetCCMoveP()); } else { - fopAcM_posMove(i_this, NULL); + fopAcM_posMove(actor, NULL); } if (i_this->mMode != 41) { @@ -1597,8 +1617,8 @@ static cPhs_State daKS_Create(fopAc_ac_c* i_this) { return cPhs_ERROR_e; } - fopAc_ac_c* i_act = fopAcM_SearchByID(a_this->mGmID); - if (i_act && fopAc_IsActor(i_act) && fopAcM_GetName(i_act) == PROC_GM && a_this->m2C8 == 5) { + fopAc_ac_c* gm_actor = fopAcM_SearchByID(a_this->mGmID); + if (gm_actor && fopAc_IsActor(gm_actor) && fopAcM_GetName(gm_actor) == PROC_GM && a_this->m2C8 == 5) { i_this->current.angle.y += cM_rndFX(8192.0f); i_this->speedF = cM_rndF(6.0f) + 34.0f; i_this->speed.y = cM_rndF(8.0f) + 22.0f;