diff --git a/config/RZDE01_00/rels/d_a_e_tk/symbols.txt b/config/RZDE01_00/rels/d_a_e_tk/symbols.txt index 5f28fc6b9a..5e84f1046d 100644 --- a/config/RZDE01_00/rels/d_a_e_tk/symbols.txt +++ b/config/RZDE01_00/rels/d_a_e_tk/symbols.txt @@ -63,6 +63,6 @@ lbl_238_data_104 = .data:0x00000104; // type:object size:0xD data:string @93851 = .data:0x00000114; // type:object size:0xC scope:local __RTTI__12daE_TK_HIO_c = .data:0x00000120; // type:object size:0x8 scope:global __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global -lbl_238_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global data:byte diff --git a/config/RZDE01_00/rels/d_a_e_tk2/symbols.txt b/config/RZDE01_00/rels/d_a_e_tk2/symbols.txt index 8bcd97d9ce..b845cbd451 100644 --- a/config/RZDE01_00/rels/d_a_e_tk2/symbols.txt +++ b/config/RZDE01_00/rels/d_a_e_tk2/symbols.txt @@ -58,6 +58,6 @@ lbl_239_data_D8 = .data:0x000000D8; // type:object size:0xE data:string @93703 = .data:0x000000E8; // type:object size:0xC scope:local __RTTI__13daE_TK2_HIO_c = .data:0x000000F4; // type:object size:0x8 scope:global __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global -lbl_239_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global data:byte diff --git a/config/RZDE01_02/rels/d_a_e_tk/symbols.txt b/config/RZDE01_02/rels/d_a_e_tk/symbols.txt index 37c5e956bf..18a0fc9edc 100644 --- a/config/RZDE01_02/rels/d_a_e_tk/symbols.txt +++ b/config/RZDE01_02/rels/d_a_e_tk/symbols.txt @@ -63,6 +63,6 @@ lbl_238_data_104 = .data:0x00000104; // type:object size:0xD data:string @93851 = .data:0x00000114; // type:object size:0xC scope:local align:4 __RTTI__12daE_TK_HIO_c = .data:0x00000120; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_238_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/RZDE01_02/rels/d_a_e_tk2/symbols.txt b/config/RZDE01_02/rels/d_a_e_tk2/symbols.txt index f68be15cb1..f01fa8d4a2 100644 --- a/config/RZDE01_02/rels/d_a_e_tk2/symbols.txt +++ b/config/RZDE01_02/rels/d_a_e_tk2/symbols.txt @@ -58,6 +58,6 @@ lbl_239_data_D8 = .data:0x000000D8; // type:object size:0xE data:string @93703 = .data:0x000000E8; // type:object size:0xC scope:local align:4 __RTTI__13daE_TK2_HIO_c = .data:0x000000F4; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_239_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/RZDJ01/rels/d_a_e_tk/symbols.txt b/config/RZDJ01/rels/d_a_e_tk/symbols.txt index afe487bc4c..a9515fa1bd 100644 --- a/config/RZDJ01/rels/d_a_e_tk/symbols.txt +++ b/config/RZDJ01/rels/d_a_e_tk/symbols.txt @@ -63,6 +63,6 @@ lbl_238_data_104 = .data:0x00000104; // type:object size:0xD data:string @93851 = .data:0x00000114; // type:object size:0xC scope:local align:4 __RTTI__12daE_TK_HIO_c = .data:0x00000120; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_238_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/RZDJ01/rels/d_a_e_tk2/symbols.txt b/config/RZDJ01/rels/d_a_e_tk2/symbols.txt index cd18a5c806..4ee3221cf2 100644 --- a/config/RZDJ01/rels/d_a_e_tk2/symbols.txt +++ b/config/RZDJ01/rels/d_a_e_tk2/symbols.txt @@ -58,6 +58,6 @@ lbl_239_data_D8 = .data:0x000000D8; // type:object size:0xE data:string @93703 = .data:0x000000E8; // type:object size:0xC scope:local align:4 __RTTI__13daE_TK2_HIO_c = .data:0x000000F4; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_239_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/RZDP01/rels/d_a_e_tk/symbols.txt b/config/RZDP01/rels/d_a_e_tk/symbols.txt index afe487bc4c..a9515fa1bd 100644 --- a/config/RZDP01/rels/d_a_e_tk/symbols.txt +++ b/config/RZDP01/rels/d_a_e_tk/symbols.txt @@ -63,6 +63,6 @@ lbl_238_data_104 = .data:0x00000104; // type:object size:0xD data:string @93851 = .data:0x00000114; // type:object size:0xC scope:local align:4 __RTTI__12daE_TK_HIO_c = .data:0x00000120; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_238_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/RZDP01/rels/d_a_e_tk2/symbols.txt b/config/RZDP01/rels/d_a_e_tk2/symbols.txt index cd18a5c806..4ee3221cf2 100644 --- a/config/RZDP01/rels/d_a_e_tk2/symbols.txt +++ b/config/RZDP01/rels/d_a_e_tk2/symbols.txt @@ -58,6 +58,6 @@ lbl_239_data_D8 = .data:0x000000D8; // type:object size:0xE data:string @93703 = .data:0x000000E8; // type:object size:0xC scope:local align:4 __RTTI__13daE_TK2_HIO_c = .data:0x000000F4; // type:object size:0x8 scope:global align:4 __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global align:4 -lbl_239_bss_8 = .bss:0x00000008; // type:object size:0x1 data:byte +hio_set = .bss:0x00000008; // type:object size:0x1 data:byte @93233 = .bss:0x0000000C; // type:object size:0xC scope:local align:4 l_HIO = .bss:0x00000018; // type:object size:0x1C scope:global align:4 data:byte diff --git a/config/Shield/rels/d_a_e_tk/symbols.txt b/config/Shield/rels/d_a_e_tk/symbols.txt index c80fc3619f..0c6de6ef25 100644 --- a/config/Shield/rels/d_a_e_tk/symbols.txt +++ b/config/Shield/rels/d_a_e_tk/symbols.txt @@ -62,5 +62,5 @@ __vt__12daE_TK_HIO_c = .data:0x000000D0; // type:object size:0xC scope:global @110122 = .data:0x000000DC; // type:object size:0xD scope:local data:string @110123 = .data:0x000000EC; // type:object size:0xC scope:local __RTTI__12daE_TK_HIO_c = .data:0x000000F8; // type:object size:0x8 scope:global -lbl_235_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +hio_set = .bss:0x00000000; // type:object size:0x1 data:byte l_HIO = .bss:0x00000004; // type:object size:0x1C scope:global align:4 data:float diff --git a/config/Shield/rels/d_a_e_tk2/symbols.txt b/config/Shield/rels/d_a_e_tk2/symbols.txt index 446816f051..8f3902a1c7 100644 --- a/config/Shield/rels/d_a_e_tk2/symbols.txt +++ b/config/Shield/rels/d_a_e_tk2/symbols.txt @@ -56,5 +56,5 @@ __vt__13daE_TK2_HIO_c = .data:0x000000D0; // type:object size:0xC scope:global @110028 = .data:0x000000DC; // type:object size:0xE scope:local data:string @110029 = .data:0x000000EC; // type:object size:0xC scope:local __RTTI__13daE_TK2_HIO_c = .data:0x000000F8; // type:object size:0x8 scope:global -lbl_237_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +hio_set = .bss:0x00000000; // type:object size:0x1 data:byte l_HIO = .bss:0x00000004; // type:object size:0x1C scope:global align:4 data:float diff --git a/config/ShieldD/rels/d_a_e_tk2D/symbols.txt b/config/ShieldD/rels/d_a_e_tk2D/symbols.txt index fb73cfa4c5..0ce7ed9422 100644 --- a/config/ShieldD/rels/d_a_e_tk2D/symbols.txt +++ b/config/ShieldD/rels/d_a_e_tk2D/symbols.txt @@ -104,5 +104,5 @@ lbl_231_data_238 = .data:0x00000238; // type:object size:0x24 @118843 = .data:0x00000410; // type:object size:0xE scope:local data:string @118844 = .data:0x00000420; // type:object size:0xC scope:local @118845 = .data:0x00000444; // type:object size:0x11 scope:local data:string -lbl_231_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +hio_set = .bss:0x00000000; // type:object size:0x1 data:byte l_HIO = .bss:0x00000004; // type:object size:0x1C scope:global data:byte diff --git a/config/ShieldD/rels/d_a_e_tkD/symbols.txt b/config/ShieldD/rels/d_a_e_tkD/symbols.txt index 62a43d9ee3..a14f779065 100644 --- a/config/ShieldD/rels/d_a_e_tkD/symbols.txt +++ b/config/ShieldD/rels/d_a_e_tkD/symbols.txt @@ -112,5 +112,5 @@ lbl_229_data_280 = .data:0x00000280; // type:object size:0x24 @118960 = .data:0x00000458; // type:object size:0xE scope:local data:string @118961 = .data:0x00000468; // type:object size:0xC scope:local @118962 = .data:0x0000048C; // type:object size:0x11 scope:local data:string -lbl_229_bss_0 = .bss:0x00000000; // type:object size:0x1 data:byte +hio_set = .bss:0x00000000; // type:object size:0x1 data:byte l_HIO = .bss:0x00000004; // type:object size:0x1C scope:global data:byte diff --git a/include/d/actor/d_a_e_tk.h b/include/d/actor/d_a_e_tk.h index ef9befab0d..7d554a3df4 100644 --- a/include/d/actor/d_a_e_tk.h +++ b/include/d/actor/d_a_e_tk.h @@ -6,6 +6,7 @@ #include "d/d_cc_uty.h" #include "d/d_path.h" #include "f_op/f_op_actor.h" +#include "m_Do/m_Do_ext.h" /** * @ingroup actors-enemies @@ -60,17 +61,18 @@ public: STATIC_ASSERT(sizeof(e_tk_class) == 0xA64); -class daE_TK_HIO_c { +class daE_TK_HIO_c : public JORReflexible { public: daE_TK_HIO_c(); - virtual ~daE_TK_HIO_c() {} + void genMessage(JORMContext*); + virtual ~daE_TK_HIO_c() {}; - /* 0x04 */ s8 field_0x04; - /* 0x08 */ f32 mRadiusScale; - /* 0x0C */ f32 mPlayerRange1; - /* 0x10 */ f32 mPlayerRange2; - /* 0x14 */ f32 mSpeedModifier1; - /* 0x18 */ f32 mSpeedModifier2; + /* 0x04 */ s8 mNo; + /* 0x08 */ f32 mBaseSize; + /* 0x0C */ f32 mPlayerDetectionDistanceNear; + /* 0x10 */ f32 mPlayerDetectionDistanceFar; + /* 0x14 */ f32 mSwimSpeedModifier; + /* 0x18 */ f32 mFleeSpeedModifier; }; STATIC_ASSERT(sizeof(daE_TK_HIO_c) == 0x1C); diff --git a/include/d/actor/d_a_e_tk2.h b/include/d/actor/d_a_e_tk2.h index 4af171d709..e4d29cf674 100644 --- a/include/d/actor/d_a_e_tk2.h +++ b/include/d/actor/d_a_e_tk2.h @@ -5,6 +5,7 @@ #include "d/d_cc_d.h" #include "d/d_cc_uty.h" #include "f_op/f_op_actor.h" +#include "m_Do/m_Do_ext.h" /** * @ingroup actors-enemies @@ -54,17 +55,18 @@ public: STATIC_ASSERT(sizeof(e_tk2_class) == 0xA50); -class daE_TK2_HIO_c { +class daE_TK2_HIO_c : public JORReflexible { public: daE_TK2_HIO_c(); virtual ~daE_TK2_HIO_c() {}; + void genMessage(JORMContext *); - /* 0x04 */ s8 field_0x04; - /* 0x08 */ f32 mRadiusScale; - /* 0x0C */ f32 mPlayerRange1; - /* 0x10 */ f32 mPlayerRange2; - /* 0x14 */ f32 mSpeedModifier1; /* Unused */ - /* 0x18 */ f32 mSpeedModifier2; /* Unused */ + /* 0x04 */ s8 mNo; + /* 0x08 */ f32 mBaseSize; + /* 0x0C */ f32 mPlayerDetectionDistanceNear; + /* 0x10 */ f32 mPlayerDetectionDistanceFar; + /* 0x14 */ f32 mSwimSpeedModifier; /* Unused */ + /* 0x18 */ f32 mFleeSpeedModifier; /* Unused */ }; STATIC_ASSERT(sizeof(daE_TK2_HIO_c) == 0x1C); diff --git a/src/d/actor/d_a_e_tk.cpp b/src/d/actor/d_a_e_tk.cpp index 7309d8b50d..96aae1b85f 100644 --- a/src/d/actor/d_a_e_tk.cpp +++ b/src/d/actor/d_a_e_tk.cpp @@ -1,13 +1,14 @@ /** -* @file d_a_e_tk.cpp + * @file d_a_e_tk.cpp * */ -#include "d/dolzel_rel.h" // IWYU pragma: keep +#include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_e_tk.h" #include "d/actor/d_a_e_tk_ball.h" #include "d/d_com_inf_game.h" +#include "d/d_s_play.h" #include "f_op/f_op_kankyo_mng.h" enum Action { @@ -45,26 +46,46 @@ static bool hio_set; static daE_TK_HIO_c l_HIO; daE_TK_HIO_c::daE_TK_HIO_c() { - field_0x04 = -1; - mRadiusScale = 1.9f; - mPlayerRange2 = 1400.0f; - mPlayerRange1 = 500.0f; - mSpeedModifier1 = 10.0f; - mSpeedModifier2 = 25.0f; + mNo = -1; + mBaseSize = 1.9f; + mPlayerDetectionDistanceFar = 1400.0f; + mPlayerDetectionDistanceNear = 500.0f; + mSwimSpeedModifier = 10.0f; + mFleeSpeedModifier = 25.0f; } -static void anm_init(e_tk_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 i_rate) { - J3DAnmTransform* anm = (J3DAnmTransform*)dComIfG_getObjectRes("E_tk", i_index); +#if DEBUG +void daE_TK_HIO_c::genMessage(JORMContext* ctext) { + // Tadpole + ctext->genLabel(" タドポール", 0x80000001, 0U, NULL); + // Base Size + ctext->genSlider("基本サイズ", &mBaseSize, 0.0f, 5.0f); + // Player Detection Distance Far + ctext->genSlider("PL認識距離 遠", &mPlayerDetectionDistanceFar, 0.0f, 3000.0f); + // Player Detection Distance Near + ctext->genSlider("PL認識距離 近", &mPlayerDetectionDistanceNear, 0.0f, 3000.0f); + ctext->genLabel(" ", 0x80000001); + // ↓ Behavior not guaranteed if changed + ctext->genLabel(" ↓変更すると動作保証しません", 0x80000001); + // Swim Speed + ctext->genSlider("泳ぎ速度", &mSwimSpeedModifier, 0.0f, 40.0f); + // Flee Speed + ctext->genSlider("逃げ速度", &mFleeSpeedModifier, 0.0f, 40.0f); +} +#endif - i_this->mpMorf->setAnm(anm, i_attr, i_morf, i_rate, 0.0f, -1.0f); +static void anm_init(e_tk_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 i_rate) { + i_this->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_tk", i_index), i_attr, i_morf, + i_rate, 0.0f, -1.0f); i_this->mAnim = i_index; } static int daE_TK_Draw(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; J3DModel* model = i_this->mpMorf->getModel(); - g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr); - g_env_light.setLightTevColorType_MAJI(model, &i_this->tevStr); + g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); + g_env_light.setLightTevColorType_MAJI(model, &actor->tevStr); i_this->mpMorf->entryDL(); return 1; } @@ -72,6 +93,7 @@ static int daE_TK_Draw(e_tk_class* i_this) { static int other_bg_check(e_tk_class* i_this, fopAc_ac_c* i_ac) { fopAc_ac_c* actor = i_this; dBgS_LinChk line_check; + cXyz _unk1; cXyz start_pos; cXyz end_pos; @@ -90,7 +112,13 @@ static int other_bg_check(e_tk_class* i_this, fopAc_ac_c* i_ac) { } static int pl_y_check(e_tk_class* i_this) { - if (i_this->current.pos.y - dComIfGp_getPlayer(0)->current.pos.y > 130.0f) { + fopAc_ac_c* actor = i_this; +#if DEBUG // TODO: Debug Fakematch. On retail, actor is accessed before the gameInfo. + fopAc_ac_c* player = dComIfGp_getPlayer(0); + if (actor->current.pos.y - player->current.pos.y > 130.0f) { +#else + if (actor->current.pos.y - dComIfGp_getPlayer(0)->current.pos.y > 130.0f) { +#endif return 0; } else { return 1; @@ -98,10 +126,11 @@ static int pl_y_check(e_tk_class* i_this) { } static int pl_check(e_tk_class* i_this, f32 i_limit, s16 i_max_diff) { + fopAc_ac_c* actor = i_this; fopAc_ac_c* player = dComIfGp_getPlayer(0); if (i_this->mPlayerDistanceLimit < i_limit) { - s16 diff = i_this->shape_angle.y - i_this->mPlayerAngleY; + s16 diff = actor->shape_angle.y - i_this->mPlayerAngleY; if (diff < i_max_diff && diff > (s16)-i_max_diff && !other_bg_check(i_this, player)) { return 1; } @@ -111,6 +140,9 @@ static int pl_check(e_tk_class* i_this, f32 i_limit, s16 i_max_diff) { } static void damage_check(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + fopAc_ac_c* player = dComIfGp_getPlayer(0); + if (i_this->mInvincibilityTimer == 0) { i_this->mStts.Move(); @@ -129,7 +161,7 @@ static void damage_check(e_tk_class* i_this) { i_this->mMode = MODE_TK_KYORO2; i_this->mActionTimer[0] = 50; } else { - cc_at_check(i_this, &i_this->mAtInfo); + cc_at_check(actor, &i_this->mAtInfo); if (i_this->mAtInfo.mHitType == HIT_TYPE_STUN) { i_this->mAction = ACT_TK_S_DAMAGE; } else { @@ -139,8 +171,8 @@ static void damage_check(e_tk_class* i_this) { } } - if (i_this->health <= 1) { - i_this->health = 0; + if (actor->health <= 1) { + actor->health = 0; i_this->mSph.SetTgHitMark(CcG_Tg_UNK_MARK_3); } } @@ -152,12 +184,12 @@ static int way_bg_check(e_tk_class* i_this, f32 i_limit) { cXyz mtx_pos; cXyz start_pos; + cXyz end_pos; start_pos = actor->current.pos; start_pos.y -= 50.0f; - mDoMtx_YrotS(*calc_mtx, actor->shape_angle.y); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); - cXyz end_pos; mtx_pos.x = 0.0; mtx_pos.y = -50.0f; mtx_pos.z = i_limit; @@ -174,8 +206,11 @@ static int way_bg_check(e_tk_class* i_this, f32 i_limit) { } static void e_tk_wait_0(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + cXyz src_pos; f32 speed_mul = 1.0f; + f32 speed_step = 1.0f + YREG_F(5); i_this->mAttentionOFF = true; @@ -187,23 +222,23 @@ static void e_tk_wait_0(e_tk_class* i_this) { case MODE_TK_APPEAR: if (i_this->mActionTimer[0] == 0) { - src_pos = i_this->home.pos - i_this->current.pos; + src_pos = actor->home.pos - actor->current.pos; i_this->mSomeAngle = cM_atan2s(src_pos.x, src_pos.z) + (s16)cM_rndFX(8000.0f); i_this->mActionTimer[0] = cM_rndF(30.0f) + 30.0f; } if (i_this->mActionTimer[2] == 0 && way_bg_check(i_this, 200.0f)) { i_this->mActionTimer[2] = 40; - src_pos = i_this->home.pos - i_this->current.pos; + src_pos = actor->home.pos - actor->current.pos; i_this->mSomeAngle = cM_atan2s(src_pos.x, src_pos.z) + (s16)cM_rndFX(2000.0f); i_this->mActionTimer[0] = cM_rndF(30.0f) + 30.0f; } if (i_this->mActionTimer[1] == 0 && pl_y_check(i_this) && - pl_check(i_this, l_HIO.mPlayerRange2, 0x4000)) + pl_check(i_this, l_HIO.mPlayerDetectionDistanceFar, 0x4000)) { i_this->mAction = ACT_TK_FIND; - if (pl_check(i_this, l_HIO.mPlayerRange1, 0x4000)) { + if (pl_check(i_this, l_HIO.mPlayerDetectionDistanceNear, 0x4000)) { i_this->mMode = MODE_TK_WAIT01; } else { i_this->mMode = MODE_TK_NONE; @@ -212,19 +247,22 @@ static void e_tk_wait_0(e_tk_class* i_this) { break; } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mSomeAngle, 0x10, 0x400); - cLib_addCalcAngleS2(&i_this->shape_angle.x, 0, 0x10, 0x400); - cLib_addCalc2(&i_this->speedF, l_HIO.mSpeedModifier1 * speed_mul, 1.0f, 1.0f); - cMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mSomeAngle, 0x10, 0x400); + cLib_addCalcAngleS2(&actor->shape_angle.x, 0, 0x10, 0x400); + cLib_addCalc2(&actor->speedF, l_HIO.mSwimSpeedModifier * speed_mul, 1.0f, speed_step); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); src_pos.x = 0.0f; src_pos.y = 0.0f; - src_pos.z = i_this->speedF; - MtxPosition(&src_pos, &i_this->speed); - i_this->current.pos += i_this->speed; + src_pos.z = actor->speedF; + MtxPosition(&src_pos, &actor->speed); + actor->current.pos += actor->speed; } static void e_tk_find(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + + cXyz local_58; f32 speed_target = 0.0f; f32 speed_step = 3.0f; @@ -247,7 +285,7 @@ static void e_tk_find(e_tk_class* i_this) { i_this->mAction = ACT_TK_ATTACK; i_this->mMode = MODE_TK_NONE; } else { - if (pl_check(i_this, l_HIO.mPlayerRange1, 0x4000)) { + if (pl_check(i_this, l_HIO.mPlayerDetectionDistanceNear, 0x4000)) { i_this->mMode = MODE_TK_KYORO2; } } @@ -279,7 +317,7 @@ static void e_tk_find(e_tk_class* i_this) { break; case MODE_TK_SWIM: - i_this->mPlayerAngleY = i_this->mPlayerAngleY + -0x8000; + ADD_ANGLE(i_this->mPlayerAngleY, 0x8000); i_this->mAttentionOFF = true; if (i_this->mpMorf->isStop()) { i_this->mAnimSpeed = 4.0f; @@ -292,10 +330,10 @@ static void e_tk_find(e_tk_class* i_this) { i_this->mAttentionOFF = true; cLib_addCalc2(&i_this->mAnimSpeed, 2.0f, 1.0f, 0.15f); i_this->mpMorf->setPlaySpeed(i_this->mAnimSpeed); - speed_target = 1.0f; - speed_step = 10.0f; + speed_target = 1.0f + YREG_F(17); + speed_step = 10.0f + YREG_F(18); if (i_this->mActionTimer[0] == 0 && - i_this->mPlayerDistanceLimit > l_HIO.mPlayerRange1 * 1.2f) + i_this->mPlayerDistanceLimit > l_HIO.mPlayerDetectionDistanceNear * 1.2f) { i_this->mMode = MODE_TK_NONE; } else { @@ -305,27 +343,28 @@ static void e_tk_find(e_tk_class* i_this) { } } if (i_this->mActionTimer[1] == 0) { - i_this->mPlayerAngleY = i_this->mPlayerAngleY - 0x8000; + ADD_ANGLE(i_this->mPlayerAngleY, 0x8000); } else { i_this->mPlayerAngleY = i_this->mSomeAngle; } break; } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); - cLib_addCalc2(&i_this->speedF, l_HIO.mSpeedModifier2 * speed_target, 1.0f, speed_step); - cMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); + cLib_addCalc2(&actor->speedF, l_HIO.mFleeSpeedModifier * speed_target, 1.0f, speed_step); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); - cXyz local_58; local_58.x = 0.0f; local_58.y = 0.0f; - local_58.z = i_this->speedF; - MtxPosition(&local_58, &i_this->speed); - i_this->current.pos += i_this->speed; - cLib_addCalcAngleS2(&i_this->shape_angle.x, 0, 4, 0x400); + local_58.z = actor->speedF; + MtxPosition(&local_58, &actor->speed); + actor->current.pos += actor->speed; + cLib_addCalcAngleS2(&actor->shape_angle.x, 0, 4, 0x400); } static void e_tk_attack(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + switch (i_this->mMode) { case MODE_TK_NONE: i_this->mMode = MODE_TK_APPEAR; @@ -336,8 +375,8 @@ static void e_tk_attack(e_tk_class* i_this) { if (pl_y_check(i_this)) { if ((int)i_this->mpMorf->getFrame() == 24) { i_this->mBallID = - fopAcM_createChild(PROC_E_TK_BALL, fopAcM_GetID(i_this), 0, &i_this->eyePos, - fopAcM_GetRoomNo(i_this), &i_this->shape_angle, 0, -1, 0); + fopAcM_createChild(PROC_E_TK_BALL, fopAcM_GetID(actor), 0, &actor->eyePos, + fopAcM_GetRoomNo(actor), &actor->shape_angle, 0, -1, 0); } if ((int)i_this->mpMorf->getFrame() == 28) { i_this->mTKBallSpawned = true; @@ -355,22 +394,24 @@ static void e_tk_attack(e_tk_class* i_this) { i_this->mAction = ACT_TK_FIND; i_this->mMode = MODE_TK_DAMAGE; } - if (pl_check(i_this, l_HIO.mPlayerRange1, 0x4000)) { + if (pl_check(i_this, l_HIO.mPlayerDetectionDistanceNear, 0x4000)) { i_this->mAction = ACT_TK_FIND; i_this->mMode = MODE_TK_KYORO2; } break; } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); } static void e_tk_pathswim(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + cXyz local_50; + cXyz _unk1; f32 speed_target = 1.0f; - f32 speed_step = 1.0f; - + f32 speed_step = 1.0f + YREG_F(5); switch (i_this->mMode) { case MODE_TK_NONE: anm_init(i_this, ANM_TK_SWIM, 5.0f, 0x2, 1.0f); @@ -400,7 +441,7 @@ static void e_tk_pathswim(e_tk_class* i_this) { } case MODE_TK_ATTACK: - local_50 = i_this->mPos - i_this->current.pos; + local_50 = i_this->mPos - actor->current.pos; if (JMAFastSqrt(local_50.x * local_50.x + local_50.z * local_50.z) < 100.0f) { dPnt* point = &i_this->mpPath->m_points[i_this->mPathID]; if (point->mArg0 != 0x2) { @@ -412,14 +453,15 @@ static void e_tk_pathswim(e_tk_class* i_this) { i_this->mMode = MODE_TK_APPEAR; } } - i_this->mSomeAngle = cM_atan2s(local_50.x, local_50.z); + i_this->mSomeAngle = (s16)cM_atan2s(local_50.x, local_50.z); break; case MODE_TK_DAMAGE: speed_target = 0.0f; speed_step = 3.0f; + dPnt* point; if (i_this->mActionTimer[1] == 0 && pl_y_check(i_this) && - pl_check(i_this, l_HIO.mPlayerRange2, 0x4000)) + pl_check(i_this, l_HIO.mPlayerDetectionDistanceFar, 0x4000)) { i_this->mAction = ACT_TK_FIND; anm_init(i_this, ANM_TK_WAIT01, 5.0f, 0x2, 1.0f); @@ -432,18 +474,20 @@ static void e_tk_pathswim(e_tk_class* i_this) { break; } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mSomeAngle, 8, 0x400); - cLib_addCalc2(&i_this->speedF, l_HIO.mSpeedModifier1 * speed_target, 1.0f, speed_step); - cMtx_YrotS(*calc_mtx, i_this->shape_angle.y); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mSomeAngle, 8, 0x400); + cLib_addCalc2(&actor->speedF, l_HIO.mSwimSpeedModifier * speed_target, 1.0f, speed_step); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); local_50.x = 0.0f; local_50.y = 0.0f; - local_50.z = i_this->speedF; - MtxPosition(&local_50, &i_this->speed); - i_this->current.pos += i_this->speed; + local_50.z = actor->speedF; + MtxPosition(&local_50, &actor->speed); + actor->current.pos += actor->speed; } static void e_tk_s_damage(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + switch (i_this->mMode) { case MODE_TK_NONE: anm_init(i_this, ANM_TK_DAMAGE, 2.0f, 0x0, 1.0f); @@ -451,7 +495,7 @@ static void e_tk_s_damage(e_tk_class* i_this) { break; case MODE_TK_APPEAR: - if (i_this->mpMorf->getFrame() > 10.0f) { + if (i_this->mpMorf->getFrame() > 10.0f + YREG_F(3)) { i_this->mAction = ACT_TK_FIND; i_this->mMode = MODE_TK_DAMAGE; } @@ -460,6 +504,8 @@ static void e_tk_s_damage(e_tk_class* i_this) { } static void e_tk_damage(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + i_this->mInvincibilityTimer = 6; i_this->mAttentionOFF = true; @@ -471,16 +517,21 @@ static void e_tk_damage(e_tk_class* i_this) { case MODE_TK_APPEAR: if (i_this->mpMorf->isStop()) { - fopAcM_createDisappear(i_this, &i_this->eyePos, 10, 0, 0x11); - fopAcM_delete(i_this); + fopAcM_createDisappear(actor, &actor->eyePos, 10, 0, 0x11); + fopAcM_delete(actor); } break; } } static void action(e_tk_class* i_this) { - i_this->mPlayerAngleY = fopAcM_searchPlayerAngleY(i_this); - i_this->mPlayerDistanceLimit = fopAcM_searchPlayerDistance(i_this); + fopAc_ac_c* actor = i_this; + + cXyz _unk1; + cXyz _unk2; + + i_this->mPlayerAngleY = fopAcM_searchPlayerAngleY(actor); + i_this->mPlayerDistanceLimit = fopAcM_searchPlayerDistance(actor); damage_check(i_this); s8 link_search_flag = false; @@ -513,27 +564,32 @@ static void action(e_tk_class* i_this) { i_this->mSound.setLinkSearch(false); } - if (i_this->speedF < 2.0f) { - cXyz this_pos = i_this->current.pos; - fopAcM_effHamonSet(&i_this->mHamonSet, &this_pos, 2.3f, 0.05f); + if (actor->speedF < 2.0f) { + cXyz this_pos = actor->current.pos; + f32 emit_rate = 0.05f + KREG_F(3); + fopAcM_effHamonSet(&i_this->mHamonSet, &this_pos, 2.3f + KREG_F(2), emit_rate); } } static int daE_TK_Execute(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + cXyz cStack_94; cXyz cStack_a0; if (i_this->mExecuteState == 0x00) { dBgS_ObjGndChk_Spl ground_check; - cStack_94 = i_this->current.pos; + cStack_94 = actor->current.pos; cStack_94.y += 200.0f; ground_check.SetPos(&cStack_94); - i_this->current.pos.y = dComIfG_Bgsp().GroundCross(&ground_check); + f32 ground_cross = dComIfG_Bgsp().GroundCross(&ground_check); + actor->current.pos.y = ground_cross + KREG_F(17); } i_this->mLifetime++; i_this->mAttentionOFF = false; - for (int i = 0; i <= 3; i++) { + for (int i = 0; i < 4; i++) { + (void)i; // Debug Fakematch: Force i into register. if (i_this->mActionTimer[i] != 0) { i_this->mActionTimer[i]--; } @@ -545,20 +601,20 @@ static int daE_TK_Execute(e_tk_class* i_this) { action(i_this); i_this->mAcch.CrrPos(dComIfG_Bgsp()); - mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y, i_this->current.pos.z); - mDoMtx_stack_c::YrotM(i_this->shape_angle.y); - mDoMtx_stack_c::XrotM(i_this->shape_angle.x); - mDoMtx_stack_c::scaleM(l_HIO.mRadiusScale, l_HIO.mRadiusScale, l_HIO.mRadiusScale); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z); + mDoMtx_stack_c::YrotM(actor->shape_angle.y); + mDoMtx_stack_c::XrotM(actor->shape_angle.x); + mDoMtx_stack_c::scaleM(l_HIO.mBaseSize, l_HIO.mBaseSize, l_HIO.mBaseSize); J3DModel* model = i_this->mpMorf->getModel(); model->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(i_this))); + i_this->mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(actor))); if (i_this->mpMorf->checkFrame(6.0f) && (i_this->mAnim == ANM_TK_APPEAR || i_this->mAnim == ANM_TK_HIDE)) { - fopKyM_createWpillar(&i_this->current.pos, 2.3f, 0); + fopKyM_createWpillar(&actor->current.pos, 2.3f + KREG_F(6), 0); } if (i_this->mAnim == ANM_TK_SWIM) { @@ -602,33 +658,31 @@ static int daE_TK_Execute(e_tk_class* i_this) { MTXCopy(model->getAnmMtx(3), *calc_mtx); cStack_94.set(0.0f, 0.0f, 0.0f); - MtxPosition(&cStack_94, &i_this->eyePos); + MtxPosition(&cStack_94, &actor->eyePos); - i_this->attention_info.position = i_this->eyePos; - i_this->attention_info.position.y = - i_this->attention_info.position.y + l_HIO.mRadiusScale * 35.0f; + actor->attention_info.position = actor->eyePos; + actor->attention_info.position.y = actor->attention_info.position.y + l_HIO.mBaseSize * 35.0f; if (i_this->mTKBallSpawned) { e_tk_ball_class* ball_actor = static_cast(fopAcM_SearchByID(i_this->mBallID)); if (ball_actor != NULL) { - ball_actor->current.pos = i_this->eyePos; + ball_actor->current.pos = actor->eyePos; ball_actor->mSuspended = false; } - cXyz scale; - scale.setall(2.0f); - dComIfGp_particle_set(0x819B, &i_this->eyePos, &i_this->shape_angle, &scale); - dComIfGp_particle_set(0x819C, &i_this->eyePos, &i_this->shape_angle, &scale); + cXyz scale(2.0f + TREG_F(8), 2.0f + TREG_F(8), 2.0f + TREG_F(8)); + dComIfGp_particle_set(0x819B, &actor->eyePos, &actor->shape_angle, &scale); + dComIfGp_particle_set(0x819C, &actor->eyePos, &actor->shape_angle, &scale); i_this->mTKBallSpawned = false; } if (i_this->mAttentionOFF) { - fopAcM_OffStatus(i_this, 0); - i_this->attention_info.flags = 0; + fopAcM_OffStatus(actor, 0); + actor->attention_info.flags = 0; } else { - fopAcM_OnStatus(i_this, 0); - i_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + fopAcM_OnStatus(actor, 0); + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; } MTXCopy(model->getAnmMtx(2), *calc_mtx); @@ -636,7 +690,7 @@ static int daE_TK_Execute(e_tk_class* i_this) { MtxPosition(&cStack_94, &cStack_a0); i_this->mSph.SetC(cStack_a0); - i_this->mSph.SetR(50.0f * l_HIO.mRadiusScale); + i_this->mSph.SetR((50.0f + JREG_F(3)) * l_HIO.mBaseSize); dComIfG_Ccsp()->Set(&i_this->mSph); @@ -648,18 +702,23 @@ static int daE_TK_IsDelete(e_tk_class* i_this) { } static int daE_TK_Delete(e_tk_class* i_this) { + fopAc_ac_c* actor = i_this; + + fopAcM_RegisterDeleteID(i_this, "E_TK"); + dComIfG_resDelete(&i_this->mPhaseReq, "E_tk"); if (i_this->mInitHIO) { hio_set = false; + mDoHIO_DELETE_CHILD(l_HIO.mNo); } - if (i_this->heap != NULL) { + if (actor->heap != NULL) { i_this->mpMorf->stopZelAnime(); } return 1; } -static int useHeapInit(fopAc_ac_c* a_this) { - e_tk_class* i_this = static_cast(a_this); +static int useHeapInit(fopAc_ac_c* actor) { + e_tk_class* i_this = static_cast(actor); i_this->mpMorf = new mDoExt_McaMorfSO((J3DModelData*)dComIfG_getObjectRes("E_tk", 0xE), NULL, NULL, @@ -673,70 +732,76 @@ static int useHeapInit(fopAc_ac_c* a_this) { return 1; } -static int daE_TK_Create(fopAc_ac_c* i_this) { - static dCcD_SrcSph cc_sph_src = { - { - {0x0, {{0x0, 0x0, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf - { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph - } // mSphAttr - }; - +static int daE_TK_Create(fopAc_ac_c* actor) { + e_tk_class* i_this = (e_tk_class*)actor; fopAcM_ct(i_this, e_tk_class); - e_tk_class* const a_this = static_cast(i_this); - cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&a_this->mPhaseReq, "E_tk"); + cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->mPhaseReq, "E_tk"); if (phase == cPhs_COMPLEATE_e) { - a_this->mArg0 = fopAcM_GetParamBit(a_this, 0, 8); - a_this->mArg1 = fopAcM_GetParamBit(a_this, 8, 4); - a_this->mArg2 = fopAcM_GetParamBit(a_this, 12, 4); - a_this->mParamPathIdx = fopAcM_GetParamBit(a_this, 16, 8); + OS_REPORT("E_tk PARAM %x\n", fopAcM_GetParam(actor)); + i_this->mArg0 = (fopAcM_GetParam(actor) & 0xFF) >> 0; + i_this->mArg1 = (fopAcM_GetParam(actor) & 0xF00) >> 8; + i_this->mArg2 = (fopAcM_GetParam(actor) & 0xF000) >> 12; + i_this->mParamPathIdx = (fopAcM_GetParam(actor) & 0xFF0000) >> 16; - if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0x1e20)) { + OS_REPORT("E_tk//////////////E_TK SET 1 !!\n"); + + if (!fopAcM_entrySolidHeap(actor, useHeapInit, 0x1e20)) { + OS_REPORT("//////////////E_TK SET NON !!\n"); return cPhs_ERROR_e; } - if (a_this->mParamPathIdx != 0xff) { - a_this->mpPath = dPath_GetRoomPath(a_this->mParamPathIdx, fopAcM_GetRoomNo(a_this)); - if (a_this->mpPath == NULL) { + OS_REPORT("//////////////E_TK SET 2 !!\n"); + + if (i_this->mParamPathIdx != 0xff) { + i_this->mpPath = dPath_GetRoomPath(i_this->mParamPathIdx, fopAcM_GetRoomNo(actor)); + if (i_this->mpPath == NULL) { + OS_REPORT("//////////////E_TK NON PATH !!!\n"); return cPhs_ERROR_e; } - a_this->mPathLoaded = a_this->mParamPathIdx + 0x1; - a_this->mPathDirection = 0x1; - a_this->mAction = ACT_TK_PATHSWIM; + i_this->mPathLoaded = i_this->mParamPathIdx + 0x1; + i_this->mPathDirection = 0x1; + i_this->mAction = ACT_TK_PATHSWIM; } if (hio_set == false) { - a_this->mInitHIO = true; + i_this->mInitHIO = true; hio_set = true; - l_HIO.field_0x04 = -1; + l_HIO.mNo = mDoHIO_CREATE_CHILD("たどぽーる", &l_HIO); // "Tadpole" } - a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; - fopAcM_SetMtx(a_this, a_this->mpMorf->getModel()->getBaseTRMtx()); - fopAcM_SetMin(a_this, -100.0f, -100.0f, -100.0f); - fopAcM_SetMax(a_this, 100.0f, 100.0f, 100.0f); + fopAcM_SetMtx(actor, i_this->mpMorf->getModel()->getBaseTRMtx()); + fopAcM_SetMin(actor, -100.0f, -100.0f, -100.0f); + fopAcM_SetMax(actor, 100.0f, 100.0f, 100.0f); - a_this->attention_info.distances[fopAc_attn_BATTLE_e] = 0x04; - a_this->health = 10; - a_this->field_0x560 = 10; + actor->attention_info.distances[fopAc_attn_BATTLE_e] = 0x04; + actor->field_0x560 = actor->health = 10; - a_this->mStts.Init(100, 0, a_this); - a_this->mSph.Set(cc_sph_src); - a_this->mSph.SetStts(&a_this->mStts); + static dCcD_SrcSph cc_sph_src = { + { + {0x0, {{0x0, 0x0, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf + { + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + } // mSphAttr + }; - a_this->mAcch.Set(&i_this->current.pos, &a_this->old.pos, a_this, 1, &a_this->mAcchCir, - fopAcM_GetSpeed_p(a_this), NULL, NULL); + i_this->mStts.Init(100, 0, actor); + i_this->mSph.Set(cc_sph_src); + i_this->mSph.SetStts(&i_this->mStts); - a_this->mAcchCir.SetWall(-50.0f, 60.0f); - a_this->mSound.init(&a_this->current.pos, &a_this->eyePos, 0x3, 0x1); - a_this->mSound.setEnemyName("E_tk"); - a_this->mAtInfo.mpSound = &a_this->mSound; - a_this->mExecuteState = 0x14; - daE_TK_Execute(a_this); + i_this->mAcch.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, + &i_this->mAcchCir, fopAcM_GetSpeed_p(actor), NULL, NULL); + + i_this->mAcchCir.SetWall(-50.0f, 60.0f); + i_this->mSound.init(&actor->current.pos, &actor->eyePos, 0x3, 0x1); + i_this->mSound.setEnemyName("E_tk"); + i_this->mAtInfo.mpSound = &i_this->mSound; + i_this->mExecuteState = 0x14; + daE_TK_Execute(i_this); } return phase; } diff --git a/src/d/actor/d_a_e_tk2.cpp b/src/d/actor/d_a_e_tk2.cpp index ca528b2276..4215e02dab 100644 --- a/src/d/actor/d_a_e_tk2.cpp +++ b/src/d/actor/d_a_e_tk2.cpp @@ -1,13 +1,14 @@ /** -* @file d_a_e_tk2.cpp + * @file d_a_e_tk2.cpp * */ -#include "d/dolzel_rel.h" // IWYU pragma: keep +#include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_e_tk2.h" #include "d/actor/d_a_e_tk_ball.h" #include "d/d_com_inf_game.h" +#include "d/d_s_play.h" enum Action { /* 0x0 */ ACT_TK2_WAIT, @@ -43,26 +44,46 @@ static bool hio_set; static daE_TK2_HIO_c l_HIO; daE_TK2_HIO_c::daE_TK2_HIO_c() { - field_0x04 = -1; - mRadiusScale = 2.3f; - mPlayerRange2 = 1400.0f; - mPlayerRange1 = 500.0f; - mSpeedModifier1 = 10.0f; - mSpeedModifier2 = 25.0f; + mNo = -1; + mBaseSize = 2.3f; + mPlayerDetectionDistanceFar = 1400.0f; + mPlayerDetectionDistanceNear = 500.0f; + mSwimSpeedModifier = 10.0f; + mFleeSpeedModifier = 25.0f; } -static void anm_init(e_tk2_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 i_rate) { - J3DAnmTransform* anm = (J3DAnmTransform*)dComIfG_getObjectRes("E_tk2", i_index); +#if DEBUG +void daE_TK2_HIO_c::genMessage(JORMContext* ctext) { + // Tadpole + ctext->genLabel(" タドポール", 0x80000001, 0U, NULL); + // Base Size + ctext->genSlider("基本サイズ", &mBaseSize, 0.0f, 5.0f); + // Player Detection Distance Far + ctext->genSlider("PL認識距離 遠", &mPlayerDetectionDistanceFar, 0.0f, 3000.0f); + // Player Detection Distance Near + ctext->genSlider("PL認識距離 近", &mPlayerDetectionDistanceNear, 0.0f, 3000.0f); + ctext->genLabel(" ", 0x80000001); + // ↓ Behavior not guaranteed if changed + ctext->genLabel(" ↓変更すると動作保証しません", 0x80000001); + // Swim Speed + ctext->genSlider("泳ぎ速度", &mSwimSpeedModifier, 0.0f, 40.0f); + // Flee Speed + ctext->genSlider("逃げ速度", &mFleeSpeedModifier, 0.0f, 40.0f); +} +#endif - i_this->mpMorf->setAnm(anm, i_attr, i_morf, i_rate, 0.0f, -1.0f); +static void anm_init(e_tk2_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 i_rate) { + i_this->mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_tk2", i_index), i_attr, i_morf, + i_rate, 0.0f, -1.0f); i_this->mAnim = i_index; } static int daE_TK2_Draw(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; J3DModel* model = i_this->mpMorf->getModel(); - g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr); - g_env_light.setLightTevColorType_MAJI(model, &i_this->tevStr); + g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); + g_env_light.setLightTevColorType_MAJI(model, &actor->tevStr); i_this->mpMorf->entryDL(); return 1; } @@ -70,6 +91,7 @@ static int daE_TK2_Draw(e_tk2_class* i_this) { static int other_bg_check(e_tk2_class* i_this, fopAc_ac_c* i_ac) { fopAc_ac_c* actor = i_this; dBgS_LinChk line_check; + cXyz _unk1; cXyz start_pos; cXyz end_pos; @@ -88,10 +110,11 @@ static int other_bg_check(e_tk2_class* i_this, fopAc_ac_c* i_ac) { } static int pl_check(e_tk2_class* i_this, f32 i_limit, s16 i_max_diff) { + fopAc_ac_c* actor = i_this; fopAc_ac_c* player = dComIfGp_getPlayer(0); if (i_this->mPlayerDistanceLimit < i_limit) { - s16 diff = i_this->shape_angle.y - i_this->mPlayerAngleY; + s16 diff = actor->shape_angle.y - i_this->mPlayerAngleY; if (diff < i_max_diff && diff > (s16)-i_max_diff && !other_bg_check(i_this, player)) { return 1; } @@ -101,6 +124,9 @@ static int pl_check(e_tk2_class* i_this, f32 i_limit, s16 i_max_diff) { } static void damage_check(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + fopAc_ac_c* player = dComIfGp_getPlayer(0); + if (i_this->mInvincibilityTimer == 0) { i_this->mStts.Move(); @@ -119,7 +145,7 @@ static void damage_check(e_tk2_class* i_this) { i_this->mMode = MODE_TK2_KYORO2; i_this->mActionTimer[0] = 50; } else { - cc_at_check(i_this, &i_this->mAtInfo); + cc_at_check(actor, &i_this->mAtInfo); if (i_this->mAtInfo.mHitType == HIT_TYPE_STUN) { i_this->mAction = ACT_TK2_S_DAMAGE; } else { @@ -129,18 +155,24 @@ static void damage_check(e_tk2_class* i_this) { } } - if (i_this->health <= 1) { - i_this->health = 0; + if (actor->health <= 1) { + actor->health = 0; i_this->mSph.SetTgHitMark(CcG_Tg_UNK_MARK_3); } - if (i_this->health <= 1) { // Yes, this is a duplicate (??) - i_this->health = 0; + if (actor->health <= 1) { // Yes, this is a duplicate (??) + actor->health = 0; i_this->mSph.SetTgHitMark(CcG_Tg_UNK_MARK_3); } } } static void e_tk2_wait_0(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + + cXyz src_pos; + f32 speed_mul = 1.0f; + f32 speed_step = 1.0f + YREG_F(5); + i_this->mAttentionOFF = true; switch (i_this->mMode) { @@ -149,7 +181,9 @@ static void e_tk2_wait_0(e_tk2_class* i_this) { break; case MODE_TK2_APPEAR: - if (i_this->mActionTimer[1] == 0 && pl_check(i_this, l_HIO.mPlayerRange2, 0x4000)) { + if (i_this->mActionTimer[1] == 0 && + pl_check(i_this, l_HIO.mPlayerDetectionDistanceFar, 0x4000)) + { i_this->mAction = ACT_TK2_FIND; i_this->mMode = MODE_TK2_NONE; } @@ -157,10 +191,16 @@ static void e_tk2_wait_0(e_tk2_class* i_this) { } i_this->mSomeAngle = i_this->mPlayerAngleY; - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mSomeAngle, 0x10, 0x400); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mSomeAngle, 0x10, 0x400); } static void e_tk2_find(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + + cXyz local_58; + f32 speed_target = 0.0f; + f32 speed_step = 3.0f; + switch (i_this->mMode) { case MODE_TK2_NONE: anm_init(i_this, ANM_TK2_APPEAR, 3.0f, 0x0, 1.0f); @@ -202,7 +242,7 @@ static void e_tk2_find(e_tk2_class* i_this) { break; case MODE_TK2_SWIM: - i_this->mPlayerAngleY = i_this->mPlayerAngleY + -0x8000; + ADD_ANGLE(i_this->mPlayerAngleY, 0x8000); i_this->mAttentionOFF = true; if (i_this->mpMorf->isStop()) { i_this->mAnimSpeed = 4.0f; @@ -215,8 +255,10 @@ static void e_tk2_find(e_tk2_class* i_this) { i_this->mAttentionOFF = true; cLib_addCalc2(&i_this->mAnimSpeed, 2.0f, 1.0f, 0.15f); i_this->mpMorf->setPlaySpeed(i_this->mAnimSpeed); + speed_target = 1.0f + YREG_F(17); + speed_step = 10.0f + YREG_F(18); if (i_this->mActionTimer[0] == 0 && - i_this->mPlayerDistanceLimit > l_HIO.mPlayerRange1 * 1.2f) + i_this->mPlayerDistanceLimit > l_HIO.mPlayerDetectionDistanceNear * 1.2f) { i_this->mMode = MODE_TK2_NONE; } else { @@ -226,16 +268,18 @@ static void e_tk2_find(e_tk2_class* i_this) { } } if (i_this->mActionTimer[1] == 0) { - i_this->mPlayerAngleY = i_this->mPlayerAngleY - 0x8000; + ADD_ANGLE(i_this->mPlayerAngleY, 0x8000); } else { i_this->mPlayerAngleY = i_this->mSomeAngle; } } - cLib_addCalcAngleS2(&(i_this)->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); } static void e_tk2_attack(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + switch (i_this->mMode) { case MODE_TK2_NONE: i_this->mMode = MODE_TK2_APPEAR; @@ -245,15 +289,15 @@ static void e_tk2_attack(e_tk2_class* i_this) { case MODE_TK2_APPEAR: if ((int)i_this->mpMorf->getFrame() == 0x18) { i_this->mBallID = - fopAcM_createChild(PROC_E_TK_BALL, fopAcM_GetID(i_this), 1, &i_this->eyePos, - fopAcM_GetRoomNo(i_this), &i_this->shape_angle, 0, -1, 0); + fopAcM_createChild(PROC_E_TK_BALL, fopAcM_GetID(actor), 1, &actor->eyePos, + fopAcM_GetRoomNo(actor), &actor->shape_angle, 0, -1, 0); } if ((int)i_this->mpMorf->getFrame() == 0x1c) { i_this->mTKBallSpawned = true; } if (i_this->mpMorf->isStop()) { anm_init(i_this, ANM_TK2_WAIT01, 1.0f, 0x02, 1.0f); - i_this->mActionTimer[0] = (short)(int)(cM_rndF(30.0f) + 70.0f); + i_this->mActionTimer[0] = cM_rndF(30.0f) + 70.0f; i_this->mMode = MODE_TK2_ATTACK; } break; @@ -261,17 +305,19 @@ static void e_tk2_attack(e_tk2_class* i_this) { case MODE_TK2_ATTACK: if (i_this->mActionTimer[0] == 0) { i_this->mMode = MODE_TK2_NONE; - } else if (!pl_check(i_this, l_HIO.mPlayerRange2 + 50.0f, 0x6000)) { + } else if (!pl_check(i_this, l_HIO.mPlayerDetectionDistanceFar + 50.0f, 0x6000)) { i_this->mAction = ACT_TK2_FIND; i_this->mMode = MODE_TK2_DAMAGE; } break; } - cLib_addCalcAngleS2(&i_this->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->mPlayerAngleY, 4, 0x800); } static void e_tk2_s_damage(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + switch (i_this->mMode) { case MODE_TK2_NONE: anm_init(i_this, ANM_TK2_DAMAGE, 2.0f, 0x0, 1.0f); @@ -279,7 +325,7 @@ static void e_tk2_s_damage(e_tk2_class* i_this) { break; case MODE_TK2_APPEAR: - if (i_this->mpMorf->getFrame() > 10.0f) { + if (i_this->mpMorf->getFrame() > 10.0f + YREG_F(3)) { i_this->mAction = ACT_TK2_FIND; i_this->mMode = MODE_TK2_DAMAGE; } @@ -288,6 +334,8 @@ static void e_tk2_s_damage(e_tk2_class* i_this) { } static void e_tk2_damage(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + i_this->mInvincibilityTimer = 6; i_this->mAttentionOFF = true; @@ -299,8 +347,8 @@ static void e_tk2_damage(e_tk2_class* i_this) { case MODE_TK2_APPEAR: if (i_this->mpMorf->isStop()) { - fopAcM_createDisappear(i_this, &i_this->eyePos, 10, 0, 0x12); - fopAcM_delete(i_this); + fopAcM_createDisappear(actor, &actor->eyePos, 10, 0, 0x12); + fopAcM_delete(actor); } break; } @@ -308,6 +356,10 @@ static void e_tk2_damage(e_tk2_class* i_this) { static void action(e_tk2_class* i_this) { fopAc_ac_c* actor = i_this; + + cXyz _unk1; + cXyz _unk2; + i_this->mPlayerAngleY = fopAcM_searchPlayerAngleY(actor); i_this->mPlayerDistanceLimit = fopAcM_searchPlayerDistance(actor); damage_check(i_this); @@ -341,20 +393,23 @@ static void action(e_tk2_class* i_this) { } static int daE_TK2_Execute(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + cXyz cStack_94; cXyz cStack_a0; if (i_this->mExecuteState == 0x00) { dBgS_ObjGndChk_Spl ground_check; - cStack_94 = i_this->current.pos; + cStack_94 = actor->current.pos; cStack_94.y += 200.0f; ground_check.SetPos(&cStack_94); - i_this->current.pos.y = dComIfG_Bgsp().GroundCross(&ground_check) - 10.0f; + f32 ground_cross = dComIfG_Bgsp().GroundCross(&ground_check); + actor->current.pos.y = ground_cross - 10.0f + JREG_F(8); } i_this->mLifetime++; i_this->mAttentionOFF = false; - for (int i = 0; i <= 3; i++) { + for (int i = 0; i < 4; i++) { if (i_this->mActionTimer[i] != 0) { i_this->mActionTimer[i]--; } @@ -366,14 +421,14 @@ static int daE_TK2_Execute(e_tk2_class* i_this) { action(i_this); i_this->mAcch.CrrPos(dComIfG_Bgsp()); - mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y, i_this->current.pos.z); - mDoMtx_stack_c::YrotM(i_this->shape_angle.y); - mDoMtx_stack_c::scaleM(l_HIO.mRadiusScale, l_HIO.mRadiusScale, l_HIO.mRadiusScale); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y, actor->current.pos.z); + mDoMtx_stack_c::YrotM(actor->shape_angle.y); + mDoMtx_stack_c::scaleM(l_HIO.mBaseSize, l_HIO.mBaseSize, l_HIO.mBaseSize); J3DModel* model = i_this->mpMorf->getModel(); model->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(i_this))); + i_this->mpMorf->play(0, dComIfGp_getReverb(fopAcM_GetRoomNo(actor))); if (i_this->mAnim == ANM_TK2_SWIM) { if (i_this->mpMorf->checkFrame(0.0f) || i_this->mpMorf->checkFrame(6.0f) || @@ -416,32 +471,30 @@ static int daE_TK2_Execute(e_tk2_class* i_this) { MTXCopy(model->getAnmMtx(3), *calc_mtx); cStack_94.set(0.0f, 0.0f, 0.0f); - MtxPosition(&cStack_94, &i_this->eyePos); + MtxPosition(&cStack_94, &actor->eyePos); - i_this->attention_info.position = i_this->eyePos; - i_this->attention_info.position.y = - i_this->attention_info.position.y + l_HIO.mRadiusScale * 35.0f; + actor->attention_info.position = actor->eyePos; + actor->attention_info.position.y = actor->attention_info.position.y + l_HIO.mBaseSize * 35.0f; if (i_this->mTKBallSpawned) { e_tk_ball_class* ball_actor = static_cast(fopAcM_SearchByID(i_this->mBallID)); if (ball_actor != NULL) { - ball_actor->current.pos = i_this->eyePos; + ball_actor->current.pos = actor->eyePos; ball_actor->mSuspended = false; } - cXyz scale; - scale.setall(2.0f); - dComIfGp_particle_set(0x8198, &i_this->eyePos, &i_this->shape_angle, &scale); - dComIfGp_particle_set(0x8199, &i_this->eyePos, &i_this->shape_angle, &scale); + cXyz scale(2.0f + TREG_F(8), 2.0f + TREG_F(8), 2.0f + TREG_F(8)); + dComIfGp_particle_set(0x8198, &actor->eyePos, &actor->shape_angle, &scale); + dComIfGp_particle_set(0x8199, &actor->eyePos, &actor->shape_angle, &scale); i_this->mTKBallSpawned = false; } if (i_this->mAttentionOFF) { - fopAcM_OffStatus(i_this, 0); - i_this->attention_info.flags = 0; + fopAcM_OffStatus(actor, 0); + actor->attention_info.flags = 0; } else { - fopAcM_OnStatus(i_this, 0); - i_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + fopAcM_OnStatus(actor, 0); + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; } MTXCopy(model->getAnmMtx(2), *calc_mtx); @@ -449,7 +502,7 @@ static int daE_TK2_Execute(e_tk2_class* i_this) { MtxPosition(&cStack_94, &cStack_a0); i_this->mSph.SetC(cStack_a0); - i_this->mSph.SetR(50.0f * l_HIO.mRadiusScale); + i_this->mSph.SetR((50.0f + JREG_F(3)) * l_HIO.mBaseSize); dComIfG_Ccsp()->Set(&i_this->mSph); @@ -461,18 +514,23 @@ static int daE_TK2_IsDelete(e_tk2_class* i_this) { } static int daE_TK2_Delete(e_tk2_class* i_this) { + fopAc_ac_c* actor = i_this; + + fopAcM_RegisterDeleteID(i_this, "E_TK2"); + dComIfG_resDelete(&i_this->mPhaseReq, "E_tk2"); if (i_this->mInitHIO) { hio_set = false; + mDoHIO_DELETE_CHILD(l_HIO.mNo); } - if (i_this->heap != NULL) { + if (actor->heap != NULL) { i_this->mpMorf->stopZelAnime(); } return 1; } -static int useHeapInit(fopAc_ac_c* a_this) { - e_tk2_class* i_this = static_cast(a_this); +static int useHeapInit(fopAc_ac_c* actor) { + e_tk2_class* i_this = static_cast(actor); i_this->mpMorf = new mDoExt_McaMorfSO((J3DModelData*)dComIfG_getObjectRes("E_tk2", 0xE), NULL, NULL, @@ -486,61 +544,66 @@ static int useHeapInit(fopAc_ac_c* a_this) { return 1; } -static int daE_TK2_Create(fopAc_ac_c* i_this) { - static dCcD_SrcSph cc_sph_src = { - { - {0x0, {{0x0, 0x0, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf - { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph - } // mSphAttr - }; - +static int daE_TK2_Create(fopAc_ac_c* actor) { + e_tk2_class* i_this = (e_tk2_class*)actor; fopAcM_ct(i_this, e_tk2_class); - e_tk2_class* a_this = static_cast(i_this); - cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&a_this->mPhaseReq, "E_tk2"); + cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->mPhaseReq, "E_tk2"); if (phase == cPhs_COMPLEATE_e) { - a_this->mArg0 = fopAcM_GetParamBit(a_this, 0, 8); - a_this->mArg1 = fopAcM_GetParamBit(a_this, 8, 4); - a_this->mArg2 = fopAcM_GetParamBit(a_this, 12, 4); + OS_REPORT("E_tk2 PARAM %x\n", fopAcM_GetParam(actor)); + i_this->mArg0 = (fopAcM_GetParam(actor) & 0xFF) >> 0; + i_this->mArg1 = (fopAcM_GetParam(actor) & 0xF00) >> 8; + i_this->mArg2 = (fopAcM_GetParam(actor) & 0xF000) >> 12; - if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0x23a0)) { + OS_REPORT("E_tk2//////////////E_TK2 SET 1 !!\n"); + + if (!fopAcM_entrySolidHeap(actor, useHeapInit, 0x23a0)) { + OS_REPORT("//////////////E_TK2 SET NON !!\n"); return cPhs_ERROR_e; } + OS_REPORT("//////////////E_TK2 SET 2 !!\n"); + if (hio_set == false) { - a_this->mInitHIO = true; + i_this->mInitHIO = true; hio_set = true; - l_HIO.field_0x04 = -1; + l_HIO.mNo = mDoHIO_CREATE_CHILD("たどぽーる2", &l_HIO); // "Tadpole 2" } - a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; - fopAcM_SetMtx(a_this, a_this->mpMorf->getModel()->getBaseTRMtx()); - fopAcM_SetMin(a_this, -100.0f, -100.0f, -100.0f); - fopAcM_SetMax(a_this, 100.0f, 100.0f, 100.0f); + fopAcM_SetMtx(actor, i_this->mpMorf->getModel()->getBaseTRMtx()); + fopAcM_SetMin(actor, -100.0f, -100.0f, -100.0f); + fopAcM_SetMax(actor, 100.0f, 100.0f, 100.0f); - a_this->attention_info.distances[fopAc_attn_BATTLE_e] = 0x04; - a_this->health = 0; - a_this->field_0x560 = 0; + actor->attention_info.distances[fopAc_attn_BATTLE_e] = 0x04; + actor->field_0x560 = actor->health = 0; - a_this->mStts.Init(100, 0, a_this); - a_this->mSph.Set(cc_sph_src); - a_this->mSph.SetStts(&a_this->mStts); + static dCcD_SrcSph cc_sph_src = { + { + {0x0, {{0x0, 0x0, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf + { + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + } // mSphAttr + }; - a_this->mAcch.Set(&i_this->current.pos, &a_this->old.pos, a_this, 1, &a_this->mAcchCir, - fopAcM_GetSpeed_p(a_this), NULL, NULL); + i_this->mStts.Init(100, 0, actor); + i_this->mSph.Set(cc_sph_src); + i_this->mSph.SetStts(&i_this->mStts); - a_this->mAcchCir.SetWall(-50.0f, 60.0f); - a_this->mSound.init(&a_this->current.pos, &a_this->eyePos, 0x3, 0x1); - a_this->mSound.setEnemyName("E_tk2"); - a_this->mAtInfo.mpSound = &a_this->mSound; - a_this->mExecuteState = 0x14; - daE_TK2_Execute(a_this); + i_this->mAcch.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, + &i_this->mAcchCir, fopAcM_GetSpeed_p(actor), NULL, NULL); + + i_this->mAcchCir.SetWall(-50.0f, 60.0f); + i_this->mSound.init(&actor->current.pos, &actor->eyePos, 0x3, 0x1); + i_this->mSound.setEnemyName("E_tk2"); + i_this->mAtInfo.mpSound = &i_this->mSound; + i_this->mExecuteState = 0x14; + daE_TK2_Execute(i_this); } return phase; } diff --git a/src/d/actor/d_a_e_tk_ball.cpp b/src/d/actor/d_a_e_tk_ball.cpp index 4429670d69..c1ca119e2e 100644 --- a/src/d/actor/d_a_e_tk_ball.cpp +++ b/src/d/actor/d_a_e_tk_ball.cpp @@ -1,12 +1,13 @@ /** -* @file d_a_e_tk_ball.cpp + * @file d_a_e_tk_ball.cpp * */ -#include "d/dolzel_rel.h" // IWYU pragma: keep +#include "d/dolzel_rel.h" // IWYU pragma: keep #include "d/actor/d_a_e_tk_ball.h" #include "d/actor/d_a_player.h" +#include "d/d_s_play.h" enum Action { /* 0x00 */ ACT_TK_BALL_MOVE, // Move in a straight line @@ -30,8 +31,10 @@ static int daE_TK_BALL_Draw(e_tk_ball_class* i_this) { return 1; } - g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr); - g_env_light.setLightTevColorType_MAJI(i_this->mpModel, &i_this->tevStr); + fopAc_ac_c* actor = i_this; + + g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); + g_env_light.setLightTevColorType_MAJI(i_this->mpModel, &actor->tevStr); mDoExt_modelUpdateDL(i_this->mpModel); return 1; } @@ -39,15 +42,20 @@ static int daE_TK_BALL_Draw(e_tk_ball_class* i_this) { static int simple_bg_check(e_tk_ball_class* i_this) { fopAc_ac_c* actor = i_this; - cXyz current_pos = actor->current.pos; + cXyz current_pos; + cXyz start_pos; + cXyz end_pos; + cXyz ray_offset; + cXyz mtx_offset; + + current_pos = actor->current.pos; current_pos.y += i_this->mArcHeight; cMtx_YrotS(*calc_mtx, actor->current.angle.y); - cXyz start_pos; - cXyz end_pos; - cXyz ray_offset(0.0f, 30.0f, -50.0f); + ray_offset.x = 0.0f; + ray_offset.y = 30.0f; + ray_offset.z = -50.0f; - cXyz mtx_offset; MtxPosition(&ray_offset, &mtx_offset); start_pos = current_pos + mtx_offset; @@ -66,13 +74,14 @@ static int simple_bg_check(e_tk_ball_class* i_this) { } static void impact_eff_set(e_tk_ball_class* i_this) { - cXyz pos = i_this->current.pos; + fopAc_ac_c* actor = i_this; + cXyz pos = actor->current.pos; pos.y += i_this->mArcHeight; - cXyz scale(2.0f, 2.0f, 2.0f); + cXyz scale(2.0f + TREG_F(8), 2.0f + TREG_F(8), 2.0f + TREG_F(8)); - csXyz rotation = i_this->current.angle; - rotation.y -= 0x8000; + csXyz rotation = actor->current.angle; + ADD_ANGLE(rotation.y, 0x8000); if (i_this->mType == TYPE_TK_BALL_WATER) { dComIfGp_particle_set(0x819B, &pos, &rotation, &scale); @@ -91,14 +100,14 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { cXyz direction_vec; cXyz speed_vec; - cXyz target_center; + cXyz unk1; switch (i_this->mMode) { case MODE_TK_BALL_INIT: i_this->mMode = MODE_TK_BALL_MOVE; i_this->mInitalPosition = actor->current.pos; direction_vec = player->eyePos; - direction_vec.y += -20.0f; + direction_vec.y += -20.0f + TREG_F(9); direction_vec -= i_this->mInitalPosition; i_this->mInitalDistance = direction_vec.abs(); @@ -112,7 +121,9 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { cMtx_YrotS(*calc_mtx, actor->current.angle.y); cMtx_XrotM(*calc_mtx, actor->current.angle.x); - direction_vec.set(0.0f, 0.0f, 50.0f); + direction_vec.x = 0.0f; + direction_vec.y = 0.0f; + direction_vec.z = 50.0f + TREG_F(10); MtxPosition(&direction_vec, &actor->speed); i_this->mAtSph.OnAtVsPlayerBit(); @@ -126,7 +137,7 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { break; } - target_center = actor->current.pos; + cXyz target_center = actor->current.pos; target_center.y += i_this->mArcHeight; i_this->mTgSph.SetC(target_center); dComIfG_Ccsp()->Set(&i_this->mTgSph); @@ -146,7 +157,7 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { if (actor_lockon && daPy_getPlayerActorClass()->getCutType() != daPy_py_c::CUT_TYPE_NONE) { i_this->mAction = ACT_TK_BALL_RETURN; i_this->mMode = MODE_TK_BALL_INIT; - actor->current.angle.y -= 0x8000; + ADD_ANGLE(actor->current.angle.y, 0x8000); } else { i_this->mAction = ACT_TK_BALL_DROP; i_this->mMode = MODE_TK_BALL_INIT; @@ -165,7 +176,7 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { speed_vec.x = 0.0; speed_vec.y = 0.0; if (daPy_getPlayerActorClass()->getCutType() != daPy_py_c::CUT_TYPE_NONE) { - speed_vec.z = 60.0f; + speed_vec.z = 60.0f + TREG_F(16); } cMtx_YrotS(*calc_mtx, actor->current.angle.y); cMtx_XrotM(*calc_mtx, actor->current.angle.x); @@ -187,46 +198,59 @@ static void e_tk_ball_move(e_tk_ball_class* i_this) { } static void e_tk_ball_return(e_tk_ball_class* i_this) { + fopAc_ac_c* actor = i_this; + + cXyz _unk1; + cXyz _unk2; + switch (i_this->mMode) { case MODE_TK_BALL_INIT: - i_this->current.pos += i_this->speed; + actor->current.pos += actor->speed; if (i_this->mActionTimer[1] == 0) { i_this->mTgSph.SetTgHitMark(CcG_Tg_UNK_MARK_0); } break; } - cXyz new_center = i_this->current.pos; + cXyz new_center = actor->current.pos; new_center.y += i_this->mArcHeight; i_this->mAtSph.MoveCAt(new_center); dComIfG_Ccsp()->Set(&i_this->mAtSph); if (i_this->mActionTimer[1] == 0 && (simple_bg_check(i_this) || i_this->mAtSph.ChkAtHit())) { impact_eff_set(i_this); - fopAcM_delete(i_this); + fopAcM_delete(actor); } } static void e_tk_ball_drop(e_tk_ball_class* i_this) { + fopAc_ac_c* actor = i_this; + + cXyz _unk1; + cXyz _unk2; + switch (i_this->mMode) { case MODE_TK_BALL_INIT: - i_this->current.pos += i_this->speed; - i_this->speed.y -= 2.0f; - if (i_this->speed.y < -50.0f) { - i_this->speed.y = -50.0f; + actor->current.pos += actor->speed; + actor->speed.y -= 2.0f; + if (actor->speed.y < -50.0f) { + actor->speed.y = -50.0f; } break; } if (simple_bg_check(i_this) || i_this->mActionTimer[0] == 0) { impact_eff_set(i_this); - fopAcM_delete(i_this); + fopAcM_delete(actor); } } static void action(e_tk_ball_class* i_this) { fopAc_ac_c* actor = i_this; + cXyz position_diff; + cXyz _unk2; + static u16 e_id[3] = {0x819D, 0x819E, 0x819A}; s8 is_moving = true; @@ -244,11 +268,11 @@ static void action(e_tk_ball_class* i_this) { } if (is_moving) { - cXyz position_diff = actor->home.pos - actor->current.pos; + position_diff = actor->home.pos - actor->current.pos; f32 pos_diff_abs = position_diff.abs(); - f32 height_scale = i_this->mInitalDistance * 0.1f; - if (height_scale > 300.0f) { - height_scale = 300.0f; + f32 height_scale = i_this->mInitalDistance * (TREG_F(19) + 0.1f); + if (height_scale > 300.0f + TREG_F(18)) { + height_scale = 300.0f + TREG_F(18); } i_this->mArcHeight = height_scale * cM_ssin((pos_diff_abs / i_this->mInitalDistance) * 32768.0f); @@ -262,7 +286,7 @@ static void action(e_tk_ball_class* i_this) { cXyz particle_position = actor->current.pos; particle_position.y += i_this->mArcHeight; - cXyz particle_scale(2.0f, 2.0f, 2.0f); + cXyz particle_scale(2.0f + TREG_F(8), 2.0f + TREG_F(8), 2.0f + TREG_F(8)); for (int i = 0; i < 2; i++) { i_this->mParticleKey[i] = dComIfGp_particle_set( @@ -294,6 +318,11 @@ static int daE_TK_BALL_Execute(e_tk_ball_class* i_this) { return 1; } + fopAc_ac_c* actor = i_this; + + cXyz _unk1; + cXyz _unk2; + i_this->mLifetime++; for (int i = 0; i < 2; i++) { if (i_this->mActionTimer[i] != 0) { @@ -306,17 +335,18 @@ static int daE_TK_BALL_Execute(e_tk_ball_class* i_this) { action(i_this); - i_this->shape_angle.y += 0x1000; - i_this->shape_angle.x += 0xE00; + ADD_ANGLE(actor->shape_angle.y, 0x1000); + ADD_ANGLE(actor->shape_angle.x, 0xE00); - mDoMtx_stack_c::transS(i_this->current.pos.x, i_this->current.pos.y + i_this->mArcHeight, - i_this->current.pos.z); - mDoMtx_stack_c::YrotM(i_this->shape_angle.y); - mDoMtx_stack_c::XrotM(i_this->shape_angle.x); - mDoMtx_stack_c::scaleM(2.0f, 2.0f, 2.0f); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y + i_this->mArcHeight, + actor->current.pos.z); + mDoMtx_stack_c::YrotM(actor->shape_angle.y); + mDoMtx_stack_c::XrotM(actor->shape_angle.x); + f32 scale = 2.0f + TREG_F(8); + mDoMtx_stack_c::scaleM(scale, scale, scale); i_this->mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(i_this))); + i_this->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(actor))); return 1; } @@ -325,29 +355,32 @@ static int daE_TK_BALL_IsDelete(e_tk_ball_class* i_this) { } static int daE_TK_BALL_Delete(e_tk_ball_class* i_this) { + fopAc_ac_c* actor = i_this; + fopAcM_RegisterDeleteID(i_this, "E_TK_BALL"); if (i_this->mType == TYPE_TK_BALL_WATER) { dComIfG_resDelete(&i_this->mPhaseReq, "E_tk"); } else { dComIfG_resDelete(&i_this->mPhaseReq, "E_tk2"); } - if (i_this->heap != NULL) { + if (actor->heap != NULL) { i_this->mSound.deleteObject(); } return 1; } static int useHeapInit(fopAc_ac_c* i_this) { - e_tk_ball_class* a_this = static_cast(i_this); - J3DModelData* ball_model; + e_tk_ball_class* actor = static_cast(i_this); + J3DModelData* modelData; - if (a_this->mType == TYPE_TK_BALL_WATER) { - ball_model = (J3DModelData*)dComIfG_getObjectRes("E_tk", 0xD); + if (actor->mType == TYPE_TK_BALL_WATER) { + modelData = (J3DModelData*)dComIfG_getObjectRes("E_tk", 0xD); } else { - ball_model = (J3DModelData*)dComIfG_getObjectRes("E_tk2", 0xD); + modelData = (J3DModelData*)dComIfG_getObjectRes("E_tk2", 0xD); } - a_this->mpModel = mDoExt_J3DModel__create(ball_model, 0x80000, 0x11000084); + JUT_ASSERT(679, modelData != 0); + actor->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); - if (a_this->mpModel == NULL) { + if (actor->mpModel == NULL) { return 0; } else { return 1; @@ -355,77 +388,84 @@ static int useHeapInit(fopAc_ac_c* i_this) { } static int daE_TK_BALL_Create(fopAc_ac_c* i_this) { - static dCcD_SrcSph at_sph_src = { - { - {0x0, {{AT_TYPE_CSTATUE_SWING, 0x1, 0xd}, {0x0, 0x0}, 0x0}}, // mObj - {dCcD_SE_METAL, 0x1, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf - { - {{0.0f, 0.0f, 0.0f}, 20.0f} // mSph - } // mSphAttr - }; + e_tk_ball_class* actor = (e_tk_ball_class*)i_this; + fopAcM_ct(actor, e_tk_ball_class); - static dCcD_SrcSph tg_sph_src = { - { - {0x0, {{0x0, 0x0, 0x0}, {0xd8fbfdff, 0x3}, 0x0}}, // mObj - {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt - {dCcD_SE_METAL, 0x5, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf - { - {{0.0f, 0.0f, 0.0f}, 35.0f} // mSph - } // mSphAttr - }; - - fopAcM_ct(i_this, e_tk_ball_class); - e_tk_ball_class* a_this = static_cast(i_this); - - a_this->mType = fopAcM_GetParam(a_this); - if (a_this->mType == TYPE_TK_BALL_UNK) { - a_this->mType = TYPE_TK_BALL_WATER; + actor->mType = fopAcM_GetParam(i_this); + if (actor->mType == TYPE_TK_BALL_UNK) { + actor->mType = TYPE_TK_BALL_WATER; } cPhs__Step phase; u32 size; - if (a_this->mType == TYPE_TK_BALL_WATER) { - phase = (cPhs__Step)dComIfG_resLoad(&a_this->mPhaseReq, "E_tk"); + if (actor->mType == TYPE_TK_BALL_WATER) { + phase = (cPhs__Step)dComIfG_resLoad(&actor->mPhaseReq, "E_tk"); size = 0x820; } else { - phase = (cPhs__Step)dComIfG_resLoad(&a_this->mPhaseReq, "E_tk2"); + phase = (cPhs__Step)dComIfG_resLoad(&actor->mPhaseReq, "E_tk2"); size = 0xEE0; } if (phase == cPhs_COMPLEATE_e) { - a_this->mArg1 = fopAcM_GetParamBit(i_this, 8, 8); - if (a_this->mArg1 == 0xff) { - a_this->mArg1 = 0x00; + OS_REPORT("E_tk_BALL PARAM %x\n", fopAcM_GetParam(i_this)); + actor->mArg1 = (fopAcM_GetParam(i_this) & 0xFF00) >> 8; + if (actor->mArg1 == 0xff) { + actor->mArg1 = 0x00; } + OS_REPORT("E_tk_BALL//////////////E_TK_BALL SET 1 !!\n"); + if (!fopAcM_entrySolidHeap(i_this, useHeapInit, size)) { + OS_REPORT("//////////////E_TK_BALL SET NON !!\n"); return cPhs_ERROR_e; } - fopAcM_SetMtx(a_this, a_this->mpModel->getBaseTRMtx()); - a_this->mStts.Init(0xff, 0, a_this); - a_this->mAtSph.Set(at_sph_src); - a_this->mAtSph.SetStts(&a_this->mStts); - if (a_this->mType == TYPE_TK_BALL_FIRE) { - a_this->mAtSph.SetAtType(AT_TYPE_100); - a_this->mAtSph.SetAtMtrl(dCcD_MTRL_FIRE); + + OS_REPORT("//////////////E_TK_BALL SET 2 !!\n"); + + static dCcD_SrcSph at_sph_src = { + { + {0x0, {{AT_TYPE_CSTATUE_SWING, 0x1, 0xd}, {0x0, 0x0}, 0x0}}, // mObj + {dCcD_SE_METAL, 0x1, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf + { + {{0.0f, 0.0f, 0.0f}, 20.0f} // mSph + } // mSphAttr + }; + + static dCcD_SrcSph tg_sph_src = { + { + {0x0, {{0x0, 0x0, 0x0}, {0xd8fbfdff, 0x3}, 0x0}}, // mObj + {dCcD_SE_NONE, 0x0, 0x0, 0x0, 0x0}, // mGObjAt + {dCcD_SE_METAL, 0x5, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf + { + {{0.0f, 0.0f, 0.0f}, 35.0f} // mSph + } // mSphAttr + }; + + fopAcM_SetMtx(i_this, actor->mpModel->getBaseTRMtx()); + actor->mStts.Init(0xff, 0, i_this); + actor->mAtSph.Set(at_sph_src); + actor->mAtSph.SetStts(&actor->mStts); + if (actor->mType == TYPE_TK_BALL_FIRE) { + actor->mAtSph.SetAtType(AT_TYPE_100); + actor->mAtSph.SetAtMtrl(dCcD_MTRL_FIRE); } - a_this->mTgSph.Set(tg_sph_src); - a_this->mTgSph.SetStts(&a_this->mStts); + actor->mTgSph.Set(tg_sph_src); + actor->mTgSph.SetStts(&actor->mStts); - a_this->mSound.init(&a_this->current.pos, 1); - a_this->shape_angle.y = cM_rndFX(32768.0f); - a_this->shape_angle.x = cM_rndFX(32768.0f); - a_this->mSuspended = true; + actor->mSound.init(&i_this->current.pos, 1); + i_this->shape_angle.y = cM_rndFX(32768.0f); + i_this->shape_angle.x = cM_rndFX(32768.0f); + actor->mSuspended = true; mDoMtx_stack_c::scaleS(0.0f, 0.0f, 0.0f); - a_this->mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); - daE_TK_BALL_Execute(a_this); + actor->mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + daE_TK_BALL_Execute(actor); } return phase; }