From 468df0d5f1809ef63bbfc2d8d4fb0c91a1a1253c Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Fri, 25 Jul 2025 04:34:43 +0100 Subject: [PATCH] d_a_dr2 (#818) --- configure.py | 2 +- include/d/actor/d_a_btd.h | 11 +- include/d/actor/d_a_dr2.h | 87 ++++- src/d/actor/d_a_dr2.cpp | 781 ++++++++++++++++++++++++++++++++++++-- src/d/actor/d_a_kui.cpp | 6 +- 5 files changed, 834 insertions(+), 53 deletions(-) diff --git a/configure.py b/configure.py index e0a734a0b..69d20255d 100755 --- a/configure.py +++ b/configure.py @@ -1364,7 +1364,7 @@ config.libs = [ ActorRel(Matching, "d_a_demo_kmm"), ActorRel(NonMatching, "d_a_door10"), ActorRel(Matching, "d_a_dr"), - ActorRel(NonMatching, "d_a_dr2"), + ActorRel(Equivalent, "d_a_dr2"), ActorRel(NonMatching, "d_a_ep"), ActorRel(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d_a_floor"), ActorRel(Matching, "d_a_grass"), diff --git a/include/d/actor/d_a_btd.h b/include/d/actor/d_a_btd.h index 2039f2f1d..56bef9288 100644 --- a/include/d/actor/d_a_btd.h +++ b/include/d/actor/d_a_btd.h @@ -6,9 +6,16 @@ class btd_class : public fopAc_ac_c { public: /* Place member variables here */ - /* 0x0290 */ u8 field_0x290[0x2e4 - 0x290]; + /* 0x0290 */ u8 field_0x0290[0x2e4 - 0x290]; /* 0x02E4 */ s16 field_0x2e4; - /* 0x02E6 */ u8 field_0x2e6[0x6e16 - 0x2e6]; + /* 0x02E6 */ u8 field_0x02E6[0x02F6 - 0x2e6]; + /* 0x02F6 */ bool field_0x2F6; + /* 0x02F7 */ u8 field_0x02F7[0x0320 - 0x02F7]; + /* 0x0320 */ cXyz field_0x320; + /* 0x032C */ cXyz field_0x32C; + /* 0x0338 */ u8 field_0x0338[0x0360 - 0x0338]; + /* 0x0360 */ f32 field_0x360; + /* 0x0364 */ u8 field_0x0364[0x6E16 - 0x0364]; /* 0x6E16 */ s16 field_0x6e16; }; diff --git a/include/d/actor/d_a_dr2.h b/include/d/actor/d_a_dr2.h index a20eeea15..20d230238 100644 --- a/include/d/actor/d_a_dr2.h +++ b/include/d/actor/d_a_dr2.h @@ -2,22 +2,83 @@ #define D_A_DR2_H #include "f_op/f_op_actor.h" +#include "d/d_particle.h" -class dr2_class : public fopAc_ac_c { -public: - /* 0x290 */ u8 field_0x290[0x3B0 - 0x290]; - /* 0x3B0 */ cXyz field_0x3B0; - /* 0x3BC */ u8 field_0x3BC[0x4BA - 0x3BC]; - /* 0x4BA */ s16 field_0x4BA; - /* 0x4BC */ u8 field_0x4BC[0x50C - 0x4BC]; -}; +class dBgW; +class mDoExt_McaMorf; +class mDoExt_btkAnm; +class mDoExt_brkAnm; +class btd_class; -class daDr2_HIO_c { -public: - daDr2_HIO_c(); +struct iwa_hahen_s { + iwa_hahen_s() {} + ~iwa_hahen_s() {} + /* 0x00 */ J3DModel* mpModel; + /* 0x04 */ bool unk_04; + /* 0x08 */ cXyz unk_08; + /* 0x14 */ cXyz unk_14; + /* 0x20 */ csXyz unk_20; +}; // size = 0x28 + +class dr2_class { public: - /* Place member variables here */ -}; + /* 0x000 */ fopEn_enemy_c actor; + /* 0x2AC */ request_of_phase_process_class mPhase; + /* 0x2B4 */ mDoExt_McaMorf* mpMorf1; + /* 0x2B8 */ mDoExt_McaMorf* mpMorf2; + /* 0x2BC */ s16 unk_2BC; + /* 0x2C0 */ iwa_hahen_s mRockFragments[6]; + /* 0x3B0 */ cXyz unk_3B0; + /* 0x3BC */ s16 unk_3BC[12]; + /* 0x3D4 */ s16 unk_3D4[12]; + /* 0x3EC */ f32 unk_3EC; + /* 0x3F0 */ f32 unk_3F0; + /* 0x3F4 */ f32 unk_3F4; + /* 0x3F8 */ f32 unk_3F8; + /* 0x3FC */ fpc_ProcID unk_3FC; + /* 0x400 */ s16 unk_400[5]; + /* 0x40A */ u8 unk_40A; + /* 0x40C */ f32 unk_40C; + /* 0x410 */ f32 unk_410; + /* 0x414 */ f32 unk_414; + /* 0x418 */ J3DModel* unk_418; + /* 0x41C */ J3DModel* unk_41C; + /* 0x420 */ mDoExt_btkAnm* unk_420; + /* 0x424 */ s16 unk_424; + /* 0x428 */ J3DModel* unk_428; + /* 0x42C */ J3DModel* unk_42C; + /* 0x430 */ mDoExt_btkAnm* unk_430; + /* 0x434 */ mDoExt_btkAnm* unk_434; + /* 0x438 */ mDoExt_brkAnm* unk_438; + /* 0x43C */ bool unk_43C; + /* 0x440 */ Mtx unk_440; + /* 0x470 */ Mtx unk_470; + /* 0x4A0 */ dBgW* mpBgW1; + /* 0x4A4 */ dBgW* mpBgW2; + /* 0x4A8 */ cXyz unk_4A8; + /* 0x4B6 */ csXyz unk_4B4; + /* 0x4BA */ s16 unk_4BA; + /* 0x4BC */ u8 field_0x4BC[0x4C0 - 0x4BC]; + /* 0x4C0 */ f32 unk_4C0; + /* 0x4C4 */ u8 unk_4C4; + /* 0x4C6 */ s16 unk_4C6; + /* 0x4C8 */ s16 unk_4C8; + /* 0x4CA */ s16 unk_4CA; + /* 0x4CC */ s16 unk_4CC; + /* 0x4CE */ s16 unk_4CE; + /* 0x4D0 */ f32 unk_4D0; +#if VERSION == VERSION_DEMO + /* 0x4D4 */ JPABaseEmitter* unk_4D4_demo; +#endif + /* 0x4D4 */ JPABaseEmitter* unk_4D4; + /* 0x4D8 */ dPa_followEcallBack unk_4D8; + /* 0x4EC */ dPa_smokeEcallBack unk_4EC; + /* 0x50C */ bool unk_50C; + /* 0x50D */ u8 unk_50D; + /* 0x50E */ u8 unk_50E; + /* 0x510 */ s16 unk_510; + /* 0x514 */ btd_class* unk_514; +}; // size = 0x518 #endif /* D_A_DR2_H */ diff --git a/src/d/actor/d_a_dr2.cpp b/src/d/actor/d_a_dr2.cpp index 1e133ca43..061c6ef5a 100644 --- a/src/d/actor/d_a_dr2.cpp +++ b/src/d/actor/d_a_dr2.cpp @@ -4,78 +4,629 @@ */ #include "d/actor/d_a_dr2.h" +#include "d/res/res_dr2.h" #include "m_Do/m_Do_ext.h" #include "d/d_procname.h" #include "d/d_priority.h" +#include "d/d_bg_w.h" +#include "d/d_s_play.h" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_btd.h" +#include "d/d_com_inf_game.h" +#include "m_Do/m_Do_ext.h" +#include "f_op/f_op_actor_mng.h" +#include "d/d_bg_s_movebg_actor.h" + +class daDr2_HIO_c : public JORReflexible { +public: + daDr2_HIO_c(); + virtual ~daDr2_HIO_c() {} + + void genMessage(JORMContext* ctx); + +public: + /* 0x04 */ s8 m04; + /* 0x08 */ f32 m08; +}; // size = 0xC + +static daDr2_HIO_c l_HIO; + +static f32 hsx[] = { -10.0f, -10.0f, 0.0f, 10.0f, 10.0f, 0.0f }; +static f32 hsz[] = { -7.0f, 7.0f, 12.0f, 7.0f, -7.0f, -12.0f }; /* 000000EC-00000110 .text __ct__11daDr2_HIO_cFv */ -daDr2_HIO_c::daDr2_HIO_c() { - /* Nonmatching */ +daDr2_HIO_c::daDr2_HIO_c() { + m04 = -1; + m08 = 1.0f; +} + +static BOOL daDr2_ToFore(dr2_class*) { + return TRUE; +} + +static BOOL daDr2_ToBack(dr2_class*) { + return TRUE; +} + +static void anm_init(dr2_class*, int, float, unsigned char, float, int) { + *(f32*)NULL = 0.0f; + *(f32*)NULL = -1.0f; } /* 00000110-00000380 .text nodeCallBack__FP7J3DNodei */ -static BOOL nodeCallBack(J3DNode*, int) { - /* Nonmatching */ +static BOOL nodeCallBack(J3DNode* node, int calcTiming) { + J3DJoint* joint = (J3DJoint*)node; + + if (calcTiming == 0) { + s32 jntNo = joint->getJntNo(); + J3DModel* model = j3dSys.getModel(); + dr2_class* i_this = (dr2_class*)model->getUserArea(); + + if (i_this != NULL) { + MTXCopy(model->getAnmMtx(jntNo), *calc_mtx); + + if (i_this->unk_40A == 3) { + if ((jntNo - 3 <= 8u) || (jntNo == 2)) { + cMtx_YrotM(*calc_mtx, i_this->unk_400[jntNo - 0x22]); + cMtx_ZrotM(*calc_mtx, i_this->unk_400[jntNo - 0x16]); + model->setAnmMtx(jntNo, *calc_mtx); + MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); + } + } else if (i_this->unk_40A == 1) { + MtxScale(i_this->unk_40C, 1.0f, 1.0f, true); + model->setAnmMtx(jntNo, *calc_mtx); + + if ((jntNo <= 3u) || (jntNo == 4)) { + MtxRotY(i_this->unk_3EC,1); + MtxRotZ(i_this->unk_3F0,1); + model->setAnmMtx(jntNo, *calc_mtx); + MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); + } + } else if ((jntNo - 5 <= 6u) || (jntNo == 4)) { + if (i_this->unk_40A == 2) { + cMtx_YrotM(*calc_mtx, i_this->unk_3BC[0]); + cMtx_ZrotM(*calc_mtx, i_this->unk_3D4[0]); + } else { + MtxRotY(i_this->unk_3EC,1); + MtxRotZ(i_this->unk_3F0,1); + } + model->setAnmMtx(jntNo, *calc_mtx); + MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); + } + + if (jntNo == 11) { + cXyz sp08; + sp08.x = REG0_F(0) + 210.0f + 5.0f; + sp08.y = REG0_F(1); + sp08.z = REG0_F(2) + -10.0f + 5.0f; + MtxPosition(&sp08, &i_this->unk_3B0); + } + } + } + return TRUE; } /* 00000380-000003F4 .text hahen_draw__FP9dr2_class */ -void hahen_draw(dr2_class*) { - /* Nonmatching */ +void hahen_draw(dr2_class* i_this) { + iwa_hahen_s * fragment = i_this->mRockFragments; + for (s32 i = 0; i < 6; i++, fragment++) { + if (fragment->unk_04) { + g_env_light.setLightTevColorType(fragment->mpModel, &i_this->actor.tevStr); + mDoExt_modelUpdate(fragment->mpModel); + } + } } /* 000003F4-0000048C .text iwa_draw__FP9dr2_class */ -void iwa_draw(dr2_class*) { - /* Nonmatching */ +void iwa_draw(dr2_class* i_this) { + if (i_this->unk_4BA < 10) { + g_env_light.setLightTevColorType(i_this->unk_418, &i_this->actor.tevStr); + mDoExt_modelUpdateDL(i_this->unk_418); + if (i_this->unk_424 != 0) { + J3DModelData* modelData = i_this->unk_41C->getModelData(); + i_this->unk_420->entry(modelData, i_this->unk_420->getFrame()); + g_env_light.setLightTevColorType(i_this->unk_41C, &i_this->actor.tevStr); + mDoExt_modelUpdateDL(i_this->unk_41C); + } + } + hahen_draw(i_this); } /* 0000048C-00000594 .text dr_draw__FP9dr2_class */ -void dr_draw(dr2_class*) { - /* Nonmatching */ +void dr_draw(dr2_class* i_this) { + if (i_this->unk_50C) { + J3DModel* model = i_this->mpMorf2->getModel(); + mDoMtx_stack_c::transS(0.0f, REG0_F(5) + 10000.0f + 9720.0f, 0.0f); + + cXyz sp08; + sp08.x = sp08.y = sp08.z = REG0_F(6) + 1.0f; + model->setBaseScale(sp08); + model->setBaseTRMtx(mDoMtx_stack_c::get()); + + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->actor.current.pos, &i_this->actor.tevStr); + g_env_light.setLightTevColorType(model, &i_this->actor.tevStr); + + i_this->mpMorf2->play(NULL, 0, 0); + i_this->mpMorf2->calc(); + i_this->mpMorf2->entryDL(); + } } /* 00000594-0000064C .text yuka_draw__FP9dr2_class */ -void yuka_draw(dr2_class*) { - /* Nonmatching */ +void yuka_draw(dr2_class* i_this) { + J3DModelData* modelData; + + if (!i_this->unk_43C) { + g_env_light.setLightTevColorType(i_this->unk_428, &i_this->actor.tevStr); + modelData = i_this->unk_428->getModelData(); + i_this->unk_430->entry(modelData, i_this->unk_430->getFrame()); + mDoExt_modelUpdateDL(i_this->unk_428); + } else { + g_env_light.setLightTevColorType(i_this->unk_42C, &i_this->actor.tevStr); + modelData = i_this->unk_42C->getModelData(); + i_this->unk_434->entry(modelData, i_this->unk_434->getFrame()); + modelData = i_this->unk_42C->getModelData(); + i_this->unk_438->entry(modelData, i_this->unk_438->getFrame()); + mDoExt_modelUpdateDL(i_this->unk_42C); + } } /* 0000064C-000006D4 .text daDr2_Draw__FP9dr2_class */ -static BOOL daDr2_Draw(dr2_class*) { - /* Nonmatching */ +static BOOL daDr2_Draw(dr2_class* i_this) { + J3DModel* model = i_this->mpMorf1->getModel(); + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->actor.current.pos, &i_this->actor.tevStr); + g_env_light.setLightTevColorType(model, &i_this->actor.tevStr); + i_this->mpMorf1->entryDL(); + iwa_draw(i_this); + yuka_draw(i_this); + dr_draw(i_this); + return TRUE; } /* 000006D4-00000720 .text s_a_d_sub__FPvPv */ -void s_a_d_sub(void*, void*) { - /* Nonmatching */ +void* s_a_d_sub(void* ac1, void* ac2) { + if (fopAcM_IsActor(ac1) && fopAcM_GetName(ac1) == PROC_BTD) { + return ac1; + } + return NULL; } /* 00000720-00000884 .text hahen_move__FP9dr2_class */ -void hahen_move(dr2_class*) { - /* Nonmatching */ +void hahen_move(dr2_class* i_this) { + iwa_hahen_s* fragment = &i_this->mRockFragments[0]; + + for (s32 i = 0; i < 6; i++, fragment++) { + if (fragment->unk_04) { + fragment->unk_08 += fragment->unk_14; + if (i & 1) { + fragment->unk_20.z += REG0_S(4) + 300; + fragment->unk_20.x += REG0_S(3) + 256; + } else { + fragment->unk_20.z -= REG0_S(4) + 300; + fragment->unk_20.x -= REG0_S(3) + 256; + } + fragment->unk_14.y -= REG0_F(7) + 0.5f; + MtxTrans(fragment->unk_08.x, fragment->unk_08.y, fragment->unk_08.z, false); + cMtx_YrotM(*calc_mtx, fragment->unk_20.y); + cMtx_XrotM(*calc_mtx, fragment->unk_20.x); + cMtx_ZrotM(*calc_mtx, fragment->unk_20.z); + + fragment->mpModel->setBaseTRMtx(*calc_mtx); + + if (fragment->unk_08.y < -100.0f) { + fragment->unk_04 = false; + } + } + } } /* 00000884-0000130C .text iwa_move__FP9dr2_class */ -void iwa_move(dr2_class*) { - /* Nonmatching */ +void iwa_move(dr2_class* i_this) { + fopAc_ac_c* a_this = &i_this->actor; + cXyz sp58; + cXyz sp4C; + cXyz sp40; + + if (i_this->unk_514 == NULL) { + i_this->unk_514 = (btd_class*)fpcM_Search(s_a_d_sub, &i_this->actor); + } + + btd_class* btd = i_this->unk_514; + if (i_this->unk_4CA != 0) { + i_this->unk_4CA--; + } + + switch(i_this->unk_4BA) { + case -1: + if (std::fabsf(a_this->current.pos.y - a_this->home.pos.y) > 200.0f) { + i_this->unk_410 = 0.0f; + } + + if (i_this->unk_4C8 == 0) { + cLib_addCalc2(&a_this->current.pos.y, a_this->home.pos.y, 0.5f, 30.0f); + + if (std::fabsf(a_this->current.pos.y - a_this->home.pos.y) < 1.0f) { + i_this->unk_4BA = 0; + } + } else { + i_this->unk_4C8--; + } + + case 0: + cLib_addCalcAngleS2(&i_this->unk_4B4.x, 0, 1, 0x100); + cLib_addCalcAngleS2(&i_this->unk_4B4.y, 0, 1, 0x100); + + if (i_this->unk_40A == 1 || i_this->unk_4CA != 0) { + if (i_this->unk_4CC == 0) { + i_this->unk_4CC = REG0_S(5) + 3; + i_this->unk_4CE = cM_rndFX(REG0_F(7) + 300.0f); + i_this->unk_4D0 = cM_rndFX(REG0_F(6) + 20.0f); + if (!i_this->unk_50E) { + i_this->unk_50D = REG0_S(5) + 1; + i_this->unk_50E = true; + i_this->unk_510 = 20; + fopAcM_seStartCurrent(a_this, JA_SE_CM_BTD_STN_FALL, 0); + } + } else { + i_this->unk_4CC--; + } + } else { + i_this->unk_4CE = 0; + i_this->unk_4D0 = 0.0f; + } + + cLib_addCalcAngleS2(&i_this->unk_4B4.z, i_this->unk_4CE, 1, REG0_S(6) + 0x100); + cLib_addCalc2(&i_this->unk_4A8.y, (i_this->unk_4D0 + a_this->home.pos.y) - 50.0f, 0.5f, 50.0f); + + if (i_this->unk_4CA == 1) { + i_this->unk_4BA++; + i_this->unk_50D = REG0_S(2) + 30; + i_this->unk_50E = true; + i_this->unk_510 = 1; + dComIfGp_particle_setToon(dPa_name::ID_SCENE_A0B8, &i_this->unk_4A8, &i_this->unk_4B4, NULL, 0xb9, &i_this->unk_4EC, fopAcM_GetRoomNo(a_this)); + fopAcM_seStartCurrent(a_this, JA_SE_CM_BTD_ROCK_FALL, 0); + } + break; + + case 1: + i_this->unk_4A8.y += a_this->speed.y; + a_this->speed.y -= REG0_F(2) + 10.0f; + + f32 fVar11 = btd->field_0x320.y + REG0_F(3); + if (i_this->unk_4A8.y < fVar11) { + i_this->unk_4A8.y = fVar11; + i_this->unk_4BA = 2; + i_this->unk_400[0] = 0x32; + btd->field_0x2F6 = true; + fopAcM_seStartCurrent(a_this, JA_SE_CM_BTD_ROCK_HIT, 0); + dComIfGp_getVibration().StartShock(REG0_S(2) + 5, -0x21, cXyz(0.0f, 1.0f, 0.0f)); + } + break; + + case 2: + i_this->unk_40A = 3; + cLib_addCalc2(&i_this->unk_414, 2000.0f, 0.5f, 100.0f); + + i_this->unk_4A8.y = btd->field_0x320.y + REG0_F(3); + i_this->unk_4B4.y = i_this->unk_514->current.angle.y; + + if (btd->field_0x320.y < REG0_F(6) + 100.0f) { + i_this->unk_4C0 = (REG0_F(6) + 100.0f) - btd->field_0x320.y; + i_this->unk_4C0 *= REG0_F(7) + 0.3f; + } + + sp4C = btd->field_0x320 - btd->field_0x32C; + sp4C.y += REG0_F(5) + -330.0f + i_this->unk_4C0; + cLib_addCalcAngleS2(&i_this->unk_4B4.x, -cM_atan2s(sp4C.y, std::sqrtf(sp4C.x * sp4C.x + sp4C.z * sp4C.z)), 1, 0x200); + + if (!btd->field_0x2F6) { + i_this->unk_4BA = 3; +#if VERSION == VERSION_DEMO + i_this->unk_4D4_demo = +#endif + dComIfGp_particle_set(dPa_name::ID_SCENE_80B7, &i_this->unk_4A8, &i_this->unk_4B4, NULL, 0xFF, &i_this->unk_4D8); + i_this->unk_424 = 1; + } + break; + + case 3: + i_this->unk_4A8.y = btd->field_0x360 + 100.0f + REG0_F(9); + cLib_addCalcAngleS2(&i_this->unk_4B4.x, 0, 1, 0x100); + cLib_addCalcAngleS2(&i_this->unk_4B4.y, 0, 1, 0x100); + + if (i_this->unk_4A8.y > a_this->home.pos.y - 1200.0f) { + a_this->current.pos.y += REG0_F(9) + 100.0f; + i_this->unk_40A = 0; + } + + if (i_this->unk_4A8.y > a_this->home.pos.y - 50.0f) { + i_this->unk_4A8.y = a_this->home.pos.y - 50.0f; + i_this->unk_4BA = -1; + i_this->unk_4C8 = 0x82; + a_this->speed.y = 0.0f; + i_this->unk_4C0 = 0.0f; +#if VERSION == VERSION_DEMO + if (i_this->unk_4D4_demo != NULL) { + i_this->unk_4D4_demo->becomeInvalidEmitter(); + i_this->unk_4D4_demo = NULL; + } +#else + i_this->unk_4D8.remove(); +#endif + dComIfGp_particle_setToon(dPa_name::ID_SCENE_A0B8, &i_this->unk_4A8, &i_this->unk_4B4, NULL, 0xb9, &i_this->unk_4EC, fopAcM_GetRoomNo(a_this)); + + i_this->unk_50D = REG0_S(2) + 10; + i_this->unk_50E = true; + i_this->unk_510 = 2; + + dComIfGp_getVibration().StartShock(REG0_S(2) + 5, -0x21, cXyz(0.0f, 1.0f, 0.0f)); + fopAcM_seStartCurrent(a_this, JA_SE_CM_BTD_ROCK_ATTACH, 0); + } + break; + + case 10: + i_this->unk_4BA++; + + iwa_hahen_s* fragment = &i_this->mRockFragments[0]; + for (s32 i = 0; i < 6; i++, fragment++) { + if (!fragment->unk_04) { + fragment->unk_04 = true; + fragment->unk_08 = i_this->unk_4A8; + fragment->unk_20 = i_this->unk_4B4; + cMtx_YrotS(*calc_mtx, fragment->unk_20.y); + cMtx_XrotM(*calc_mtx, fragment->unk_20.x); + sp58.x = (REG0_F(2) + 3.0f) * hsx[i]; + sp58.y = 0.0f; + sp58.z = (REG0_F(2) + 3.0f) * hsz[i]; + MtxPosition(&sp58, &fragment->unk_14); + } + } + + case 11: + i_this->unk_40A = 0; + break; + } + + switch (i_this->unk_50E) { + case 1: + if (i_this->unk_4D4 != NULL) { + i_this->unk_4D4->becomeInvalidEmitter(); + } + + i_this->unk_4D4 = dComIfGp_particle_set(dPa_name::ID_SCENE_80B9, &i_this->unk_4A8); + if (i_this->unk_4D4 != NULL) { + i_this->unk_4D4->setRate(i_this->unk_50D); + i_this->unk_50E++; + } + break; + + case 2: + if (i_this->unk_510 != 0) { + i_this->unk_510--; + if (i_this->unk_510 == 0 +#if VERSION > VERSION_DEMO + && i_this->unk_4D4 != NULL +#endif + ) { + i_this->unk_4D4->becomeInvalidEmitter(); + } + } + +#if VERSION > VERSION_DEMO + if (i_this->unk_4D4 != NULL) +#endif + { + if (i_this->unk_4D4->isEnableDeleteEmitter()) { + i_this->unk_50E = false; + i_this->unk_4D4 = NULL; + break; + } + } + + JSUList* list = i_this->unk_4D4->getParticleList(); + JSULink* link = list->getFirst(); + while (link != list->getEnd()) { + JGeometry::TVec3 tvec; + link->getObject()->getGlobalPosition(tvec); + sp40.x = tvec.x; + sp40.y = tvec.y; + sp40.z = tvec.z; + dComIfGp_particle_setSimple(dPa_name::ID_SCENE_8062, &sp40, 0xB9); + link = link->getNext(); + } + break; + } + + if (i_this->unk_424 != 0) { + i_this->unk_420->setFrame(i_this->unk_424); + i_this->unk_424++; + if (i_this->unk_424 > 180) { + i_this->unk_424 = 0; + } + } + + hahen_move(i_this); } /* 0000130C-0000172C .text move__FP9dr2_class */ -void move(dr2_class*) { - /* Nonmatching */ +void move(dr2_class* i_this) { + fopAc_ac_c* a_this = &i_this->actor; + daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); + fopAc_ac_c* foundActor = fopAcM_SearchByID(i_this->unk_3FC); + s16 atan; + f32 atanF; + + if (i_this->unk_40A == 3) { + for (s32 i = 2; i < 12; i++) { + i_this->unk_3BC[i] = i_this->unk_414 * cM_ssin(i_this->unk_2BC * 2800 + i * 3000); + i_this->unk_3D4[i] = i_this->unk_414 * cM_scos(i_this->unk_2BC * 2300 + i * 2000); + } + } else { + i_this->unk_40A = 0; + if (foundActor != NULL && foundActor->health == 3) { + cXyz sp30 = player->getLeftHandPos() - foundActor->current.pos; + cXyz sp24; + + cMtx_YrotS(*calc_mtx, -player->shape_angle.y); + MtxPosition(&sp30, &sp24); + + s32 atan = cM_atan2s(sp24.z, -sp24.y); + i_this->actor.current.angle.y = player->shape_angle.y; + s16 atan2 = atan; + atan2 *= (REG0_F(3) + -0.125f); + + cLib_addCalcAngleS2(&i_this->unk_3BC[0], atan2, 0x10, 0x40); + cLib_addCalcAngleS2(&i_this->unk_3D4[0], 0, 0x10, 0x40); + i_this->unk_40A = 2; + } else if (foundActor != NULL && foundActor->health == 2) { + i_this->unk_40A = 1; +#if VERSION == VERSION_DEMO + i_this->actor.current.angle.y = fopAcM_searchPlayerAngleY(&i_this->actor); +#else + i_this->actor.current.angle.y = fopAcM_searchPlayerAngleY(a_this); +#endif + player->shape_angle.y = i_this->actor.current.angle.y - -0x8000; + player->current.angle.y = i_this->actor.current.angle.y - -0x8000; + + cLib_addCalc2(&i_this->unk_3EC, REG0_F(9) + -0.175f, 0.5f, REG0_F(10) + 0.0125f); + cLib_addCalc0(&i_this->unk_3F0, 0.5f, 0.10000000149011612f); + + if (i_this->unk_3EC < -0.1f) { + cLib_addCalc2(&i_this->unk_40C, 1.04f, 0.1f, REG0_F(14) + 0.005f); + } + } else { + i_this->unk_40C = 0.98f; + i_this->actor.current.angle.y = i_this->actor.home.angle.y; + + i_this->unk_3F4 += 0.04f; + if (i_this->unk_3F4 > 6.2831855f) { + i_this->unk_3EC -= 6.2831855f; + } + + i_this->unk_3F8 += 0.05f; + if (i_this->unk_3F8 > 6.2831855f) { + i_this->unk_3F0 -= 6.2831855f; + } + + i_this->unk_3EC = i_this->unk_410 * cM_fsin(i_this->unk_3F4); + i_this->unk_3F0 = i_this->unk_410 * cM_fsin(i_this->unk_3F8); + + if (foundActor != NULL && foundActor->health == 1) { + cLib_addCalc2(&i_this->unk_410, 0.0f, 0.5f, 0.001f); + i_this->unk_4CC = 20; + } else { + cLib_addCalc2(&i_this->unk_410, 0.048f, 0.5f, 0.001f); + } + } + } + + i_this->mpMorf1->play(&a_this->eyePos, 0, 0); + i_this->mpMorf1->calc(); } /* 0000172C-00001810 .text dr_move__FP9dr2_class */ -void dr_move(dr2_class*) { - /* Nonmatching */ +void dr_move(dr2_class* i_this) { + if (i_this->unk_4C6 != 0) { + i_this->unk_4C6--; + } + + switch (i_this->unk_4C4) { + case 0: + if (i_this->unk_50C) { + i_this->unk_4C6 = 0; + J3DAnmTransform* pAnimRes = (J3DAnmTransform*)dComIfG_getObjectRes("Dr2", DR2_BCK_DR_BOSS_DEMO1); + i_this->mpMorf2->setAnm(pAnimRes, 0, 1.0f, 1.0f, 0.0f, -1.0f, NULL); + i_this->unk_4C4 = 1; + } + break; + + case 1: + if (!i_this->unk_50C) { + i_this->unk_4C4 = false; + } + break; + + } } /* 00001810-000019B8 .text yuka_move__FP9dr2_class */ -void yuka_move(dr2_class*) { - /* Nonmatching */ +void yuka_move(dr2_class* i_this) { + if (dComIfGs_isStageBossEnemy() +#if VERSION > VERSION_DEMO + && (dComIfGp_getStartStageName()[0] != 'X') +#endif +) { + i_this->unk_43C = true; + i_this->unk_434->setFrame(299.0f); + i_this->unk_438->setFrame(299.0f); + } + + Mtx sp08; + MTXScale(sp08, REG0_F(9) + 1.0f, REG0_F(9) + 1.0f, REG0_F(9) + 1.0f); + + if (i_this->unk_43C) { + MtxTrans(0.0f, -10000.0f, 0.0f, false); + } else { + MtxTrans(0.0f, 0.0f, 0.0f, false); + i_this->unk_430->play(); + } + + i_this->unk_428->setBaseTRMtx(*calc_mtx); + MTXConcat(*calc_mtx, sp08, i_this->unk_440); + + i_this->mpBgW1->Move(); + if (!i_this->unk_43C) { + MtxTrans(0.0f, -10000.0f, 0.0f, false); + } else { + MtxTrans(0.0f, 0.0f, 0.0f, false); + i_this->unk_434->play(); + i_this->unk_438->play(); + } + + i_this->unk_42C->setBaseTRMtx(*calc_mtx); + MTXConcat(*calc_mtx, sp08, i_this->unk_470); + i_this->mpBgW2->Move(); } /* 000019B8-00001B90 .text daDr2_Execute__FP9dr2_class */ -static BOOL daDr2_Execute(dr2_class*) { - /* Nonmatching */ +static BOOL daDr2_Execute(dr2_class* i_this) { + i_this->unk_2BC++; + + for (s32 i = 0; i < 5; i++) { + if (i_this->unk_400[i] != 0) { + i_this->unk_400[i]--; + } + } + + move(i_this); + + fopAcM_SearchByID(i_this->unk_3FC); + i_this->actor.scale.x = i_this->actor.scale.y = i_this->actor.scale.z = l_HIO.m08; + + J3DModel* model = i_this->mpMorf1->getModel(); + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, &i_this->actor.current.pos, &i_this->actor.tevStr); + g_env_light.setLightTevColorType(model, &i_this->actor.tevStr); + model->setBaseScale(i_this->actor.scale); + mDoMtx_stack_c::transS(i_this->actor.current.pos.x, i_this->actor.current.pos.y, i_this->actor.current.pos.z); + mDoMtx_stack_c::YrotM(i_this->actor.current.angle.y); + model->setBaseTRMtx(mDoMtx_stack_c::get()); + + iwa_move(i_this); + + mDoMtx_stack_c::transS(i_this->unk_4A8.x, i_this->unk_4A8.y, i_this->unk_4A8.z); + + mDoMtx_stack_c::YrotM(i_this->unk_4B4.y); + mDoMtx_stack_c::XrotM(i_this->unk_4B4.x); + mDoMtx_stack_c::YrotM(i_this->actor.home.angle.y); + mDoMtx_stack_c::ZrotM(i_this->unk_4B4.z); + mDoMtx_stack_c::YrotM(-i_this->unk_4B4.y); + + i_this->unk_418->setBaseTRMtx(mDoMtx_stack_c::get()); + i_this->unk_41C->setBaseTRMtx(mDoMtx_stack_c::get()); + + dr_move(i_this); + yuka_move(i_this); + return TRUE; } /* 00001B90-00001B98 .text daDr2_IsDelete__FP9dr2_class */ @@ -84,18 +635,180 @@ static BOOL daDr2_IsDelete(dr2_class*) { } /* 00001B98-00001C58 .text daDr2_Delete__FP9dr2_class */ -static BOOL daDr2_Delete(dr2_class*) { - /* Nonmatching */ +static BOOL daDr2_Delete(dr2_class* i_this) { + dComIfG_resDeleteDemo(&i_this->mPhase, "Dr2"); + mDoHIO_deleteChild(l_HIO.m04); + i_this->unk_4D8.remove(); + i_this->unk_4EC.remove(); +#if VERSION > VERSION_DEMO + mDoAud_seDeleteObject(&i_this->unk_4A8); +#endif + dComIfG_Bgsp()->Release(i_this->mpBgW1); + dComIfG_Bgsp()->Release(i_this->mpBgW2); + return TRUE; } /* 00001C58-00002458 .text useHeapInit__FP10fopAc_ac_c */ -static BOOL useHeapInit(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL useHeapInit(fopAc_ac_c* a_this) { + dr2_class* i_this = (dr2_class*)a_this; + + i_this->mpMorf1 = new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BMD_DR_SIPPO), NULL, NULL, NULL, J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, 0, NULL, 0, 0x11020203); + + if ((i_this->mpMorf1 == NULL) || (i_this->mpMorf1->mpModel == NULL)) { + return FALSE; + } + + for (u16 i = 0; i < i_this->mpMorf1->getModel()->getModelData()->getJointNum(); i++) { + i_this->mpMorf1->getModel()->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); + } + i_this->mpMorf1->getModel()->setUserArea((u32)i_this); + + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BDL_IWA00); + JUT_ASSERT(VERSION_SELECT(1347, 1361, 1361, 1361), modelData != NULL); + + i_this->unk_418 = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (i_this->unk_418 == NULL) { + return FALSE; + } + + modelData = (J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BMD_GAN_MAGMA); + JUT_ASSERT(VERSION_SELECT(1356, 1370, 1370, 1370), modelData != NULL); + + i_this->unk_41C = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (i_this->unk_41C == NULL) { + return FALSE; + } + + i_this->unk_420 = new mDoExt_btkAnm(); + if (i_this->unk_420 == NULL) { + return FALSE; + } + + J3DAnmTextureSRTKey* srtKey = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes("Dr2", DR2_BTK_GAN_MAGMA); + BOOL init = i_this->unk_420->init(i_this->unk_41C->getModelData(), srtKey, true, J3DFrameCtrl::EMode_NONE, 1.0f, 0, -1, false, 0); +#if VERSION > VERSION_DEMO + if (!init) { + return FALSE; + } +#endif + + for (s32 i = 0; i < 6; i++) { + static s32 hahen_model[] = { 15, 16, 17, 18, 19, 20 }; + + modelData = (J3DModelData*)dComIfG_getObjectRes("Dr2", hahen_model[i]); + i_this->mRockFragments[i].mpModel = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (i_this->mRockFragments[i].mpModel == NULL) { + return FALSE; + } + } + + i_this->mpMorf2 = new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BMD_DR), + NULL, NULL, (J3DAnmTransformKey*)dComIfG_getObjectRes("Dr2", DR2_BCK_DR_BOSS_DEMO1), + J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, 0, NULL, 0, 0x11020203); + + if (i_this->mpMorf2 == NULL || i_this->mpMorf2->mpModel == NULL) { + return FALSE; + } + + modelData = (J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BMD_MBYO1); + JUT_ASSERT(VERSION_SELECT(1405, 1429, 1429, 1429), modelData != NULL); + + i_this->unk_428 = mDoExt_J3DModel__create(modelData, 0, 0x11020203); + if (i_this->unk_428 == NULL) { + return FALSE; + } + + modelData = (J3DModelData*)dComIfG_getObjectRes("Dr2", DR2_BMD_MBYO2); + JUT_ASSERT(VERSION_SELECT(1412, 1436, 1436, 1436), modelData != NULL); + + i_this->unk_42C = mDoExt_J3DModel__create(modelData,0,0x11020203); + if (i_this->unk_42C == NULL) { + return FALSE; + } + + i_this->unk_430 = new mDoExt_btkAnm(); + if (i_this->unk_430 == NULL) { + return FALSE; + } + + srtKey = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes("Dr2", DR2_BTK_MBYO1); + if (!i_this->unk_430->init(i_this->unk_428->getModelData(), srtKey, true, J3DFrameCtrl::EMode_LOOP, 1.0f, 0, -1, false, 0)) { + return FALSE; + } + + i_this->unk_434 = new mDoExt_btkAnm(); + if (i_this->unk_434 == NULL) { + return FALSE; + } + + srtKey = (J3DAnmTextureSRTKey*)dComIfG_getObjectRes("Dr2", DR2_BTK_MBYO2); + if (!i_this->unk_434->init(i_this->unk_42C->getModelData(), srtKey, true, J3DFrameCtrl::EMode_NONE, 1.0f, 0, -1, false, 0)) { + return FALSE; + } + + i_this->unk_438 = new mDoExt_brkAnm(); + if (i_this->unk_438 == NULL) { + return FALSE; + } + + J3DAnmTevRegKey* tevRegKey = (J3DAnmTevRegKey*)dComIfG_getObjectRes("Dr2", DR2_BRK_MBYO2); + if (!i_this->unk_438->init(i_this->unk_42C->getModelData(), tevRegKey, true, J3DFrameCtrl::EMode_NONE, 1.0f, 0, -1, false, 0)) { + return FALSE; + } + + i_this->mpBgW1 = new dBgW(); + if (i_this->mpBgW1 == NULL) { + return FALSE; + } + + i_this->mpBgW2 = new dBgW(); + if (i_this->mpBgW2 == NULL) { + return FALSE; + } + + cBgD_t* cBgD = (cBgD_t*)dComIfG_getObjectRes("Dr2", DR2_DZB_MBYO1); + i_this->mpBgW1->Set(cBgD, dBgW::MOVE_BG_e, &i_this->unk_440); + i_this->mpBgW1->SetCrrFunc(dBgS_MoveBGProc_Typical); + + cBgD = (cBgD_t*)dComIfG_getObjectRes("Dr2", DR2_DZB_MBYO2); + i_this->mpBgW2->Set(cBgD, dBgW::MOVE_BG_e, &i_this->unk_470); + i_this->mpBgW2->SetCrrFunc(dBgS_MoveBGProc_Typical); + + return TRUE; } /* 000024A0-00002668 .text daDr2_Create__FP10fopAc_ac_c */ -static cPhs_State daDr2_Create(fopAc_ac_c*) { - /* Nonmatching */ +static cPhs_State daDr2_Create(fopAc_ac_c* a_this) { + dr2_class* i_this = (dr2_class*)a_this; + + fopAcM_SetupActor(&i_this->actor, dr2_class); + + cPhs_State ret = dComIfG_resLoad(&i_this->mPhase, "Dr2"); + if (ret == cPhs_COMPLEATE_e) { + i_this->unk_4EC.setFollowOff(); + if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0xDFE0)) { + return cPhs_ERROR_e; + } + + if (dComIfG_Bgsp()->Regist(i_this->mpBgW1, a_this)) { + return cPhs_ERROR_e; + } + + if (dComIfG_Bgsp()->Regist(i_this->mpBgW2, a_this)) { + return cPhs_ERROR_e; + } + + l_HIO.m04 = mDoHIO_createChild("ドラゴンシッポ", &l_HIO); + fopAcM_prm_class* params = fopAcM_CreateAppend(); + params->base.parameters = 0x511; + params->room_no = a_this->current.roomNo; + + i_this->unk_3FC = fopAcM_Create(PROC_KUI, NULL, params); + i_this->unk_4A8.x = a_this->home.pos.x; + i_this->unk_4A8.y = a_this->home.pos.y + REG0_F(7) - 50.0f; + i_this->unk_4A8.z = a_this->home.pos.z; + } + return ret; } static actor_method_class l_daDr2_Method = { diff --git a/src/d/actor/d_a_kui.cpp b/src/d/actor/d_a_kui.cpp index 14269467e..12aaf7a63 100644 --- a/src/d/actor/d_a_kui.cpp +++ b/src/d/actor/d_a_kui.cpp @@ -218,9 +218,9 @@ static BOOL daKui_Execute(kui_class* i_this) { btd_class* btd = search_btd(i_this); if (dragon_tail != NULL && btd != NULL) { - if ((dragon_tail->field_0x4BA == 0 || dragon_tail->field_0x4BA >= 10) && btd->field_0x2e4 < 10) { - actor->current.pos = dragon_tail->field_0x3B0; - actor->current.angle = dragon_tail->current.angle; + if ((dragon_tail->unk_4BA == 0 || dragon_tail->unk_4BA >= 10) && btd->field_0x2e4 < 10) { + actor->current.pos = dragon_tail->unk_3B0; + actor->current.angle = dragon_tail->actor.current.angle; } else { actor->current.pos.set(0.0f, -10000.0f, 0.0f); }