From 5716efc4c86f5e7e03263f0ed426c5e9ae834cd3 Mon Sep 17 00:00:00 2001 From: Carco_21 <144170194+carter-ktb21@users.noreply.github.com> Date: Wed, 3 Dec 2025 17:16:08 -0500 Subject: [PATCH] d_a_e_dn work (#2899) * d_a_e_dn work * PR cleanup and more documentation --- config/GZ2E01/rels/d_a_e_dn/symbols.txt | 2 +- configure.py | 2 +- include/d/actor/d_a_e_dn.h | 148 +- include/f_op/f_op_actor.h | 18 +- src/d/actor/d_a_e_dn.cpp | 3131 ++++++++++++----------- src/d/actor/d_a_e_rd.cpp | 12 +- src/d/actor/d_a_obj_key.cpp | 2 +- 7 files changed, 1696 insertions(+), 1619 deletions(-) diff --git a/config/GZ2E01/rels/d_a_e_dn/symbols.txt b/config/GZ2E01/rels/d_a_e_dn/symbols.txt index 759afc6fe3f..4d7df8c258f 100644 --- a/config/GZ2E01/rels/d_a_e_dn/symbols.txt +++ b/config/GZ2E01/rels/d_a_e_dn/symbols.txt @@ -219,7 +219,7 @@ __global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:globa @1012 = .bss:0x0000003C; // type:object size:0x1 scope:local @1010 = .bss:0x00000040; // type:object size:0x1 scope:local @1009 = .bss:0x00000044; // type:object size:0x1 scope:local -lbl_65_bss_45 = .bss:0x00000045; // type:object size:0x1 data:byte +l_initHIO = .bss:0x00000045; // type:object size:0x1 data:byte @3805 = .bss:0x00000048; // type:object size:0xC scope:local l_HIO = .bss:0x00000054; // type:object size:0x28 scope:global data:byte target_info = .bss:0x0000007C; // type:object size:0x28 scope:global diff --git a/configure.py b/configure.py index dd01d2719cb..17bf9c32d10 100755 --- a/configure.py +++ b/configure.py @@ -260,7 +260,7 @@ cflags_base = [ ] if config.version == "ShieldD": - cflags_base.extend(["-O0", "-inline off", "-RTTI on", "-str reuse", "-enc SJIS", "-DDEBUG=1", "-DWIDESCREEN_SUPPORT=1"]) + cflags_base.extend(["-O0", "-inline off", "-RTTI on", "-str reuse", "-enc SJIS", "-DDEBUG=1", "-DWIDESCREEN_SUPPORT=1", '-pragma "nosyminline on"']) elif config.version == "RZDE01_00" or config.version == "RZDE01_02" or config.version == "Shield": cflags_base.extend(["-O4,p", "-inline auto", "-ipa file", "-RTTI on", "-str reuse", "-enc SJIS", "-DWIDESCREEN_SUPPORT=1"]) else: diff --git a/include/d/actor/d_a_e_dn.h b/include/d/actor/d_a_e_dn.h index 88c1341e963..79491af5e19 100644 --- a/include/d/actor/d_a_e_dn.h +++ b/include/d/actor/d_a_e_dn.h @@ -13,56 +13,56 @@ * * @details * - */ +*/ + class e_dn_class { public: e_dn_class(); /* 0x0000 */ fopEn_enemy_c actor; - /* 0x05AC */ request_of_phase_process_class mPhase; - /* 0x05B4 */ s16 mMode; - /* 0x05B6 */ u8 field_0x5b6; - /* 0x05B7 */ u8 field_0x5b7; - /* 0x05B8 */ u8 field_0x5b8; - /* 0x05B9 */ u8 field_0x5b9; + /* 0x05AC */ request_of_phase_process_class phase; + /* 0x05B4 */ s16 mode; + /* 0x05B6 */ u8 arg0; + /* 0x05B7 */ u8 arg1; + /* 0x05B8 */ u8 arg2; + /* 0x05B9 */ u8 arg3; /* 0x05BC */ cXyz field_0x5bc; /* 0x05C8 */ cXyz field_0x5c8; - /* 0x05D4 */ s16 field_0x5d4; + /* 0x05D4 */ s16 cur_angle_y_target; /* 0x05D6 */ s16 field_0x5d6; /* 0x05D8 */ s8 field_0x5d8; - /* 0x05DC */ mDoExt_McaMorfSO* mpModelMorf; - /* 0x05E0 */ int mAnmID; - /* 0x05E4 */ J3DModel* mpKnifeModel; - /* 0x05E8 */ Z2CreatureEnemy mSound; - /* 0x068C */ J3DModel* mpShieldModel; - /* 0x0690 */ J3DModel* mpSkullModel; + /* 0x05DC */ mDoExt_McaMorfSO* anm_p; + /* 0x05E0 */ int anm_no; + /* 0x05E4 */ J3DModel* knife_model; + /* 0x05E8 */ Z2CreatureEnemy sound; + /* 0x068C */ J3DModel* tate_model; + /* 0x0690 */ J3DModel* skull_model; /* 0x0694 */ s8 field_0x694; - /* 0x0698 */ cXyz field_0x698; + /* 0x0698 */ cXyz skull_trans; /* 0x06A4 */ cXyz field_0x6a4; - /* 0x06B0 */ s16 field_0x6b0; - /* 0x06B2 */ s16 field_0x6b2; - /* 0x06B4 */ dJntCol_c mJntCol; - /* 0x06C4 */ s8 field_0x6c4; - /* 0x06C8 */ f32 field_0x6c8; - /* 0x06CC */ s16 field_0x6cc; - /* 0x06CE */ s16 mAction; - /* 0x06D0 */ f32 mPlayerDistance; - /* 0x06D4 */ s16 mYAngleToPlayer; - /* 0x06D6 */ s16 mXAngleToPlayer; - /* 0x06D8 */ f32 field_0x6d8; - /* 0x06DC */ u32 mShadowKey; - /* 0x06E0 */ s16 field_0x6e0[4]; - /* 0x06E8 */ s16 field_0x6e8; - /* 0x06EA */ s16 field_0x6ea; - /* 0x06EC */ s16 field_0x6ec; - /* 0x06EE */ s8 field_0x6ee; - /* 0x06EF */ s8 field_0x6ef; - /* 0x06F0 */ s8 field_0x6f0; - /* 0x06F1 */ s8 field_0x6f1; + /* 0x06B0 */ s16 skull_y_rot; + /* 0x06B2 */ s16 skull_x_rot; + /* 0x06B4 */ dJntCol_c jc; + /* 0x06C4 */ s8 death_flag; + /* 0x06C8 */ f32 color; + /* 0x06CC */ s16 frame_counter; + /* 0x06CE */ s16 action; + /* 0x06D0 */ f32 pl_dir; + /* 0x06D4 */ s16 search_angle_y; + /* 0x06D6 */ s16 search_angle_x; + /* 0x06D8 */ f32 pl_range; + /* 0x06DC */ u32 shadow_key; + /* 0x06E0 */ s16 timer[4]; + /* 0x06E8 */ s16 invulnerability_timer; + /* 0x06EA */ s16 unk_timer_1; + /* 0x06EC */ s16 unk_timer_2; + /* 0x06EE */ s8 tail_at_sph_flag; + /* 0x06EF */ s8 at_chk_flag; + /* 0x06F0 */ s8 at_sph_center_flag; + /* 0x06F1 */ s8 guard_flag; /* 0x06F2 */ s8 field_0x6f2; /* 0x06F3 */ s8 field_0x6f3; /* 0x06F4 */ s8 field_0x6f4; - /* 0x06F5 */ u8 field_0x6f5; /* 0x06F6 */ s16 field_0x6f6; /* 0x06F8 */ s16 field_0x6f8; /* 0x06FA */ s16 field_0x6fa; @@ -75,16 +75,16 @@ public: /* 0x070C */ s16 field_0x70c; /* 0x070E */ s16 field_0x70e; /* 0x0710 */ s8 field_0x710; - /* 0x0711 */ u8 field_0x711[15]; - /* 0x0720 */ f32 field_0x720; + /* 0x0714 */ cXyz field_0x711; + /* 0x0720 */ f32 cur_pos_y_offset; /* 0x0724 */ csXyz field_0x724; /* 0x072A */ csXyz field_0x72a; /* 0x0730 */ csXyz field_0x730; - /* 0x0736 */ s8 field_0x736; - /* 0x0737 */ s8 field_0x737; - /* 0x0738 */ cXyz field_0x738; - /* 0x0744 */ int field_0x744; - /* 0x0748 */ u8 field_0x748[4]; + /* 0x0736 */ s8 unk_timer_3; + /* 0x0737 */ s8 left_right_flag; + /* 0x0738 */ cXyz find_pos; + /* 0x0744 */ int learn; + /* 0x0748 */ u8 field_0x748[0x74c - 0x748]; /* 0x074C */ f32 field_0x74c; /* 0x0750 */ s16 field_0x750; /* 0x0754 */ f32 field_0x754; @@ -95,49 +95,45 @@ public: /* 0x07A4 */ csXyz field_0x7a4[11]; /* 0x07E8 */ f32 field_0x7e8; /* 0x07EC */ s16 field_0x7ec[2]; - /* 0x07F0 */ s16 field_0x7f0; - /* 0x07F2 */ s16 field_0x7f2; - /* 0x07F4 */ s16 field_0x7f4; - /* 0x07F6 */ s16 field_0x7f6; - /* 0x07FA */ s16 field_0x7f8; - /* 0x07FA */ s16 field_0x7fa; + /* 0x07F0 */ s16 jnt_waist_z_rot; + /* 0x07F2 */ s16 jnt_arml1_z_rot_offset; + /* 0x07F4 */ s16 jnt_arml2_z_rot_offset; + /* 0x07F6 */ s16 jnt_armr1_z_rot_offset; + /* 0x07FA */ s16 jnt_armr2_z_rot_offset; + /* 0x07FA */ s16 jnt_legl1_y_rot; /* 0x07FC */ s16 field_0x7fc[3]; /* 0x0802 */ s16 field_0x802[4]; - /* 0x080A */ s16 field_0x80a; - /* 0x080C */ s16 field_0x80c; + /* 0x080A */ s16 death_jnt_rot; + /* 0x080C */ s16 death_jnt_rot_counter; /* 0x080E */ csXyz field_0x80e[4]; - /* 0x0826 */ s16 field_0x826; - /* 0x0828 */ s16 field_0x828; - /* 0x082A */ s16 field_0x82a; - /* 0x082C */ s16 field_0x82c; - /* 0x082E */ s8 field_0x82e; - /* 0x082F */ u8 field_0x82f; - /* 0x0830 */ s16 field_0x830; - /* 0x0832 */ s16 field_0x832; - /* 0x0834 */ u8 field_0x834[2]; + /* 0x0826 */ s16 jnt_tail_y_rot_offset; + /* 0x0828 */ s16 unk_timer_4; + /* 0x082A */ s16 angle_y_offset; + /* 0x082C */ s16 unk_counter_1; + /* 0x082E */ s8 snap_angle_y_flag; + /* 0x0830 */ csXyz field_0x830; /* 0x0836 */ csXyz field_0x836; /* 0x083C */ f32 field_0x83c; - /* 0x0840 */ s16 field_0x840; - /* 0x0842 */ s16 field_0x842; - /* 0x0844 */ dBgS_AcchCir mAcchCir; - /* 0x0884 */ dBgS_ObjAcch mObjAcch; + /* 0x0840 */ s16 unk_timer_5; + /* 0x0842 */ s16 unk_counter_2; + /* 0x0844 */ dBgS_AcchCir acchcir; + /* 0x0884 */ dBgS_ObjAcch objacch; /* 0x0A5C */ f32 field_0xa5c; - /* 0x0A60 */ dCcD_Stts mStts; - /* 0x0A9C */ dCcD_Sph field_0xa9c[3]; - /* 0x0E44 */ dCcD_Sph field_0xe44; - /* 0x0F7C */ dCcD_Sph field_0xf7c; - /* 0x10B4 */ dCcU_AtInfo mAtInfo; - /* 0x10D8 */ u8 field_0x10d8; - /* 0x10D9 */ u8 field_0x10d9; - /* 0x10DA */ s8 field_0x10da; - /* 0x10DB */ u8 field_0x10db; + /* 0x0A60 */ dCcD_Stts stts; + /* 0x0A9C */ dCcD_Sph cc_sph[3]; + /* 0x0E44 */ dCcD_Sph at_sph; + /* 0x0F7C */ dCcD_Sph tate_sph; + /* 0x10B4 */ dCcU_AtInfo at_info; + /* 0x10D8 */ u8 status; + /* 0x10D9 */ u8 hio_init; + /* 0x10DA */ s8 unk_timer_6; /* 0x10DC */ u32 field_0x10dc; /* 0x10E0 */ u32 field_0x10e0; - /* 0x10E4 */ s8 field_0x10e4; + /* 0x10E4 */ s8 set_smoke_flag; /* 0x10E8 */ u32 field_0x10e8[2]; /* 0x10F0 */ u32 field_0x10f0[2]; - /* 0x10F8 */ u32 field_0x10f8; - /* 0x10FC */ u32 field_0x10fc; + /* 0x10F8 */ u32 dn_tail_blur_a_prtcl; + /* 0x10FC */ u32 dn_tail_blur_b_prtcl; /* 0x1100 */ u8 field_0x1100[12]; }; diff --git a/include/f_op/f_op_actor.h b/include/f_op/f_op_actor.h index 03d840ffd38..2a145bf4963 100644 --- a/include/f_op/f_op_actor.h +++ b/include/f_op/f_op_actor.h @@ -312,10 +312,10 @@ public: bool checkWolfNoLock() const { return mFlags & fopEn_flag_WolfNoLock; } BOOL checkHeadLockFlg() const { return mFlags & fopEn_flag_HeadLock; } BOOL checkWolfBiteDamage() const { return mFlags & fopEn_flag_WolfBiteDamage; } - bool checkWolfDownPullFlg() const { return mFlags & fopEn_flag_WolfDownPull; } + BOOL checkWolfDownPullFlg() const { return mFlags & fopEn_flag_WolfDownPull; } bool checkDownFlg() { return mFlags & fopEn_flag_Down; } BOOL checkCutDownHitFlg() const { return mFlags & fopEn_flag_CutDownHit; } - bool checkWolfDownStartFlg() const { return mFlags & fopEn_flag_WolfDownStart; } + BOOL checkWolfDownStartFlg() const { return mFlags & fopEn_flag_WolfDownStart; } bool checkDeadFlg() const { return mFlags & fopEn_flag_Dead; } BOOL checkThrowMode(u8 param_1) const { return mThrowMode & param_1; } @@ -329,27 +329,21 @@ public: void onWolfDownStartFlg() { mFlags |= (fopEn_flag_WolfDownPull | fopEn_flag_WolfDownStart); } void onWolfDownPullEndFlg() { mFlags |= fopEn_flag_WolfDownPullEnd; } void onWolfNoLock() { mFlags |= (u16)fopEn_flag_WolfNoLock; } - #if DEBUG void onDownFlg() { mFlags |= (u16)fopEn_flag_Down; } void onHeadLockFlg() { mFlags |= (u16)fopEn_flag_HeadLock; } - #else - void onDownFlg() { mFlags |= fopEn_flag_Down; } - void onHeadLockFlg() { mFlags |= fopEn_flag_HeadLock; } - #endif #if DEBUG void offWolfBiteDamage() { mFlags &= (u16)~fopEn_flag_WolfBiteDamage; } - #else - void offWolfBiteDamage() { mFlags &= ~fopEn_flag_WolfBiteDamage; } - #endif - void offCutDownHitFlg() { mFlags &= ~fopEn_flag_CutDownHit; } + void offCutDownHitFlg() { mFlags &= (u16)~fopEn_flag_CutDownHit; } void offWolfDownPullFlg() { mFlags &= ~fopEn_flag_WolfDownPull; } - #if DEBUG void offDownFlg() { mFlags &= (u16)~(fopEn_flag_WolfDownPull | fopEn_flag_WolfDownStart | fopEn_flag_CutDownHit | fopEn_flag_Down); } void offWolfNoLock() { mFlags &= (u16)~fopEn_flag_WolfNoLock; } void offHeadLockFlg() { mFlags &= (u16)~fopEn_flag_HeadLock; } void offThrowMode(u8 throwMode) { mThrowMode &= (u8)~throwMode; } #else + void offWolfBiteDamage() { mFlags &= ~fopEn_flag_WolfBiteDamage; } + void offCutDownHitFlg() { mFlags &= ~fopEn_flag_CutDownHit; } + void offWolfDownPullFlg() { mFlags &= ~fopEn_flag_WolfDownPull; } void offDownFlg() { mFlags &= ~(fopEn_flag_WolfDownPull | fopEn_flag_WolfDownStart | fopEn_flag_CutDownHit | fopEn_flag_Down); } void offWolfNoLock() { mFlags &= ~fopEn_flag_WolfNoLock; } void offHeadLockFlg() { mFlags &= ~fopEn_flag_HeadLock; } diff --git a/src/d/actor/d_a_e_dn.cpp b/src/d/actor/d_a_e_dn.cpp index 7c62b43b46b..f547d690e53 100644 --- a/src/d/actor/d_a_e_dn.cpp +++ b/src/d/actor/d_a_e_dn.cpp @@ -21,18 +21,56 @@ public: void genMessage(JORMContext*); - /* 0x04 */ s8 field_0x4; + /* 0x04 */ s8 no; /* 0x08 */ f32 model_size; // 基本サイズ /* 0x0C */ f32 movement_speed; // 移動速度 /* 0x10 */ f32 dash_speed; // 突進速度 /* 0x14 */ f32 battle_init_range; // 戦闘開始範囲 /* 0x18 */ f32 attack_init_range; // 攻撃開始範囲 - /* 0x1C */ s16 field_0x1c; // 防御静止間 - /* 0x1E */ s16 field_0x1e; // 魂抜間 弱 - /* 0x20 */ s16 field_0x20; // 魂抜間 強 + /* 0x1C */ s16 defense_pause_time; // 防御静止間 + /* 0x1E */ s16 soul_disappear_time_weak; // 魂抜間 弱 + /* 0x20 */ s16 soul_disappear_time_strong; // 魂抜間 強 /* 0x22 */ u8 field_0x22; /* 0x23 */ u8 invulnerable; // 不死身 - /* 0x24 */ u8 field_0x24; // 学習なし + /* 0x24 */ u8 no_learn; // 学習なし +}; + +enum Joint { + /* 0x00 */ JNT_WORLD_ROOT, + /* 0x01 */ JNT_BACKBONE01, + /* 0x02 */ JNT_BACKBONE02, + /* 0x03 */ JNT_NECK01, + /* 0x04 */ JNT_NECK02, + /* 0x05 */ JNT_FIN, + /* 0x06 */ JNT_HEAD, + /* 0x07 */ JNT_JAW1, + /* 0x08 */ JNT_JAW2, + /* 0x09 */ JNT_TONGUE, + /* 0x0A */ JNT_SHOULDERL, + /* 0x0B */ JNT_ARML1, + /* 0x0C */ JNT_ARML2, + /* 0x0D */ JNT_HANDL, + /* 0x0E */ JNT_FINGERL1, + /* 0x0F */ JNT_FINGERL2, + /* 0x10 */ JNT_SHOULDERR, + /* 0x11 */ JNT_ARMR1, + /* 0x12 */ JNT_ARMR2, + /* 0x13 */ JNT_HANDR1, + /* 0x14 */ JNT_FINGERR1, + /* 0x15 */ JNT_FINGERR2, + /* 0x16 */ JNT_WAIST, + /* 0x17 */ JNT_LEGL1, + /* 0x18 */ JNT_LEGL2, + /* 0x19 */ JNT_LEGL3, + /* 0x1A */ JNT_FOOTL, + /* 0x1B */ JNT_LEGR1, + /* 0x1C */ JNT_LEGR2, + /* 0x1D */ JNT_LEGR3, + /* 0x1E */ JNT_FOOTR, + /* 0x1F */ JNT_TAIL01, + /* 0x20 */ JNT_TAIL02, + /* 0x21 */ JNT_TAIL03, + /* 0x22 */ JNT_TAIL04, }; enum Action { @@ -92,41 +130,57 @@ enum Animation { }; daE_DN_HIO_c::daE_DN_HIO_c() { - field_0x4 = -1; + no = -1; model_size = 1.1f; movement_speed = 7.5f; dash_speed = 25.0f; battle_init_range = 300.0f; attack_init_range = 350.0f; - field_0x1c = 3; - field_0x1e = 40; - field_0x20 = 80; + defense_pause_time = 3; + soul_disappear_time_weak = 40; + soul_disappear_time_strong = 80; field_0x22 = 1; invulnerable = 0; - field_0x24 = 0; + no_learn = 0; } +#if DEBUG +void daE_DN_HIO_c::genMessage(JORMContext* ctx) { + ctx->genLabel(" リザードマン", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("基本サイズ", &model_size, 0.0f, 5.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("移動速度", &movement_speed, 0.0f, 20.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("突進速度", &dash_speed, 0.0f, 40.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("戦闘開始範囲", &battle_init_range, 0.0f, 2000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("攻撃開始範囲", &attack_init_range, 0.0f, 1000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genCheckBox("不死身", &invulnerable, 1, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genCheckBox("学習なし", &no_learn, 1, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("魂抜間 弱", &soul_disappear_time_weak, 0, 100, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("魂抜間 強", &soul_disappear_time_strong, 0, 100, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("防御静止間", &defense_pause_time, 0, 20, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); +} +#endif + static void dn_disappear(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp1c, sp28; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + cXyz work, pos; - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); - sp1c.set(0.0f, 0.0f, 0.0f); - MtxPosition(&sp1c, &sp28); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), *calc_mtx); + work.set(0.0f, 0.0f, 0.0f); + MtxPosition(&work, &pos); - fopAcM_createDisappear(a_this, &sp28, 13, 0, 21); - fopAcM_delete(a_this); + fopAcM_createDisappear(actor, &pos, 13, 0, 21); + fopAcM_delete(actor); - int swBit = fopAcM_GetParam(a_this) >> 24; + int swBit = (fopAcM_GetParam(actor) & 0xFF000000) >> 24; if (swBit != 0xFF) { - dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(a_this)); + dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(actor)); } } -static void anm_init(e_dn_class* i_this, int i_anmID, f32 i_morf, u8 i_attr, f32 i_rate) { - i_this->mpModelMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_dn", i_anmID), i_attr, i_morf, +static void anm_init(e_dn_class* i_this, int i_anm_id, f32 i_morf, u8 i_attr, f32 i_rate) { + i_this->anm_p->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_dn", i_anm_id), i_attr, i_morf, i_rate, 0.0f, -1.0f); - i_this->mAnmID = i_anmID; + i_this->anm_no = i_anm_id; } static int nodeCallBack(J3DJoint* i_joint, int param_2) { @@ -137,64 +191,64 @@ static int nodeCallBack(J3DJoint* i_joint, int param_2) { if (i_this != NULL) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); - if (jointNo != 0) { - if (jointNo == 22) { - cMtx_YrotM(*calc_mtx, i_this->field_0x832); - cMtx_ZrotM(*calc_mtx, i_this->field_0x7f0 + (i_this->field_0x830 - i_this->field_0x762[2].x)); - } else if (jointNo == 23) { - cMtx_YrotM(*calc_mtx, i_this->field_0x7fa); - } else if (jointNo == 24) { + if (jointNo != JNT_WORLD_ROOT) { + if (jointNo == JNT_WAIST) { + cMtx_YrotM(*calc_mtx, (s16)i_this->field_0x830.y); + cMtx_ZrotM(*calc_mtx, i_this->jnt_waist_z_rot + (-i_this->field_0x762[2].x + i_this->field_0x830.x)); + } else if (jointNo == JNT_LEGL1) { + cMtx_YrotM(*calc_mtx, i_this->jnt_legl1_y_rot); + } else if (jointNo == JNT_LEGL2) { cMtx_ZrotM(*calc_mtx, i_this->field_0x7fc[0]); - } else if (jointNo == 27) { + } else if (jointNo == JNT_LEGR1) { cMtx_YrotM(*calc_mtx, i_this->field_0x7fc[1]); - } else if (jointNo == 28) { + } else if (jointNo == JNT_LEGR2) { cMtx_ZrotM(*calc_mtx, i_this->field_0x7fc[2]); - } else if (jointNo == 2) { - cMtx_YrotM(*calc_mtx, (i_this->field_0x6fa / 2) + (i_this->field_0x762[1].y + - i_this->field_0x6f6)); + } else if (jointNo == JNT_BACKBONE02) { + cMtx_YrotM(*calc_mtx, (i_this->field_0x6fa / 2) + (-i_this->field_0x6f6 + i_this->field_0x762[1].y)); cMtx_ZrotM(*calc_mtx, i_this->field_0x762[1].x + i_this->field_0x7ec[1]); - } else if (jointNo == 3 || jointNo == 4) { - cMtx_YrotM(*calc_mtx, i_this->field_0x762[0].y + (i_this->field_0x6fa - i_this->field_0x6f6)); - cMtx_ZrotM(*calc_mtx, i_this->field_0x7ec[0] + (i_this->field_0x762[0].x - i_this->field_0x6f8)); - } else if (jointNo == 11) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[3].y + i_this->field_0x7f2); - } else if (jointNo == 12) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[4].y + i_this->field_0x7f4); - } else if (jointNo == 17) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[5].y + i_this->field_0x7f6); - } else if (jointNo == 18) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[6].y + i_this->field_0x7f8); - } else if (jointNo >= 31 && jointNo <= 34) { - cMtx_YrotM(*calc_mtx, i_this->field_0x762[jointNo - 2].x + i_this->field_0x826); - cMtx_ZrotM(*calc_mtx, i_this->field_0x762[jointNo - 3].z); + } else if (jointNo == JNT_NECK01 || jointNo == JNT_NECK02) { + cMtx_YrotM(*calc_mtx, i_this->field_0x762[0].y + (-i_this->field_0x6f6 + i_this->field_0x6fa)); + cMtx_ZrotM(*calc_mtx, i_this->field_0x7ec[0] + (-i_this->field_0x6f8 + i_this->field_0x762[0].x)); + } else if (jointNo == JNT_ARML1) { + cMtx_ZrotM(*calc_mtx, i_this->field_0x762[3].y + i_this->jnt_arml1_z_rot_offset); + } else if (jointNo == JNT_ARML2) { + cMtx_ZrotM(*calc_mtx, i_this->field_0x762[4].y + i_this->jnt_arml2_z_rot_offset); + } else if (jointNo == JNT_ARMR1) { + cMtx_ZrotM(*calc_mtx, i_this->field_0x762[5].y + i_this->jnt_armr1_z_rot_offset); + } else if (jointNo == JNT_ARMR2) { + cMtx_ZrotM(*calc_mtx, i_this->field_0x762[6].y + i_this->jnt_armr2_z_rot_offset); + } else if (jointNo >= JNT_TAIL01 && jointNo <= JNT_TAIL04) { + cMtx_YrotM(*calc_mtx, i_this->field_0x80e[jointNo - 31].y + i_this->jnt_tail_y_rot_offset); + cMtx_ZrotM(*calc_mtx, (s16)i_this->field_0x80e[jointNo - 31].x); } } - if (i_this->field_0x80a != 0) { + if (i_this->death_jnt_rot != 0) { if ((jointNo & 1) != 0) { - cMtx_YrotM(*calc_mtx, i_this->field_0x80a); + cMtx_YrotM(*calc_mtx, i_this->death_jnt_rot); } else if ((jointNo & 2) != 0) { - cMtx_XrotM(*calc_mtx, i_this->field_0x80a); + cMtx_XrotM(*calc_mtx, i_this->death_jnt_rot); } else if ((jointNo & 4) != 0) { - cMtx_ZrotM(*calc_mtx, i_this->field_0x80a); + cMtx_ZrotM(*calc_mtx, i_this->death_jnt_rot); } } model->setAnmMtx(jointNo, *calc_mtx); MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); - if (jointNo == 0) { + if (jointNo == TREG_S(0)) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); - cMtx_YrotM(*calc_mtx, 0); - cMtx_XrotM(*calc_mtx, 0); - cMtx_ZrotM(*calc_mtx, 0); + cMtx_YrotM(*calc_mtx, TREG_S(1)); + cMtx_XrotM(*calc_mtx, TREG_S(2)); + cMtx_ZrotM(*calc_mtx, TREG_S(3)); model->setAnmMtx(jointNo, *calc_mtx); MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); } - if (jointNo == 0) { + if (jointNo == TREG_S(4)) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); - cMtx_YrotM(*calc_mtx, 0); - cMtx_XrotM(*calc_mtx, 0); - cMtx_ZrotM(*calc_mtx, 0); + cMtx_YrotM(*calc_mtx, TREG_S(5)); + cMtx_XrotM(*calc_mtx, TREG_S(6)); + cMtx_ZrotM(*calc_mtx, TREG_S(7)); model->setAnmMtx(jointNo, *calc_mtx); MTXCopy(*calc_mtx, J3DSys::mCurrentMtx); } @@ -205,76 +259,74 @@ static int nodeCallBack(J3DJoint* i_joint, int param_2) { } static int daE_DN_Draw(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - - if (i_this->field_0x10d8 != 0) { + if (i_this->status != 0) { return 1; } - J3DModel* model = i_this->mpModelMorf->getModel(); - g_env_light.settingTevStruct(0, &a_this->current.pos, &a_this->tevStr); - g_env_light.setLightTevColorType_MAJI(model, &a_this->tevStr); + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - J3DModelData* modelData; - J3DMaterial* matNode_p; - if (i_this->field_0x6c4 != 0) { - modelData = model->getModelData(); + J3DModel* model = i_this->anm_p->getModel(); + g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); + g_env_light.setLightTevColorType_MAJI(model, &actor->tevStr); + + if (i_this->death_flag != 0) { + J3DModelData* modelData = model->getModelData(); for (u16 i = 0; i < modelData->getMaterialNum(); i++) { - matNode_p = modelData->getMaterialNodePointer(i); - matNode_p->getTevColor(0)->r = i_this->field_0x6c8; - matNode_p->getTevColor(0)->g = i_this->field_0x6c8; - matNode_p->getTevColor(0)->b = i_this->field_0x6c8; + J3DMaterial* matNode_p = modelData->getMaterialNodePointer(i); + matNode_p->getTevColor(0)->r = i_this->color; + matNode_p->getTevColor(0)->g = i_this->color; + matNode_p->getTevColor(0)->b = i_this->color; } } - i_this->mpModelMorf->entryDL(); + i_this->anm_p->entryDL(); - if (i_this->field_0x6c4 != 0) { - modelData = model->getModelData(); + if (i_this->death_flag != 0) { + J3DModelData* modelData = model->getModelData(); for (u16 i = 0; i < modelData->getMaterialNum(); i++) { - matNode_p = modelData->getMaterialNodePointer(i); + J3DMaterial* matNode_p = modelData->getMaterialNodePointer(i); matNode_p->getTevColor(0)->r = 0; matNode_p->getTevColor(0)->g = 0; matNode_p->getTevColor(0)->b = 0; } } - g_env_light.setLightTevColorType_MAJI(i_this->mpKnifeModel, &a_this->tevStr); - mDoExt_modelUpdateDL(i_this->mpKnifeModel); + g_env_light.setLightTevColorType_MAJI(i_this->knife_model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->knife_model); - if (i_this->mpSkullModel != NULL) { - g_env_light.setLightTevColorType_MAJI(i_this->mpSkullModel, &a_this->tevStr); - mDoExt_modelUpdateDL(i_this->mpSkullModel); + if (i_this->skull_model != NULL) { + g_env_light.setLightTevColorType_MAJI(i_this->skull_model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->skull_model); } - g_env_light.setLightTevColorType_MAJI(i_this->mpShieldModel, &a_this->tevStr); - mDoExt_modelUpdateDL(i_this->mpShieldModel); + g_env_light.setLightTevColorType_MAJI(i_this->tate_model, &actor->tevStr); + mDoExt_modelUpdateDL(i_this->tate_model); - cXyz sp50; - sp50.set(a_this->current.pos.x, a_this->current.pos.y + 50.0f, a_this->current.pos.z); - i_this->mShadowKey = dComIfGd_setShadow(i_this->mShadowKey, 1, model, &sp50, 950.0f, 0.0f, - a_this->current.pos.y, i_this->mObjAcch.GetGroundH(), - i_this->mObjAcch.m_gnd, &a_this->tevStr, 0, 1.0f, + cXyz shadow_pos; + shadow_pos.set(actor->current.pos.x, actor->current.pos.y + 50.0f + BREG_F(18), actor->current.pos.z); + i_this->shadow_key = dComIfGd_setShadow(i_this->shadow_key, 1, model, &shadow_pos, BREG_F(19) + 950.0f, 0.0f, + actor->current.pos.y, i_this->objacch.GetGroundH(), + i_this->objacch.m_gnd, &i_this->actor.tevStr, 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); - dComIfGd_addRealShadow(i_this->mShadowKey, i_this->mpKnifeModel); - if (i_this->mpSkullModel != NULL) { - dComIfGd_addRealShadow(i_this->mShadowKey, i_this->mpSkullModel); + dComIfGd_addRealShadow(i_this->shadow_key, i_this->knife_model); + if (i_this->skull_model != NULL) { + dComIfGd_addRealShadow(i_this->shadow_key, i_this->skull_model); } - dComIfGd_addRealShadow(i_this->mShadowKey, i_this->mpShieldModel); + dComIfGd_addRealShadow(i_this->shadow_key, i_this->tate_model); return 1; } static BOOL other_bg_check(e_dn_class* i_this, fopAc_ac_c* i_actor) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; dBgS_LinChk lin_chk; - cXyz start, end; + cXyz unused, start, end; end = i_actor->current.pos; end.y += 100.0f; - start = a_this->current.pos; - start.y = a_this->eyePos.y; - lin_chk.Set(&start, &end, a_this); + start = actor->current.pos; + start.y = actor->eyePos.y; + lin_chk.Set(&start, &end, actor); if (dComIfG_Bgsp().LineCross(&lin_chk)) { return TRUE; @@ -283,17 +335,17 @@ static BOOL other_bg_check(e_dn_class* i_this, fopAc_ac_c* i_actor) { return FALSE; } -static BOOL other_bg_check2(e_dn_class* i_this, cXyz* param_2) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; +static BOOL other_bg_check2(e_dn_class* i_this, cXyz* i_pos) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; dBgS_LinChk lin_chk; - cXyz start, end; + cXyz unused, start, end; - end = *param_2; + end = *i_pos; end.y += 100.0f; - start = a_this->current.pos; - start.y = a_this->eyePos.y; + start = actor->current.pos; + start.y = actor->eyePos.y; - lin_chk.Set(&start, &end, a_this); + lin_chk.Set(&start, &end, actor); if (dComIfG_Bgsp().LineCross(&lin_chk)) { return TRUE; @@ -321,12 +373,13 @@ static void* s_b_sub(void* i_actor, void* i_data) { } static dBomb_c* search_bomb(e_dn_class* i_this, int param_2) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - dBomb_c* bomb; - if ((i_this->field_0x744 & 0x10000000) == 0) { + if ((i_this->learn & 0x10000000) == 0) { return NULL; } + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + dBomb_c* bomb; + target_info_count = 0; for (int i = 0; i < 10; i++) { target_info[i] = NULL; @@ -336,30 +389,31 @@ static dBomb_c* search_bomb(e_dn_class* i_this, int param_2) { f32 threshold = 50.0f; if (target_info_count != 0) { - cXyz sp44, sp50, sp5c; + cXyz work, bomb_dist, sp5c; for (int i = 0; i < target_info_count;) { bomb = (dBomb_c*)target_info[i]; - sp44.x = bomb->current.pos.x - a_this->eyePos.x; - sp44.y = 50.0f + bomb->current.pos.y - a_this->eyePos.y; - sp44.z = bomb->current.pos.z - a_this->eyePos.z; - sp50.x = bomb->current.pos.x - a_this->current.pos.x; - sp50.y = bomb->current.pos.y - a_this->current.pos.y; - sp50.z = bomb->current.pos.z - a_this->current.pos.z; + work.x = bomb->current.pos.x - actor->eyePos.x; + work.y = 50.0f + bomb->current.pos.y - actor->eyePos.y; + work.z = bomb->current.pos.z - actor->eyePos.z; + bomb_dist.x = bomb->current.pos.x - actor->current.pos.x; + bomb_dist.y = bomb->current.pos.y - actor->current.pos.y; + bomb_dist.z = bomb->current.pos.z - actor->current.pos.z; - if (sp44.abs() < threshold && !(sp50.abs() > i_this->mPlayerDistance + 30.0f) && (!other_bg_check(i_this, bomb) || !param_2)) { + if (work.abs() < threshold && !(bomb_dist.abs() > i_this->pl_dir + 30.0f) && (!other_bg_check(i_this, bomb) || !param_2)) { if (param_2) { - if (fabsf(50.0f + bomb->current.pos.y - a_this->eyePos.y) <= 300.0f) { - s16 sVar1 = a_this->shape_angle.y - cM_atan2s(sp44.x, sp44.z); - if (sVar1 < 0) { - sVar1 = -1 * sVar1; + f32 absVal = fabsf(50.0f + bomb->current.pos.y - actor->eyePos.y); + if (absVal <= 300.0f) { + s16 angle = actor->shape_angle.y - cM_atan2s(work.x, work.z); + if (angle < 0) { + angle = -1 * angle; } - if ((u16)sVar1 < 20000) { + if ((u16)angle < 20000) { // ~110° return bomb; } - cMtx_YrotS(*calc_mtx, -a_this->shape_angle.y); - MtxPosition(&sp44, &sp5c); + cMtx_YrotS(*calc_mtx, -actor->shape_angle.y); + MtxPosition(&work, &sp5c); if (fabsf(sp5c.x) < 500.0f && fabsf(sp5c.y) < 300.0f && sp5c.z > -125.0f && sp5c.z < 500.0f) { return bomb; @@ -387,42 +441,44 @@ static dBomb_c* search_bomb(e_dn_class* i_this, int param_2) { } static dBomb_c* bomb_view_check(e_dn_class* i_this) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; return search_bomb(i_this, TRUE); } static dBomb_c* bomb_check(e_dn_class* i_this) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; return search_bomb(i_this, FALSE); } static BOOL player_way_check(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - - s16 sVar1 = a_this->shape_angle.y - dComIfGp_getPlayer(0)->shape_angle.y; - if ((int)sVar1 < 0) { - sVar1 = -sVar1; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* player = dComIfGp_getPlayer(0); + s16 way = actor->shape_angle.y - player->shape_angle.y; + if (way < 0) { + way = way * -1; } - if (((u32)sVar1 & 0xFFFF) < 0x6000) { + if ((u32)((s16)way & 0xFFFF) < 0x6000) { return FALSE; } return TRUE; } -static int pl_check(e_dn_class* i_this, f32 param_2, s16 param_3) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; +static int pl_check(e_dn_class* i_this, f32 search_area, s16 search_angle) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); - if (i_this->mPlayerDistance < param_2) { - s16 sVar1 = a_this->shape_angle.y - i_this->mYAngleToPlayer; - if (sVar1 < param_3 && sVar1 > (s16)-param_3 && !other_bg_check(i_this, player)) { + if (i_this->pl_dir < search_area) { + s16 angle = actor->shape_angle.y - i_this->search_angle_y; + if (angle < search_angle && angle > (s16)-search_angle && !other_bg_check(i_this, player)) { return 1; } } for (int i = 0; i <= 2; i++) { - if (i_this->field_0xa9c[i].ChkCoHit() != 0) { - if (player == dCc_GetAc(i_this->field_0xa9c[i].GetCoHitObj()->GetAc())) { + if (i_this->cc_sph[i].ChkCoHit() != 0) { + if (player == dCc_GetAc(i_this->cc_sph[i].GetCoHitObj()->GetAc())) { return 2; } } @@ -432,63 +488,63 @@ static int pl_check(e_dn_class* i_this, f32 param_2, s16 param_3) { } static BOOL move_gake_check(e_dn_class* i_this, f32 param_2, s8 param_3) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; dBgS_GndChk gnd_chk; - cXyz sp84, sp90; + cXyz work, pos; - cMtx_YrotS(*calc_mtx, a_this->shape_angle.y); - sp84.x = 0.0f; - sp84.y = 100.0f; + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); + work.x = 0.0f; + work.y = 100.0f; if (param_3 != 0) { - sp84.z = -param_2; + work.z = -param_2; } else { - sp84.z = param_2; + work.z = param_2; } - MtxPosition(&sp84, &sp90); - sp90 += a_this->current.pos; - gnd_chk.SetPos(&sp90); + MtxPosition(&work, &pos); + pos += actor->current.pos; + gnd_chk.SetPos(&pos); - if (a_this->current.pos.y - dComIfG_Bgsp().GroundCross(&gnd_chk) > 300.0f) { + if (actor->current.pos.y - dComIfG_Bgsp().GroundCross(&gnd_chk) > 300.0f) { return TRUE; } return FALSE; } -static BOOL jump_pos_check(e_dn_class* i_this, cXyz* param_2) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; +static BOOL jump_pos_check(e_dn_class* i_this, cXyz* i_pos) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; dBgS_GndChk gnd_chk; - cXyz sp94, spa0; - f32 fVar1 = 300.0f; + cXyz work, new_pos; + f32 z_offset = KREG_F(16) + 300.0f; - cMtx_YrotS(*calc_mtx, i_this->mYAngleToPlayer); - sp94.x = 0.0f; - sp94.y = 200.0f; + cMtx_YrotS(*calc_mtx, i_this->search_angle_y); + work.x = 0.0f; + work.y = 200.0f; int i = 0; - while (i < 10) { - sp94.z = fVar1; - MtxPosition(&sp94, &spa0); - spa0 += a_this->current.pos; - gnd_chk.SetPos(&spa0); - spa0.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + while (i < KREG_S(7) + 10) { + work.z = z_offset; + MtxPosition(&work, &new_pos); + new_pos += actor->current.pos; + gnd_chk.SetPos(&new_pos); + new_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if ((a_this->current.pos.y - spa0.y) < 200.0f) { - *param_2 = spa0; - sp94.z += 200.0f; - MtxPosition(&sp94, &spa0); - spa0 += a_this->current.pos; - gnd_chk.SetPos(&spa0); - spa0.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + if ((actor->current.pos.y - new_pos.y) < 200.0f) { + *i_pos = new_pos; + work.z += KREG_F(18) + 200.0f; + MtxPosition(&work, &new_pos); + new_pos += actor->current.pos; + gnd_chk.SetPos(&new_pos); + new_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if ((a_this->current.pos.y - spa0.y) < 200.0f) { - *param_2 = spa0; + if ((actor->current.pos.y - new_pos.y) < 200.0f) { + *i_pos = new_pos; } return TRUE; } - fVar1 += 50.0f; + z_offset += 50.0f; i++; } @@ -496,141 +552,141 @@ static BOOL jump_pos_check(e_dn_class* i_this, cXyz* param_2) { } static void e_dn_stay(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp30; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; i_this->field_0x6f4 = 5; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_WAIT_01, 10.0f, J3DFrameCtrl::EMode_LOOP, cM_rndF(0.1f) + 0.9f); - i_this->mMode = 1; + i_this->mode = 1; // fallthrough case 1: - if (fopAcM_otoCheck(a_this, 2000.0f) || daPy_getPlayerActorClass()->checkWolfBark()) { + if (fopAcM_otoCheck(actor, 2000.0f) || daPy_getPlayerActorClass()->checkWolfBark()) { SND_INFLUENCE* sound = dKy_Sound_get(); - sp30 = sound->position - a_this->current.pos; - if (cM_atan2s(sp30.y, JMAFastSqrt(sp30.x * sp30.x + sp30.z * sp30.z)) > 0x1000) { - i_this->mMode = 5; + cXyz posDelta = sound->position - actor->current.pos; + s16 angle = cM_atan2s(posDelta.y, JMAFastSqrt(posDelta.x * posDelta.x + posDelta.z * posDelta.z)); + if (angle > 0x1000) { // 22.5° + i_this->mode = 5; } else { - i_this->mMode = 2; + i_this->mode = 2; } - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 10.0f; - i_this->field_0x738 = sound->position; + i_this->timer[0] = cM_rndF(10.0f) + 10.0f; + i_this->find_pos = sound->position; } break; case 2: - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { anm_init(i_this, ANM_FIND, 3.0f, J3DFrameCtrl::EMode_NONE, 1.5f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); - i_this->mMode = 3; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); + i_this->mode = 3; } break; case 3: - if (i_this->mpModelMorf->isStop()) { - if (other_bg_check2(i_this, &i_this->field_0x738)) { - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 20.0f; - i_this->mMode = 4; + if (i_this->anm_p->isStop()) { + if (other_bg_check2(i_this, &i_this->find_pos)) { + i_this->timer[0] = cM_rndF(10.0f) + 20.0f; + i_this->mode = 4; } else { - i_this->mAction = ACTION_OTOREAC; - i_this->mMode = 0; + i_this->action = ACTION_OTOREAC; + i_this->mode = 0; } } break; case 4: - if (i_this->field_0x6e0[0] == 0) { - i_this->mMode = 10; - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 30.0f; + if (i_this->timer[0] == 0) { + i_this->mode = 10; + i_this->timer[0] = cM_rndF(10.0f) + 30.0f; anm_init(i_this, ANM_WAIT_03, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.5f); } break; case 5: - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { anm_init(i_this, ANM_FIND, 3.0f, J3DFrameCtrl::EMode_NONE, 1.5f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); - i_this->mMode = 6; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); + i_this->mode = 6; } break; case 6: - if (i_this->mpModelMorf->isStop()) { - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 20.0f; - i_this->mMode = 7; + if (i_this->anm_p->isStop()) { + i_this->timer[0] = cM_rndF(10.0f) + 20.0f; + i_this->mode = 7; } break; case 7: - if (i_this->field_0x6e0[0] == 0) { - i_this->mMode = 10; - i_this->field_0x6e0[0] = cM_rndF(40.0f) + 50.0f; + if (i_this->timer[0] == 0) { + i_this->mode = 10; + i_this->timer[0] = cM_rndF(40.0f) + 50.0f; anm_init(i_this, ANM_WAIT_04, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.3f); - i_this->mpModelMorf->setFrame(cM_rndF(75.0f)); + i_this->anm_p->setFrame(cM_rndF(75.0f)); } break; case 8: - if (i_this->mpModelMorf->isStop()) { - i_this->mMode = 0; + if (i_this->anm_p->isStop()) { + i_this->mode = 0; } break; case 10: - if (i_this->field_0x6e0[0] == 0) { - i_this->mMode = 0; + if (i_this->timer[0] == 0) { + i_this->mode = 0; } } - if ((i_this->field_0x6cc & 15) == 0) { - if (pl_check(i_this, i_this->field_0x6d8, 0x4000) != 0) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = -10; - i_this->field_0x6e0[0] = 60; + if ((i_this->frame_counter & 15) == 0) { // Every 16 frames + if (pl_check(i_this, i_this->pl_range, 0x4000) != 0) { // 90° + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = -10; + i_this->timer[0] = 60; } else if (bomb_view_check(i_this) != NULL) { - i_this->mAction = ACTION_BOMB_ACTION; - i_this->mMode = 0; + i_this->action = ACTION_BOMB_ACTION; + i_this->mode = 0; } } } static void e_dn_otoreac(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp40, sp4c; - f32 fVar1 = 0.0f; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + cXyz work, unused; + f32 dash_speed = 0.0f; i_this->field_0x6f4 = 2; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_WAIT_01, 10.0f, J3DFrameCtrl::EMode_LOOP, cM_rndF(0.2f) + 1.5f); - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 20.0f; - i_this->mMode = 1; + i_this->timer[0] = cM_rndF(10.0f) + 20.0f; + i_this->mode = 1; // fallthrough case 1: - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { anm_init(i_this, ANM_RUN, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndFX(0.05f) + 1.0f); - i_this->mMode = 2; + i_this->mode = 2; } break; case 2: - fVar1 = l_HIO.dash_speed; - if ((i_this->field_0x6cc & 3) == 0) { - if ((i_this->field_0x6cc & 4) != 0) { - i_this->field_0x10e4 = 1; + dash_speed = l_HIO.dash_speed; + if ((i_this->frame_counter & 3) == 0) { // Every 4 frames + if ((i_this->frame_counter & 4) != 0) { // Every 5 frames + i_this->set_smoke_flag = 1; } else { - i_this->field_0x10e4 = 2; + i_this->set_smoke_flag = 2; } } - sp40 = i_this->field_0x738 - a_this->current.pos; - cLib_addCalcAngleS2(&a_this->current.angle.y, cM_atan2s(sp40.x, sp40.z), 2, 0xC00); - if (sp40.abs() < 250.0f || i_this->mObjAcch.ChkWallHit() != 0) { - i_this->mAction = ACTION_NORMAL; - i_this->mMode = 0; - i_this->field_0x6e0[0] = cM_rndF(50.0f) + 50.0f; + work = i_this->find_pos - actor->current.pos; + cLib_addCalcAngleS2(&actor->current.angle.y, cM_atan2s(work.x, work.z), 2, 0xC00); + if (work.abs() < 250.0f || i_this->objacch.ChkWallHit() != 0) { + i_this->action = ACTION_NORMAL; + i_this->mode = 0; + i_this->timer[0] = cM_rndF(50.0f) + 50.0f; anm_init(i_this, ANM_WAIT_03, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } break; @@ -638,322 +694,330 @@ static void e_dn_otoreac(e_dn_class* i_this) { } - cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 5.0f); - if ((i_this->field_0x6cc & 15) == 0) { - if (pl_check(i_this, i_this->field_0x6d8, 0x4000) != 0) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = -10; - i_this->field_0x6e0[0] = 60; + cLib_addCalc2(&actor->speedF, dash_speed, 1.0f, 5.0f); + if ((i_this->frame_counter & 15) == 0) { // Every 16 frames + if (pl_check(i_this, i_this->pl_range, 0x4000) != 0) { // 90° + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = -10; + i_this->timer[0] = 60; } else if (bomb_view_check(i_this) != NULL) { - i_this->mAction = ACTION_BOMB_ACTION; - i_this->mMode = 0; + i_this->action = ACTION_BOMB_ACTION; + i_this->mode = 0; } } } static void e_dn_bomb_action(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - s16 sVar2; - cXyz sp3c, sp48; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + s16 angle; + cXyz work, bomb_pos_target; dBomb_c* bomb = bomb_check(i_this); if (bomb == NULL) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; return; } - sp3c.x = bomb->current.pos.x - a_this->current.pos.x; - sp3c.z = bomb->current.pos.z - a_this->current.pos.z; - s16 sVar1 = cM_atan2s(sp3c.x, sp3c.z); - f32 fVar1 = 0.0f; + work.x = bomb->current.pos.x - actor->current.pos.x; + work.z = bomb->current.pos.z - actor->current.pos.z; + s16 target_angle_y = cM_atan2s(work.x, work.z); + f32 dash_speed = 0.0f; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_FIND, 3.0f, J3DFrameCtrl::EMode_NONE, 1.5f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_FIND_BOMB, -1); - i_this->mMode = 1; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_FIND_BOMB, -1); + i_this->mode = 1; break; case 1: - if (i_this->mpModelMorf->isStop()) { - i_this->mMode = 2; + if (i_this->anm_p->isStop()) { + i_this->mode = 2; } break; case 2: - i_this->mMode = 3; + i_this->mode = 3; anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->field_0x6e0[1] = cM_rndF(10.0f) + 10.0f; + i_this->timer[1] = cM_rndF(10.0f) + 10.0f; // fallthrough case 3: - if (i_this->field_0x6e0[1] == 0 && bomb->speedF < 0.1f) { - i_this->mMode = 4; + if (i_this->timer[1] == 0 && bomb->speedF < 0.1f) { + i_this->mode = 4; anm_init(i_this, ANM_RUN, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndFX(0.05f) + 1.0f); } break; case 4: - if (i_this->field_0x5b7 == 1 && bomb->speedF < 0.1f && !bomb->checkStateCarry() && JMAFastSqrt(sp3c.x * sp3c.x + sp3c.z * sp3c.z) < 250.0f) { - sVar2 = i_this->mYAngleToPlayer - a_this->shape_angle.y; - if (sVar2 < 0x4000 && sVar2 > -0x4000) { - i_this->mMode = 10; + if (i_this->arg1 == 1 && bomb->speedF < 0.1f && !bomb->checkStateCarry() && JMAFastSqrt(work.x * work.x + work.z * work.z) < 250.0f) { + angle = i_this->search_angle_y - actor->shape_angle.y; + if (angle < 0x4000 && angle > -0x4000) { // ±90° + i_this->mode = 10; break; } } - sVar1 += 0x8000; - fVar1 = l_HIO.dash_speed; - if (JMAFastSqrt(sp3c.x * sp3c.x + sp3c.z * sp3c.z) > 600.0f) { - i_this->mMode = 5; + target_angle_y += 0x8000; // 180° + dash_speed = l_HIO.dash_speed; + if (JMAFastSqrt(work.x * work.x + work.z * work.z) > 600.0f) { + i_this->mode = 5; anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } break; case 5: - i_this->mSound.startCreatureSoundLevel(Z2SE_EN_DN_V_LOOK_BOMB, 0, -1); - sVar1 = i_this->mYAngleToPlayer; - if (JMAFastSqrt(sp3c.x * sp3c.x + sp3c.z * sp3c.z) < 500.0f) { - i_this->mMode = 2; + i_this->sound.startCreatureSoundLevel(Z2SE_EN_DN_V_LOOK_BOMB, 0, -1); + target_angle_y = i_this->search_angle_y; + if (JMAFastSqrt(work.x * work.x + work.z * work.z) < 500.0f) { + i_this->mode = 2; } break; case 10: i_this->field_0x6f2 = 0; - fVar1 = l_HIO.dash_speed; - if (JMAFastSqrt(sp3c.x * sp3c.x + sp3c.z * sp3c.z) < 100.0f) { - i_this->field_0x6e0[0] = 20; - i_this->mMode = 11; + dash_speed = l_HIO.dash_speed; + if (JMAFastSqrt(work.x * work.x + work.z * work.z) < 100.0f) { + i_this->timer[0] = 20; + i_this->mode = 11; anm_init(i_this, ANM_RUN, 5.0f, J3DFrameCtrl::EMode_NONE, cM_rndFX(0.05f) + 1.0f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_KICK_BOMB, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_KICK_BOMB, -1); } if (bomb->speedF > 0.1f) { - i_this->mMode = 2; + i_this->mode = 2; } break; case 11: i_this->field_0x6f2 = 0; - sVar1 = i_this->mYAngleToPlayer; + target_angle_y = i_this->search_angle_y; - if (i_this->field_0x6e0[0] >= 10) { - cMtx_YrotS(*calc_mtx, sVar1); - sp3c.x = -30.0f; - sp3c.y = 0.0f; - sp3c.z = 60.0f; - MtxPosition(&sp3c, &sp48); - sp48 += a_this->current.pos; + if (i_this->timer[0] >= 10) { + cMtx_YrotS(*calc_mtx, target_angle_y); + work.x = TREG_F(15) + -30.0f; + work.y = 0.0f; + work.z = TREG_F(16) + 60.0f; + MtxPosition(&work, &bomb_pos_target); + bomb_pos_target += actor->current.pos; - cLib_addCalc2(&bomb->current.pos.x, sp48.x, 1.0f, 15.0f); - cLib_addCalc2(&bomb->current.pos.z, sp48.z, 1.0f, 15.0f); + cLib_addCalc2(&bomb->current.pos.x, bomb_pos_target.x, 1.0f, 15.0f); + cLib_addCalc2(&bomb->current.pos.z, bomb_pos_target.z, 1.0f, 15.0f); - if (i_this->field_0x6e0[0] == 10) { + if (i_this->timer[0] == 10) { bomb->speedF = 30.0f; bomb->speed.y = 30.0f; - bomb->current.angle.y = a_this->shape_angle.y; + bomb->current.angle.y = actor->shape_angle.y; } } - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mMode = 5; + i_this->mode = 5; } } - cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 5.0f); - cLib_addCalcAngleS2(&a_this->current.angle.y, sVar1, 4, 0x1000); + cLib_addCalc2(&actor->speedF, dash_speed, 1.0f, 5.0f); + cLib_addCalcAngleS2(&actor->current.angle.y, target_angle_y, 4, 0x1000); i_this->field_0x6f4 = 2; - i_this->field_0x738 = bomb->current.pos; + i_this->find_pos = bomb->current.pos; } static void e_dn_normal(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp44, sp50; - f32 fVar1 = 0.0f; - s16 sVar1 = 0x4000; - s16 sVar2, sVar3; + f32 movement_speed = 0.0f; + s16 search_angle, angle, angle_delta; + search_angle = 0x4000; // 90° - switch (i_this->mMode) { + switch (i_this->mode) { case 0: case 1: case 2: - if (i_this->field_0x6e0[0] == 0) { - if (fopAcM_wayBgCheck(a_this, 200.0f, 50.0f) || move_gake_check(i_this, 200.0f, 0)) { - sVar2 = cM_rndFX(10000.0f) + 32768.0f; - i_this->field_0x6e0[1] = 40; + if (i_this->timer[0] == 0) { + if (fopAcM_wayBgCheck(actor, 200.0f, 50.0f) || move_gake_check(i_this, 200.0f, 0)) { + angle = cM_rndFX(10000.0f) + 32768.0f; + i_this->timer[1] = 40; } else { - sp50.x = a_this->home.pos.x + cM_rndFX(600.0f); - sp50.y = a_this->home.pos.y; - sp50.z = a_this->home.pos.z + cM_rndFX(600.0f); - sp44 = sp50 - a_this->current.pos; + sp50.x = actor->home.pos.x + cM_rndFX(600.0f); + sp50.y = actor->home.pos.y; + sp50.z = actor->home.pos.z + cM_rndFX(600.0f); + sp44 = sp50 - actor->current.pos; - sVar2 = cM_atan2s(sp44.x, sp44.z) - a_this->current.angle.y; - if (sVar2 > 0x3000) { - sVar2 = 0x3000; - } else if (sVar2 < -0x3000) { - sVar2 = -0x3000; + angle = cM_atan2s(sp44.x, sp44.z) - actor->current.angle.y; + if (angle > 0x3000) { // 67.5° + angle = 0x3000; + } else if (angle < -0x3000) { + angle = -0x3000; } } - i_this->field_0x5d4 = a_this->current.angle.y + sVar2; + i_this->cur_angle_y_target = actor->current.angle.y + angle; anm_init(i_this, ANM_WALK, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mMode = 3; - i_this->field_0x6e0[0] = cM_rndF(100.0f) + 100.0f; + i_this->mode = 3; + i_this->timer[0] = cM_rndF(100.0f) + 100.0f; } else { - sVar1 = 0x7000; + search_angle = 0x7000; // 157.5° } break; case 3: - fVar1 = l_HIO.movement_speed; - sVar2 = a_this->current.angle.y; - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5d4, 2, 0x400); - sVar3 = a_this->current.angle.y - i_this->field_0x5d4; - if (sVar3 > 0x1000 || sVar3 < -0x1000) { - fVar1 = 0.0f; + movement_speed = l_HIO.movement_speed; + angle = actor->current.angle.y; + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->cur_angle_y_target, 2, 0x400); + + /* If the actor is facing roughly 22.5° from the target y, stop moving */ + angle_delta = actor->current.angle.y - i_this->cur_angle_y_target; + if (angle_delta > 0x1000 || angle_delta < -0x1000) { + movement_speed = 0.0f; } - sVar2 -= a_this->current.angle.y; - sVar2 *= 2; - if (sVar2 > 0x1000) { - sVar2 = 0x1000; - } else if (sVar2 < -0x1000) { - sVar2 = -0x1000; + /* Calculate how much the actor turned */ + angle -= actor->current.angle.y; + /* Scale turn strength */ + angle *= (s16)(YREG_S(5) + 2); + + /* Ensure the targeted angle is no more than ±22.5° */ + s16 max_turn = YREG_S(6) + 0x1000; + if (angle > max_turn) { + angle = max_turn; + } else if (angle < (s16)-max_turn) { + angle = -max_turn; } - cLib_addCalcAngleS2(&i_this->field_0x826, sVar2, 2, 0x400); + cLib_addCalcAngleS2(&i_this->jnt_tail_y_rot_offset, angle, 2, 0x400); - if (i_this->field_0x6e0[0] == 0 || - (i_this->field_0x6e0[1] == 0 && (fopAcM_wayBgCheck(a_this, 200.0f, 50.0f) || move_gake_check(i_this, 200.0f, 0)))) { - i_this->mMode = 2; - i_this->field_0x6e0[0] = cM_rndF(100.0f) + 50.0f; + if (i_this->timer[0] == 0 || + (i_this->timer[1] == 0 && (fopAcM_wayBgCheck(actor, 200.0f, 50.0f) || move_gake_check(i_this, 200.0f, 0)))) { + i_this->mode = 2; + i_this->timer[0] = cM_rndF(100.0f) + 50.0f; anm_init(i_this, ANM_WAIT_03, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } break; } - cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 3.0f); - BOOL bVar1 = fopAcM_otoCheck(a_this, 2000.0f) | daPy_getPlayerActorClass()->checkWolfBark(); - if ((i_this->field_0x6cc & 15) == 0 || bVar1) { - if (bVar1 || pl_check(i_this, i_this->field_0x6d8, sVar1) != 0) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = -10; - i_this->field_0x6e0[0] = 60; + cLib_addCalc2(&actor->speedF, movement_speed, 1.0f, 3.0f); + BOOL oto_check = fopAcM_otoCheck(actor, 2000.0f) | daPy_getPlayerActorClass()->checkWolfBark(); + /* Run the following checks every 16 frames or immediately if the above sound check is true */ + if ((i_this->frame_counter & 15) == 0 || oto_check) { + if (oto_check || pl_check(i_this, i_this->pl_range, search_angle) != 0) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = -10; + i_this->timer[0] = 60; } if (bomb_view_check(i_this) != NULL) { - i_this->mAction = ACTION_BOMB_ACTION; - i_this->mMode = 0; + i_this->action = ACTION_BOMB_ACTION; + i_this->mode = 0; } } } static void e_dn_drawback(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_DRAWBACK, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; - a_this->speedF = -5.0f; - i_this->field_0x6e8 = 10; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DRAWBACK, -1); - i_this->field_0x5d4 = player->shape_angle.y + 0x8000; + i_this->mode = 1; + actor->speedF = KREG_F(4) + -5.0f; + i_this->invulnerability_timer = 10; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DRAWBACK, -1); + i_this->cur_angle_y_target = player->shape_angle.y + 0x8000; // Target current angle towards player break; case 1: - a_this->onHeadLockFlg(); - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5d4, 4, 0x400); - cLib_addCalc0(&a_this->speedF, 1.0f, 0.1f); + i_this->actor.onHeadLockFlg(); + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->cur_angle_y_target, 4, 0x400); + cLib_addCalc0(&actor->speedF, 1.0f, KREG_F(5) + 0.1f); - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_AWAKE, -1); + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_AWAKE, -1); } break; } - if (move_gake_check(i_this, 50.0f, 1)) { - i_this->mAction = ACTION_BACKDROP; - i_this->mMode = 0; + if (move_gake_check(i_this, KREG_F(9) + 50.0f, 1)) { + i_this->action = ACTION_BACKDROP; + i_this->mode = 0; } } static void e_dn_wolfbite(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); - i_this->field_0x6e8 = 10; - cLib_addCalc0(&a_this->speedF, 1.0f, 2.0f); + i_this->invulnerability_timer = 10; + cLib_addCalc0(&actor->speedF, 1.0f, 2.0f); - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_HANGED, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DRAWBACK, -1); - a_this->health -= 10; + i_this->mode = 1; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DRAWBACK, -1); + actor->health -= (s16)10; break; case 1: - if (i_this->mpModelMorf->isStop()) { + if (i_this->anm_p->isStop()) { anm_init(i_this, ANM_HANGED_WAIT, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mMode = 2; + i_this->mode = 2; } break; case 2: - if (i_this->mAnmID == ANM_HANGED_DAMAGE) { - if (i_this->mpModelMorf->isStop()) { + if (i_this->anm_no == ANM_HANGED_DAMAGE) { + if (i_this->anm_p->isStop()) { anm_init(i_this, ANM_HANGED_WAIT, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } } - if (a_this->health <= 0 || a_this->checkWolfBiteDamage()) { - a_this->offWolfBiteDamage(); + if (actor->health <= 0 || actor->checkWolfBiteDamage()) { + actor->offWolfBiteDamage(); anm_init(i_this, ANM_HANGED_DAMAGE, 2.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - a_this->health -= 10; - if (a_this->health <= 0) { + actor->health -= (s16)10; + if (actor->health <= 0) { player->offWolfEnemyHangBite(); - i_this->field_0x750 = (a_this->shape_angle.y - 0x8000) - player->shape_angle.y; + i_this->field_0x750 = (actor->shape_angle.y - 0x8000) - player->shape_angle.y; i_this->field_0x74c = 150.0f; - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; i_this->field_0x724.y = player->shape_angle.y + 0x8000; - a_this->speed.y = 0.0f; + actor->speed.y = 0.0f; i_this->field_0x704 = -1.0f; - i_this->field_0x828 = 50; - i_this->mSound.startCollisionSE(Z2SE_HIT_WOLFBITE, 32); + i_this->unk_timer_4 = DREG_S(2) + 50; + i_this->sound.startCollisionSE(Z2SE_HIT_WOLFBITE, 32); i_this->field_0x710 = 1; - i_this->field_0x6e8 = 1000; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); + i_this->invulnerability_timer = 1000; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); return; } - i_this->mSound.startCollisionSE(Z2SE_HIT_WOLFBITE, 30); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); + i_this->sound.startCollisionSE(Z2SE_HIT_WOLFBITE, 30); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); } - if (!player->checkWolfEnemyHangBiteOwn(a_this)) { + if (!player->checkWolfEnemyHangBiteOwn(actor)) { anm_init(i_this, ANM_HANGED_BRUSH, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 3; + i_this->mode = 3; } break; case 3: - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_AWAKE, -1); + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_AWAKE, -1); } } } static int way_check(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - s16 sVar1 = a_this->shape_angle.y - i_this->mYAngleToPlayer; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + s16 sVar1 = actor->shape_angle.y - i_this->search_angle_y; if (sVar1 <= 0x4000 && sVar1 >= -0x4000) { return 0; } @@ -969,10 +1033,10 @@ int learn_check; static void* shot_s_sub(void* i_actor, void* i_data) { e_dn_class* i_this = (e_dn_class*)i_data; - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; if ((fopAcM_IsActor(i_actor) && (learn_check & 0x80000000) != 0 && fopAcM_GetName(i_actor) == PROC_ARROW && (fopAcM_GetParam(i_actor) == 1 || fopAcM_GetParam(i_actor) == 2))) { - cXyz sp28(a_this->current.pos - ((fopAc_ac_c*)i_actor)->current.pos); + cXyz sp28(actor->current.pos - ((fopAc_ac_c*)i_actor)->current.pos); if (sp28.abs() < 1000.0f) { return i_actor; } @@ -982,431 +1046,441 @@ static void* shot_s_sub(void* i_actor, void* i_data) { } static void e_dn_fight_run(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp4c, sp58; f32 fVar1 = 0.0f; - int frame = i_this->mpModelMorf->getFrame(); + int frame = i_this->anm_p->getFrame(); + BOOL wayCheck; s8 sVar4 = 1; - if (pl_check(i_this, i_this->field_0x6d8 + 50.0f, 0x7FFF) == 0 && i_this->field_0x6e0[0] == 0) { - if (i_this->field_0x6ea == 0) { + if (pl_check(i_this, i_this->pl_range + 50.0f, 0x7FFF) == 0 && i_this->timer[0] == 0) { + if (i_this->unk_timer_1 == 0) { sVar4 = 0; } } else { - i_this->field_0x6ea = 40; + i_this->unk_timer_1 = 40; } - switch (i_this->mMode) { + switch (i_this->mode) { case -10: anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->field_0x6e0[1] = cM_rndF(10.0f) + 15.0f; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); - i_this->mMode = -9; + i_this->timer[1] = cM_rndF(10.0f) + 15.0f; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_FIND, -1); + i_this->mode = -9; break; case -9: - cLib_addCalc0(&a_this->speedF, 1.0f, 5.0f); - if (i_this->field_0x6e0[1] == 0) { - i_this->mMode = 0; + cLib_addCalc0(&actor->speedF, 1.0f, 5.0f); + if (i_this->timer[1] == 0) { + i_this->mode = 0; } break; case 0: anm_init(i_this, ANM_RUN, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndFX(0.05f) + 1.0f); - i_this->mMode = 1; - i_this->field_0x82c = 0; + i_this->mode = 1; + i_this->unk_counter_1 = 0; // fallthrough case 1: fVar1 = l_HIO.dash_speed; - if ((i_this->field_0x6cc & 3) == 0) { - if ((i_this->field_0x6cc & 4) != 0) { - i_this->field_0x10e4 = 1; + if ((i_this->frame_counter & 3) == 0) { // Every 4 frames + if ((i_this->frame_counter & 4) != 0) { // Every 5 frames + i_this->set_smoke_flag = 1; } else { - i_this->field_0x10e4 = 2; + i_this->set_smoke_flag = 2; } } - if (i_this->mObjAcch.ChkWallHit() != 0 && !fopAcM_wayBgCheck(a_this, 200.0f, 120.0f)) { - i_this->field_0x82c++; - } else if (i_this->mPlayerDistance < l_HIO.battle_init_range) { + if (i_this->objacch.ChkWallHit() != 0 && !fopAcM_wayBgCheck(actor, 200.0f, 120.0f)) { + i_this->unk_counter_1++; + } else if (i_this->pl_dir < l_HIO.battle_init_range) { anm_init(i_this, ANM_WAIT_02, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->mMode = 2; - i_this->field_0x6e0[2] = cM_rndF(30.0f) + 30.0f; + i_this->mode = 2; + i_this->timer[2] = JREG_F(1) + (cM_rndF(30.0f) + 30.0f); } - if (i_this->field_0x82c > 20) { - i_this->mAction = ACTION_JUMP; - i_this->mMode = 0; + if (i_this->unk_counter_1 > 20) { + i_this->action = ACTION_JUMP; + i_this->mode = 0; return; } - if (move_gake_check(i_this, 50.0f, 0)) { - i_this->mAction = ACTION_GAKEJUMP; - i_this->mMode = 0; - i_this->field_0x6e8 = 100; - a_this->speedF = 0.0f; + if (move_gake_check(i_this, KREG_F(6) + 50.0f, 0)) { + i_this->action = ACTION_GAKEJUMP; + i_this->mode = 0; + i_this->invulnerability_timer = 100; + actor->speedF = 0.0f; return; } break; case 2: - i_this->field_0x82e = 1; + i_this->snap_angle_y_flag = 1; if (frame == 7 || frame == 21) { - a_this->speed.y = 10.0f; - if (i_this->mPlayerDistance > (l_HIO.battle_init_range + 250.0f)) { - i_this->mMode = 0; - a_this->current.angle.y = a_this->shape_angle.y; + actor->speed.y = XREG_F(4) + 10.0f; + if (i_this->pl_dir > (l_HIO.battle_init_range + 250.0f)) { + i_this->mode = 0; + actor->current.angle.y = actor->shape_angle.y; break; } - if (i_this->mPlayerDistance > (l_HIO.battle_init_range + 100.0f)) { - a_this->current.angle.y = i_this->mYAngleToPlayer; - } else if (i_this->mPlayerDistance < (l_HIO.battle_init_range - 100.0f)) { - a_this->current.angle.y = -i_this->mYAngleToPlayer; + if (i_this->pl_dir > (l_HIO.battle_init_range + 100.0f)) { + actor->current.angle.y = i_this->search_angle_y; + } else if (i_this->pl_dir < (l_HIO.battle_init_range - 100.0f)) { + actor->current.angle.y = -i_this->search_angle_y; } else { - a_this->current.angle.y = cM_rndFX(32763.0f); + actor->current.angle.y = cM_rndFX(32763.0f); } - a_this->speedF = cM_rndF(5.0f) + 5.0f; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_BREATH, -1); + actor->speedF = cM_rndF(XREG_F(5) + 5.0f) + 5.0f; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_BREATH, -1); } if (frame == 13 || frame == 27) { - a_this->speedF = 0.0f; - i_this->field_0x10e4 = 3; + actor->speedF = 0.0f; + i_this->set_smoke_flag = 3; if (frame == 13) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); } else { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); } } - a_this->gravity = -5.0f; + actor->gravity = XREG_F(6) + -5.0f; break; } s16 sVar1; - if (i_this->mMode >= 0) { - if (i_this->field_0x82e == 0) { - sVar1 = a_this->current.angle.y; - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mYAngleToPlayer, 2, 0x800); - sVar1 -= a_this->current.angle.y; - s16 sVar2 = a_this->current.angle.y - i_this->mYAngleToPlayer; + if (i_this->mode >= 0) { + if (i_this->snap_angle_y_flag == 0) { + sVar1 = actor->current.angle.y; + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->search_angle_y, 2, 0x800); + sVar1 -= actor->current.angle.y; + s16 sVar2 = actor->current.angle.y - i_this->search_angle_y; if (sVar2 > 0x800 || sVar2 < -0x800) { fVar1 = 0.0f; } - cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 5.0f); + cLib_addCalc2(&actor->speedF, fVar1, 1.0f, 5.0f); } else { - sVar1 = a_this->shape_angle.y; - cLib_addCalcAngleS2(&a_this->shape_angle.y, i_this->mYAngleToPlayer, 4, 0x800); - sVar1 -= a_this->shape_angle.y; + sVar1 = actor->shape_angle.y; + cLib_addCalcAngleS2(&actor->shape_angle.y, i_this->search_angle_y, 4, 0x800); + sVar1 -= actor->shape_angle.y; } - sVar1 *= 2; - if (sVar1 > 0x1000) { - sVar1 = 0x1000; - } else if (sVar1 < -0x1000) { - sVar1 = -0x1000; + sVar1 *= (s16)(YREG_S(5) + 2); + s16 sVar4 = YREG_S(6) + 0x1000; + if (sVar1 > sVar4) { + sVar1 = sVar4; + } else if (sVar1 < (s16)-sVar4) { + sVar1 = -sVar4; } - cLib_addCalcAngleS2(&i_this->field_0x826, sVar1, 2, 0x400); + cLib_addCalcAngleS2(&i_this->jnt_tail_y_rot_offset, sVar1, 2, 0x400); } - u8 sVar3 = 0; - learn_check = i_this->field_0x744; - if (fpcM_Search(shot_s_sub, i_this) != NULL || ((i_this->field_0x744 & 0x1000) != 0 && daPy_getPlayerActorClass()->checkHookshotShootReturnMode())) { - sVar3 = 1; + u8 def = 0; + learn_check = i_this->learn; + if (fpcM_Search(shot_s_sub, i_this) != NULL || ((i_this->learn & 0x1000) != 0 && daPy_getPlayerActorClass()->checkHookshotShootReturnMode())) { + def = 1; OS_REPORT(" DEF ON !!\n"); } if (sVar4 == 0) { - if (i_this->field_0x6ea == 0) { - i_this->mAction = ACTION_NORMAL; - i_this->mMode = 0; - i_this->field_0x6e0[0] = cM_rndF(50.0f) + 50.0f; + if (i_this->unk_timer_1 == 0) { + i_this->action = ACTION_NORMAL; + i_this->mode = 0; + i_this->timer[0] = cM_rndF(50.0f) + 50.0f; anm_init(i_this, ANM_WAIT_03, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - if (i_this->field_0x82e == 0) { - return; + if (i_this->snap_angle_y_flag != 0) { + actor->current.angle.y = actor->shape_angle.y; } - a_this->current.angle.y = a_this->shape_angle.y; return; } - } else { - if (dComIfGp_checkPlayerStatus1(0, 0x2000000) != 0 || - (((i_this->mXAngleToPlayer < 0x1000 && i_this->mXAngleToPlayer > -0x1000) || sVar3 != 0) && player_way_check(i_this))) { - if ((sVar3 != 0 || (i_this->mPlayerDistance < l_HIO.battle_init_range && (i_this->field_0x744 & cc_pl_cut_bit_get()) != 0 && - ((daPy_getPlayerActorClass()->getCutAtFlg() != 0 || daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_JUMP) || - (i_this->field_0x744 & 0x400) != 0))) && i_this->field_0x74c < 1.0f) { - i_this->mAction = ACTION_GUARD; - if (cc_pl_cut_bit_get() == 0x100) { - i_this->mMode = 0; - } else { - i_this->mMode = 5; - } - - i_this->field_0x708 = 30.0f; - i_this->field_0x70c = a_this->shape_angle.y; - i_this->field_0x6e0[0] = 0; - i_this->field_0x6e8 = 15; + } else if ( + dComIfGp_checkPlayerStatus1(0, 0x2000000) != 0 || + (((i_this->search_angle_x < 0x1000 && i_this->search_angle_x > -0x1000) || def != 0) && player_way_check(i_this)) + ) { + if ( + (def != 0 || (i_this->pl_dir < l_HIO.battle_init_range && (i_this->learn & cc_pl_cut_bit_get()) != 0 && + ((daPy_getPlayerActorClass()->getCutAtFlg() != 0 || daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_JUMP) || + (i_this->learn & 0x400) != 0))) && i_this->field_0x74c < 1.0f + ) { + i_this->action = ACTION_GUARD; + if (cc_pl_cut_bit_get() == 0x100) { + i_this->mode = 0; } else { - if (i_this->mPlayerDistance < l_HIO.attack_init_range) { - if (i_this->field_0x6e0[2] == 0) { - i_this->field_0x6e0[2] = cM_rndF(30.0f) + 30.0f; - if (cM_rndF(1.0f) < 1.0f) { - if (way_check(i_this) == 0 && cM_rndF(1.0f) < 0.75f) { - if (i_this->mPlayerDistance < l_HIO.attack_init_range - 100.0f) { - i_this->mAction = ACTION_ATTACK_0; - } else { - i_this->mAction = ACTION_ATTACK; - } + i_this->mode = 5; + } - i_this->mMode = 0; - } else { - i_this->mAction = ACTION_TAIL_ATTACK; - i_this->mMode = 0; - } + i_this->field_0x708 = TREG_F(10) + 30.0f; + i_this->field_0x70c = actor->shape_angle.y; + i_this->timer[0] = 0; + i_this->invulnerability_timer = 15; + } else if (i_this->pl_dir < l_HIO.attack_init_range) { + if (i_this->timer[2] == 0) { + i_this->timer[2] = JREG_F(1) + (cM_rndF(30.0f) + 30.0f); + f32 fVar1 = 1.0f; + if (cM_rndF(1.0f) < fVar1) { + wayCheck = way_check(i_this); + if (!wayCheck && cM_rndF(1.0f) < 0.75f) { + if (i_this->pl_dir < (l_HIO.attack_init_range - 100.0f) + TREG_F(7)) { + i_this->action = ACTION_ATTACK_0; + } else { + i_this->action = ACTION_ATTACK; } + + i_this->mode = 0; + } else { + i_this->action = ACTION_TAIL_ATTACK; + i_this->mode = 0; } } - } } } i_this->field_0x6f4 = 1; - if ((i_this->field_0x6cc & 15) == 0 && bomb_view_check(i_this) != NULL) { - i_this->mAction = ACTION_BOMB_ACTION; - i_this->mMode = 0; + if ((i_this->frame_counter & 15) == 0 && bomb_view_check(i_this) != NULL) { // Every 16 frames + i_this->action = ACTION_BOMB_ACTION; + i_this->mode = 0; } - if (i_this->field_0x5b7 == 1 && move_gake_check(i_this, 150.0f, 1) && (i_this->field_0x6cc & 15) == 0 && cM_rndF(1.0f) < 0.5f) { + if ( + i_this->arg1 == 1 && move_gake_check(i_this, KREG_F(8) + 150.0f, 1) && + (i_this->frame_counter & 15) == 0 && cM_rndF(1.0f) < 0.5f // Every 16 frames + ) { i_this->field_0x700 = cM_rndF(10.0f) + 10.0f; i_this->field_0x701 = cM_rndF(1.9f); } - if (move_gake_check(i_this, 50.0f, 1)) { - if (i_this->field_0x5b7 == 1) { + if (move_gake_check(i_this, KREG_F(9) + 50.0f, 1)) { + if (i_this->arg1 == 1) { if (cM_rndF(1.0f) < 0.5f) { - i_this->mAction = ACTION_TAIL_ATTACK; - i_this->mMode = 0; + i_this->action = ACTION_TAIL_ATTACK; + i_this->mode = 0; } else { - i_this->mAction = ACTION_GAKEJUMP; - i_this->mMode = 0; - i_this->field_0x5c8 = a_this->current.pos; - i_this->field_0x5bc = a_this->current.pos; - i_this->field_0x6e8 = 100; + i_this->action = ACTION_GAKEJUMP; + i_this->mode = 0; + i_this->field_0x5c8 = actor->current.pos; + i_this->field_0x5bc = actor->current.pos; + i_this->invulnerability_timer = 100; } - a_this->speedF = 0.0f; + actor->speedF = 0.0f; } else { - i_this->mAction = ACTION_BACKDROP; - i_this->mMode = 0; + i_this->action = ACTION_BACKDROP; + i_this->mode = 0; } } - if (i_this->mAction != 3 && i_this->field_0x82e != 0) { - a_this->current.angle.y = a_this->shape_angle.y; + if (i_this->action != 3 && i_this->snap_angle_y_flag != 0) { + actor->current.angle.y = actor->shape_angle.y; } } static void e_dn_jump(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; i_this->field_0x6f4 = 1; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_JUMP_A, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; - return; + i_this->mode = 1; + break; case 1: - if (!i_this->mpModelMorf->isStop()) { - return; + if (!i_this->anm_p->isStop()) { + break; } - a_this->speed.y = 50.0f; - i_this->mMode = 2; - i_this->field_0x10e4 = 3; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_JUMP, -1); + actor->speed.y = KREG_F(13) + 50.0f; + i_this->mode = 2; + i_this->set_smoke_flag = 3; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_JUMP, -1); // fallthrough case 2: - a_this->speedF = 30.0f; - if (a_this->speed.y <= 0.0f) { - anm_init(i_this, ANM_JUMP_B, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 3; + actor->speedF =KREG_F(13) + 30.0f; + if (!(actor->speed.y <= 0.0f)) { + break; } - return; + + anm_init(i_this, ANM_JUMP_B, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->mode = 3; + break; case 3: - if (!i_this->mObjAcch.ChkGroundHit()) { - return; + if (!i_this->objacch.ChkGroundHit()) { + break; } anm_init(i_this, ANM_JUMP_C, 1.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 4; - i_this->field_0x10e4 = 3; - i_this->field_0x6e0[0] = 3; - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); - return; + i_this->mode = 4; + i_this->set_smoke_flag = 3; + i_this->timer[0] = 3; + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); + break; case 4: - if (i_this->field_0x6e0[0] == 1) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); + if (i_this->timer[0] == 1) { + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); } - cLib_addCalc0(&a_this->speedF, 1.0f, 10.0f); - if (!i_this->mpModelMorf->isStop()) { - return; + cLib_addCalc0(&actor->speedF, 1.0f, 10.0f); + if (!i_this->anm_p->isStop()) { + break; } - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; - return; + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } static void e_dn_gakejump(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp24, sp30; i_this->field_0x6f4 = 1; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: if (jump_pos_check(i_this, &i_this->field_0x5bc)) { anm_init(i_this, ANM_JUMP_A, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 2; - a_this->current.angle.y = i_this->mYAngleToPlayer; - return; + i_this->mode = 2; + actor->current.angle.y = i_this->search_angle_y; + break; } - if (i_this->mAnmID != ANM_WAIT_01) { + if (i_this->anm_no != ANM_WAIT_01) { anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndF(0.1f) + 0.9f); - i_this->field_0x6e0[0] = cM_rndF(15.0f) + 35.0f; - i_this->mMode = 1; + i_this->timer[0] = cM_rndF(15.0f) + 35.0f; + i_this->mode = 1; } - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mYAngleToPlayer, 4, 0x800); - return; + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->search_angle_y, 4, 0x800); + break; case 1: i_this->field_0x6f4 = 2; - cMtx_YrotS(*calc_mtx, a_this->shape_angle.y); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); sp24.x = 0.0f; sp24.y = 0.0f; sp24.z = 100.0f; - MtxPosition(&sp24, &i_this->field_0x738); - i_this->field_0x738 += a_this->current.pos; + MtxPosition(&sp24, &i_this->find_pos); + i_this->find_pos += actor->current.pos; - if (i_this->field_0x6e0[0] != 0) { - return; + if (i_this->timer[0] != 0) { + break; } - i_this->mMode = 0; - return; + i_this->mode = 0; + break; case 2: - if (!i_this->mpModelMorf->isStop()) { - return; + if (!i_this->anm_p->isStop()) { + break; } if (jump_pos_check(i_this, &i_this->field_0x5bc)) { - i_this->mMode = 3; - i_this->field_0x10e4 = 3; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_JUMP, -1); - i_this->field_0x6e0[0] = 20; - i_this->field_0x6e0[1] = 60; - i_this->field_0x5c8 = a_this->current.pos; + i_this->mode = 3; + i_this->set_smoke_flag = 3; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_JUMP, -1); + i_this->timer[0] = 20; + i_this->timer[1] = 60; + i_this->field_0x5c8 = actor->current.pos; } else { anm_init(i_this, ANM_WAIT_01, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndF(0.1f) + 0.9f); - i_this->field_0x6e0[0] = cM_rndF(15.0f) + 35.0f; - i_this->mMode = 1; - return; + i_this->timer[0] = cM_rndF(15.0f) + 35.0f; + i_this->mode = 1; + break; } // fallthrough case 3: i_this->field_0x5d8 = 1; - sp24 = i_this->field_0x5bc - a_this->current.pos; - i_this->field_0x5d4 = cM_atan2s(sp24.x, sp24.z); + sp24 = i_this->field_0x5bc - actor->current.pos; + i_this->cur_angle_y_target = cM_atan2s(sp24.x, sp24.z); i_this->field_0x5d6 = -cM_atan2s(sp24.y, JMAFastSqrt(sp24.x * sp24.x + sp24.z * sp24.z)); - a_this->speedF = 50.0f; + actor->speedF = KREG_F(13) + 50.0f; - if (i_this->field_0x6e0[0] == 1) { + if (i_this->timer[0] == 1) { anm_init(i_this, ANM_JUMP_B, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } - if (sp24.abs() < (a_this->speedF * 1.1f)) { - a_this->current.pos = i_this->field_0x5bc; + if (sp24.abs() < (actor->speedF * 1.1f)) { + actor->current.pos = i_this->field_0x5bc; anm_init(i_this, ANM_JUMP_C, 1.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 4; - i_this->field_0x10e4 = 3; - i_this->field_0x6e0[0] = 3; - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); - a_this->speedF = 0.0f; - i_this->field_0x6e8 = 0; + i_this->mode = 4; + i_this->set_smoke_flag = 3; + i_this->timer[0] = 3; + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); + actor->speedF = 0.0f; + i_this->invulnerability_timer = 0; } - if (i_this->field_0x6e0[1] == 0 || i_this->mObjAcch.ChkWallHit() != 0) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + if (!(i_this->timer[1] == 0 || i_this->objacch.ChkWallHit() != 0)) { + break; } - return; + + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; + break; case 4: - if (i_this->field_0x6e0[0] == 1) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); + if (i_this->timer[0] == 1) { + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); } - if (!i_this->mpModelMorf->isStop()) { - return; + if (!i_this->anm_p->isStop()) { + break; } - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; - return; + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } static fopAc_ac_c* at_hit_check(e_dn_class* i_this) { - if (i_this->mMode >= 10) { + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* player = dComIfGp_getPlayer(0); + + if (i_this->mode >= 10) { return NULL; } - if (i_this->field_0xe44.ChkAtHit() != 0) { - return dCc_GetAc(i_this->field_0xe44.GetAtHitObj()->GetAc()); + if (i_this->at_sph.ChkAtHit() != 0) { + return dCc_GetAc(i_this->at_sph.GetAtHitObj()->GetAc()); } return NULL; } static void e_dn_attack_0(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp2c, sp38; - int frame = i_this->mpModelMorf->getFrame(); + int frame = i_this->anm_p->getFrame(); i_this->field_0x6f4 = 1; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: - anm_init(i_this, ANM_ATTACK_TAIL_01, 6.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_KNIFE, -1); - i_this->mMode = 1; + anm_init(i_this, ANM_ATTACK_TAIL_01, TREG_F(14) + 6.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_KNIFE, -1); + i_this->mode = 1; // fallthrough case 1: if (frame >= 22 && frame <= 28) { - i_this->field_0x6ef = 1; - i_this->field_0x6ee = 0; + i_this->at_chk_flag = 1; + i_this->tail_at_sph_flag = 0; } - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } - cLib_addCalc0(&a_this->speedF, 1.0f, 5.0f); + cLib_addCalc0(&actor->speedF, 1.0f, 5.0f); - if (i_this->field_0x6ef != 0) { + if (i_this->at_chk_flag != 0) { fopAc_ac_c* actor_p = at_hit_check(i_this); if (actor_p != NULL && fopAcM_GetName(actor_p) == PROC_ALINK && daPy_getPlayerActorClass()->checkPlayerGuard()) { dComIfGp_getVibration().StartShock(3, 31, cXyz(0.0f, 1.0f, 0.0f)); @@ -1415,94 +1489,95 @@ static void e_dn_attack_0(e_dn_class* i_this) { } static void e_dn_attack(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp34, sp40; - int frame = i_this->mpModelMorf->getFrame(); + int frame = i_this->anm_p->getFrame(); i_this->field_0x6f4 = 1; s16 sVar1, sVar2; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: - anm_init(i_this, ANM_ATTACK_TAIL_02, 6.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_KNIFE2_A, -1); - i_this->mMode = 1; + anm_init(i_this, ANM_ATTACK_TAIL_02, TREG_F(14) + 6.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_KNIFE2_A, -1); + i_this->mode = 1; // fallthrough case 1: if (frame < 10 || (frame >= 25 && frame <= 30)) { - sVar1 = a_this->current.angle.y; - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mYAngleToPlayer, 2, 0x800); - sVar1 -= a_this->current.angle.y; - sVar1 *= 2; - if (sVar1 > 0x1000) { - sVar1 = 0x1000; - } else if (sVar1 < -0x1000) { - sVar1 = -0x1000; + sVar1 = actor->current.angle.y; + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->search_angle_y, 2, 0x800); + sVar1 -= actor->current.angle.y; + sVar1 *= (s16)(YREG_S(5) + 2); + s16 sVar3 = YREG_S(6) + 0x1000; + if (sVar1 > sVar3) { + sVar1 = sVar3; + } else if (sVar1 < (s16)-sVar3) { + sVar1 = -sVar3; } - cLib_addCalcAngleS2(&i_this->field_0x826, sVar1, 2, 0x400); + cLib_addCalcAngleS2(&i_this->jnt_tail_y_rot_offset, sVar1, 2, 0x400); } if (frame >= 13 && frame <= 18) { - i_this->field_0x6ef = 1; - i_this->field_0x6ee = 0; + i_this->at_chk_flag = 1; + i_this->tail_at_sph_flag = 0; } if (frame >= 25 && frame <= 30) { - i_this->field_0x6ef = 1; - i_this->field_0x6ee = 1; - cMtx_YrotS(*calc_mtx, a_this->current.angle.y); + i_this->at_chk_flag = 1; + i_this->tail_at_sph_flag = 1; + cMtx_YrotS(*calc_mtx, actor->current.angle.y); sp34.x = 0.0f; sp34.y = 0.0f; - sp34.z = 25.0f; + sp34.z = BREG_F(17) + 25.0f; MtxPosition(&sp34, &sp40); - a_this->current.pos += sp40; + actor->current.pos += sp40; } - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } - cLib_addCalc0(&a_this->speedF, 1.0f, 5.0f); - if (i_this->field_0x6ef != 0) { + cLib_addCalc0(&actor->speedF, 1.0f, 5.0f); + if (i_this->at_chk_flag != 0) { fopAc_ac_c* actor_p = at_hit_check(i_this); if (actor_p != NULL && fopAcM_GetName(actor_p) == PROC_ALINK && daPy_getPlayerActorClass()->checkPlayerGuard()) { - i_this->mpModelMorf->setPlaySpeed(0.0f); - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + i_this->anm_p->setPlaySpeed(0.0f); + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } } static void tail_eff_set(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - J3DModel* model = i_this->mpModelMorf->getModel(); - i_this->field_0x10f8 = dComIfGp_particle_set(i_this->field_0x10f8, 0x815F, &a_this->current.pos, NULL, NULL); - JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->field_0x10f8); + J3DModel* model = i_this->anm_p->getModel(); + i_this->dn_tail_blur_a_prtcl = dComIfGp_particle_set(i_this->dn_tail_blur_a_prtcl, dPa_RM(ID_ZI_S_DNTAILBLUR_A), &actor->current.pos, NULL, NULL); + JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->dn_tail_blur_a_prtcl); if (emitter != NULL) { - MTXCopy(model->getAnmMtx(0), *calc_mtx); + MTXCopy(model->getAnmMtx(JNT_WORLD_ROOT), *calc_mtx); emitter->setGlobalRTMatrix(*calc_mtx); } - i_this->field_0x10fc = dComIfGp_particle_set(i_this->field_0x10fc, 0x8160, &a_this->current.pos, NULL, NULL); - emitter = dComIfGp_particle_getEmitter(i_this->field_0x10fc); + i_this->dn_tail_blur_b_prtcl = dComIfGp_particle_set(i_this->dn_tail_blur_b_prtcl, dPa_RM(ID_ZI_S_DNTAILBLUR_B), &actor->current.pos, NULL, NULL); + emitter = dComIfGp_particle_getEmitter(i_this->dn_tail_blur_b_prtcl); if (emitter != NULL) { - MTXCopy(model->getAnmMtx(0), *calc_mtx); + MTXCopy(model->getAnmMtx(JNT_WORLD_ROOT), *calc_mtx); emitter->setGlobalRTMatrix(*calc_mtx); } } static void e_dn_tail_attack(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp30, sp3c; - int frame = i_this->mpModelMorf->getFrame(); + int frame = i_this->anm_p->getFrame(); i_this->field_0x6f4 = 1; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: - anm_init(i_this, ANM_ATTACK_01, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; + anm_init(i_this, ANM_ATTACK_01, TREG_F(14) + 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->mode = 1; break; case 1: @@ -1511,114 +1586,114 @@ static void e_dn_tail_attack(e_dn_class* i_this) { } if (frame >= 33 && frame <= 41) { - i_this->field_0x6ef = 1; - i_this->field_0x6ee = 2; - cMtx_YrotS(*calc_mtx, i_this->mYAngleToPlayer); + i_this->at_chk_flag = 1; + i_this->tail_at_sph_flag = 2; + cMtx_YrotS(*calc_mtx, i_this->search_angle_y); sp30.x = 0.0f; sp30.y = 0.0f; - sp30.z = 30.0f; + sp30.z = BREG_F(18) + 30.0f; MtxPosition(&sp30, &sp3c); - a_this->current.pos += sp3c; + actor->current.pos += sp3c; } if (frame == 40) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); } else if (frame == 43) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); } - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } - a_this->current.angle.y += i_this->field_0x82a; - a_this->shape_angle.y += i_this->field_0x82a; - cLib_addCalcAngleS2(&i_this->field_0x82a, 0, 1, 300); - cLib_addCalc0(&a_this->speedF, 1.0f, 3.0f); + actor->current.angle.y += i_this->angle_y_offset; + actor->shape_angle.y += i_this->angle_y_offset; + cLib_addCalcAngleS2(&i_this->angle_y_offset, 0, 1, 300); + cLib_addCalc0(&actor->speedF, 1.0f, 3.0f); } static void e_dn_guard(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - i_this->field_0x6f1 = 1; + i_this->guard_flag = 1; i_this->field_0x6f4 = 1; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_WAIT_02, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; - a_this->speed.y = 20.0f; - a_this->speedF = -8.0f; - i_this->field_0x10e4 = 3; + i_this->mode = 1; + actor->speed.y = KREG_F(0) + 20.0f; + actor->speedF = KREG_F(1) + -8.0f; + i_this->set_smoke_flag = 3; break; case 1: - i_this->field_0x6e8 = 5; - if (i_this->mpModelMorf->getFrame() >= 5.0f) { - i_this->mMode = 5; - i_this->field_0x6e0[0] = 20; + i_this->invulnerability_timer = 5; + if (i_this->anm_p->getFrame() >= 5.0f) { + i_this->mode = 5; + i_this->timer[0] = KREG_S(1) + 20; } break; case 5: anm_init(i_this, ANM_GUARD, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_GUARD, -1); - i_this->mMode = 6; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_GUARD, -1); + i_this->mode = 6; // fallthrough case 6: - i_this->field_0x6e8 = 5; - if (i_this->mObjAcch.ChkGroundHit()) { - cLib_addCalc0(&a_this->speedF, 1.0f, 10.0f); + i_this->invulnerability_timer = 5; + if (i_this->objacch.ChkGroundHit()) { + cLib_addCalc0(&actor->speedF, 1.0f, 10.0f); } - if (i_this->mpModelMorf->getFrame() >= 8.0f) { - i_this->mpModelMorf->setPlaySpeed(0.0f); - i_this->mMode = 7; - a_this->speedF = 0.0f; + if (i_this->anm_p->getFrame() >= 8.0f) { + i_this->anm_p->setPlaySpeed(0.0f); + i_this->mode = 7; + actor->speedF = 0.0f; } break; case 7: - i_this->field_0x6e8 = 5; + i_this->invulnerability_timer = 5; if (cc_pl_cut_bit_get() == 0x80 || cc_pl_cut_bit_get() == 0x800) { - i_this->field_0x6e0[0] = 20; + i_this->timer[0] = KREG_S(0) + 20; } - if (i_this->field_0x6e0[0] == 0) { - i_this->mMode = 8; - i_this->mpModelMorf->setPlaySpeed(1.0f); + if (i_this->timer[0] == 0) { + i_this->mode = 8; + i_this->anm_p->setPlaySpeed(1.0f); } break; case 8: - if (i_this->mpModelMorf->isStop()) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; + if (i_this->anm_p->isStop()) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; } } } static void e_dn_s_damage(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: - i_this->mMode = 1; - i_this->field_0x6e0[0] = 20; + i_this->mode = 1; + i_this->timer[0] = 20; anm_init(i_this, ANM_WAIT_01, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); break; case 1: - if (i_this->field_0x6e0[0] == 0) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0; - i_this->field_0x6e0[0] = 40; + if (i_this->timer[0] == 0) { + i_this->action = ACTION_FIGHT_RUN; + i_this->mode = 0; + i_this->timer[0] = 40; } } - cLib_addCalc0(&a_this->speedF, 1.0f, 3.0f); + cLib_addCalc0(&actor->speedF, 1.0f, 3.0f); } static BOOL kado_check(e_dn_class* i_this) { @@ -1630,53 +1705,53 @@ static BOOL kado_check(e_dn_class* i_this) { 80.0f, -80.0f, }; - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; dBgS_LinChk lin_chk; - cXyz sp9c, spa8, spb4; - BOOL rv = FALSE; + cXyz work, start, end; + BOOL kado = FALSE; cMtx_YrotS(*calc_mtx, i_this->field_0x724.y); for (int i = 0; i < 2; i++) { - spa8 = a_this->current.pos; - spa8.y += 100.0f; - sp9c.x = 0.0f; - sp9c.y = 0.0f; - sp9c.z = 70.0f; - MtxPosition(&sp9c, &spb4); - spa8 += spb4; - sp9c.y = 50.0f; - sp9c.z = -150.0f; - sp9c.x = 1.0f * kado_check_x[i]; - MtxPosition(&sp9c, &spb4); - spb4 += spa8; - lin_chk.Set(&spa8, &spb4, a_this); + start = actor->current.pos; + start.y += JREG_F(0) + 100.0f; + work.x = JREG_F(1); + work.y = JREG_F(2); + work.z = JREG_F(3) + 70.0f; + MtxPosition(&work, &end); + start += end; + work.y = JREG_F(4) + 50.0f; + work.z = JREG_F(5) + -150.0f; + work.x = (JREG_F(6) + 1.0f) * kado_check_x[i]; + MtxPosition(&work, &end); + end += start; + lin_chk.Set(&start, &end, actor); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - rv |= kado_bit[i]; + kado |= kado_bit[i]; } } - if (rv == 3) { - rv = FALSE; + if (kado == 3) { + kado = FALSE; } - return rv; + return kado; } static BOOL body_gake(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - J3DModel* model = i_this->mpModelMorf->getModel(); - cXyz sp7c, sp88; + J3DModel* model = i_this->anm_p->getModel(); + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + cXyz work, body_pos; - MTXCopy(model->getAnmMtx(2), *calc_mtx); - sp7c.set(0.0f, 0.0f, 0.0f); - MtxPosition(&sp7c, &sp88); + MTXCopy(model->getAnmMtx(JNT_BACKBONE02), *calc_mtx); + work.set(BREG_F(10), BREG_F(11), BREG_F(12)); + MtxPosition(&work, &body_pos); dBgS_ObjGndChk gnd_chk; - sp88.y += 100.0f; - gnd_chk.SetPos(&sp88); - sp88.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + body_pos.y += 100.0f; + gnd_chk.SetPos(&body_pos); + body_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); - if ((a_this->current.pos.y - sp88.y) > 300.0f) { + if ((actor->current.pos.y - body_pos.y) > 300.0f) { return TRUE; } @@ -1684,160 +1759,162 @@ static BOOL body_gake(e_dn_class* i_this) { } static void e_dn_damage(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp34, sp40; - if (a_this->health <= 0) { - fopAcM_OffStatus(a_this, 0); - a_this->attention_info.flags = 0; + if (actor->health <= 0) { + fopAcM_OffStatus(actor, 0); + actor->attention_info.flags = 0; } if (daPy_py_c::checkNowWolf() != 0) { - if (i_this->field_0x6f3 == 0 && a_this->checkWolfDownStartFlg()) { - if (i_this->field_0x6e0[0] > 40) { - i_this->field_0x6e0[0] = 90; + if (i_this->field_0x6f3 == 0 && actor->checkWolfDownStartFlg()) { + if (i_this->timer[0] > 40) { + i_this->timer[0] = 90; OS_REPORT(" DN WOLFHIT LONG \n"); - } else if (i_this->field_0x6e0[0] > 20) { - i_this->field_0x6e0[0] = 70; + } else if (i_this->timer[0] > 20) { + i_this->timer[0] = 70; OS_REPORT(" DN WOLFHIT MID \n"); } else { - i_this->field_0x6e0[0] = 50; + i_this->timer[0] = 50; OS_REPORT(" DN WOLFHIT SHORT \n"); } - i_this->mMode = 30; + i_this->mode = 30; i_this->field_0x6f3 = 1; - if (i_this->field_0x5b7 == 1) { - i_this->field_0x6e0[1] = l_HIO.field_0x20 + 1; + if (i_this->arg1 == 1) { + i_this->timer[1] = l_HIO.soul_disappear_time_strong + 1; } else { - i_this->field_0x6e0[1] = l_HIO.field_0x1e + 1; + i_this->timer[1] = l_HIO.soul_disappear_time_weak + 1; } } - } else if (i_this != NULL && a_this->checkCutDownHitFlg()) { - a_this->offCutDownHitFlg(); - i_this->mMode = 3; - a_this->health = 0; - i_this->field_0x6e0[0] = 100; - i_this->field_0x6e0[1] = 46; - a_this->offDownFlg(); - a_this->health = 0; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); - i_this->field_0x6c4 = 1; + } else if (actor != NULL && actor->checkCutDownHitFlg()) { + actor->offCutDownHitFlg(); + i_this->mode = 3; + actor->health = 0; + i_this->timer[0] = 100; + i_this->timer[1] = 46; + actor->offDownFlg(); + actor->health = 0; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); + i_this->death_flag = 1; daPy_getPlayerActorClass()->onEnemyDead(); - i_this->field_0x80c = 15; + i_this->death_jnt_rot_counter = TREG_S(7) + 15; } - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_BLOWNOFF, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); - i_this->mMode = 1; - a_this->speedF = 0.0f; - i_this->field_0x7e8 = 8000.0f; + i_this->mode = 1; + actor->speedF = 0.0f; + i_this->field_0x7e8 = BREG_F(10) + 8000.0f; - if (a_this->health <= 0) { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); - i_this->field_0x6c4 = 1; + if (actor->health <= 0) { + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); + i_this->death_flag = 1; daPy_getPlayerActorClass()->onEnemyDead(); } else { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE2, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE2, -1); } - i_this->field_0x6e0[0] = 0; + i_this->timer[0] = 0; break; case 1: - if (i_this->mObjAcch.ChkWallHit() != 0 && i_this->field_0x6e0[0] == 0) { - int iVar1 = kado_check(i_this); - if (iVar1 != 0) { - OS_REPORT(" ..KADO KABE ..%x\n", iVar1); - if (iVar1 == 2) { + if (i_this->objacch.ChkWallHit() != 0 && i_this->timer[0] == 0) { + int kado_kabe = kado_check(i_this); + if (kado_kabe != 0) { + OS_REPORT(" ..KADO KABE ..%x\n", kado_kabe); + if (kado_kabe == 2) { i_this->field_0x70e = 0xC00; - i_this->field_0x724.y += -7000; + i_this->field_0x724.y += TREG_S(8) + -7000; } else { i_this->field_0x70e = -0xC00; - i_this->field_0x724.y += 7000; + i_this->field_0x724.y += -(TREG_S(8) - 7000); } - i_this->field_0x7e8 = 8000.0f; - i_this->field_0x754 = 100.0f; - i_this->field_0x75c = 100.0f; - i_this->field_0x828 = 40; - i_this->field_0x6e0[0] = 60; + i_this->field_0x7e8 = BREG_F(10) + 8000.0f; + i_this->field_0x754 = BREG_F(4) + 100.0f; + i_this->field_0x75c = BREG_F(5) + 100.0f; + i_this->unk_timer_4 = DREG_S(1) + 40; + i_this->timer[0] = 60; } else { - i_this->mMode = 10; - a_this->speed.y = 0.0f; + i_this->mode = 10; + actor->speed.y = 0.0f; i_this->field_0x704 *= 0.2f; i_this->field_0x724.y += 0x8000; - i_this->field_0x7e8 = 8000.0f; - i_this->field_0x840 = 5; - i_this->field_0x754 = 100.0f; - i_this->field_0x75c = 100.0f; - i_this->field_0x828 = 40; + i_this->field_0x7e8 = BREG_F(10) + 8000.0f; + i_this->unk_timer_5 = BREG_S(7) + 5; + i_this->field_0x754 = BREG_F(4) + 100.0f; + i_this->field_0x75c = BREG_F(5) + 100.0f; + i_this->unk_timer_4 = DREG_S(1) + 40; i_this->field_0x70e = 0; } - } else { - cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, 0x300); - a_this->current.angle.y += i_this->field_0x70e; - a_this->shape_angle.y = a_this->current.angle.y; + break; + } - if (i_this->field_0x724.x <= -0x3000 && i_this->mObjAcch.ChkGroundHit()) { - i_this->mMode = 2; - i_this->field_0x736 = 10; - i_this->mSound.startCreatureSound(Z2SE_CM_BODYFALL_M, 0, -1); + cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, BREG_S(4) + 0x300); + actor->current.angle.y += i_this->field_0x70e; + actor->shape_angle.y = actor->current.angle.y; - if (i_this->field_0x737 == 0) { - anm_init(i_this, ANM_DIE_LEFT, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + if (i_this->field_0x724.x <= -0x3000 && i_this->objacch.ChkGroundHit()) { + i_this->mode = 2; + i_this->unk_timer_3 = 10; + i_this->sound.startCreatureSound(Z2SE_CM_BODYFALL_M, 0, -1); + + if (i_this->left_right_flag == 0) { + anm_init(i_this, ANM_DIE_LEFT, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + } else { + anm_init(i_this, ANM_DIE_RIGHT, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + } + + if (i_this->field_0x710 != 0) { + i_this->field_0x704 = 0.0f; + i_this->field_0x7e8 = BREG_F(12) + 2000.0f; + } else { + if (i_this->left_right_flag == 0) { + i_this->field_0x754 = -100.0f - BREG_F(6); + i_this->field_0x75c = -100.0f - BREG_F(7); } else { - anm_init(i_this, ANM_DIE_RIGHT, 5.0f, J3DFrameCtrl::EMode_NONE, 1.0f); + i_this->field_0x754 = BREG_F(4) + 100.0f; + i_this->field_0x75c = BREG_F(5) + 100.0f; } - if (i_this->field_0x710 != 0) { - i_this->field_0x704 = 0.0f; - i_this->field_0x7e8 = 2000.0f; - } else { - if (i_this->field_0x737 == 0) { - i_this->field_0x754 = -100.0f; - i_this->field_0x75c = -100.0f; - } else { - i_this->field_0x754 = 100.0f; - i_this->field_0x75c = 100.0f; - } + i_this->field_0x758 = -0x5000; + i_this->field_0x760 = -0x4000; + i_this->unk_timer_4 = DREG_S(1) + 40; + i_this->field_0x704 *= 0.5f; + actor->speed.y = TREG_F(6) + 20.0f; + i_this->field_0x70e /= 2; + actor->current.angle.y = i_this->field_0x724.y; + i_this->field_0x7e8 = BREG_F(12) + 8000.0f; - i_this->field_0x758 = -0x5000; - i_this->field_0x760 = -0x4000; - i_this->field_0x828 = 40; - i_this->field_0x704 *= 0.5f; - a_this->speed.y = 20.0f; - i_this->field_0x70e /= 2; - a_this->current.angle.y = i_this->field_0x724.y; - i_this->field_0x7e8 = 8000.0f; + J3DModel* model = i_this->anm_p->getModel(); + MTXCopy(model->getAnmMtx(JNT_BACKBONE02), *calc_mtx); + sp34.set(0.0f, 0.0f, 0.0f); + MtxPosition(&sp34, &sp40); - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); - sp34.set(0.0f, 0.0f, 0.0f); - MtxPosition(&sp34, &sp40); - - fopAcM_effSmokeSet1(&i_this->field_0x10dc, &i_this->field_0x10e0, &sp40, NULL, 1.8f, &a_this->tevStr, 1); - } + fopAcM_effSmokeSet1(&i_this->field_0x10dc, &i_this->field_0x10e0, &sp40, NULL, 1.8f, &actor->tevStr, 1); } } break; case 2: - a_this->current.angle.y += i_this->field_0x70e; - a_this->shape_angle.y = a_this->current.angle.y; - cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, 0x300); + actor->current.angle.y += i_this->field_0x70e; + actor->shape_angle.y = actor->current.angle.y; + cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, BREG_S(4) + 0x300); - if (i_this->mObjAcch.ChkGroundHit()) { - if (a_this->health > 0 && !daPy_py_c::checkNowWolf()) { - a_this->onDownFlg(); + if (i_this->objacch.ChkGroundHit()) { + if (actor->health > 0 && !daPy_py_c::checkNowWolf()) { + actor->onDownFlg(); } - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 5); - i_this->field_0x736 = 10; + dKy_Sound_set(actor->current.pos, 100, fopAcM_GetID(&i_this->actor), 5); + i_this->unk_timer_3 = 10; - if (i_this->field_0x737 == 0) { + if (i_this->left_right_flag == 0) { anm_init(i_this, ANM_DIE_LEFT, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } else { anm_init(i_this, ANM_DIE_RIGHT, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); @@ -1850,277 +1927,282 @@ static void e_dn_damage(e_dn_class* i_this) { i_this->field_0x802[i] = cM_rndF(10.0f); } - a_this->current.angle.y = i_this->field_0x724.y; + actor->current.angle.y = i_this->field_0x724.y; if (daPy_py_c::checkNowWolf() != 0) { - i_this->field_0x6e0[0] = 80; - i_this->field_0x6e0[1] = 55; + i_this->timer[0] = 80; + i_this->timer[1] = 55; } else { - i_this->field_0x6e0[0] = cM_rndF(10.0f) + 60.0f; - i_this->field_0x6e0[1] = 35; + i_this->timer[0] = cM_rndF(10.0f) + 60.0f; + i_this->timer[1] = 35; } - i_this->mMode = 3; - i_this->field_0x7e8 = 1500.0f; + i_this->mode = 3; + i_this->field_0x7e8 = BREG_F(13) + 1500.0f; - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); + J3DModel* model = i_this->anm_p->getModel(); + MTXCopy(model->getAnmMtx(JNT_BACKBONE02), *calc_mtx); sp34.set(0.0f, 0.0f, 0.0f); MtxPosition(&sp34, &sp40); - fopAcM_effSmokeSet1(&i_this->field_0x10dc, &i_this->field_0x10e0, &sp40, NULL, 1.0f, &a_this->tevStr, 1); + fopAcM_effSmokeSet1(&i_this->field_0x10dc, &i_this->field_0x10e0, &sp40, NULL, 1.0f, &actor->tevStr, 1); } break; case 3: if (body_gake(i_this)) { - i_this->field_0x704 = -20.0f; - i_this->field_0x724.x -= 0x300; + i_this->field_0x704 = VREG_F(8) + -20.0f; + i_this->field_0x724.x -= (s16)(VREG_S(7) + 0x300); } - if (a_this->health <= 0 && i_this->field_0x6e0[1] == 0) { - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); + if (actor->health <= 0 && i_this->timer[1] == 0) { + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), *calc_mtx); sp34.set(0.0f, 0.0f, 0.0f); MtxPosition(&sp34, &sp40); + + s8 unused = 0; dn_disappear(i_this); - fopAcM_delete(a_this); + fopAcM_delete(actor); return; } - if (daPy_getPlayerActorClass()->getCutType() != daPy_py_c::CUT_TYPE_DOWN && i_this->field_0x6e0[0] == 0) { - i_this->mMode = 20; - if (i_this->field_0x737 == 0) { + if (daPy_getPlayerActorClass()->getCutType() != daPy_py_c::CUT_TYPE_DOWN && i_this->timer[0] == 0) { + i_this->mode = 20; + if (i_this->left_right_flag == 0) { anm_init(i_this, ANM_DIE_LEFT_UP, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } else { anm_init(i_this, ANM_DIE_RIGHT_UP, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); - if (i_this != NULL) { - a_this->offDownFlg(); + if (actor != NULL) { + actor->offDownFlg(); } } break; case 10: - if (i_this->field_0x840 != 0) { - cLib_addCalcAngleS2(&i_this->field_0x724.x, 0, 1, 0x300); + if (i_this->unk_timer_5 != 0) { + cLib_addCalcAngleS2(&i_this->field_0x724.x, 0, 1, BREG_S(4) + 0x300); } else { - cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, 0x800); - if (i_this->mObjAcch.ChkGroundHit()) { - i_this->mMode = 2; - if (i_this->field_0x737 == 0) { - i_this->field_0x754 = -100.0f; - i_this->field_0x75c = -100.0f; + cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 1, BREG_S(5) + 0x800); + if (i_this->objacch.ChkGroundHit()) { + i_this->mode = 2; + if (i_this->left_right_flag == 0) { + i_this->field_0x754 = -100.0f - BREG_F(6); + i_this->field_0x75c = -100.0f - BREG_F(7); } else { - i_this->field_0x754 = 100.0f; - i_this->field_0x75c = 100.0f; + i_this->field_0x754 = BREG_F(4) + 100.0f; + i_this->field_0x75c = BREG_F(5) + 100.0f; } i_this->field_0x758 = -0x5000; i_this->field_0x760 = -0x4000; i_this->field_0x704 *= 0.5f; - a_this->speed.y = 20.0f; - a_this->current.angle.y = i_this->field_0x724.y; - i_this->field_0x7e8 = 8000.0f; + actor->speed.y = TREG_F(6) + 20.0f; + actor->current.angle.y = i_this->field_0x724.y; + i_this->field_0x7e8 = BREG_F(12) + 8000.0f; } } break; case 20: - if (i_this->mpModelMorf->getFrame() >= 35.0f) { - i_this->field_0x730.z = 0; - i_this->field_0x730.x = 0; + if (i_this->anm_p->getFrame() >= 35.0f) { + i_this->field_0x730.x = i_this->field_0x730.z = 0; } - if (i_this->mpModelMorf->isStop()) { - i_this->field_0x724.y = 0; - i_this->field_0x724.x = 0; + if (i_this->anm_p->isStop()) { + i_this->field_0x724.x = i_this->field_0x724.y = 0; anm_init(i_this, ANM_WAIT_01, 0.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); - i_this->field_0x6e0[0] = 5; - i_this->mMode = 21; + i_this->timer[0] = 5; + i_this->mode = 21; - if (i_this != NULL) { - a_this->offDownFlg(); + if (actor != NULL) { + actor->offDownFlg(); } } break; case 21: case 22: - i_this->field_0x6e8 = 0; - if (i_this->field_0x6e0[0] == 0) { - i_this->mAction = ACTION_NORMAL; - i_this->mMode = 0; - i_this->field_0x6e0[0] = cM_rndF(50.0f) + 50.0f; + i_this->invulnerability_timer = 0; + if (i_this->timer[0] == 0) { + i_this->action = ACTION_NORMAL; + i_this->mode = 0; + i_this->timer[0] = cM_rndF(50.0f) + 50.0f; anm_init(i_this, ANM_WAIT_03, 10.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } break; case 30: - if (!a_this->checkWolfDownPullFlg()) { - i_this->field_0x6e0[1] = 0; + if (!actor->checkWolfDownPullFlg()) { + i_this->timer[1] = 0; } - if (i_this->field_0x6e0[0] == 0) { - i_this->mMode = 31; - if (i_this->field_0x737 == 0) { + if (i_this->timer[0] == 0) { + i_this->mode = 31; + if (i_this->left_right_flag == 0) { anm_init(i_this, ANM_BRUSH_LEFT_UP, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } else { anm_init(i_this, ANM_BRUSH_RIGHT_UP, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); - i_this->field_0x6e0[0] = 10; - } else if (i_this->field_0x6e0[1] == 1) { - a_this->onWolfDownPullEndFlg(); - a_this->offCutDownHitFlg(); - a_this->health = 0; - i_this->field_0x6e0[0] = 1000; - i_this->field_0x6e0[1] = 35; - i_this->mMode = 3; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_UP, -1); + i_this->timer[0] = 10; + } else if (i_this->timer[1] == 1) { + actor->onWolfDownPullEndFlg(); + actor->offCutDownHitFlg(); + actor->health = 0; + i_this->timer[0] = 1000; + i_this->timer[1] = 35; + i_this->mode = 3; } break; case 31: - if (i_this->field_0x6e0[0] == 0) { - a_this->offDownFlg(); - i_this->mMode = 20; + if (i_this->timer[0] == 0) { + actor->offDownFlg(); + i_this->mode = 20; i_this->field_0x6f3 = 0; } } - if (i_this != NULL && a_this->checkDownFlg()) { + if (actor != NULL && actor->checkDownFlg()) { i_this->field_0x6f2 = 0; } - if (i_this->field_0x80c != 0) { - i_this->field_0x80c--; - i_this->field_0x80a = i_this->field_0x80c * cM_ssin(i_this->field_0x80c * 0x3800) * 100.0f; + if (i_this->death_jnt_rot_counter != 0) { + i_this->death_jnt_rot_counter--; + i_this->death_jnt_rot = i_this->death_jnt_rot_counter * cM_ssin(i_this->death_jnt_rot_counter * (TREG_S(9) + 0x3800)) * (TREG_F(5) + 100.0f); } } static void e_dn_backdrop(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + f32 zero = 0.0f; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_DRAWBACK, 3.0f, J3DFrameCtrl::EMode_NONE, 0.5f); - i_this->mMode = 1; - i_this->field_0x724.y = a_this->shape_angle.y; + i_this->mode = 1; + i_this->field_0x724.y = (s16)actor->shape_angle.y; i_this->field_0x724.x = 0; - a_this->speedF = -3.0f; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); + actor->speedF = -3.0f; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); // fallthrough case 1: if (i_this->field_0x724.x < -0x4000) { - a_this->speedF = -6.0f; + actor->speedF = -6.0f; } - if (a_this->speed.y < -20.0f) { - i_this->mMode = 2; - a_this->speedF = 0.0f; + if (actor->speed.y < -20.0f) { + i_this->mode = 2; + actor->speedF = 0.0f; } // fallthrough case 2: + // Target: -157.5 degrees, Step: (field_0x724.x - (-157.5 degrees)) / 2, Max Step: 11.25 degrees cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x7000, 2, 0x800); - if (i_this->mMode == 2 && a_this->current.pos.y <= (i_this->mObjAcch.GetGroundH() + 100.0f)) { - a_this->current.pos.y = i_this->mObjAcch.GetGroundH() + 100.0f; + + if (i_this->mode == 2 && actor->current.pos.y <= (KREG_F(17) + (i_this->objacch.GetGroundH() + 100.0f))) { + actor->current.pos.y = KREG_F(17) + (i_this->objacch.GetGroundH() + 100.0f); i_this->field_0x724.x = -0x4000; - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; i_this->field_0x704 = 0.0f; - a_this->health = 0; + actor->health = 0; } } } static void e_dn_water(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp20, sp2c, sp38; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + cXyz sp20, sp2c; - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), *calc_mtx); sp20.set(0.0f, 0.0f, 0.0f); MtxPosition(&sp20, &sp2c); - i_this->field_0x6e8 = 10; - switch (i_this->mMode) { + i_this->invulnerability_timer = 10; + switch (i_this->mode) { case 0: - case 1: - a_this->speed.y = 0.0f; - if (i_this->field_0x737 == 0) { + case 1: { + actor->speed.y = 0.0f; + if (i_this->left_right_flag == 0) { anm_init(i_this, ANM_DROWNED_A, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } else { anm_init(i_this, ANM_DROWNED_B, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); } - i_this->field_0x6e0[0] = 60; - a_this->speedF = 0.0f; - i_this->field_0x704 = 0.0f; - i_this->field_0x708 = 0.0f; + i_this->timer[0] = 60; + i_this->field_0x708 = i_this->field_0x704 = actor->speedF = 0.0f; - sp38 = a_this->current.pos; - sp38.y = i_this->field_0xa5c; - if (i_this->mMode == 0) { - fopKyM_createWpillar(&sp38, 1.5f, 0); + cXyz pos = actor->current.pos; + pos.y = i_this->field_0xa5c; + if (i_this->mode == 0) { + fopKyM_createWpillar(&pos, 1.5f, 0); } else { - fopKyM_createMpillar(&sp38, 1.0f); + fopKyM_createMpillar(&pos, 1.0f); } - i_this->mMode = 10; + i_this->mode = 10; break; + } case 10: - a_this->speed.y = 0.0f; - cLib_addCalc2(&a_this->current.pos.y, i_this->field_0xa5c, 0.5f, 5.0f); - cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 4, 0x400); + actor->speed.y = 0.0f; + cLib_addCalc2(&actor->current.pos.y, i_this->field_0xa5c, 0.5f, 5.0f); + cLib_addCalcAngleS2(&i_this->field_0x724.x, -0x4000, 4, BREG_S(4) + 0x400); - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { dn_disappear(i_this); } + break; } } static void e_dn_reg(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; cXyz sp34, sp40; - f32 fVar1 = 0.0f; + f32 dash_speed = 0.0f; + int frame = i_this->anm_p->getFrame(); i_this->field_0x6f2 = 0; - i_this->field_0x6e8 = 10; + i_this->invulnerability_timer = 10; - switch (i_this->mMode) { + switch (i_this->mode) { case 0: anm_init(i_this, ANM_RUN, 5.0f, J3DFrameCtrl::EMode_LOOP, cM_rndFX(0.05f) + 1.0f); - i_this->mMode = 1; + i_this->mode = 1; - if ((i_this->field_0x5b6 & 1) != 0) { - a_this->current.pos.set(-8613.0f, 2000.0f, 8017.0f); - a_this->current.angle.set(0, 0x19A0, 0); + if ((i_this->arg0 & 1) != 0) { + actor->current.pos.set(-8613.0f, 2000.0f, 8017.0f); + actor->current.angle.set(0, 0x19A0, 0); } else { - a_this->current.pos.set(-8044.0f, 2000.0f, 8616.0f); - a_this->current.angle.set(0, -0x629E, 0); + actor->current.pos.set(-8044.0f, 2000.0f, 8616.0f); + actor->current.angle.set(0, -0x629E, 0); } - a_this->old.pos = a_this->current.pos; - i_this->field_0x5d4 = a_this->current.angle.y; - i_this->field_0x6e0[0] = 14; + actor->old.pos = actor->current.pos; + i_this->cur_angle_y_target = actor->current.angle.y; + i_this->timer[0] = nREG_S(0) + 14; // fallthrough case 1: - fVar1 = l_HIO.dash_speed; - if ((i_this->field_0x6cc & 3) == 0) { - if ((i_this->field_0x6cc & 4) != 0) { - i_this->field_0x10e4 = 1; + dash_speed = l_HIO.dash_speed; + if ((i_this->frame_counter & 3) == 0) { // Every 4 frames + if ((i_this->frame_counter & 4) != 0) { // Every 5 frames + i_this->set_smoke_flag = 1; } else { - i_this->field_0x10e4 = 2; + i_this->set_smoke_flag = 2; } } - if (i_this->field_0x6e0[0] == 0) { + if (i_this->timer[0] == 0) { fopAc_ac_c* player = dComIfGp_getPlayer(0); - cMtx_YrotS(*calc_mtx, player->shape_angle.y); + cMtx_YrotS(*calc_mtx, (s16)player->shape_angle.y); - if ((i_this->field_0x5b6 & 1) != 0) { + if ((i_this->arg0 & 1) != 0) { sp34.x = 100.0f; } else { sp34.x = -100.0f; @@ -2129,73 +2211,73 @@ static void e_dn_reg(e_dn_class* i_this) { sp34.z = 0.0f; MtxPosition(&sp34, &sp40); sp40 += player->current.pos; - sp34 = sp40 - a_this->current.pos; - i_this->field_0x5d4 = cM_atan2s(sp34.x, sp34.z); + sp34 = sp40 - actor->current.pos; + i_this->cur_angle_y_target = cM_atan2s(sp34.x, sp34.z); } break; case 2: - if ((i_this->field_0x5b6 & 1) != 0) { - i_this->field_0x750 = a_this->shape_angle.y - (0x4000 << 2) + 0x4000; - i_this->field_0x724.y = a_this->shape_angle.y + 0x4000; + if ((i_this->arg0 & 1) != 0) { + i_this->field_0x750 = actor->shape_angle.y - (0x4000 << 2) + 0x4000; + i_this->field_0x724.y = actor->shape_angle.y + 0x4000; i_this->field_0x70e = (cM_rndFX(800.0f) + 3000.0f); } else { - i_this->field_0x750 = a_this->shape_angle.y - 0x4000; - i_this->field_0x724.y = a_this->shape_angle.y - 0x4000; + i_this->field_0x750 = actor->shape_angle.y - 0x4000; + i_this->field_0x724.y = actor->shape_angle.y - 0x4000; i_this->field_0x70e = -(cM_rndFX(800.0f) + 3000.0f); } i_this->field_0x74c = 150.0f; - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; - a_this->speed.y = cM_rndF(10.0f) + 40.0f; - i_this->field_0x704 = -30.0f; - i_this->field_0x828 = 50; - a_this->health = 0; + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; + actor->speed.y = TREG_F(13) + 40.0f + cM_rndF(10.0f); + i_this->field_0x704 = TREG_F(18) + -30.0f; + i_this->unk_timer_4 = DREG_S(2) + 50; + actor->health = 0; break; } - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5d4, 2, 0x800); - s16 sVar1 = a_this->current.angle.y - i_this->field_0x5d4; + cLib_addCalcAngleS2(&actor->current.angle.y, i_this->cur_angle_y_target, 2, 0x800); + s16 sVar1 = actor->current.angle.y - i_this->cur_angle_y_target; if (sVar1 > 0x800 || sVar1 < -0x800) { - fVar1 = 0.0f; + dash_speed = 0.0f; } - a_this->speedF = fVar1; + actor->speedF = dash_speed; i_this->field_0x6f4 = 1; } static void wolfkick_damage(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); - i_this->field_0x750 = (a_this->shape_angle.y - 0x8000) - i_this->mAtInfo.mHitDirection.y; + i_this->field_0x750 = (actor->shape_angle.y - 0x8000) - i_this->at_info.mHitDirection.y; i_this->field_0x74c = 150.0f; - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; i_this->field_0x724.y = player->shape_angle.y + 0x8000; - a_this->speed.y = 0.0f; + actor->speed.y = 0.0f; i_this->field_0x704 = -1.0f; - i_this->field_0x828 = 50; - i_this->mSound.startCollisionSE(Z2SE_HIT_WOOD_WEAPON, 31); + i_this->unk_timer_4 = DREG_S(2) + 50; + i_this->sound.startCollisionSE(Z2SE_HIT_WOOD_WEAPON, 31); i_this->field_0x710 = 1; } static void big_damage(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - i_this->field_0x750 = (a_this->shape_angle.y - 0x8000) - i_this->mAtInfo.mHitDirection.y; + i_this->field_0x750 = (actor->shape_angle.y - 0x8000) - i_this->at_info.mHitDirection.y; i_this->field_0x74c = 150.0f; - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; - i_this->field_0x724.y = i_this->mAtInfo.mHitDirection.y; - a_this->speed.y = cM_rndF(10.0f) + 25.0f; - i_this->field_0x704 = -20.0f; - i_this->field_0x828 = 50; - if ((i_this->mAtInfo.mHitBit & 0x80) != 0) { + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; + i_this->field_0x724.y = i_this->at_info.mHitDirection.y; + actor->speed.y = TREG_F(13) + 25.0f + cM_rndF(10.0f); + i_this->field_0x704 = TREG_F(18) + -20.0f; + i_this->unk_timer_4 = DREG_S(2) + 50; + if ((i_this->at_info.mHitBit & 0x80) != 0) { OS_REPORT("SPIN CUT HIT !!\n"); i_this->field_0x70e = cM_rndFX(800.0f) + 3000.0f; - } else if ((i_this->mAtInfo.mHitBit & 0x800) != 0) { + } else if ((i_this->at_info.mHitBit & 0x800) != 0) { OS_REPORT("SPIN CUT L HIT !!\n"); i_this->field_0x70e = -(cM_rndFX(800.0f) + 3000.0f); } else { @@ -2206,188 +2288,185 @@ static void big_damage(e_dn_class* i_this) { } static void small_damage(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; - i_this->mAction = ACTION_S_DAMAGE; - i_this->mMode = 0; - i_this->field_0x828 = 50; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); + i_this->action = ACTION_S_DAMAGE; + i_this->mode = 0; + i_this->unk_timer_4 = DREG_S(6) + 50; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); - if (i_this->field_0x82e != 0) { - a_this->current.angle.y = a_this->shape_angle.y; + if (i_this->snap_angle_y_flag != 0) { + actor->current.angle.y = actor->shape_angle.y; } - i_this->field_0x750 = (a_this->shape_angle.y - 0x8000) - i_this->mAtInfo.mHitDirection.y; + i_this->field_0x750 = (actor->shape_angle.y - 0x8000) - i_this->at_info.mHitDirection.y; i_this->field_0x74c = 150.0f; - i_this->field_0x708 = 25.0f; - i_this->field_0x70c = i_this->mAtInfo.mHitDirection.y; + i_this->field_0x708 = TREG_F(0) + 25.0f; + i_this->field_0x70c = i_this->at_info.mHitDirection.y; } static void damage_check(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); - if (l_HIO.field_0x24 != 0) { - i_this->field_0x744 = 0; + if (l_HIO.no_learn != 0) { + i_this->learn = 0; } - i_this->mStts.Move(); + i_this->stts.Move(); - if (i_this->field_0x6e8 == 0) { - fopEn_enemy_c* dn_p = (fopEn_enemy_c*)i_this; + if (i_this->invulnerability_timer == 0) { + fopEn_enemy_c* enemy = (fopEn_enemy_c*)actor; + dCcU_AtInfo atInfo; if (l_HIO.invulnerable != 0) { - a_this->health = 100; + actor->health = 100; } for (int i = 0; i <= 2; i++) { - if (i_this->field_0xa9c[i].ChkTgHit() != 0) { - i_this->mAtInfo.mpCollider = i_this->field_0xa9c[i].GetTgHitObj(); + if (i_this->cc_sph[i].ChkTgHit() != 0) { + i_this->at_info.mpCollider = i_this->cc_sph[i].GetTgHitObj(); if (player->getCutType() != daPy_py_c::CUT_TYPE_WOLF_B_LEFT && player->getCutType() != daPy_py_c::CUT_TYPE_WOLF_B_RIGHT && - i_this->mAtInfo.mpCollider->ChkAtType(AT_TYPE_WOLF_ATTACK)) { - if (!player->onWolfEnemyHangBite(dn_p)) { - return; + i_this->at_info.mpCollider->ChkAtType(AT_TYPE_WOLF_ATTACK)) { + if (player->onWolfEnemyHangBite(enemy)) { + OS_REPORT("DN PL BITE HANG \n"); + i_this->action = ACTION_WOLFBITE; + i_this->mode = 0; + i_this->invulnerability_timer = 1000; + i_this->sound.startCollisionSE(Z2SE_HIT_WOLFBITE, 31); } - - OS_REPORT("DN PL BITE HANG \n"); - i_this->mAction = ACTION_WOLFBITE; - i_this->mMode = 0; - i_this->field_0x6e8 = 1000; - i_this->mSound.startCollisionSE(Z2SE_HIT_WOLFBITE, 31); return; } - i_this->field_0x10da = 3; - if (i_this->mAtInfo.mpCollider->ChkAtType(AT_TYPE_10000000)) { + i_this->unk_timer_6 = 3; + if (i_this->at_info.mpCollider->ChkAtType(AT_TYPE_10000000)) { wolfkick_damage(i_this); - i_this->field_0x6e8 = 1000; + i_this->invulnerability_timer = 1000; } else { - at_power_check(&i_this->mAtInfo); - s16 sVar1 = a_this->health; - cc_at_check(a_this, &i_this->mAtInfo); + at_power_check(&i_this->at_info); + s16 sVar1 = actor->health; + cc_at_check(actor, &i_this->at_info); if (daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_HEAD_JUMP) { - i_this->mAtInfo.mHitStatus = 0; + i_this->at_info.mHitStatus = 0; } - if (i_this->mAtInfo.mpCollider->ChkAtType(AT_TYPE_UNK)) { - i_this->field_0x6e8 = 20; + if (i_this->at_info.mpCollider->ChkAtType(AT_TYPE_UNK)) { + i_this->invulnerability_timer = 20; } else { - i_this->field_0x6e8 = 10; + i_this->invulnerability_timer = 10; } - if (i_this->mAtInfo.mAttackPower <= 1) { - i_this->field_0x6e8 = 10; + if (i_this->at_info.mAttackPower <= 1) { + i_this->invulnerability_timer = 10; } - i_this->field_0x744 |= i_this->mAtInfo.mHitBit; - if (i_this->mAtInfo.mHitType == 16 || i_this->mAtInfo.mpCollider->ChkAtType(AT_TYPE_HOOKSHOT)) { - a_this->health = sVar1; - i_this->mAction = ACTION_DRAWBACK; - i_this->mMode = 0; + i_this->learn |= i_this->at_info.mHitBit; + if (i_this->at_info.mHitType == 16 || i_this->at_info.mpCollider->ChkAtType(AT_TYPE_HOOKSHOT)) { + actor->health = sVar1; + i_this->action = ACTION_DRAWBACK; + i_this->mode = 0; - if (i_this->field_0x82e != 0) { - a_this->current.angle.y = a_this->shape_angle.y; + if (i_this->snap_angle_y_flag != 0) { + actor->current.angle.y = actor->shape_angle.y; } - i_this->field_0x750 = (a_this->shape_angle.y - 0x8000) - i_this->mAtInfo.mHitDirection.y; - i_this->field_0x74c = 100.0f; - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); - } else { - if (daPy_getPlayerActorClass()->checkHorseRide() != 0 && dComIfGp_getHorseActor()->speedF >= 20.0f && i_this->mAtInfo.mHitType == 1) { - i_this->mAtInfo.mAttackPower = 20; - if (cM_rndF(1.0f) < 0.5f) { - i_this->mAtInfo.mHitBit |= 0x80; - } else { - i_this->mAtInfo.mHitBit |= 0x800; - } - } + i_this->field_0x750 = (actor->shape_angle.y - 0x8000) - i_this->at_info.mHitDirection.y; + i_this->field_0x74c = KREG_F(9) + 100.0f; + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DAMAGE, -1); + break; + } - if (a_this->health <= 0 || i_this->mAtInfo.mHitStatus != 0) { - if (player->getCutType() == daPy_py_c::CUT_TYPE_JUMP && player->checkCutJumpCancelTurn()) { - small_damage(i_this); - i_this->field_0x6e8 = 3; - } else { - big_damage(i_this); - i_this->field_0x6e8 = 1000; - } + if (daPy_getPlayerActorClass()->checkHorseRide() != 0 && dComIfGp_getHorseActor()->speedF >= 20.0f && i_this->at_info.mHitType == 1) { + i_this->at_info.mAttackPower = 20; + if (cM_rndF(1.0f) < 0.5f) { + i_this->at_info.mHitBit |= 0x80; } else { - small_damage(i_this); + i_this->at_info.mHitBit |= 0x800; } - - a_this->speedF = 0.0f; } + + if (actor->health <= 0 || i_this->at_info.mHitStatus != 0) { + if (player->getCutType() == daPy_py_c::CUT_TYPE_JUMP && player->checkCutJumpCancelTurn()) { + small_damage(i_this); + i_this->invulnerability_timer = 3; + } else { + big_damage(i_this); + i_this->invulnerability_timer = 1000; + } + } else { + small_damage(i_this); + } + + actor->speedF = 0.0f; } break; } } - for (int i = 0; i < 3; i++) { - if (a_this->health <= 1) { - i_this->field_0xa9c[i].SetTgHitMark((CcG_Tg_HitMark)3); + for (int i = 0; i <= 2; i++) { + if (actor->health <= 1) { + i_this->cc_sph[i].SetTgHitMark((CcG_Tg_HitMark)3); } } } } static void action(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); - cXyz sp240, sp24c; + cXyz work, sp24c; i_this->field_0x6f4 = 0; - f32 fVar1 = fopAcM_searchPlayerDistanceXZ(a_this); - i_this->mPlayerDistance = fVar1; - s16 sVar1 = fopAcM_searchPlayerAngleY(a_this); - i_this->mYAngleToPlayer = sVar1; - sVar1 = fopAcM_searchPlayerAngleX(a_this); - i_this->mXAngleToPlayer = sVar1; + i_this->pl_dir = fopAcM_searchPlayerDistanceXZ(actor); + i_this->search_angle_y = fopAcM_searchPlayerAngleY(actor); + i_this->search_angle_x = fopAcM_searchPlayerAngleX(actor); damage_check(i_this); - i_this->field_0x82e = 0; + i_this->snap_angle_y_flag = 0; - s8 bVar1 = 0; + s8 pl_search = 0; s8 bVar2 = 1; - a_this->offHeadLockFlg(); - if (fopAcM_otherBgCheck(player, a_this)) { - fopAcM_OffStatus(a_this, 0); - a_this->attention_info.flags = 0; + actor->offHeadLockFlg(); + if (fopAcM_otherBgCheck(player, actor)) { + fopAcM_OffStatus(actor, 0); + actor->attention_info.flags = 0; } else { - fopAcM_OnStatus(a_this, 0); - a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + fopAcM_OnStatus(actor, 0); + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; } - switch (i_this->mAction) { + switch (i_this->action) { case ACTION_NORMAL: e_dn_normal(i_this); break; case ACTION_FIGHT_RUN: e_dn_fight_run(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_ATTACK_0: e_dn_attack_0(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_ATTACK: e_dn_attack(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_TAIL_ATTACK: e_dn_tail_attack(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_GUARD: e_dn_guard(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_JUMP: e_dn_jump(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_STAY: @@ -2400,7 +2479,7 @@ static void action(e_dn_class* i_this) { case ACTION_DRAWBACK: e_dn_drawback(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_WOLFBITE: @@ -2430,7 +2509,7 @@ static void action(e_dn_class* i_this) { case ACTION_GAKEJUMP: e_dn_gakejump(i_this); - bVar1 = 1; + pl_search = 1; break; case ACTION_REG: @@ -2438,146 +2517,148 @@ static void action(e_dn_class* i_this) { break; } - f32 fVar6 = 0.0f; if (bVar2) { dBgS_ObjGndChk obj_gnd_chk; dBgS_ObjGndChk_Spl spl_chk; - sp240 = a_this->current.pos; - sp240.y += 150.0f; - spl_chk.SetPos(&sp240); - obj_gnd_chk.SetPos(&sp240); + work = actor->current.pos; + work.y += 150.0f; + spl_chk.SetPos(&work); + obj_gnd_chk.SetPos(&work); i_this->field_0xa5c = dComIfG_Bgsp().GroundCross(&spl_chk); - fVar1 = i_this->field_0xa5c - dComIfG_Bgsp().GroundCross(&obj_gnd_chk); - if (a_this->current.pos.y < i_this->field_0xa5c && fVar1 > 100.0f) { + f32 fVar1 = i_this->field_0xa5c - dComIfG_Bgsp().GroundCross(&obj_gnd_chk); + if (actor->current.pos.y < i_this->field_0xa5c && fVar1 > 100.0f) { OS_REPORT("DN YOGAN \n"); - i_this->mAction = ACTION_WATER; + i_this->action = ACTION_WATER; if (dComIfG_Bgsp().GetPolyAtt0(spl_chk) == 6) { - i_this->mMode = 1; + i_this->mode = 1; } else { - i_this->mMode = 0; + i_this->mode = 0; } - a_this->current.pos.y = i_this->field_0xa5c; + actor->current.pos.y = i_this->field_0xa5c; } } - if (bVar1) { - i_this->mSound.setLinkSearch(true); + if (pl_search) { + i_this->sound.setLinkSearch(true); } else { - i_this->mSound.setLinkSearch(false); + i_this->sound.setLinkSearch(false); } - if (i_this->field_0x82e == 0) { - cLib_addCalcAngleS2(&a_this->shape_angle.y, a_this->current.angle.y, 2, 0x2000); + if (i_this->snap_angle_y_flag == 0) { + cLib_addCalcAngleS2(&actor->shape_angle.y, actor->current.angle.y, 2, 0x2000); } - cLib_addCalcAngleS2(&a_this->shape_angle.x, a_this->current.angle.x, 2, 0x2000); - cLib_addCalcAngleS2(&a_this->shape_angle.z, a_this->current.angle.z, 2, 0x2000); + cLib_addCalcAngleS2(&actor->shape_angle.x, actor->current.angle.x, 2, 0x2000); + cLib_addCalcAngleS2(&actor->shape_angle.z, actor->current.angle.z, 2, 0x2000); if (i_this->field_0x5d8 != 0) { - cMtx_YrotS(*calc_mtx, i_this->field_0x5d4); + cMtx_YrotS(*calc_mtx, i_this->cur_angle_y_target); cMtx_XrotM(*calc_mtx, i_this->field_0x5d6); - sp240.x = 0.0f; - sp240.y = 0.0f; - sp240.z = a_this->speedF; - MtxPosition(&sp240, &sp24c); - a_this->current.pos += sp24c; - sp240 = i_this->field_0x5bc - i_this->field_0x5c8; - fVar1 = sp240.abs(); - sp240 = i_this->field_0x5bc - a_this->current.pos; - f32 fVar2 = sp240.abs(); - f32 fVar3 = fVar1 * 0.3f; - if (fVar3 > 250.0f) { - fVar3 = 250.0f; + work.x = 0.0f; + work.y = 0.0f; + work.z = actor->speedF; + MtxPosition(&work, &sp24c); + actor->current.pos += sp24c; + work = i_this->field_0x5bc - i_this->field_0x5c8; + f32 fVar1 = work.abs(); + work = i_this->field_0x5bc - actor->current.pos; + f32 fVar2 = work.abs(); + f32 fVar3 = fVar1 * (NREG_F(19) + 0.3f); + if (fVar3 > NREG_F(18) + 250.0f) { + fVar3 = NREG_F(18) + 250.0f; } - i_this->field_0x720 = fVar3 * cM_ssin((fVar2 / fVar1) * 32768.0f); + i_this->cur_pos_y_offset = fVar3 * cM_ssin((fVar2 / fVar1) * 32768.0f); i_this->field_0x5d8 = 0; } else { - cLib_addCalc0(&i_this->field_0x720, 1.0f, 30.0f); + cLib_addCalc0(&i_this->cur_pos_y_offset, 1.0f, 30.0f); - if (i_this->field_0x704 != fVar6) { + if (i_this->field_0x704) { cMtx_YrotS(*calc_mtx, i_this->field_0x724.y); - if (i_this->field_0x840 == 0) { - sp240.z = i_this->field_0x704; + if (i_this->unk_timer_5 == 0) { + work.z = i_this->field_0x704; } else { - sp240.z = 0.0f; - a_this->speed.y = 0.0f; + work.z = 0.0f; + actor->speed.y = 0.0f; } - a_this->gravity = -4.0f; + actor->gravity = -4.0f; } else { - cMtx_YrotS(*calc_mtx, a_this->current.angle.y); - sp240.z = a_this->speedF; + cMtx_YrotS(*calc_mtx, actor->current.angle.y); + work.z = actor->speedF; } - sp240.x = 0.0f; - sp240.y = 0.0f; - MtxPosition(&sp240, &sp24c); + work.x = 0.0f; + work.y = 0.0f; + MtxPosition(&work, &sp24c); - a_this->speed.x = sp24c.x; - a_this->speed.z = sp24c.z; - a_this->speed.y += a_this->gravity; - a_this->current.pos += a_this->speed; - a_this->gravity = -5.0f; + actor->speed.x = sp24c.x; + actor->speed.z = sp24c.z; + actor->speed.y += actor->gravity; + actor->current.pos += actor->speed; + actor->gravity = -5.0f; - if (a_this->speed.y < -100.0f) { - a_this->speed.y = -100.0f; + if (actor->speed.y < -100.0f) { + actor->speed.y = -100.0f; } - if (i_this->mAction != 9 && i_this->field_0x6f2 != 0) { - cXyz* move_pos = i_this->mStts.GetCCMoveP(); + if (i_this->action != ACTION_STAY && i_this->field_0x6f2 != 0) { + cXyz* move_pos = i_this->stts.GetCCMoveP(); if (move_pos != NULL) { - a_this->current.pos.x += move_pos->x; - a_this->current.pos.z += move_pos->z; + actor->current.pos.x += move_pos->x; + actor->current.pos.z += move_pos->z; } } if (i_this->field_0x708 > 0.1f) { - sp240.x = 0.0f; - sp240.y = 0.0f; - sp240.z = -i_this->field_0x708; + work.x = 0.0f; + work.y = 0.0f; + work.z = -i_this->field_0x708; cMtx_YrotS(*calc_mtx, i_this->field_0x70c); - MtxPosition(&sp240, &sp24c); - a_this->current.pos += sp24c; - cLib_addCalc0(&i_this->field_0x708, 1.0f, 7.0f); + MtxPosition(&work, &sp24c); + actor->current.pos += sp24c; + cLib_addCalc0(&i_this->field_0x708, 1.0f, TREG_F(12) + 7.0f); } } - sVar1 = 0x800; + s16 max_step, sVar2, sVar3; + sVar2 = 0; + sVar3 = 0; + max_step = 0x800; if (i_this->field_0x700 != 0) { i_this->field_0x700--; i_this->field_0x6f4 = 2; - cMtx_YrotS(*calc_mtx, a_this->shape_angle.y); + cMtx_YrotS(*calc_mtx, actor->shape_angle.y); if (i_this->field_0x701 != 0) { - sp240.x = 100.0f; + work.x = 100.0f; } else { - sp240.x = -100.0f; + work.x = -100.0f; } - sp240.y = 100.0f; - sp240.z = -100.0f; - MtxPosition(&sp240, &i_this->field_0x738); - i_this->field_0x738 += a_this->current.pos; - sVar1 = 0x400; + work.y = JREG_F(4) + 100.0f; + work.z = -100.0f; + MtxPosition(&work, &i_this->find_pos); + i_this->find_pos += actor->current.pos; + max_step = 0x400; } if (i_this->field_0x6f4 != 0) { if (i_this->field_0x6f4 == 5) { - if ((i_this->field_0x6cc & 15) == 0 && cM_rndF(1.0f) < 0.3f) { + if ((i_this->frame_counter & 15) == 0 && cM_rndF(1.0f) < 0.3f) { // Every 16 frames i_this->field_0x6fc = cM_rndFX(2500.0f); } } else { if (i_this->field_0x6f4 == 1) { - sp240 = player->eyePos - a_this->current.pos; + work = player->eyePos - actor->current.pos; } else if (i_this->field_0x6f4 == 2) { - sp240 = i_this->field_0x738 - a_this->current.pos; + work = i_this->find_pos - actor->current.pos; } else { - sp240 = player->eyePos - a_this->current.pos; + work = player->eyePos - actor->current.pos; } - sp240.y += l_HIO.model_size * -150.0f; + work.y += -(TREG_F(2) + 150.0f) * l_HIO.model_size; - s16 sVar2 = cM_atan2s(sp240.x, sp240.z) - a_this->shape_angle.y; - s16 sVar3 = a_this->shape_angle.x + cM_atan2s(sp240.y, JMAFastSqrt(sp240.x * sp240.x + sp240.z * sp240.z)); + sVar2 = cM_atan2s(work.x, work.z) - actor->shape_angle.y; + sVar3 = actor->shape_angle.x + cM_atan2s(work.y, JMAFastSqrt(work.x * work.x + work.z * work.z)); if (sVar2 > 0x2710) { sVar2 = 10000; } else if (sVar2 < -10000) { @@ -2590,14 +2671,14 @@ static void action(e_dn_class* i_this) { sVar3 = -20000; } - cLib_addCalcAngleS2(&i_this->field_0x6f6, sVar2 / 2, 2, sVar1); - cLib_addCalcAngleS2(&i_this->field_0x6f8, sVar3 / 2, 2, sVar1); + cLib_addCalcAngleS2(&i_this->field_0x6f6, sVar2 / 2, 2, max_step); + cLib_addCalcAngleS2(&i_this->field_0x6f8, sVar3 / 2, 2, max_step); } i_this->field_0x6fc = 0; } else { - cLib_addCalcAngleS2(&i_this->field_0x6f6, 0, 2, sVar1); - cLib_addCalcAngleS2(&i_this->field_0x6f8, 0, 2, sVar1); + cLib_addCalcAngleS2(&i_this->field_0x6f6, 0, 2, max_step); + cLib_addCalcAngleS2(&i_this->field_0x6f8, 0, 2, max_step); i_this->field_0x6fc = 0; } @@ -2605,87 +2686,87 @@ static void action(e_dn_class* i_this) { if (i_this->field_0x6fe != 0) { i_this->field_0x6fe--; - i_this->field_0x6fa = i_this->field_0x6fe * cM_ssin(i_this->field_0x6fe * 12000) * 200.0f; + i_this->field_0x6fa = i_this->field_0x6fe * cM_ssin(i_this->field_0x6fe * (BREG_S(5) + 12000)) * (BREG_F(18) + 200.0f); } if (i_this->field_0x74c > 1.0f) { cMtx_YrotS(*calc_mtx, i_this->field_0x750); - sp240.x = 0.0f; - sp240.y = 0.0f; - sp240.z = i_this->field_0x74c * 120.0f; - if (sp240.z > 15000.0f) { - sp240.z = 15000.0f; + work.x = 0.0f; + work.y = 0.0f; + work.z = (TREG_F(7) + 120.0f) * i_this->field_0x74c; + if (work.z > 15000.0f) { + work.z = 15000.0f; } - MtxPosition(&sp240, &sp24c); + MtxPosition(&work, &sp24c); i_this->field_0x7a4[0].y = sp24c.x; i_this->field_0x7a4[0].x = sp24c.z; i_this->field_0x7a4[1].y = sp24c.x; i_this->field_0x7a4[1].x = sp24c.z; - cLib_addCalc0(&i_this->field_0x74c, 0.5f, 10.0f); + cLib_addCalc0(&i_this->field_0x74c, 0.5f, TREG_F(7) + 10.0f); } if (fabsf(i_this->field_0x75c) > 1.0f) { - i_this->field_0x7a4[1].x = i_this->field_0x75c * cM_scos(i_this->field_0x760) * 70.0f; + i_this->field_0x7a4[1].x = i_this->field_0x75c * cM_scos(i_this->field_0x760) * (BREG_F(0) + 70.0f); i_this->field_0x7a4[2].x += i_this->field_0x7a4[1].x; - cLib_addCalc0(&i_this->field_0x75c, 1.0f, 3.0f); - i_this->field_0x760 += 4000; + cLib_addCalc0(&i_this->field_0x75c, 1.0f, BREG_F(1) + 3.0f); + i_this->field_0x760 += BREG_S(0) + 4000; } if (fabsf(i_this->field_0x754) > 1.0f) { - i_this->field_0x7a4[0].x = i_this->field_0x754 * cM_scos(i_this->field_0x758) * 70.0f; - cLib_addCalc0(&i_this->field_0x754, 1.0f, 3.0f); - i_this->field_0x758 += 4000; + i_this->field_0x7a4[0].x = i_this->field_0x754 * cM_scos(i_this->field_0x758) * (BREG_F(2) + 70.0f); + cLib_addCalc0(&i_this->field_0x754, 1.0f, BREG_F(3) + 3.0f); + i_this->field_0x758 += BREG_S(1) + 4000; } - if (a_this->speed.y < 0.0f && i_this->mObjAcch.ChkGroundHit()) { + if (actor->speed.y < 0.0f && i_this->objacch.ChkGroundHit()) { cLib_addCalc0(&i_this->field_0x75c, 1.0f, 30.0f); cLib_addCalc0(&i_this->field_0x754, 1.0f, 30.0f); } - if (i_this->field_0x704 != fVar6) { - s16 sVar4 = i_this->field_0x724.y - a_this->shape_angle.y; - i_this->field_0x7a4[3].y = 0x4000 - sVar4; - if (i_this->field_0x7a4[3].y > 0x1770) { + if (i_this->field_0x704) { + s16 sVar4 = i_this->field_0x724.y - actor->shape_angle.y; + i_this->field_0x7a4[3].y = 0x4000 + -sVar4; + if (i_this->field_0x7a4[3].y > 6000) { // ~33° i_this->field_0x7a4[3].y = 6000; - } else if (i_this->field_0x7a4[3].y < -9000) { + } else if (i_this->field_0x7a4[3].y < -9000) { // ~49.4° i_this->field_0x7a4[3].y = -9000; } - i_this->field_0x7a4[4].y = 0x4000 - sVar4; - if (i_this->field_0x7a4[4].y > 0x4268) { + i_this->field_0x7a4[4].y = 0x4000 + -sVar4; + if (i_this->field_0x7a4[4].y > 17000) { // ~93.4° i_this->field_0x7a4[4].y = 17000; } else if (i_this->field_0x7a4[4].y < 0) { i_this->field_0x7a4[4].y = 0; } i_this->field_0x7a4[5].y = sVar4 + 0x4000; - if (i_this->field_0x7a4[5].y > 0x1770) { + if (i_this->field_0x7a4[5].y > 6000) { i_this->field_0x7a4[5].y = 6000; } else if (i_this->field_0x7a4[5].y < -9000) { i_this->field_0x7a4[5].y = -9000; } i_this->field_0x7a4[6].y = sVar4 + 0x4000; - if (i_this->field_0x7a4[6].y > 0x4268) { + if (i_this->field_0x7a4[6].y > 17000) { i_this->field_0x7a4[6].y = 17000; } else if (i_this->field_0x7a4[6].y < 0) { i_this->field_0x7a4[6].y = 0; } cMtx_YrotS(*calc_mtx, sVar4); - sp240.x = 0.0f; - sp240.y = 0.0f; - sp240.z = 12000.0f; - MtxPosition(&sp240, &sp24c); + work.x = 0.0f; + work.y = 0.0f; + work.z = BREG_F(8) + 12000.0f; + MtxPosition(&work, &sp24c); i_this->field_0x836.y = -sp24c.x; i_this->field_0x836.x = -sp24c.z * 1.3f; - if (i_this->field_0x836.x > 10000) { - i_this->field_0x836.x = 10000; + if (i_this->field_0x836.x > (s16)(BREG_S(6) + 10000)) { + i_this->field_0x836.x = BREG_S(6) + 10000; } - i_this->field_0x836.x += 6000; + i_this->field_0x836.x += BREG_S(7) + 6000; } static s16 j_spd[11] = { @@ -2699,66 +2780,64 @@ static void action(e_dn_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0x762[i].x, i_this->field_0x7a4[i].x, 2, j_spd[i]); cLib_addCalcAngleS2(&i_this->field_0x762[i].y, i_this->field_0x7a4[i].y, 2, j_spd[i]); cLib_addCalcAngleS2(&i_this->field_0x762[i].z, i_this->field_0x7a4[i].z, 2, j_spd[i]); - i_this->field_0x7a4[i].z = 0; - i_this->field_0x7a4[i].x = 0; + i_this->field_0x7a4[i].x = i_this->field_0x7a4[i].z = 0; if (i >= 3 && i <= 6) { - if (i_this->field_0x7fc[i] == 0) { - s16 sVar5; + if (i_this->field_0x802[i - 3] == 0) { + s16 max_step; if (i == 4 || i == 6) { - sVar5 = 0x600; + max_step = 0x600; // ~8.4° } else { - sVar5 = 0x800; + max_step = 0x800; // 11.25° } - cLib_addCalcAngleS2(&i_this->field_0x7a4[i].y, 0, 1, sVar5); + cLib_addCalcAngleS2(&i_this->field_0x7a4[i].y, 0, 1, max_step); } else { - i_this->field_0x7fc[i]--; + i_this->field_0x802[i - 3]--; } } else { i_this->field_0x7a4[i].y = 0; } if (i >= 3) { - i_this->field_0x7ec[i] = i_this->field_0x7e8 * cM_scos(i_this->field_0x6cc * 4000 + i * 20000); + i_this->field_0x7ec[i] = i_this->field_0x7e8 * cM_scos(i_this->frame_counter * (BREG_S(0) + 4000) + i * (BREG_S(1) + 20000)); } } - cLib_addCalc0(&i_this->field_0x7e8, 1.0f, 100.0f); - cLib_addCalcAngleS2(&i_this->field_0x832, i_this->field_0x836.y, 2, 0x800); - cLib_addCalcAngleS2(&i_this->field_0x830, i_this->field_0x836.x, 2, 0x800); - i_this->field_0x836.x = 0; - i_this->field_0x836.y = 0; - if (i_this->field_0x828 != 0) { - i_this->field_0x828--; + cLib_addCalc0(&i_this->field_0x7e8, 1.0f, BREG_F(11) + 100.0f); + cLib_addCalcAngleS2(&i_this->field_0x830.y, i_this->field_0x836.y, 2, 0x800); + cLib_addCalcAngleS2(&i_this->field_0x830.x, i_this->field_0x836.x, 2, 0x800); + i_this->field_0x836.y = i_this->field_0x836.x = 0; + if (i_this->unk_timer_4 != 0) { + i_this->unk_timer_4--; } - fVar1 = i_this->field_0x828 * 1.0f; + f32 fVar1 = i_this->unk_timer_4 * (DREG_F(13) + 1.0f); if (fVar1 > 30.0f) { fVar1 = 30.0f; } fVar1 *= fVar1; for (int i = 0; i < 4; i++) { - i_this->field_0x80e[i].x = fVar1 * (cM_ssin(i_this->field_0x6cc * 5000 + i * -15000) * 5.0f); - i_this->field_0x80e[i].y = fVar1 * (cM_ssin(i_this->field_0x6cc * 0x12C0 + i * -13000) * 5.0f); + i_this->field_0x80e[i].x = fVar1 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 5000) + i * (DREG_S(7) + -15000)) * (DREG_F(18) + 5.0f)); + i_this->field_0x80e[i].y = fVar1 * (cM_ssin(i_this->frame_counter * (DREG_S(5) + 0x12C0) + i * (DREG_S(7) + -13000)) * (DREG_F(18) + 5.0f)); } - J3DModel* model; - cLib_addCalcAngleS2(&i_this->field_0x826, 0, 4, 0x100); - if (i_this->field_0x736 != 0) { - i_this->field_0x736--; + cLib_addCalcAngleS2(&i_this->jnt_tail_y_rot_offset, 0, 4, 0x100); + if (i_this->unk_timer_3 != 0) { + i_this->unk_timer_3--; if (i_this->field_0x724.x != 0) { Vec sp258; cXyz sp264, sp270; dBgS_GndChk gnd_chk; - int sVar6 = 0; - s16 sVar7 = 0; + s16 sVar6, sVar7; + sVar6 = 0; + sVar7 = 0; fVar1 = 100.0f; - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), *calc_mtx); - sp240.set(0.0f, 0.0f, 0.0f); - MtxPosition(&sp240, &sp264); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), *calc_mtx); + work.set(0.0f, 0.0f, 0.0f); + MtxPosition(&work, &sp264); sp264.y += 100.0f; sp264.y += 100.0f; gnd_chk.SetPos(&sp264); @@ -2772,7 +2851,10 @@ static void action(e_dn_class* i_this) { sp258.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (sp258.y != -G_CM3D_F_INF) { - sVar7 = -cM_atan2s(sp258.y - sp264.y, sp258.z - sp264.z); + f32 z, y; + y = sp258.y - sp264.y; + z = sp258.z - sp264.z; + sVar7 = -cM_atan2s(y, z); if (sVar7 > 0x3000 || sVar7 < -0x3000) { sVar7 = 0; } @@ -2784,7 +2866,10 @@ static void action(e_dn_class* i_this) { gnd_chk.SetPos(&sp258); sp258.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (sp258.y != -G_CM3D_F_INF) { - sVar6 = cM_atan2s(sp258.y - sp264.y, sp258.x - sp264.x); + f32 x, y; + y = sp258.y - sp264.y; + x = sp258.x - sp264.x; + sVar6 = (s16)cM_atan2s(y, x); if (sVar6 > 0x3000 || sVar6 < -0x3000) { sVar6 = 0; } @@ -2792,25 +2877,25 @@ static void action(e_dn_class* i_this) { } dBgS_LinChk lin_chk; - cXyz sp27c, sp288, sp294; + cXyz work, start, end; - sp288 = a_this->current.pos; - sp288.y += 30.0f; - model = i_this->mpModelMorf->getModel(); - sp27c.set(0.0f, 0.0f, 0.0f); - MTXCopy(model->getAnmMtx(4), *calc_mtx); - MtxPosition(&sp27c, &sp294); - sp294.y += 30.0f; - lin_chk.Set(&sp288, &sp294, a_this); + start = actor->current.pos; + start.y += JREG_F(5) + 30.0f; + J3DModel* model = i_this->anm_p->getModel(); + work.set(0.0f, 0.0f, 0.0f); + MTXCopy(model->getAnmMtx((int)BREG_S(8) + JNT_NECK02), *calc_mtx); + MtxPosition(&work, &end); + end.y += JREG_F(6) + 30.0f; + lin_chk.Set(&start, &end, actor); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - sp27c = sp288 - sp294; - cMtx_YrotS(*calc_mtx, cM_atan2s(sp27c.x, sp27c.z)); - sp27c.x = 0.0f; - sp27c.y = 0.0f; - sp27c.z = 50.0f; - MtxPosition(&sp27c, &sp24c); - a_this->current.pos += sp24c; + work = start - end; + cMtx_YrotS(*calc_mtx, cM_atan2s(work.x, work.z)); + work.x = 0.0f; + work.y = 0.0f; + work.z = TREG_F(11) + 50.0f; + MtxPosition(&work, &sp24c); + actor->current.pos += sp24c; } i_this->field_0x730.x = sVar7; @@ -2821,82 +2906,83 @@ static void action(e_dn_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0x72a.x, i_this->field_0x730.x, 1, 0x400); cLib_addCalcAngleS2(&i_this->field_0x72a.z, i_this->field_0x730.z, 1, 0x400); - if (i_this->field_0x10e4 != 0) { - model = i_this->mpModelMorf->getModel(); - sp240.set(0.0f, 0.0f, 0.0f); + if (i_this->set_smoke_flag != 0) { + J3DModel* model = i_this->anm_p->getModel(); + work.set(0.0f, 0.0f, 0.0f); static int foot_idx[2] = { - 26, 30, + JNT_FOOTL, JNT_FOOTR, }; for (int i = 0; i < 2; i++) { - if ((i_this->field_0x10e4 == 3 || (i_this->field_0x10e4 == 2 && i == 1)) || (i_this->field_0x10e4 == 1 && i == 0)) { + if (i_this->set_smoke_flag == 3 || (i_this->set_smoke_flag == 2 && i == 1) || (i_this->set_smoke_flag == 1 && i == 0)) { MTXCopy(model->getAnmMtx(foot_idx[i]), *calc_mtx); - MtxPosition(&sp240, &sp24c); - fopAcM_effSmokeSet1(&i_this->field_0x10e8[i], &i_this->field_0x10f0[i], &sp24c, &a_this->shape_angle, 1.0f, &a_this->tevStr, 0); + MtxPosition(&work, &sp24c); + fopAcM_effSmokeSet2(&i_this->field_0x10e8[i], &i_this->field_0x10f0[i], &sp24c, &actor->shape_angle, + TREG_F(8) + 1.0f, &actor->tevStr); } } - i_this->field_0x10e4 = 0; + i_this->set_smoke_flag = 0; } - if (i_this->field_0x10da != 0) { - i_this->field_0x10da--; - if (i_this->field_0x10da == 0) { - dComIfGp_particle_set(0x15E, &a_this->eyePos, &a_this->shape_angle, NULL); + if (i_this->unk_timer_6 != 0) { + i_this->unk_timer_6--; + if (i_this->unk_timer_6 == 0) { + dComIfGp_particle_set(ID_ZI_J_TUBA00, &actor->eyePos, &actor->shape_angle, NULL); } } cXyz sp2a4(1.3f, 1.3f, 1.3f); - setMidnaBindEffect(a_this, &i_this->mSound, &a_this->eyePos, &sp2a4); + setMidnaBindEffect(actor, &i_this->sound, &actor->eyePos, &sp2a4); } static void anm_se_set(e_dn_class* i_this) { - int frame = i_this->mpModelMorf->getFrame(); + int frame = i_this->anm_p->getFrame(); - if (i_this->mAnmID == ANM_ATTACK_01) { + if (i_this->anm_no == ANM_ATTACK_01) { if (frame == 35) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_TAIL, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_TAIL, 0, -1); } else if (frame == 28) { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_TAIL, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_TAIL, -1); } - } else if (i_this->mAnmID == ANM_ATTACK_TAIL_01) { + } else if (i_this->anm_no == ANM_ATTACK_TAIL_01) { if (frame == 18) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_KNIFE, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_KNIFE, 0, -1); } - } else if (i_this->mAnmID == ANM_ATTACK_TAIL_02) { + } else if (i_this->anm_no == ANM_ATTACK_TAIL_02) { if (frame == 10) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_KNIFE2_A, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_KNIFE2_A, 0, -1); } if (frame == 24) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_KNIFE2_B, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_KNIFE2_B, 0, -1); } - } else if (i_this->mAnmID == ANM_WALK) { + } else if (i_this->anm_no == ANM_WALK) { if (frame == 3) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_L, 0, -1); } else if (frame == 18) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_R, 0, -1); } - } else if (i_this->mAnmID == ANM_RUN) { + } else if (i_this->anm_no == ANM_RUN) { if (frame == 10) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_L, 0, -1); } else if (frame == 4) { - i_this->mSound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_BREATH, -1); + i_this->sound.startCreatureSound(Z2SE_EN_DN_FN_RUN_R, 0, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_BREATH, -1); } - } else if (i_this->mAnmID == ANM_WAIT_03) { + } else if (i_this->anm_no == ANM_WAIT_03) { if (frame == 15) { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_SEARCH, -1); + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_SEARCH, -1); } - } else if (i_this->mAnmID == ANM_WAIT_04 && frame == 15) { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_SEARCH2, -1); + } else if (i_this->anm_no == ANM_WAIT_04 && frame == 15) { + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_SEARCH2, -1); } } int c_start; static int daE_DN_Execute(e_dn_class* i_this) { - if (i_this->field_0x10d8 != 0) { + if (i_this->status != 0) { return 1; } @@ -2905,286 +2991,287 @@ static int daE_DN_Execute(e_dn_class* i_this) { return 1; } - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp2c; - cXyz sp38; - cXyz sp44; - i_this->field_0x6cc++; + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + cXyz work; + cXyz pos; + cXyz downPos; + i_this->frame_counter++; for (int i = 0; i < 4; i++) { - if (i_this->field_0x6e0[i] != 0) { - i_this->field_0x6e0[i]--; + if (i_this->timer[i] != 0) { + i_this->timer[i]--; } } - if (i_this->field_0x6e8 != 0) { - i_this->field_0x6e8--; + if (i_this->invulnerability_timer != 0) { + i_this->invulnerability_timer--; } - if (i_this->field_0x6ec != 0) { - i_this->field_0x6ec--; + if (i_this->unk_timer_2 != 0) { + i_this->unk_timer_2--; } - if (i_this->field_0x840 != 0) { - i_this->field_0x840--; + if (i_this->unk_timer_5 != 0) { + i_this->unk_timer_5--; } - if (i_this->field_0x6ea != 0) { - i_this->field_0x6ea--; + if (i_this->unk_timer_1 != 0) { + i_this->unk_timer_1--; } i_this->field_0x6f2 = 1; action(i_this); - if (i_this->field_0x840 == 0 && i_this->field_0x5d8 == 0) { + if (i_this->unk_timer_5 == 0 && i_this->field_0x5d8 == 0) { if (i_this->field_0x704) { cMtx_YrotS(*calc_mtx, i_this->field_0x724.y); - sp2c.x = 0.0f; - sp2c.y = TREG_F(8); - sp2c.z = i_this->field_0x83c; - MtxPosition(&sp2c, &sp38); - a_this->current.pos += sp38; - a_this->old.pos += sp38; + work.x = 0.0f; + work.y = TREG_F(8); + work.z = i_this->field_0x83c; + MtxPosition(&work, &pos); + actor->current.pos += pos; + actor->old.pos += pos; cLib_addCalc2(&i_this->field_0x83c, i_this->field_0x704 * (2.0f + TREG_F(9)), 1.0f, 5.0f + TREG_F(17)); } else { cLib_addCalc0(&i_this->field_0x83c, 1.0f, 5.0f + TREG_F(17)); } - i_this->mObjAcch.CrrPos(dComIfG_Bgsp()); + i_this->objacch.CrrPos(dComIfG_Bgsp()); if (i_this->field_0x704) { - a_this->current.pos -= sp38; - a_this->old.pos -= sp38; + actor->current.pos -= pos; + actor->old.pos -= pos; } - if (!i_this->mObjAcch.ChkGroundHit()) { - if (a_this->speed.y < -10.0f) { - i_this->field_0x842++; - if (i_this->field_0x842 == 13) { - i_this->mSound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); + if (!i_this->objacch.ChkGroundHit()) { + if (actor->speed.y < -10.0f) { + i_this->unk_counter_2++; + if (i_this->unk_counter_2 == 13) { + i_this->sound.startCreatureVoice(Z2SE_EN_DN_V_DEATH, -1); } } } else { - if (i_this->field_0x842 >= 13 + ZREG_S(8)) { - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; - a_this->speed.y = 0.0f; + if (i_this->unk_counter_2 >= 13 + ZREG_S(8)) { + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; + actor->speed.y = 0.0f; i_this->field_0x704 = -1.0; i_this->field_0x724.x = -0x3000; - i_this->field_0x828 = 50 + DREG_S(2); - i_this->field_0x6e8 = 1000; - a_this->health = 0; + i_this->unk_timer_4 = 50 + DREG_S(2); + i_this->invulnerability_timer = 1000; + actor->health = 0; } - i_this->field_0x842 = 0; + i_this->unk_counter_2 = 0; } } - mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y + i_this->field_0x720, a_this->current.pos.z); + mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y + i_this->cur_pos_y_offset, actor->current.pos.z); mDoMtx_stack_c::XrotM((s16) i_this->field_0x72a.x); mDoMtx_stack_c::ZrotM((s16) i_this->field_0x72a.z); mDoMtx_stack_c::YrotM((s16) i_this->field_0x724.y); mDoMtx_stack_c::XrotM((s16) i_this->field_0x724.x); mDoMtx_stack_c::YrotM(-i_this->field_0x724.y); - mDoMtx_stack_c::YrotM((s16) a_this->shape_angle.y); - mDoMtx_stack_c::XrotM((s16) a_this->shape_angle.x); - mDoMtx_stack_c::ZrotM(a_this->shape_angle.z); - mDoMtx_stack_c::scaleM(l_HIO.model_size * a_this->scale.x, l_HIO.model_size * a_this->scale.x, l_HIO.model_size * a_this->scale.x); + mDoMtx_stack_c::YrotM((s16) actor->shape_angle.y); + mDoMtx_stack_c::XrotM((s16) actor->shape_angle.x); + mDoMtx_stack_c::ZrotM(actor->shape_angle.z); + mDoMtx_stack_c::scaleM(l_HIO.model_size * actor->scale.x, l_HIO.model_size * actor->scale.x, l_HIO.model_size * actor->scale.x); - J3DModel* model = i_this->mpModelMorf->getModel(); + J3DModel* model = i_this->anm_p->getModel(); model->setBaseTRMtx(mDoMtx_stack_c::get()); - i_this->mpModelMorf->play(0, 0); + i_this->anm_p->play(0, 0); anm_se_set(i_this); - i_this->mpModelMorf->modelCalc(); - MTXCopy(model->getAnmMtx(2), *calc_mtx); + i_this->anm_p->modelCalc(); + MTXCopy(model->getAnmMtx(JNT_BACKBONE02), *calc_mtx); - sp2c.set(0.0f, 0.0f, 0.0f); - MtxPosition(&sp2c, &sp38); - sp2c.set(YREG_F(1), YREG_F(2), -200.0f + YREG_F(3)); - MtxPosition(&sp2c, &sp44); - if (sp38.y < sp44.y) { - i_this->field_0x737 = 0; + work.set(0.0f, 0.0f, 0.0f); + MtxPosition(&work, &pos); + work.set(YREG_F(1), YREG_F(2), -200.0f + YREG_F(3)); + MtxPosition(&work, &downPos); + if (pos.y < downPos.y) { + i_this->left_right_flag = 0; } else { - i_this->field_0x737 = 1; + i_this->left_right_flag = 1; } cXyz sp50(0.0f, 0.0f, 0.0f); - if (i_this->field_0x6e8 != 0) { + if (i_this->invulnerability_timer != 0) { sp50.set(-20000.0f, 200000.0f, 30000.0f); } - MTXCopy(model->getAnmMtx(6), *calc_mtx); - sp2c.set(30.0f + KREG_F(12), 30.0f + KREG_F(13), 0.0f + KREG_F(14)); - MtxPosition(&sp2c, &a_this->eyePos); + MTXCopy(model->getAnmMtx(JNT_HEAD), *calc_mtx); + work.set(30.0f + KREG_F(12), 30.0f + KREG_F(13), 0.0f + KREG_F(14)); + MtxPosition(&work, &actor->eyePos); - i_this->field_0xa9c[0].SetC(a_this->eyePos + sp50); + i_this->cc_sph[0].SetC(actor->eyePos + sp50); if (daPy_getPlayerActorClass()->checkHorseRide()) { - i_this->field_0xa9c[0].SetR(70.0f); + i_this->cc_sph[0].SetR(70.0f); } else { - i_this->field_0xa9c[0].SetR(50.0f); + i_this->cc_sph[0].SetR(50.0f); } - a_this->attention_info.position = a_this->eyePos; - a_this->attention_info.position.y += 70.0f + BREG_F(7); + actor->attention_info.position = actor->eyePos; + actor->attention_info.position.y += 70.0f + BREG_F(7); - MTXCopy(model->getAnmMtx(1), *calc_mtx); - sp2c.set(-30.0f + BREG_F(11), BREG_F(12), BREG_F(13)); - MtxPosition(&sp2c, &sp38); - i_this->field_0xa9c[1].SetC(sp38 + sp50); - i_this->field_0xa9c[1].SetR(45.0f); - MTXCopy(model->getAnmMtx(2), *calc_mtx); - sp2c.set(20.0f + BREG_F(14), BREG_F(15), BREG_F(16)); - MtxPosition(&sp2c, &sp38); - i_this->field_0xa9c[2].SetC(sp38 + sp50); - i_this->field_0xa9c[2].SetR(45.0f); + MTXCopy(model->getAnmMtx(JNT_BACKBONE01), *calc_mtx); + work.set(-30.0f + BREG_F(11), BREG_F(12), BREG_F(13)); + MtxPosition(&work, &pos); + i_this->cc_sph[1].SetC(pos + sp50); + i_this->cc_sph[1].SetR(45.0f); + + MTXCopy(model->getAnmMtx(JNT_BACKBONE02), *calc_mtx); + work.set(20.0f + BREG_F(14), BREG_F(15), BREG_F(16)); + MtxPosition(&work, &pos); + i_this->cc_sph[2].SetC(pos + sp50); + i_this->cc_sph[2].SetR(45.0f); for (int i = 0; i <= 2; i++) { if (i_this->field_0x6f2 != 0) { - i_this->field_0xa9c[i].OnCoSetBit(); + i_this->cc_sph[i].OnCoSetBit(); } else { - i_this->field_0xa9c[i].OffCoSetBit(); + i_this->cc_sph[i].OffCoSetBit(); } - dComIfG_Ccsp()->Set(&i_this->field_0xa9c[i]); + dComIfG_Ccsp()->Set(&i_this->cc_sph[i]); } - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(19), *calc_mtx); - i_this->mpKnifeModel->setBaseTRMtx(*calc_mtx); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_HANDR1), *calc_mtx); + i_this->knife_model->setBaseTRMtx(*calc_mtx); - if (i_this->field_0x6ef != 0 && i_this->field_0x6ee <= 1) { - sp2c.set(BREG_F(7), 60.0f + BREG_F(8), BREG_F(9)); - MtxPosition(&sp2c, &sp38); - if (i_this->field_0x6f0 == 0) { - i_this->field_0x6f0 = 1; - i_this->field_0xe44.StartCAt(sp38); + if (i_this->at_chk_flag != 0 && i_this->tail_at_sph_flag <= 1) { + work.set(BREG_F(7), 60.0f + BREG_F(8), BREG_F(9)); + MtxPosition(&work, &pos); + if (i_this->at_sph_center_flag == 0) { + i_this->at_sph_center_flag = 1; + i_this->at_sph.StartCAt(pos); } else { - i_this->field_0xe44.MoveCAt(sp38); + i_this->at_sph.MoveCAt(pos); } - if (i_this->field_0x6ee == 1) { - i_this->field_0xe44.SetR(l_HIO.model_size * 80.0f); + if (i_this->tail_at_sph_flag == 1) { + i_this->at_sph.SetR(l_HIO.model_size * 80.0f); } else { - i_this->field_0xe44.SetR(l_HIO.model_size * 50.0f); + i_this->at_sph.SetR(l_HIO.model_size * 50.0f); } - i_this->field_0xe44.SetAtAtp(1); + i_this->at_sph.SetAtAtp(1); } - if (i_this->mpSkullModel != NULL) { + if (i_this->skull_model != NULL) { if (i_this->field_0x694 == 0) { - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(6), mDoMtx_stack_c::get()); - mDoMtx_stack_c::multVecZero(&i_this->field_0x698); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_HEAD), mDoMtx_stack_c::get()); + mDoMtx_stack_c::multVecZero(&i_this->skull_trans); } else { - i_this->field_0x698 += i_this->field_0x6a4; - if (i_this->field_0x6a4.y <= i_this->mObjAcch.GetGroundH()) { - i_this->mpSkullModel = NULL; + i_this->skull_trans += i_this->field_0x6a4; + if (i_this->field_0x6a4.y <= i_this->objacch.GetGroundH()) { + i_this->skull_model = NULL; } i_this->field_0x6a4.y -= 5.0f; - mDoMtx_stack_c::transS(i_this->field_0x698.x, i_this->field_0x698.y, i_this->field_0x698.z); - mDoMtx_stack_c::YrotM(i_this->field_0x6b0); - mDoMtx_stack_c::XrotM(i_this->field_0x6b2); + mDoMtx_stack_c::transS(i_this->skull_trans.x, i_this->skull_trans.y, i_this->skull_trans.z); + mDoMtx_stack_c::YrotM(i_this->skull_y_rot); + mDoMtx_stack_c::XrotM(i_this->skull_x_rot); } - i_this->mpSkullModel->setBaseTRMtx(mDoMtx_stack_c::get()); + i_this->skull_model->setBaseTRMtx(mDoMtx_stack_c::get()); } - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(12), *calc_mtx); - i_this->mpShieldModel->setBaseTRMtx(*calc_mtx); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_ARML2), *calc_mtx); + i_this->tate_model->setBaseTRMtx(*calc_mtx); - if (i_this->field_0x6ef != 0 && i_this->field_0x6ee == 2) { - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(34), *calc_mtx); - sp2c.set(BREG_F(7), BREG_F(8), BREG_F(9)); - MtxPosition(&sp2c, &sp38); + if (i_this->at_chk_flag != 0 && i_this->tail_at_sph_flag == 2) { + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_TAIL04), *calc_mtx); + work.set(BREG_F(7), BREG_F(8), BREG_F(9)); + MtxPosition(&work, &pos); - if (i_this->field_0x6f0 == 0) { - i_this->field_0x6f0 = 1; - i_this->field_0xe44.StartCAt(sp38); + if (i_this->at_sph_center_flag == 0) { + i_this->at_sph_center_flag = 1; + i_this->at_sph.StartCAt(pos); } else { - i_this->field_0xe44.MoveCAt(sp38); + i_this->at_sph.MoveCAt(pos); } - i_this->field_0xe44.SetAtAtp(2); - i_this->field_0xe44.SetR((70.0f + BREG_F(10)) * l_HIO.model_size); + i_this->at_sph.SetAtAtp(2); + i_this->at_sph.SetR((70.0f + BREG_F(10)) * l_HIO.model_size); } - if (i_this->field_0x6ef == 0) { + if (i_this->at_chk_flag == 0) { cXyz sp68(-23500.0f, -20000.0f, -50000.0f); - i_this->field_0xe44.SetC(a_this->current.pos + sp68); - i_this->field_0x6f0 = 0; + i_this->at_sph.SetC(actor->current.pos + sp68); + i_this->at_sph_center_flag = 0; } else { - i_this->field_0x6ef = 0; + i_this->at_chk_flag = 0; } - dComIfG_Ccsp()->Set(&i_this->field_0xe44); + dComIfG_Ccsp()->Set(&i_this->at_sph); - if (i_this->field_0x6f1 != 0 && i_this->field_0x6ec == 0) { - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(12), *calc_mtx); - sp2c.set(50.0f + JREG_F(5), JREG_F(6), 30.0f + JREG_F(7)); - MtxPosition(&sp2c, &sp38); - i_this->field_0xf7c.SetC(sp38); - i_this->field_0xf7c.SetR((70.0f + JREG_F(8)) * l_HIO.model_size); + if (i_this->guard_flag != 0 && i_this->unk_timer_2 == 0) { + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_ARML2), *calc_mtx); + work.set(50.0f + JREG_F(5), JREG_F(6), 30.0f + JREG_F(7)); + MtxPosition(&work, &pos); + i_this->tate_sph.SetC(pos); + i_this->tate_sph.SetR((70.0f + JREG_F(8)) * l_HIO.model_size); - if (i_this->field_0xf7c.ChkTgHit()) { - def_se_set(&i_this->mSound, i_this->field_0xf7c.GetTgHitObj(), 40, 0); - dScnPly_c::setPauseTimer(l_HIO.field_0x1c); - i_this->field_0x6ec = 10; - cMtx_YrotS(*calc_mtx, (s16)a_this->shape_angle.y); - sp2c.x = KREG_F(0); - sp2c.y = 120.0f + KREG_F(1); - sp2c.z = 50.0f + KREG_F(2); - MtxPosition(&sp2c, &sp38); - sp38 += a_this->current.pos; - dComIfGp_setHitMark(2, NULL, &sp38, &a_this->shape_angle, NULL, 0); + if (i_this->tate_sph.ChkTgHit()) { + def_se_set(&i_this->sound, i_this->tate_sph.GetTgHitObj(), 40, 0); + dScnPly_c::setPauseTimer(l_HIO.defense_pause_time); + i_this->unk_timer_2 = 10; + cMtx_YrotS(*calc_mtx, (s16)actor->shape_angle.y); + work.x = KREG_F(0); + work.y = 120.0f + KREG_F(1); + work.z = 50.0f + KREG_F(2); + MtxPosition(&work, &pos); + pos += actor->current.pos; + dComIfGp_setHitMark(2, NULL, &pos, &actor->shape_angle, NULL, 0); } } else { cXyz sp74(-23500.0f, -20000.0f, -30000.0f); - i_this->field_0xf7c.SetC(a_this->current.pos + sp74); + i_this->tate_sph.SetC(actor->current.pos + sp74); } - i_this->field_0x6f1 = 0; - dComIfG_Ccsp()->Set(&i_this->field_0xf7c); - if (i_this->field_0x6c4 != 0) { - cLib_addCalc2(&i_this->field_0x6c8, -20.0f, 1.0f, 0.4f); + i_this->guard_flag = 0; + dComIfG_Ccsp()->Set(&i_this->tate_sph); + if (i_this->death_flag != 0) { + cLib_addCalc2(&i_this->color, -20.0f, 1.0f, 0.4f); } fopAc_ac_c* player = dComIfGp_getPlayer(0); - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(2), mDoMtx_stack_c::get()); - mDoMtx_stack_c::multVecZero(&sp38); - sp2c = player->current.pos - sp38; - s16 tans_val = cM_atan2s(sp2c.x, sp2c.z); + MTXCopy(i_this->anm_p->getModel()->getAnmMtx(JNT_BACKBONE02), mDoMtx_stack_c::get()); + mDoMtx_stack_c::multVecZero(&pos); + work = player->current.pos - pos; + s16 tans_val = cM_atan2s(work.x, work.z); cMtx_YrotS(*calc_mtx, tans_val); - sp2c.x = 0.0; - sp2c.y = 45.0f; - sp2c.z = 30.0f; - MtxPosition(&sp2c, &sp44); - sp44 += sp38; + work.x = 0.0; + work.y = NREG_F(18) + 45.0f; + work.z = (BREG_F(12) + 60.0f) - 30.0f; + MtxPosition(&work, &downPos); + downPos += pos; // The following pokes a hole in the "c-style actors don't inherit" theory.... - ((fopEn_enemy_c*) i_this)->setDownPos(&sp44); - cXyz sp80(a_this->eyePos); - sp80.y += 180.0f; + ((fopEn_enemy_c*) i_this)->setDownPos(&downPos); + cXyz sp80(actor->eyePos); + sp80.y += NREG_F(7) + 180.0f; ((fopEn_enemy_c*) i_this)->setHeadLockPos(&sp80); - a_this->attention_info.flags |= fopAc_AttnFlag_UNK_0x200000; + actor->attention_info.flags |= fopAc_AttnFlag_UNK_0x200000; - if ((a_this->current.pos.y - a_this->home.pos.y) < -5000.0f) { - fopAcM_delete(a_this); + if ((actor->current.pos.y - actor->home.pos.y) < -5000.0f) { + fopAcM_delete(actor); OS_REPORT("DN NARAKU\n"); - int swBit = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; + int swBit = (fopAcM_GetParam(actor) & 0xFF000000) >> 24; if (swBit != 0xFF) { - dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(a_this)); + dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(actor)); } } // City in the Sky - Dynalfos Room: // i.e. where you can scare the 2 lizard dudes with the clawshot, make them fall to their deaths, // then the fan in the middle turns on. - if (strcmp(dComIfGp_getStartStageName(), "D_MN07") == 0 && fopAcM_GetRoomNo(a_this) == 8 - && a_this->health != 0 && a_this->current.pos.y <= -300.0f) { - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; + if (strcmp(dComIfGp_getStartStageName(), "D_MN07") == 0 && fopAcM_GetRoomNo(actor) == 8 + && actor->health != 0 && actor->current.pos.y <= -300.0f) { + i_this->action = ACTION_DAMAGE; + i_this->mode = 0; i_this->field_0x704 = 0.0; - a_this->health = 0; + actor->health = 0; } return 1; @@ -3195,15 +3282,18 @@ static int daE_DN_IsDelete(e_dn_class* i_this) { } static int daE_DN_Delete(e_dn_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - dComIfG_resDelete(&i_this->mPhase, "E_dn"); + fopEn_enemy_c* actor = (fopEn_enemy_c*)&i_this->actor; + fpc_ProcID no = fopAcM_GetID(i_this); - if (i_this->field_0x10d9 != 0) { + dComIfG_resDelete(&i_this->phase, "E_dn"); + + if (i_this->hio_init != 0) { l_initHIO = 0; + mDoHIO_DELETE_CHILD(l_HIO.no); } - if (a_this->heap != NULL) { - i_this->mpModelMorf->stopZelAnime(); + if (actor->heap != NULL) { + i_this->anm_p->stopZelAnime(); } return 1; @@ -3220,17 +3310,17 @@ dJntColData_c jc_data[12] = { {0, 1, 28, 15.0f, &jv_offset}, {0, 1, 32, 20.0f, &jv_offset}, }; -static int useHeapInit(fopAc_ac_c* a_this) { - e_dn_class* i_this = (e_dn_class*)a_this; +static int useHeapInit(fopAc_ac_c* actor) { + e_dn_class* i_this = (e_dn_class*)actor; - i_this->mpModelMorf = new mDoExt_McaMorfSO((J3DModelData*)dComIfG_getObjectRes("E_dn", 38), NULL, NULL, + i_this->anm_p = new mDoExt_McaMorfSO((J3DModelData*)dComIfG_getObjectRes("E_dn", 38), NULL, NULL, (J3DAnmTransform*)dComIfG_getObjectRes("E_dn", 31), 0, 1.0f, - 0, -1, &i_this->mSound, 0x80000, 0x11000084); - if (i_this->mpModelMorf == NULL || i_this->mpModelMorf->getModel() == NULL) { + 0, -1, &i_this->sound, 0x80000, 0x11000084); + if (i_this->anm_p == NULL || i_this->anm_p->getModel() == NULL) { return 0; } - J3DModel* model = i_this->mpModelMorf->getModel(); + J3DModel* model = i_this->anm_p->getModel(); model->setUserArea((uintptr_t)i_this); for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { @@ -3239,29 +3329,29 @@ static int useHeapInit(fopAc_ac_c* a_this) { } } - if (i_this->mJntCol.init(a_this, &jc_data[0], model, 12) == 0) { + if (i_this->jc.init(actor, &jc_data[0], model, 12) == 0) { return 0; } J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("E_dn", 39); JUT_ASSERT(5420, modelData != NULL); - i_this->mpKnifeModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); - if (i_this->mpKnifeModel == NULL) { + i_this->knife_model = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + if (i_this->knife_model == NULL) { return 0; } modelData = (J3DModelData*)dComIfG_getObjectRes("E_dn", 41); JUT_ASSERT(5432, modelData != NULL); - i_this->mpShieldModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); - if (i_this->mpShieldModel == NULL) { + i_this->tate_model = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + if (i_this->tate_model == NULL) { return 0; } - if (i_this->field_0x5b7 == 1) { + if (i_this->arg1 == 1) { modelData = (J3DModelData*)dComIfG_getObjectRes("E_dn", 40); JUT_ASSERT(5443, modelData != NULL); - i_this->mpSkullModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); - if (i_this->mpSkullModel == NULL) { + i_this->skull_model = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + if (i_this->skull_model == NULL) { return 0; } } @@ -3269,68 +3359,65 @@ static int useHeapInit(fopAc_ac_c* a_this) { return 1; } -static cPhs__Step daE_DN_Create(fopAc_ac_c* a_this) { - e_dn_class* i_this = (e_dn_class*)a_this; +static cPhs__Step daE_DN_Create(fopAc_ac_c* actor) { + e_dn_class* i_this = (e_dn_class*)actor; - fopAcM_ct(a_this, e_dn_class); + fopAcM_ct(actor, e_dn_class); - cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->mPhase, "E_dn"); + cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->phase, "E_dn"); if (phase == cPhs_COMPLEATE_e) { - int swBit = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; + int swBit = (fopAcM_GetParam(actor) & 0xFF000000) >> 24; if (swBit != 0xFF) { - if (dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(a_this))) { + if (dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(actor))) { return cPhs_ERROR_e; } } - OS_REPORT("E_dn PARAM %x\n", fopAcM_GetParam(a_this)); - i_this->field_0x5b6 = fopAcM_GetParam(a_this); - i_this->field_0x5b9 = 1; - i_this->field_0x5b7 = (fopAcM_GetParam(a_this) & 0xF00) >> 8; - i_this->field_0x5b8 = (fopAcM_GetParam(a_this) & 0xF000) >> 12; + OS_REPORT("E_dn PARAM %x\n", fopAcM_GetParam(actor)); + i_this->arg0 = fopAcM_GetParam(actor); + i_this->arg3 = 1; + i_this->arg1 = (fopAcM_GetParam(actor) & 0xF00) >> 8; + i_this->arg2 = (fopAcM_GetParam(actor) & 0xF000) >> 12; - if ((a_this->home.angle.z & 0xFF) == 0 || (a_this->home.angle.z & 0xFF) == 0xFF) { - i_this->field_0x6d8 = 100000.0f; + if ((actor->home.angle.z & 0xFF) == 0 || (actor->home.angle.z & 0xFF) == 0xFF) { + i_this->pl_range = 100000.0f; } else { - i_this->field_0x6d8 = (a_this->home.angle.z & 0xFF) * 100.0f; + i_this->pl_range = (actor->home.angle.z & 0xFF) * 100.0f; } - OS_REPORT("E_dn AZ %x\n", a_this->home.angle.z); - OS_REPORT("E_dn PR %d\n", i_this->field_0x6d8); - a_this->shape_angle.z = 0; - a_this->current.angle.z = 0; - a_this->home.angle.z = 0; + OS_REPORT("E_dn AZ %x\n", actor->home.angle.z); + OS_REPORT("E_dn PR %d\n", (int)i_this->pl_range); + actor->home.angle.z = actor->current.angle.z = actor->shape_angle.z = 0; + u8 param = (fopAcM_GetParam(actor) & 0xFF0000) >> 16; OS_REPORT("E_dn//////////////E_DN SET 1 !!\n"); - if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0x3BF0)) { + if (!fopAcM_entrySolidHeap(actor, useHeapInit, 0x3BF0)) { OS_REPORT("//////////////E_DN SET NON !!\n"); return cPhs_ERROR_e; } if (l_initHIO == 0) { - i_this->field_0x10d9 = 1; + i_this->hio_init = 1; l_initHIO = 1; - l_HIO.field_0x4 = -1; + l_HIO.no = mDoHIO_CREATE_CHILD("リザードマン", &l_HIO); } - fopAcM_OnStatus(a_this, fopAcM_STATUS_UNK_0x100); - a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; - fopAcM_SetMtx(a_this, i_this->mpModelMorf->getModel()->getBaseTRMtx()); - fopAcM_SetMin(a_this, -200.0f, -200.0f, -200.0f); - fopAcM_SetMax(a_this, 200.0f, 200.0f, 200.0f); + fopAcM_OnStatus(actor, fopAcM_STATUS_UNK_0x100); + actor->attention_info.flags = fopAc_AttnFlag_BATTLE_e; + fopAcM_SetMtx(actor, i_this->anm_p->getModel()->getBaseTRMtx()); + fopAcM_SetMin(actor, -200.0f, -200.0f, -200.0f); + fopAcM_SetMax(actor, 200.0f, 200.0f, 200.0f); - i_this->mObjAcch.Set(fopAcM_GetPosition_p(a_this), fopAcM_GetOldPosition_p(a_this), a_this, 1, - &i_this->mAcchCir, fopAcM_GetSpeed_p(a_this), NULL, NULL); - i_this->mAcchCir.SetWall(80.0f, 100.0f); + i_this->objacch.Set(fopAcM_GetPosition_p(actor), fopAcM_GetOldPosition_p(actor), actor, 1, + &i_this->acchcir, fopAcM_GetSpeed_p(actor), NULL, NULL); + i_this->acchcir.SetWall(80.0f, 100.0f); - if (i_this->field_0x5b7 == 1) { - a_this->health = 100; - a_this->field_0x560 = 100; + if (i_this->arg1 == 1) { + actor->field_0x560 = actor->health = 100; } else { - a_this->health = 100; - a_this->field_0x560 = 100; + actor->field_0x560 = actor->health = 100; } - i_this->mStts.Init(200, 0, a_this); + i_this->stts.Init(200, 0, actor); static dCcD_SrcSph cc_sph_src = { { @@ -3344,8 +3431,8 @@ static cPhs__Step daE_DN_Create(fopAc_ac_c* a_this) { } // mSphAttr }; for (int i = 0; i <= 2; i++) { - i_this->field_0xa9c[i].Set(cc_sph_src); - i_this->field_0xa9c[i].SetStts(&i_this->mStts); + i_this->cc_sph[i].Set(cc_sph_src); + i_this->cc_sph[i].SetStts(&i_this->stts); } static dCcD_SrcSph at_sph_src = { @@ -3359,8 +3446,8 @@ static cPhs__Step daE_DN_Create(fopAc_ac_c* a_this) { {{0.0f, 0.0f, 0.0f}, 35.0f} // mSph } // mSphAttr }; - i_this->field_0xe44.Set(at_sph_src); - i_this->field_0xe44.SetStts(&i_this->mStts); + i_this->at_sph.Set(at_sph_src); + i_this->at_sph.SetStts(&i_this->stts); static dCcD_SrcSph tate_sph_src = { { @@ -3373,25 +3460,25 @@ static cPhs__Step daE_DN_Create(fopAc_ac_c* a_this) { {{0.0f, 0.0f, 0.0f}, 100.0f} // mSph } // mSphAttr }; - i_this->field_0xf7c.Set(tate_sph_src); - i_this->field_0xf7c.SetStts(&i_this->mStts); + i_this->tate_sph.Set(tate_sph_src); + i_this->tate_sph.SetStts(&i_this->stts); - i_this->field_0x6cc = (int)cM_rndF(65535.0f) & 0xFF00; + i_this->frame_counter = (int)cM_rndF(65535.0f) & 0xFF00; - if (i_this->field_0x5b6 == 0) { - i_this->mAction = ACTION_STAY; + if (i_this->arg0 == 0) { + i_this->action = ACTION_STAY; } - if ((i_this->field_0x5b6 == 13 || i_this->field_0x5b6 == 14) || (i_this->field_0x5b6 == 15 || i_this->field_0x5b6 == 16)) { - i_this->field_0x10d8 = 1; - i_this->mAction = ACTION_REG; - fopAcM_OnStatus(a_this, fopAcM_STATUS_UNK_0x4000); - i_this->mAcchCir.SetWall(80.0f, 2.0f); + if ((i_this->arg0 == 13 || i_this->arg0 == 14) || (i_this->arg0 == 15 || i_this->arg0 == 16)) { + i_this->status = 1; + i_this->action = ACTION_REG; + fopAcM_OnStatus(actor, fopAcM_STATUS_UNK_0x4000); + i_this->acchcir.SetWall(80.0f, 2.0f); } - i_this->mSound.init(&a_this->current.pos, &a_this->eyePos, 3, 1); - i_this->mSound.setEnemyName("E_dn"); - i_this->mAtInfo.mpSound = &i_this->mSound; + i_this->sound.init(&actor->current.pos, &actor->eyePos, 3, 1); + i_this->sound.setEnemyName("E_dn"); + i_this->at_info.mpSound = &i_this->sound; c_start = 1; daE_DN_Execute(i_this); diff --git a/src/d/actor/d_a_e_rd.cpp b/src/d/actor/d_a_e_rd.cpp index ae8962bbf23..331a517ade2 100644 --- a/src/d/actor/d_a_e_rd.cpp +++ b/src/d/actor/d_a_e_rd.cpp @@ -5507,8 +5507,8 @@ static void* s_wb_sub2(void* i_actor, void* i_data) { } static void* s_lv9dn_sub(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN && ((e_dn_class*)i_actor)->field_0x10d8 != 0) { - ((e_dn_class*)i_actor)->field_0x10d8 = 0; + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN && ((e_dn_class*)i_actor)->status != 0) { + ((e_dn_class*)i_actor)->status = 0; return i_actor; } @@ -5516,9 +5516,9 @@ static void* s_lv9dn_sub(void* i_actor, void* i_data) { } static void* s_lv9dn_sub2(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN && ((e_dn_class*)i_actor)->field_0x10d8 == 0) { - ((e_dn_class*)i_actor)->field_0x10d8 = 1; - ((e_dn_class*)i_actor)->mMode = 0; + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN && ((e_dn_class*)i_actor)->status == 0) { + ((e_dn_class*)i_actor)->status = 1; + ((e_dn_class*)i_actor)->mode = 0; } return NULL; @@ -5526,7 +5526,7 @@ static void* s_lv9dn_sub2(void* i_actor, void* i_data) { static void* s_lv9dn_sub3(void* i_actor, void* i_data) { if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN) { - ((e_dn_class*)i_actor)->mMode = 2; + ((e_dn_class*)i_actor)->mode = 2; } return NULL; diff --git a/src/d/actor/d_a_obj_key.cpp b/src/d/actor/d_a_obj_key.cpp index c9974a81d45..ac9a10a87f1 100644 --- a/src/d/actor/d_a_obj_key.cpp +++ b/src/d/actor/d_a_obj_key.cpp @@ -279,7 +279,7 @@ static void chain_control_01(obj_key_class* i_this) { J3DModel* parent_model; if (fopAcM_GetName(pparent) == PROC_E_DN) { e_dn_class* dn = (e_dn_class*)pparent; - parent_model = dn->mpModelMorf->getModel(); + parent_model = dn->anm_p->getModel(); MTXCopy(parent_model->getAnmMtx(1), *calc_mtx); spC4.set(5.0f + KREG_F(0), 30.0f + KREG_F(1), 20.0f + KREG_F(2));