From 24c08d322e32677f804c970c68930295afeb7475 Mon Sep 17 00:00:00 2001 From: YunataSavior <58997725+YunataSavior@users.noreply.github.com> Date: Sun, 11 Jan 2026 19:49:05 -0800 Subject: [PATCH] e_rd, npc_ks dbg work (#3029) * Partial e_rd, npc_ks dbg work * More e_rd matching * e_rd fixes and dbg ctor matched * obj_ita dbg equiv * e_st dbg almost equiv * Some obj_ladder dbg work * dbg e_rd PR comments * Further e_rd dbg clangd fixes --- config/GZ2E01/rels/d_a_e_rd/symbols.txt | 2 +- config/GZ2J01/rels/d_a_e_rd/symbols.txt | 2 +- config/GZ2P01/rels/d_a_e_rd/symbols.txt | 2 +- config/ShieldD/rels/d_a_e_rdD/symbols.txt | 1 + include/d/actor/d_a_e_rd.h | 30 +- include/d/actor/d_a_obj_kago.h | 6 +- include/d/actor/d_a_obj_ladder.h | 24 +- include/d/d_s_play.h | 52 +- include/global.h | 7 + src/d/actor/d_a_e_rd.cpp | 1533 ++++++++++++--------- src/d/actor/d_a_e_st.cpp | 219 +-- src/d/actor/d_a_e_wb.cpp | 2 +- src/d/actor/d_a_npc_ks.cpp | 175 ++- src/d/actor/d_a_obj_hb.cpp | 20 +- src/d/actor/d_a_obj_ita.cpp | 63 +- src/d/actor/d_a_obj_ladder.cpp | 252 +++- 16 files changed, 1390 insertions(+), 1000 deletions(-) diff --git a/config/GZ2E01/rels/d_a_e_rd/symbols.txt b/config/GZ2E01/rels/d_a_e_rd/symbols.txt index 8b250dd142..8bb317bb58 100644 --- a/config/GZ2E01/rels/d_a_e_rd/symbols.txt +++ b/config/GZ2E01/rels/d_a_e_rd/symbols.txt @@ -446,7 +446,7 @@ S_find = .bss:0x000000AC; // type:object size:0x2 scope:global data:2byte lbl_70_bss_AE = .bss:0x000000AE; // type:object size:0x1 scope:local align:1 data:byte @4242 = .bss:0x000000B0; // type:object size:0xC scope:local S_find_pos = .bss:0x000000BC; // type:object size:0xC scope:global align:4 data:float -data_80519200 = .bss:0x000000C8; // type:object size:0x1 data:byte +desert_substage = .bss:0x000000C8; // type:object size:0x1 data:byte data_80519201 = .bss:0x000000C9; // type:object size:0x1 data:byte target_info = .bss:0x000000CC; // type:object size:0x28 scope:global data:4byte target_info_count = .bss:0x000000F4; // type:object size:0x4 scope:global data:4byte diff --git a/config/GZ2J01/rels/d_a_e_rd/symbols.txt b/config/GZ2J01/rels/d_a_e_rd/symbols.txt index 3c83698aaa..fbcf2cf96e 100644 --- a/config/GZ2J01/rels/d_a_e_rd/symbols.txt +++ b/config/GZ2J01/rels/d_a_e_rd/symbols.txt @@ -445,7 +445,7 @@ S_find = .bss:0x000000AC; // type:object size:0x2 scope:global data:2byte lbl_70_bss_AE = .bss:0x000000AE; // type:object size:0x1 data:byte @4242 = .bss:0x000000B0; // type:object size:0xC scope:local S_find_pos = .bss:0x000000BC; // type:object size:0xC scope:global align:4 data:float -data_80519200 = .bss:0x000000C8; // type:object size:0x1 data:byte +desert_substage = .bss:0x000000C8; // type:object size:0x1 data:byte data_80519201 = .bss:0x000000C9; // type:object size:0x1 data:byte target_info = .bss:0x000000CC; // type:object size:0x28 scope:global data:4byte target_info_count = .bss:0x000000F4; // type:object size:0x4 scope:global data:4byte diff --git a/config/GZ2P01/rels/d_a_e_rd/symbols.txt b/config/GZ2P01/rels/d_a_e_rd/symbols.txt index 2a2f2830e9..d37f816021 100644 --- a/config/GZ2P01/rels/d_a_e_rd/symbols.txt +++ b/config/GZ2P01/rels/d_a_e_rd/symbols.txt @@ -445,7 +445,7 @@ S_find = .bss:0x000000AC; // type:object size:0x2 scope:global data:2byte lbl_70_bss_AE = .bss:0x000000AE; // type:object size:0x1 data:byte @4242 = .bss:0x000000B0; // type:object size:0xC scope:local S_find_pos = .bss:0x000000BC; // type:object size:0xC scope:global align:4 data:float -data_80519200 = .bss:0x000000C8; // type:object size:0x1 data:byte +desert_substage = .bss:0x000000C8; // type:object size:0x1 data:byte data_80519201 = .bss:0x000000C9; // type:object size:0x1 data:byte target_info = .bss:0x000000CC; // type:object size:0x28 scope:global data:4byte target_info_count = .bss:0x000000F4; // type:object size:0x4 scope:global data:4byte diff --git a/config/ShieldD/rels/d_a_e_rdD/symbols.txt b/config/ShieldD/rels/d_a_e_rdD/symbols.txt index 0ef070121b..f0d5879231 100644 --- a/config/ShieldD/rels/d_a_e_rdD/symbols.txt +++ b/config/ShieldD/rels/d_a_e_rdD/symbols.txt @@ -506,6 +506,7 @@ lbl_68_bss_68 = .bss:0x00000068; // type:object size:0x1 data:byte lbl_68_bss_69 = .bss:0x00000069; // type:object size:0x7 data:byte target_info = .bss:0x00000070; // type:object size:0x28 scope:global data:4byte target_info_count = .bss:0x00000098; // type:object size:0x4 scope:global data:4byte +data_80519230 = .bss:0x0000009C; // type:object size:0x1 data:byte @LOCAL@path_check__FP10e_rd_class@check_index = .bss:0x000000A0; // type:object size:0xFF scope:local rd_count = .bss:0x000001A0; // type:object size:0x4 scope:global data:4byte lbl_68_bss_1A4 = .bss:0x000001A4; // type:object size:0x1 data:byte diff --git a/include/d/actor/d_a_e_rd.h b/include/d/actor/d_a_e_rd.h index 90b48ca3f5..90a3fec56a 100644 --- a/include/d/actor/d_a_e_rd.h +++ b/include/d/actor/d_a_e_rd.h @@ -7,6 +7,7 @@ #include "d/d_msg_flow.h" #include "d/d_path.h" #include "f_op/f_op_actor_mng.h" +#include "m_Do/m_Do_ext.h" /** * @ingroup actors-enemies @@ -45,9 +46,7 @@ public: /* 0x06A0 */ s8 field_0x6a0; /* 0x06A4 */ cXyz field_0x6a4; /* 0x06B0 */ cXyz field_0x6b0; - /* 0x06BC */ u8 field_0x6bc[0x6be - 0x6bc]; - /* 0x06BE */ s16 field_0x6be; - /* 0x06C0 */ s16 field_0x6c0; + /* 0x06BC */ csXyz field_0x6bc; /* 0x06C2 */ s8 field_0x6c2; /* 0x06C3 */ u8 field_0x6c3; /* 0x06C4 */ J3DModel* mpEyeModels[2]; @@ -101,22 +100,17 @@ public: /* 0x09CE */ s16 field_0x9ce; /* 0x09D0 */ s16 field_0x9d0; /* 0x09D4 */ cXyz field_0x9d4; - /* 0x09E0 */ u8 field_0x9e0[0x9ec - 0x9e0]; + /* 0x09E0 */ cXyz field_0x9e0; // unused, dbg offset 0xa18 /* 0x09EC */ f32 field_0x9ec; /* 0x09F0 */ f32 field_0x9f0; /* 0x09F4 */ s16 field_0x9f4; /* 0x09F6 */ s16 field_0x9f6; /* 0x09F8 */ s8 field_0x9f8; - /* 0x09F9 */ u8 field_0x9f9[0xa0c - 0x9f9]; - /* 0x0A0C */ s16 field_0xa0c; - /* 0x0A0E */ s16 field_0xa0e; - /* 0x0A10 */ u8 field_0xa10[0xa12 - 0xa10]; - /* 0x0A12 */ s16 field_0xa12; - /* 0x0A14 */ u8 field_0xa14[0xa16 - 0xa14]; - /* 0x0A16 */ s16 field_0xa16; - /* 0x0A18 */ s16 field_0xa18; - /* 0x0A1A */ u8 field_0xa1a[0xa1c - 0xa1a]; - /* 0x0A1C */ s16 field_0xa1c; + /* 0x09FC */ cXyz field_0x9fc; // unused, dbg offset 0xa34 + /* 0x0A08 */ u8 field_0xa08[0x0A0C - 0x0A08]; + /* 0x0A0C */ csXyz field_0xa0c; + /* 0x0A12 */ csXyz field_0xa12; + /* 0x0A18 */ csXyz field_0xa18; /* 0x0A1E */ s8 field_0xa1e; /* 0x0A1F */ s8 field_0xa1f; /* 0x0A20 */ u32 field_0xa20; @@ -136,12 +130,8 @@ public: /* 0x0AD2 */ s16 field_0xad2[4]; /* 0x0ADA */ s16 field_0xada; /* 0x0ADC */ s16 field_0xadc; - /* 0x0ADE */ s16 field_0xade; - /* 0x0AE0 */ s16 field_0xae0; - /* 0x0AE2 */ u8 field_0xae2[0xae4 - 0xae2]; - /* 0x0AE4 */ s16 field_0xae4; - /* 0x0AE6 */ s16 field_0xae6; - /* 0x0AE8 */ u8 field_0xae8[0xaec - 0xae8]; + /* 0x0ADE */ csXyz field_0xade; // dbg offset 0xb1c + /* 0x0AE4 */ csXyz field_0xae4; /* 0x0AEC */ f32 field_0xaec; /* 0x0AF0 */ s16 field_0xaf0; /* 0x0AF2 */ s16 field_0xaf2; diff --git a/include/d/actor/d_a_obj_kago.h b/include/d/actor/d_a_obj_kago.h index 0ffa07fd61..10806570dd 100644 --- a/include/d/actor/d_a_obj_kago.h +++ b/include/d/actor/d_a_obj_kago.h @@ -34,10 +34,10 @@ public: void setHamonPrtcl(); u8 getType() { - int iVar1 = fopAcM_GetParam(this) & 0xFF; - u8 rv; + u8 adj_arg = argument & 0x7F; + u8 iVar1 = fopAcM_GetParam(this) & 0xFF; - switch ((argument & 127)) { + switch (adj_arg) { case 0: switch (iVar1) { case 0: diff --git a/include/d/actor/d_a_obj_ladder.h b/include/d/actor/d_a_obj_ladder.h index ff3a376eaf..eb48cf0f16 100644 --- a/include/d/actor/d_a_obj_ladder.h +++ b/include/d/actor/d_a_obj_ladder.h @@ -13,6 +13,15 @@ * */ namespace daObjLadder { + enum Type_e { + TYPE_0, + TYPE_1, + TYPE_2, + TYPE_3, + TYPE_4, + TYPE_5, + }; + class Act_c : public dBgS_MoveBgActor { public: enum Prm_e { @@ -22,15 +31,6 @@ namespace daObjLadder { PRM_16 = 16, }; - enum Type_e { - TYPE_0, - TYPE_1, - TYPE_2, - TYPE_3, - TYPE_4, - TYPE_5, - }; - enum Mode { MODE_WAIT, MODE_DEMOREQ, @@ -62,15 +62,15 @@ namespace daObjLadder { int Execute(Mtx**); int Draw(); - u8 prm_get_evId() { + u8 prm_get_evId() const { return daObj::PrmAbstract(this, PRM_8, PRM_16); } - int prm_get_swSave() { + int prm_get_swSave() const { return daObj::PrmAbstract(this,PRM_8, PRM_8); } - Type_e prm_get_type() { + Type_e prm_get_type() const { return(Type_e)daObj::PrmAbstract(this,PRM_3, PRM_0); } diff --git a/include/d/d_s_play.h b/include/d/d_s_play.h index 5736f0838c..6698a628e9 100644 --- a/include/d/d_s_play.h +++ b/include/d/d_s_play.h @@ -205,107 +205,107 @@ extern dScnPly_preset_HIO_c g_presetHIO; #define tREG_S(i) g_regHIO.mChildReg[25].mShortReg[i] #else // Morita -#define TREG_F(i) (0) +#define TREG_F(i) (0.0f) #define TREG_S(i) (0) // Matsutani -#define DREG_F(i) (0) +#define DREG_F(i) (0.0f) #define DREG_S(i) (0) // Iwawaki -#define IREG_F(i) (0) +#define IREG_F(i) (0.0f) #define IREG_S(i) (0) // Sasa -#define SREG_F(i) (0) +#define SREG_F(i) (0.0f) #define SREG_S(i) (0) // Umemiya -#define UREG_F(i) (0) +#define UREG_F(i) (0.0f) #define UREG_S(i) (0) // Ogawa -#define OREG_F(i) (0) +#define OREG_F(i) (0.0f) #define OREG_S(i) (0) // Sakaguchi -#define YREG_F(i) (0) +#define YREG_F(i) (0.0f) #define YREG_S(i) (0) // Sakai -#define KREG_F(i) (0) +#define KREG_F(i) (0.0f) #define KREG_S(i) (0) // Hara -#define BREG_F(i) (0) +#define BREG_F(i) (0.0f) #define BREG_S(i) (0) // Sumiyoshi -#define MREG_F(i) (0) +#define MREG_F(i) (0.0f) #define MREG_S(i) (0) // Takeshita -#define AREG_F(i) (0) +#define AREG_F(i) (0.0f) #define AREG_S(i) (0) // Yoshida -#define PREG_F(i) (0) +#define PREG_F(i) (0.0f) #define PREG_S(i) (0) // Noma -#define NREG_F(i) (0) +#define NREG_F(i) (0.0f) #define NREG_S(i) (0) // Nishiwaki -#define WREG_F(i) (0) +#define WREG_F(i) (0.0f) #define WREG_S(i) (0) // Masaro -#define JREG_F(i) (0) +#define JREG_F(i) (0.0f) #define JREG_S(i) (0) // Hayakawa -#define HREG_F(i) (0) +#define HREG_F(i) (0.0f) #define HREG_S(i) (0) // Sadamoto -#define VREG_F(i) (0) +#define VREG_F(i) (0.0f) #define VREG_S(i) (0) // Nishikawa -#define XREG_F(i) (0) +#define XREG_F(i) (0.0f) #define XREG_S(i) (0) // Suzuki -#define ZREG_F(i) (0) +#define ZREG_F(i) (0.0f) #define ZREG_S(i) (0) // Nakanishi -#define nREG_F(i) (0) +#define nREG_F(i) (0.0f) #define nREG_S(i) (0) // Kuwajima -#define kREG_F(i) (0) +#define kREG_F(i) (0.0f) #define kREG_S(i) (0) // Okajima -#define oREG_F(i) (0) +#define oREG_F(i) (0.0f) #define oREG_S(i) (0) // Yamazaki -#define yREG_F(i) (0) +#define yREG_F(i) (0.0f) #define yREG_S(i) (0) // Ashida -#define aREG_F(i) (0) +#define aREG_F(i) (0.0f) #define aREG_S(i) (0) // Okada -#define hREG_F(i) (0) +#define hREG_F(i) (0.0f) #define hREG_S(i) (0) // Takahashi -#define tREG_F(i) (0) +#define tREG_F(i) (0.0f) #define tREG_S(i) (0) #endif diff --git a/include/global.h b/include/global.h index cf8e285c23..d9e3511b22 100644 --- a/include/global.h +++ b/include/global.h @@ -138,4 +138,11 @@ static const float INF = 2000000000.0f; #define ASM #endif +// potential fakematch? +#if PLATFORM_SHIELD + #define UNSET_FLAG(var, flag) (var) &= (u16)~(flag) +#else + #define UNSET_FLAG(var, flag) (var) &= ~(flag) +#endif + #endif diff --git a/src/d/actor/d_a_e_rd.cpp b/src/d/actor/d_a_e_rd.cpp index 89904ae397..afb31f2cd6 100644 --- a/src/d/actor/d_a_e_rd.cpp +++ b/src/d/actor/d_a_e_rd.cpp @@ -36,7 +36,7 @@ public: /* ライダー (Rider) */ /* 0x08 */ f32 model_size; // 基本サイズ (Basic size) - /* 0x0C */ f32 field_0xc; // リーダーサイズ比 (Leader size ratio) + /* 0x0C */ f32 leader_size_ratio; // リーダーサイズ比 (Leader size ratio) /* 0x10 */ f32 movement_speed; // 移動速度 (Movement speed) /* こん棒兵の場合 (In the case of the club soldier) */ @@ -46,8 +46,7 @@ public: /* 0x20 */ f32 swing_speed; // 振り速さ (Swing speed) /* 矢兵の場合 (In the case of arrow soldiers) */ - /* 0x24 */ s16 field_0x24; // 号令→構えの間 (Command → Preparation) - /* 0x26 */ u8 padding[2]; + /* 0x24 */ s16 command_to_ready_stance; // 号令→構えの間 (Command → Preparation) /* 0x28 */ f32 attack_range; // 攻撃範囲 (Attack range) /* 0x2C */ f32 mounted_launch_distance; // 騎乗発射距離 (Mounted launch distance) /* 0x30 */ f32 wolf_falling_power_y; // 狼倒れ力Y (Wolf falling power Y) @@ -60,7 +59,7 @@ public: /* 0x3C */ f32 field_0x3c; // 一騎(ダ)サイズ (One-man army (Da) size) /* 0x40 */ f32 jump_g; // 飛びG (Jump G) /* 0x44 */ f32 jump_z; // 飛びZ (Jump Z) - /* 0x48 */ f32 field_0x48; // 飛びZ(騎乗停止) (Jump Z (Stop riding)) + /* 0x48 */ f32 jump_z_suspended; // 飛びZ(騎乗停止) (Jump Z (Stop riding)) /* 0x4C */ f32 jump_y; // 飛びY (Jump Y) }; @@ -207,13 +206,13 @@ enum Joint { daE_RD_HIO_c::daE_RD_HIO_c() { field_0x4 = -1; model_size = 1.2f; - field_0xc = 1.2f; + leader_size_ratio = 1.2f; movement_speed = 3.5f; dash_speed = 14.0f; battle_init_range = 250.0f; attack_init_range = 300.0f; swing_speed = 1.1f; - field_0x24 = 60; + command_to_ready_stance = 60; attack_range = 1300.0f; mounted_launch_distance = 2000.0f; wolf_falling_power_y = 3.0f; @@ -223,30 +222,84 @@ daE_RD_HIO_c::daE_RD_HIO_c() { eye_polygon = 1; one_hit_kill = 0; field_0x3c = 75.0f; - field_0x48 = 5.0f; + jump_z_suspended = 5.0f; jump_z = 10.0f; jump_y = 33.0f; jump_g = 5.0f; } +#if DEBUG +void daE_RD_HIO_c::genMessage(JORMContext* ctext) { + // Rider (a.k.a. Bulblins) + ctext->genLabel(" ライダー", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // basic size + ctext->genSlider("基本サイズ", &model_size, 0.0f, 5.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // leader size ratio + ctext->genSlider("リーダーサイズ比", &leader_size_ratio, 0.0f, 2.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // movement speed + ctext->genSlider("移動速度", &movement_speed, 0.0f, 20.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // ~~ In the case of a club-wielding soldier ~~ + ctext->genLabel(" ~~ こん棒兵の場合 ~~", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // speed rush + ctext->genSlider("突進速度", &dash_speed, 0.0f, 40.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // combat start range + ctext->genSlider("戦闘開始範囲", &battle_init_range, 0.0f, 2000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // attack range + ctext->genSlider("攻撃開始範囲", &attack_init_range, 0.0f, 1000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // swing speed + ctext->genSlider("振り速さ", &swing_speed, 0.0f, 3.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genLabel(" ", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // ~~ In the case of archers ~~ + ctext->genLabel(" ~~ 矢兵の場合 ~~", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // Command → Ready stance + ctext->genSlider("号令→構えの間", &command_to_ready_stance, 0, 200, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // attack range + ctext->genSlider("攻撃範囲", &attack_range, 0.0f, 2000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // riding firing distance + ctext->genSlider("騎乗発射距離", &mounted_launch_distance, 0.0f, 3000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // wolf takedown power Y + ctext->genSlider("狼倒れ力Y", &wolf_falling_power_y, 0.0f, 50.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // wolf takedown power Z + ctext->genSlider("狼倒れ力Z", &wolf_falling_power_z, 0.0f, 50.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // flying Z (Rider suspended) + ctext->genSlider("飛びZ(騎乗停止)", &jump_z_suspended, 0.0f, 50.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // flying Z + ctext->genSlider("飛びZ", &jump_z, 0.0f, 50.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // flying y + ctext->genSlider("飛びY", &jump_y, 0.0f, 50.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // jump g + ctext->genSlider("飛びG", &jump_g, 0.0f, 20.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + // invincible + ctext->genCheckBox("不死身", &invulnerable, 1, 0, NULL, -1, -1, 0x200, 0x18); + // eye polygons + ctext->genCheckBox("目ポリゴン", &eye_polygon, 1, 0, NULL, -1, -1, 0x200, 0x18); + // one-hit kill + ctext->genCheckBox("一撃必殺", &one_hit_kill, 1, 0, NULL, -1, -1, 0x200, 0x18); + // ikki (da) size + ctext->genSlider("一騎(ダ)サイズ", &field_0x3c, 0.0f, 150.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); +} +#endif + static fopAc_ac_c* get_pla(fopAc_ac_c* a_this) { fopAc_ac_c* player = dComIfGp_getPlayer(0); + // "coach" refers to the Ilia/Telma transport wagon: fopAc_ac_c* actor = fopAcM_SearchByName(PROC_NPC_COACH); if (actor == NULL) { return dComIfGp_getPlayer(0); } - f32 fVar1, fVar2, fVar3, fVar4; - fVar1 = player->current.pos.x - a_this->current.pos.x; - fVar3 = player->current.pos.z - a_this->current.pos.z; - fVar2 = actor->current.pos.x - a_this->current.pos.x; - fVar4 = actor->current.pos.z - a_this->current.pos.z; - if (fVar1 * fVar1 + fVar3 * fVar3 > fVar2 * fVar2 + fVar4 * fVar4) { + + f32 link_rd_x_diff, coach_rd_x_diff, link_rd_z_diff, coach_rd_z_diff; + link_rd_x_diff = player->current.pos.x - a_this->current.pos.x; + link_rd_z_diff = player->current.pos.z - a_this->current.pos.z; + coach_rd_x_diff = actor->current.pos.x - a_this->current.pos.x; + coach_rd_z_diff = actor->current.pos.z - a_this->current.pos.z; + // If the XZ-dist of Link is further than the coach, then focus the coach. + if (SQUARE(link_rd_x_diff) + SQUARE(link_rd_z_diff) > SQUARE(coach_rd_x_diff) + SQUARE(coach_rd_z_diff)) { return actor; } return dComIfGp_getPlayer(0); - } static void anm_init(e_rd_class* i_this, int i_anmID, f32 i_morf, u8 i_mode, f32 i_speed) { @@ -278,22 +331,24 @@ static void horn_anm_init(e_rd_class* i_this, int i_anmID, f32 i_morf, u8 i_mode static int nodeCallBack(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jointNo = i_joint->getJntNo(); + J3DJoint* my_joint = i_joint; + int jointNo = my_joint->getJntNo(); J3DModel* model = j3dSys.getModel(); e_rd_class* i_this = (e_rd_class*)model->getUserArea(); + fopEn_enemy_c* a_this = &i_this->actor; if (i_this != NULL) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); if (jointNo == JNT_KOSI) { if (i_this->field_0x9c8 == 3) { - cMtx_YrotM(*calc_mtx, i_this->field_0x9ca); + cMtx_YrotM(*calc_mtx, s16(i_this->field_0x9ca)); } } else if (jointNo == JNT_HIP1) { if (i_this->field_0x9c8 == 3) { cMtx_XrotM(*calc_mtx, i_this->field_0x9ca); } - cMtx_YrotM(*calc_mtx, i_this->field_0xae0); - cMtx_ZrotM(*calc_mtx, i_this->field_0xabc[2] + (i_this->field_0xade - i_this->field_0xa32[2].x)); + cMtx_YrotM(*calc_mtx, s16(i_this->field_0xade.y)); + cMtx_ZrotM(*calc_mtx, -i_this->field_0xa32[2].x + i_this->field_0xade.x + i_this->field_0xabc[2]); } else if (jointNo == JNT_KOKAL) { cMtx_YrotM(*calc_mtx, i_this->field_0xaca); } else if (jointNo == JNT_SUNEL1) { @@ -304,7 +359,6 @@ static int nodeCallBack(J3DJoint* i_joint, int param_2) { cMtx_ZrotM(*calc_mtx, i_this->field_0xacc[2]); } else if (jointNo == JNT_MUNE2) { cMtx_YrotM(*calc_mtx, i_this->field_0xa32[1].y); - if (i_this->field_0x9c8 == 3) { cMtx_XrotM(*calc_mtx, i_this->field_0x9ca); } @@ -323,15 +377,15 @@ static int nodeCallBack(J3DJoint* i_joint, int param_2) { } } else if (jointNo == JNT_HEAD) { if (i_this->field_0x9c8 != 3 && i_this->field_0x9c8 != 4) { - cMtx_YrotM(*calc_mtx, (i_this->field_0x9ce - i_this->field_0x9ca) / 2); - cMtx_ZrotM(*calc_mtx, (i_this->field_0xabc[0] + (i_this->field_0xa32[0].x - i_this->field_0x9cc)) / 2); + cMtx_YrotM(*calc_mtx, (-i_this->field_0x9ca + i_this->field_0x9ce) / 2); + cMtx_ZrotM(*calc_mtx, (-i_this->field_0x9cc + i_this->field_0xa32[0].x + i_this->field_0xabc[0]) / 2); } } else if (jointNo == JNT_KUBI) { cMtx_YrotM(*calc_mtx, i_this->field_0xa32[0].y); if (i_this->field_0x9c8 != 3 && i_this->field_0x9c8 != 4) { - cMtx_YrotM(*calc_mtx, (i_this->field_0x9ce - i_this->field_0x9ca) / 2); - cMtx_ZrotM(*calc_mtx, (i_this->field_0xabc[0] + (i_this->field_0xa32[0].x - i_this->field_0x9cc)) / 2); + cMtx_YrotM(*calc_mtx, (-i_this->field_0x9ca + i_this->field_0x9ce) / 2); + cMtx_ZrotM(*calc_mtx, (-i_this->field_0x9cc + i_this->field_0xa32[0].x + i_this->field_0xabc[0]) / 2); } else { cMtx_ZrotM(*calc_mtx, i_this->field_0xa32[0].x + i_this->field_0xabc[0]); } @@ -365,9 +419,11 @@ static int nodeCallBack(J3DJoint* i_joint, int param_2) { static int nodeCallBack_B(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jointNo = i_joint->getJntNo(); + J3DJoint* my_joint = i_joint; + int jointNo = my_joint->getJntNo(); J3DModel* model = j3dSys.getModel(); e_rd_class* i_this = (e_rd_class*)model->getUserArea(); + fopEn_enemy_c* a_this = &i_this->actor; if (i_this != NULL) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); @@ -387,10 +443,11 @@ static int nodeCallBack_B(J3DJoint* i_joint, int param_2) { static int nodeCallBack_bow(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jointNo = i_joint->getJntNo(); + J3DJoint* my_joint = i_joint; + int jointNo = my_joint->getJntNo(); J3DModel* model = j3dSys.getModel(); e_rd_class* i_this = (e_rd_class*)model->getUserArea(); - + fopEn_enemy_c* a_this = &i_this->actor; if (i_this != NULL && i_this->field_0x9a8 != 0) { MTXCopy(model->getAnmMtx(jointNo), *calc_mtx); cMtx_ZrotM(*calc_mtx, i_this->field_0x9a8); @@ -405,11 +462,10 @@ static int nodeCallBack_bow(J3DJoint* i_joint, int param_2) { static int daE_RD_Draw(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; J3DModel* model; - J3DModelData* modelData; J3DMaterial* matNode_p; + J3DModelData* model_data; i_this->field_0x5bb = 0; - if (i_this->field_0xafb != 0) { return 1; } @@ -419,19 +475,17 @@ static int daE_RD_Draw(e_rd_class* i_this) { g_env_light.setLightTevColorType_MAJI(model, &a_this->tevStr); if (i_this->mBossMode == 0 && i_this->field_0x968 != 0) { - modelData = model->getModelData(); - for (u16 i = 0; i < modelData->getMaterialNum(); i++) { - matNode_p = modelData->getMaterialNodePointer(i); - matNode_p->getTevColor(0)->r = i_this->field_0x96c; - matNode_p->getTevColor(0)->g = i_this->field_0x96c; - matNode_p->getTevColor(0)->b = i_this->field_0x96c; + model_data = model->getModelData(); + for (u16 i = 0; i < model_data->getMaterialNum(); i++) { + J3DMaterial* mat_node_p = model_data->getMaterialNodePointer(i); + mat_node_p->getTevColor(0)->r = i_this->field_0x96c; + mat_node_p->getTevColor(0)->g = i_this->field_0x96c; + mat_node_p->getTevColor(0)->b = i_this->field_0x96c; } } if (i_this->mBossMode == 3) { - modelData = model->getModelData(); - matNode_p = modelData->getMaterialNodePointer(3); - J3DShape* shape = matNode_p->getShape(); + J3DShape* shape = model->getModelData()->getMaterialNodePointer(3)->getShape(); if (shape != NULL) { shape->hide(); } @@ -440,7 +494,7 @@ static int daE_RD_Draw(e_rd_class* i_this) { i_this->mpModelMorf->entryDL(); if (i_this->mBossMode == 0 && i_this->field_0x968 != 0) { - modelData = model->getModelData(); + J3DModelData* modelData = model->getModelData(); for (u16 i = 0; i < modelData->getMaterialNum(); i++) { matNode_p = modelData->getMaterialNodePointer(i); matNode_p->getTevColor(0)->r = 0; @@ -479,10 +533,9 @@ static int daE_RD_Draw(e_rd_class* i_this) { if (i_this->field_0x1297 != 0) { for (int i = 0; i < 2; i++) { g_env_light.setLightTevColorType_MAJI(i_this->mpEyeModels[i], &a_this->tevStr); - - modelData = i_this->mpEyeModels[i]->getModelData(); - for (u16 j = 0; j < modelData->getMaterialNum(); j++) { - matNode_p = modelData->getMaterialNodePointer(j); + model_data = i_this->mpEyeModels[i]->getModelData(); + for (u16 j = 0; j < model_data->getMaterialNum(); j++) { + matNode_p = model_data->getMaterialNodePointer(j); matNode_p->getTevColor(1)->r = 0xFF; matNode_p->getTevColor(1)->g = 0x8A; matNode_p->getTevColor(1)->b = 0x18; @@ -496,10 +549,10 @@ static int daE_RD_Draw(e_rd_class* i_this) { cXyz sp44; sp44.set(a_this->current.pos.x, a_this->current.pos.y + 100.0f, a_this->current.pos.z); i_this->mShadowKey = dComIfGd_setShadow(i_this->mShadowKey, 1, model, &sp44, - 1200.0f, 0.0f, a_this->current.pos.y, - i_this->mObjAcch.GetGroundH(), i_this->mObjAcch.m_gnd, - &a_this->tevStr, 0, 1.0f, - dDlst_shadowControl_c::getSimpleTex()); + 1200.0f + BREG_F(19), 0.0f, a_this->current.pos.y, + i_this->mObjAcch.GetGroundH(), i_this->mObjAcch.m_gnd, + &i_this->actor.tevStr, 0, 1.0f, + dDlst_shadowControl_c::getSimpleTex()); if (i_this->field_0x5bc == 1) { dComIfGd_addRealShadow(i_this->mShadowKey, i_this->field_0x694); } @@ -520,6 +573,7 @@ static int daE_RD_Draw(e_rd_class* i_this) { static BOOL other_bg_check(e_rd_class* i_this, fopAc_ac_c* i_other) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; dBgS_LinChk lin_chk; + cXyz unused_vec; cXyz start; cXyz end; @@ -547,7 +601,6 @@ static BOOL otoCheck(fopAc_ac_c* i_actor, f32 param_2) { if (sp8c.abs() < param_2) { dBgS_LinChk lin_chk; cXyz start, end; - end = sound->position; end.y += 100.0f; start = i_actor->current.pos; @@ -559,7 +612,7 @@ static BOOL otoCheck(fopAc_ac_c* i_actor, f32 param_2) { } } } - + return FALSE; } @@ -587,11 +640,11 @@ static daE_RD_HIO_c l_HIO; static s16 S_find; -static s8 lbl_70_bss_AE; +static bool lbl_70_bss_AE; static cXyz S_find_pos; -static u8 data_80519200; +static u8 desert_substage; static u8 data_80519201; @@ -602,6 +655,7 @@ static int target_info_count; static s8 data_80519230; static void* s_b_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && dBomb_c::checkBombActor((fopAc_ac_c*)i_actor) && !((dBomb_c*)i_actor)->checkStateExplode() && target_info_count < 10) { target_info[target_info_count] = (fopAc_ac_c*)i_actor; @@ -611,16 +665,80 @@ static void* s_b_sub(void* i_actor, void* i_data) { return NULL; } -static dBomb_c* search_bomb(e_rd_class* i_this, int param_2) { +static dBomb_c* search_bomb(e_rd_class* i_this, int param_1) { if ((i_this->field_0xa20 & 0x10000000) == 0) { return NULL; } + fopAc_ac_c* a_this = &i_this->actor; + dBomb_c* bomb; + target_info_count = 0; for (int i = 0; i < 10; i++) { target_info[i] = NULL; } + // For whatever reason, the original devs omitted this function call. Not sure if intentionall or by mistake. + // In any case, because target_info_count is left at 0 and only incremented + // in s_b_sub, the entire rest of this function disappears in release asm. +#if 0 + fpcM_Search(s_b_sub, i_this); +#endif + + f32 threshold = 100.0f; + f32 compare_val_f = 1500.0f; + if (target_info_count != 0) { + cXyz vec1, vec2, vec3; + for (int i = 0; i < target_info_count;) { + bomb = (dBomb_c*)target_info[i]; + vec1.x = bomb->current.pos.x - a_this->eyePos.x; + vec1.y = 50.0f + bomb->current.pos.y - a_this->eyePos.y; + vec1.z = bomb->current.pos.z - a_this->eyePos.z; + vec2.x = bomb->current.pos.x - a_this->current.pos.x; + vec2.z = bomb->current.pos.z - a_this->current.pos.z; + f32 dist1 = JMAFastSqrt(SQUARE(vec1.x) + SQUARE(vec1.z)); + f32 dist2 = JMAFastSqrt(SQUARE(vec2.x) + SQUARE(vec2.z)); + if (dist1 < threshold && !(dist2 > i_this->mPlayerDistance + 30.0f) + && (!other_bg_check(i_this, bomb) || !param_1)) + { + if (param_1) { + f32 abs_res = fabsf(50.0f + bomb->current.pos.y - a_this->eyePos.y); + if (abs_res <= 300.0f) { + s16 ang_y = a_this->shape_angle.y - cM_atan2s(vec1.x, vec1.z); + if (ang_y < 0) { + ang_y = (-1 * ang_y); + } + + if ((u16)ang_y < 20000) { + return bomb; + } + + cMtx_YrotS(*calc_mtx, -a_this->shape_angle.y); + MtxPosition(&vec1, &vec3); + if (fabsf(vec3.x) < 500.0f && fabsf(vec3.y) < 300.0f + && vec3.z > -125.0f && vec3.z < 500.0f) + { + return bomb; + } + } + } else { + return bomb; + } + } + + i++; + if (i == target_info_count) { + i = 0; + threshold += 100.0f; + if (threshold > compare_val_f) { + return NULL; + } + } + } + } else { + return NULL; + } + return NULL; } @@ -651,7 +769,7 @@ static void ride_off(e_rd_class* i_this) { e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); if (bullbo != NULL) { - bullbo->mStatusFlags &= ~i_this->field_0x9be; + UNSET_FLAG(bullbo->mStatusFlags, i_this->field_0x9be); i_this->field_0x9be = 0; if (bullbo->mActionID != 22 && bullbo->mActionID != 23 && bullbo->mActionID != 24) { @@ -692,13 +810,16 @@ static void ride_off(e_rd_class* i_this) { } static void* s_wb_sub(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_WB && ((e_wb_class*)i_actor)->mActionID != ACTION_DROP && - ((e_wb_class*)i_actor)->mActionID != ACTION_DAMAGE && ((e_wb_class*)i_actor)->mActionID != ACTION_A_DAMAGE && ((e_wb_class*)i_actor)->mActionID != ACTION_STAND) { + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_WB) { + e_wb_class* wild_boar_p = (e_wb_class*) i_actor; e_rd_class* i_this = (e_rd_class*)i_data; - if (i_this->mBossMode == ((e_wb_class*)i_actor)->field_0x79d && - (data_80519230 != 0 || (((e_wb_class*)i_actor)->mStatusFlags & 3) != 3) && target_info_count < 10) { - target_info[target_info_count] = (fopAc_ac_c*)i_actor; - target_info_count++; + if (wild_boar_p->mActionID != ACTION_DROP && wild_boar_p->mActionID != ACTION_DAMAGE + && wild_boar_p->mActionID != ACTION_A_DAMAGE && wild_boar_p->mActionID != ACTION_STAND) { + if (i_this->mBossMode == wild_boar_p->field_0x79d && + (data_80519230 != 0 || (wild_boar_p->mStatusFlags & 3) != 3) && target_info_count < 10) { + target_info[target_info_count] = (fopAc_ac_c*)i_actor; + target_info_count++; + } } } @@ -725,7 +846,7 @@ static fpc_ProcID search_wb(e_rd_class* i_this, s16 param_2) { f32 fVar2 = 1500.0f; // Hyrule Field - Bridge of Eldin if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0 && fopAcM_GetRoomNo(a_this) == 0) { - fVar2 = HREG_F(0) + 5000.0f; + fVar2 = hREG_F(0) + 5000.0f; } if (target_info_count != 0) { @@ -765,13 +886,18 @@ static fpc_ProcID search_wb(e_rd_class* i_this, s16 param_2) { } static void wb_check(e_rd_class* i_this, s16 param_2) { + e_wb_class* bullbo; fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - if (data_80519200 != 118 || fopAcM_GetRoomNo(a_this) != 1) { + if (desert_substage != 118 || fopAcM_GetRoomNo(a_this) != 1) { + // Arbiter's Grounds Exterior - a.k.a. Bulblin camp + // OR most other areas in the game. Except for (non-exhaustive): + // 1. Outside Link's home + // 2. Ordon Spring i_this->mWbActorID = search_wb(i_this, param_2); - e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); + bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); if (bullbo != NULL) { - if (data_80519200 != 0) { + if (desert_substage != 0) { if (i_this->field_0x5bc != 1) { if ((bullbo->mStatusFlags & 1) == 0) { return; @@ -785,10 +911,10 @@ static void wb_check(e_rd_class* i_this, s16 param_2) { i_this->mMode = 0; if ((bullbo->mStatusFlags & 1) == 0) { - bullbo->mStatusFlags |= 1; + bullbo->mStatusFlags |= (u16) 1; i_this->field_0x9be = 1; } else if ((bullbo->mStatusFlags & 2) == 0) { - bullbo->mStatusFlags |= 2; + bullbo->mStatusFlags |= (u16) 2; i_this->field_0x9be = 2; } } @@ -822,7 +948,7 @@ static BOOL pl_check(e_rd_class* i_this, f32 param_2, s16 param_3) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* actor = get_pla(a_this); - if ((data_80519200 == 0 && dComIfGp_event_runCheck())) { + if ((desert_substage == 0 && dComIfGp_event_runCheck())) { return FALSE; } @@ -843,7 +969,8 @@ static BOOL pl_check(e_rd_class* i_this, f32 param_2, s16 param_3) { for (int i = 0; i <= 2; i++) { if (i_this->field_0xd58[i].ChkCoHit()) { - if (daPy_getPlayerActorClass() == dCc_GetAc(i_this->field_0xd58[i].GetCoHitObj()->GetAc())) { + cCcD_Obj* hit_obj = i_this->field_0xd58[i].GetCoHitObj(); + if (daPy_getPlayerActorClass() == dCc_GetAc(hit_obj->GetAc())) { return TRUE; } } @@ -854,10 +981,12 @@ static BOOL pl_check(e_rd_class* i_this, f32 param_2, s16 param_3) { } static dBomb_c* bomb_view_check(e_rd_class* i_this) { + fopEn_enemy_c* unused_p = &i_this->actor; return search_bomb(i_this, 1); } static dBomb_c* bomb_check(e_rd_class* i_this) { + fopEn_enemy_c* unused_p = &i_this->actor; return search_bomb(i_this, 0); } @@ -909,7 +1038,7 @@ static BOOL way_check(e_rd_class* i_this) { dBgS_LinChk lin_chk; lin_chk.Set(&start, &end, a_this); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - sVar1 += 0x1000; + sVar1 += (s16) 0x1000; } else { i_this->field_0x5cc = sVar1; return TRUE; @@ -929,13 +1058,13 @@ static BOOL path_check(e_rd_class* i_this) { cXyz start, end; start = a_this->current.pos; - start.y += hREG_F(0) + 10.0f; + start.y += WREG_F(0) + 10.0f; dPnt* points = i_this->mPath->m_points; for (int i = 0; i < i_this->mPath->m_num; i++, points++) { if (i < 0xFF) { end.x = points->m_position.x; - end.y = points->m_position.y + 10.0f + hREG_F(1); + end.y = points->m_position.y + 10.0f + WREG_F(1); end.z = points->m_position.z; lin_chk.Set(&start, &end, a_this); if (!dComIfG_Bgsp().LineCross(&lin_chk)) { @@ -949,7 +1078,8 @@ static BOOL path_check(e_rd_class* i_this) { f32 fVar2, fVar3, fVar4; f32 fVar1 = 100.0f; bool bVar1 = false; - for (int i = 0; i < 100; i++) { + f32 reg_f27; // unused + for (int i = 0; i < 100;) { points = i_this->mPath->m_points; for (int j = 0; j < i_this->mPath->m_num; j++, points++) { if (j < 0xFF && check_index[j] != 0) { @@ -964,8 +1094,12 @@ static BOOL path_check(e_rd_class* i_this) { } } - if (bVar1) break; - fVar1 += 50.0f; + if (bVar1) { + break; + } + + ++i; + reg_f27 = fVar1 += 50.0f; } if (!bVar1) { @@ -988,118 +1122,121 @@ static void e_rd_normal(e_rd_class* i_this) { if (wb_init_ride(i_this)) { i_this->field_0x5b6 = 0; } - } else { - f32 fVar1 = 0.0f; - s16 sVar1 = 0x4000; - if (data_80519200 != 0) { - sVar1 = 0x6000; - } - switch (i_this->mMode) { - case 0: - if (i_this->field_0x5bd != 0) { - anm_init(i_this, BCK_RD_ARMAMENT, 2.0f, 0, 1.0f); - i_this->mMode = 1; - } else { - i_this->mMode = 2; - } - break; + return; + } - case 1: - if ((int)i_this->mpModelMorf->getFrame() == 11) { - i_this->field_0x5bd = 0; + cXyz unused_vec_0, unused_vec_1; + f32 fVar1 = 0.0f; + s16 sVar1 = 0x4000; + if (desert_substage != 0) { + sVar1 = 0x6000; + } + + switch (i_this->mMode) { + case 0: + if (i_this->field_0x5bd != 0) { + anm_init(i_this, BCK_RD_ARMAMENT, 2.0f, 0, 1.0f); + i_this->mMode = 1; + } else { + i_this->mMode = 2; + } + break; + + case 1: + if ((int)i_this->mpModelMorf->getFrame() == 11) { + i_this->field_0x5bd = 0; + } + + if (i_this->mpModelMorf->isStop()) { + i_this->mMode = 2; + } + break; + + case 2: + if (i_this->field_0x990[0] == 0) { + if (i_this->mPath != NULL && path_check(i_this)) { + i_this->mAction = ACTION_JYUNKAI; + i_this->mMode = 0; + return; } - if (i_this->mpModelMorf->isStop()) { - i_this->mMode = 2; - } - break; - - case 2: - if (i_this->field_0x990[0] == 0) { - if (i_this->mPath != NULL && path_check(i_this)) { - i_this->mAction = ACTION_JYUNKAI; - i_this->mMode = 0; - return; - } - - if (way_check(i_this)) { - anm_init(i_this, BCK_RD_WALK, 10.0f, 2, 1.0f); - i_this->mMode = 3; - i_this->field_0x990[0] = cM_rndF(100.0f) + 100.0f; - } - } else if (data_80519200 != 0) { - sVar1 = 0x7000; - } else { - sVar1 = 0x6000; - } - break; - - case 3: - fVar1 = l_HIO.movement_speed; - if (a_this->speedF >= 3.0f && move_gake_check(i_this, 100.0f)) { - i_this->mMode = 4; - i_this->field_0x990[0] = cM_rndF(100.0f) + 50.0f; - anm_init(i_this, BCK_RD_KYORO2, 10.0f, 2, 1.0f); - } else { - if (i_this->field_0x990[0] == 0 || (a_this->speedF >= 3.0f && way_bg_check(i_this, 200.0f))) { - i_this->mMode = 2; - i_this->field_0x990[0] = cM_rndF(100.0f) + 50.0f; - anm_init(i_this, BCK_RD_KYORO2, 10.0f, 2, 1.0f); - } - } - break; - - case 4: - i_this->field_0x9c8 = 0xFF; - if (i_this->field_0x990[0] == 0) { - i_this->field_0x5cc = a_this->current.angle.y + 0x8000 + (s16)cM_rndFX(4000.0f); + if (way_check(i_this)) { anm_init(i_this, BCK_RD_WALK, 10.0f, 2, 1.0f); i_this->mMode = 3; i_this->field_0x990[0] = cM_rndF(100.0f) + 100.0f; } - } - - if (fVar1) { - cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5cc, 8, 0x400); - s16 sVar1 = a_this->current.angle.y - i_this->field_0x5cc; - if (sVar1 > 0x400 || sVar1 < -0x400) { - fVar1 = 0.0f; - } - } - - cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 3.0f); - f32 fVar2 = i_this->field_0x980; - BOOL bVar1 = FALSE; - if (i_this->field_0x9a1 == 1 || S_find != 0) { - if (i_this->field_0x9a1 == 1) { - bVar1 = TRUE; - } - - fVar2 = 10000.0f; - sVar1 = 0x7FFF; - } - - if (((i_this->field_0x970 & 7) == 0 || bVar1) && i_this->mMode >= 2) { - if ((i_this->field_0x970 & 8) != 0 && !bVar1) { - wb_check(i_this, sVar1); + } else if (desert_substage != 0) { + sVar1 = 0x7000; } else { - if (pl_check(i_this, fVar2, sVar1)) { - if (i_this->field_0x5bc == 1) { - i_this->mAction = ACTION_FIGHT_RUN; - i_this->mMode = 0xFFF6; - i_this->field_0x990[0] = 60; - } else if (i_this->field_0x5bc >= 2) { - i_this->mAction = ACTION_BOW_RUN; - i_this->mMode = 0xFFF6; - } - } + sVar1 = 0x6000; + } + break; - if (bomb_view_check(i_this) != NULL) { - i_this->mAction = ACTION_BOMB; - i_this->mMode = 0; + case 3: + fVar1 = l_HIO.movement_speed; + if (a_this->speedF >= 3.0f && move_gake_check(i_this, 100.0f)) { + i_this->mMode = 4; + i_this->field_0x990[0] = cM_rndF(100.0f) + 50.0f; + anm_init(i_this, BCK_RD_KYORO2, 10.0f, 2, 1.0f); + } else { + if (i_this->field_0x990[0] == 0 || (a_this->speedF >= 3.0f && way_bg_check(i_this, 200.0f))) { + i_this->mMode = 2; + i_this->field_0x990[0] = cM_rndF(100.0f) + 50.0f; + anm_init(i_this, BCK_RD_KYORO2, 10.0f, 2, 1.0f); } } + break; + + case 4: + i_this->field_0x9c8 = 0xFF; + if (i_this->field_0x990[0] == 0) { + i_this->field_0x5cc = a_this->current.angle.y + 0x8000 + (s16)cM_rndFX(4000.0f); + anm_init(i_this, BCK_RD_WALK, 10.0f, 2, 1.0f); + i_this->mMode = 3; + i_this->field_0x990[0] = cM_rndF(100.0f) + 100.0f; + } + } + + if (fVar1) { + cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5cc, 8, 0x400); + s16 sVar1 = a_this->current.angle.y - i_this->field_0x5cc; + if (sVar1 > 0x400 || sVar1 < -0x400) { + fVar1 = 0.0f; + } + } + + cLib_addCalc2(&a_this->speedF, fVar1, 1.0f, 3.0f); + f32 fVar2 = i_this->field_0x980; + BOOL bVar1 = FALSE; + if (i_this->field_0x9a1 == 1 || S_find != 0) { + if (i_this->field_0x9a1 == 1) { + bVar1 = TRUE; + } + + fVar2 = 10000.0f; + sVar1 = 0x7FFF; + } + + if (((i_this->field_0x970 & 7) == 0 || bVar1) && i_this->mMode >= 2) { + if ((i_this->field_0x970 & 8) != 0 && !bVar1) { + wb_check(i_this, sVar1); + } else { + if (pl_check(i_this, fVar2, sVar1)) { + if (i_this->field_0x5bc == 1) { + i_this->mAction = ACTION_FIGHT_RUN; + i_this->mMode = 0xFFF6; + i_this->field_0x990[0] = 60; + } else if (i_this->field_0x5bc >= 2) { + i_this->mAction = ACTION_BOW_RUN; + i_this->mMode = 0xFFF6; + } + } + + if (bomb_view_check(i_this) != NULL) { + i_this->mAction = ACTION_BOMB; + i_this->mMode = 0; + } } } } @@ -1120,7 +1257,7 @@ static void e_rd_fight_run(e_rd_class* i_this) { } f32 fVar1; - if (data_80519200 != 0) { + if (desert_substage != 0) { fVar1 = 24.0f; } else { fVar1 = l_HIO.dash_speed; @@ -1202,7 +1339,7 @@ static void e_rd_fight_run(e_rd_class* i_this) { } fVar3 = 0.0f; - a_this->speedF = fVar3; + a_this->speedF = 0.0f; if (!move_gake_check(i_this, 100.0f)) { i_this->mMode = 2; } @@ -1246,7 +1383,8 @@ static void e_rd_fight_run(e_rd_class* i_this) { i_this->field_0x998 = 20; } else if (i_this->field_0x5bd == 0 && i_this->mPlayerDistance < l_HIO.attack_init_range && i_this->field_0x990[2] == 0) { i_this->field_0x990[2] = cM_rndF(20.0f) + 20.0f; - if (cM_rndF(1.0f) < 0.5f) { + f32 compare_val_f = 0.5f; + if (cM_rndF(1.0f) < compare_val_f) { i_this->mAction = ACTION_FIGHT; i_this->mMode = 0; } @@ -1268,12 +1406,16 @@ static void e_rd_fight_run(e_rd_class* i_this) { } static fopAc_ac_c* at_hit_check(e_rd_class* i_this) { + fopEn_enemy_c* unused_p = &i_this->actor; + fopAc_ac_c* actor_p; if (i_this->mMode >= 10) { return NULL; } if (i_this->field_0x1100.ChkAtHit()) { - return i_this->field_0x1100.GetAtHitObj()->GetAc(); + cCcD_Obj* at_hit_obj_p = i_this->field_0x1100.GetAtHitObj(); + actor_p = dCc_GetAc(at_hit_obj_p->GetAc()); + return actor_p; } return NULL; @@ -1285,12 +1427,13 @@ static void e_rd_fight(e_rd_class* i_this) { int frame = i_this->mpModelMorf->getFrame(); switch (i_this->mMode) { - case 0: - anm_init(i_this, BCK_RD_ATTACK01, HREG_F(0) + 6.0f, 0, 1.0f); + case 0: { + anm_init(i_this, BCK_RD_ATTACK01, TREG_F(14) + 6.0f, 0, 1.0f); if (l_HIO.field_0x38 == 0) { i_this->field_0x990[0] = 25; } else if (l_HIO.field_0x38 == 1) { + // in practice, only goes in here i_this->field_0x990[0] = 15; } else if (l_HIO.field_0x38 == 2) { i_this->field_0x990[0] = 10; @@ -1300,8 +1443,9 @@ static void e_rd_fight(e_rd_class* i_this) { i_this->field_0x990[1] = 5; i_this->mSound.startCreatureVoice(Z2SE_EN_RD_V_WAND_ATTACK, -1); break; + } - case 1: + case 1: { if (i_this->field_0x990[1] != 0) { cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mPlayerAngleY, 4, 0x800); } @@ -1314,12 +1458,13 @@ static void e_rd_fight(e_rd_class* i_this) { i_this->mMode = 2; } break; + } - case 2: + case 2: { if (frame >= 44 && frame <= 47) { i_this->field_0x9ab = 1; } - + if (i_this->mpModelMorf->checkFrame(44.0f)) { i_this->mSound.startCreatureSound(Z2SE_EN_RD_SWING_CLUB, 0, -1); } @@ -1332,6 +1477,7 @@ static void e_rd_fight(e_rd_class* i_this) { if (l_HIO.field_0x38 == 0) { iVar1 = 64; } else if (l_HIO.field_0x38 == 1) { + // in practice, only goes in here iVar1 = 54; } else if (l_HIO.field_0x38 == 2) { iVar1 = 44; @@ -1342,6 +1488,7 @@ static void e_rd_fight(e_rd_class* i_this) { if (l_HIO.field_0x38 == 0) { i_this->field_0x990[0] = 20; } else if (l_HIO.field_0x38 == 1) { + // in practice, only goes in here i_this->field_0x990[0] = 15; } else if (l_HIO.field_0x38 == 2) { i_this->field_0x990[0] = 10; @@ -1349,26 +1496,28 @@ static void e_rd_fight(e_rd_class* i_this) { anm_init(i_this, BCK_RD_KAMAE, 5.0f, 2, 1.0f); } + } + // fallthrough intentional + default: break; case 3: - case 10: + case 10: { if (i_this->field_0x990[0] == 0) { i_this->mAction = ACTION_FIGHT_RUN; i_this->mMode = 0; } - break; + } } cLib_addCalc0(&a_this->speedF, 1.0f, 3.0f); - if (i_this->field_0x9ab != 0) { fopAc_ac_c* actor = at_hit_check(i_this); if (actor != NULL && fopAcM_GetName(actor) == PROC_ALINK) { if (daPy_getPlayerActorClass()->checkPlayerGuard()) { i_this->mpModelMorf->setPlaySpeed(-1.0f); dComIfGp_getVibration().StartShock(4, 31, cXyz(0.0f, 1.0f, 0.0f)); - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 5); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 5); i_this->mMode = 10; i_this->field_0x990[0] = 10; } @@ -1378,9 +1527,10 @@ static void e_rd_fight(e_rd_class* i_this) { static void e_rd_bow_run(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz unused_vec_0, unused_vec_1; f32 fVar1 = 0.0f; f32 fVar2; - if (data_80519200 != 0) { + if (desert_substage != 0) { fVar2 = 24.0f; } else { fVar2 = l_HIO.dash_speed; @@ -1431,7 +1581,7 @@ static void e_rd_bow_run(e_rd_class* i_this) { case 1: fVar1 = fVar2; - playerAngleY += 0x8000; + ADD_ANGLE_2(playerAngleY, 0x8000); if (i_this->mPlayerDistance > l_HIO.attack_range || i_this->field_0x990[0] == 0 || i_this->mObjAcch.ChkWallHit() || move_gake_check(i_this, 100.0f)) { bVar1 = 1; } @@ -1481,12 +1631,14 @@ static void e_rd_bow_run(e_rd_class* i_this) { static void e_rd_bow(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz unused_vec_0, unused_vec_1; int frame = i_this->mpModelMorf->getFrame(); switch (i_this->mMode) { case 0: anm_init(i_this, BCK_RD_SHOOT_READY, 5.0f, 0, 1.0f); - i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), 0, 5.0f, 0.9f, 0.0f, -1.0f); + i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), + 0, 5.0f, 0.9f + TREG_F(3), 0.0f, -1.0f); i_this->mMode = 1; a_this->speedF = 0.0f; break; @@ -1525,12 +1677,12 @@ static void e_rd_bow(e_rd_class* i_this) { break; case 3: - if (frame <= 3) { + if (frame <= 3 + XREG_S(5)) { i_this->field_0x9a2 = 1; i_this->field_0x9c8 = 4; } - if (frame == 2) { + if (frame == 2 + XREG_S(7)) { i_this->field_0x9a3 = 1; } @@ -1562,6 +1714,7 @@ static void* s_command3_sub(void* i_actor, void* i_data) { static s8 e_rd_bow2(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* actor = get_pla(a_this); + cXyz unused_vec_0, unused_vec_1; int frame = i_this->mpModelMorf->getFrame(); s8 rv = 0; @@ -1592,7 +1745,8 @@ static s8 e_rd_bow2(e_rd_class* i_this) { case 2: anm_init(i_this, BCK_RD_SHOOT_READY, 5.0f, 0, 1.0f); - i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), 0, 5.0f, 0.9f, 0.0f, -1.0f); + i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), + 0, 5.0f, 0.9f + TREG_F(3), 0.0f, -1.0f); i_this->mMode = 3; a_this->speedF = 0.0f; break; @@ -1633,12 +1787,12 @@ static s8 e_rd_bow2(e_rd_class* i_this) { break; case 5: - if (frame <= 3) { + if (frame <= 3 + XREG_S(5)) { i_this->field_0x9a2 = 1; i_this->field_0x9c8 = 4; } - if (frame == 2) { + if (frame == 2 + XREG_S(7)) { i_this->field_0x9a3 = 1; } @@ -1663,13 +1817,14 @@ static s8 e_rd_bow2(e_rd_class* i_this) { static void e_rd_bow_ikki(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp2c; + cXyz vec_0x24, vec_0x18; int frame = i_this->mpModelMorf->getFrame(); switch (i_this->mMode) { case 0: anm_init(i_this, BCK_RD_SHOOT_READY, 5.0f, 0, 1.0f); - i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), 0, 5.0f, 0.9f, 0.0f, -1.0f); + i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), + 0, 5.0f, 0.9f + TREG_F(3), 0.0f, -1.0f); i_this->mMode = 1; a_this->speedF = 0.0f; break; @@ -1700,11 +1855,11 @@ static void e_rd_bow_ikki(e_rd_class* i_this) { break; case 3: - if (frame <= 3) { + if (frame <= 3 + XREG_S(5)) { i_this->field_0x9a2 = 1; } - if (frame == 2) { + if (frame == 2 + XREG_S(7)) { i_this->field_0x9a3 = 1; } @@ -1717,8 +1872,8 @@ static void e_rd_bow_ikki(e_rd_class* i_this) { i_this->field_0x9c8 = 14; i_this->field_0x9d4.set(34800.0f, 100.0f, -14900.0f); - sp2c = i_this->field_0x9d4 - a_this->current.pos; - a_this->current.angle.y = cM_atan2s(sp2c.x, sp2c.z); + vec_0x24 = i_this->field_0x9d4 - a_this->current.pos; + a_this->current.angle.y = cM_atan2s(vec_0x24.x, vec_0x24.z); } static void e_rd_avoid(e_rd_class* i_this) { @@ -1729,8 +1884,8 @@ static void e_rd_avoid(e_rd_class* i_this) { case 0: anm_init(i_this, BCK_RD_AVOID, 1.0f, 0, 1.0f); i_this->mMode = 1; - a_this->speedF = -30.0f; - a_this->speed.y = 20.0f; + a_this->speedF = -30.0f + XREG_F(1); + a_this->speed.y = 20.0f + XREG_F(2); i_this->mSound.startCreatureVoice(Z2SE_EN_RD_V_DODGE, -1); break; @@ -1765,7 +1920,7 @@ static void e_rd_wb_search(e_rd_class* i_this) { s8 bVar1 = 0; fopAc_ac_c* bullbo_actor = fopAcM_SearchByID(i_this->mWbActorID); e_wb_class* bullbo = (e_wb_class*)bullbo_actor; - if (bullbo == NULL) { + if (bullbo_actor == NULL) { bVar1 = 1; } else { if (bullbo->mActionID == 22 || bullbo->mActionID == 21 || bullbo->mActionID == 23 || bullbo->mActionID == 24) { @@ -1773,8 +1928,9 @@ static void e_rd_wb_search(e_rd_class* i_this) { } else if (i_this->mMode <= 3) { for (int i = 0; i <= 2; i++) { if (i_this->field_0xd58[i].ChkCoHit()) { - e_wb_class* actor_p = (e_wb_class*)dCc_GetAc(i_this->field_0xd58[i].GetCoHitObj()->GetAc()); - if (actor_p != NULL && actor_p != bullbo && fopAcM_GetName(actor_p) == PROC_E_WB) { + cCcD_Obj* co_hit_obj_p = i_this->field_0xd58[i].GetCoHitObj(); + fopAc_ac_c* actor_p = dCc_GetAc(co_hit_obj_p->GetAc()); + if (actor_p != NULL && actor_p != bullbo_actor && fopAcM_GetName(actor_p) == PROC_E_WB) { bVar1 = 1; } } @@ -1847,7 +2003,7 @@ static void e_rd_wb_search(e_rd_class* i_this) { } sp54 = sp60 - a_this->current.pos; - i_this->field_0x5cc = cM_atan2s(sp54.x, sp54.z); + i_this->field_0x5cc = (s16) cM_atan2s(sp54.x, sp54.z); i_this->mMode = 3; anm_init(i_this, BCK_RD_RUN, 5.0f, 2, 1.5f); } @@ -1872,7 +2028,7 @@ static void e_rd_wb_search(e_rd_class* i_this) { sp60 += bullbo_actor->current.pos; sp54 = sp60 - a_this->current.pos; - i_this->field_0x5cc = cM_atan2s(sp54.x, sp54.z); + i_this->field_0x5cc = (s16) cM_atan2s(sp54.x, sp54.z); cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->field_0x5cc, 2, 0x400); sp54 = sp60 - a_this->current.pos; sp54.y = 0.0f; @@ -1947,64 +2103,71 @@ static void e_rd_wb_search(e_rd_class* i_this) { static void e_rd_wb_ride(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; cXyz sp1c, sp28; - e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); + fopAc_ac_c* wb_actor_p = fopAcM_SearchByID(i_this->mWbActorID); - if (bullbo == NULL) { + if (wb_actor_p == NULL) { i_this->mAction = ACTION_NORMAL; i_this->mMode = 0; ride_off(i_this); - } else if ((bullbo->mStatusFlags & 3) == 0) { + return; + } + + e_wb_class* bullbo = (e_wb_class*) wb_actor_p; + if ((bullbo->mStatusFlags & 3) == 0) { OS_REPORT("......BOSS DL !!!!\n"); if (bullbo->mActionID == 1) { bullbo->mActionID = 0; } fopAcM_delete(a_this); - } else { - switch (i_this->mMode) { - case 0: - i_this->mMode = 1; - if (i_this->mBossMode == 0) { - anm_init(i_this, BCK_RD_JUMP_C, 1.0f, 0, 1.0f); - } - // fallthrough - case 1: - if (i_this->mpModelMorf->isStop() || i_this->mBossMode != 0) { - if (i_this->mBossMode != 0) { - bullbo->mActionMode = 0; - i_this->mMode = 0; + return; + } - if (i_this->mBossMode == 3) { - bullbo->mActionID = 17; - // Hyrule Field - if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0) { - bullbo->mActionMode = -100; - i_this->mAction = ACTION_IKKI2_START; - } else { - i_this->mAction = ACTION_WB_RUN; - } - } else if (i_this->mBossMode == 2) { - bullbo->mActionID = 15; - i_this->mAction = ACTION_WB_RUN; - } else if (i_this->mBossMode == 4) { - bullbo->mActionID = 19; - i_this->mAction = ACTION_LV9_END; - } else if (cDmr_SkipInfo == 0) { - i_this->mAction = ACTION_KIBA_START; - bullbo->mActionID = 30; + switch (i_this->mMode) { + case 0: { + i_this->mMode = 1; + if (i_this->mBossMode == 0) { + anm_init(i_this, BCK_RD_JUMP_C, 1.0f, 0, 1.0f); + } + } + // fallthrough + case 1: { + if (i_this->mpModelMorf->isStop() || i_this->mBossMode != 0) { + if (i_this->mBossMode != 0) { + bullbo->mActionMode = 0; + i_this->mMode = 0; + + if (i_this->mBossMode == 3) { + bullbo->mActionID = 17; + // Hyrule Field + if (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0) { + bullbo->mActionMode = -100; + i_this->mAction = ACTION_IKKI2_START; } else { - bullbo->mActionID = 8; i_this->mAction = ACTION_WB_RUN; - bullbo->field_0x79c = 10; - Z2GetAudioMgr()->subBgmStart(Z2BGM_HORSE_BATTLE); } - } else { - bullbo->mActionID = 6; - bullbo->mActionMode = 0; + } else if (i_this->mBossMode == 2) { + bullbo->mActionID = 15; i_this->mAction = ACTION_WB_RUN; - i_this->mMode = 0; + } else if (i_this->mBossMode == 4) { + bullbo->mActionID = 19; + i_this->mAction = ACTION_LV9_END; + } else if (cDmr_SkipInfo == 0) { + i_this->mAction = ACTION_KIBA_START; + bullbo->mActionID = 30; + } else { + bullbo->mActionID = 8; + i_this->mAction = ACTION_WB_RUN; + bullbo->field_0x79c = 10; + Z2GetAudioMgr()->subBgmStart(Z2BGM_HORSE_BATTLE); } + } else { + bullbo->mActionID = 6; + bullbo->mActionMode = 0; + i_this->mAction = ACTION_WB_RUN; + i_this->mMode = 0; } } + } } } @@ -2263,8 +2426,9 @@ static void e_rd_wb_run(e_rd_class* i_this) { static void* s_wbrun_sub(void* i_actor, void* i_data) { if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_WB) { e_wb_class* bullbo = (e_wb_class*)i_actor; + fopAc_ac_c* actor_p = (fopAc_ac_c*)i_data; if (bullbo->field_0x79d == 0) { - cXyz sp24(bullbo->mEnemy.current.pos - ((fopAc_ac_c*)i_data)->current.pos); + cXyz sp24(bullbo->mEnemy.current.pos - actor_p->current.pos); if (sp24.abs() > KREG_F(11) + 7000.0f) { return i_actor; } @@ -2276,15 +2440,17 @@ static void* s_wbrun_sub(void* i_actor, void* i_data) { static void e_rd_wb_run_B(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); + cXyz unused_vec_0, unused_vec_1; + fopAc_ac_c* base_bulb_p = fopAcM_SearchByID(i_this->mWbActorID); dAttention_c* attention; - if (bullbo != NULL) { + if (base_bulb_p != NULL) { if (i_this->mBossMode == 2 || i_this->mBossMode == 3) { fopAcM_OffStatus(a_this, 0); a_this->attention_info.flags = 0; } + e_wb_class* bullbo = (e_wb_class*) base_bulb_p; if (daPy_getPlayerActorClass()->checkHorseRide()) { attention = dComIfGp_getAttention(); if (attention->Lockon() && a_this == attention->LockonTarget(0)) { @@ -2357,13 +2523,15 @@ static void e_rd_wb_run_B(e_rd_class* i_this) { static void e_rd_wb_bjump(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); + cXyz unused_vec_0, unused_vec_1; + fopAc_ac_c* base_bulb_p = fopAcM_SearchByID(i_this->mWbActorID); dAttention_c* attention; - if (bullbo != NULL) { + if (base_bulb_p != NULL) { + e_wb_class* bullbo = (e_wb_class*) base_bulb_p; if (daPy_getPlayerActorClass()->checkHorseRide()) { attention = dComIfGp_getAttention(); - if (attention->Lockon() && i_this == (e_rd_class*)attention->LockonTarget(0)) { + if (attention->Lockon() && a_this == attention->LockonTarget(0)) { bullbo->field_0x6c0 = 1; } } @@ -2404,6 +2572,7 @@ static void e_rd_bomb_action(e_rd_class* i_this) { cXyz sp48, sp54; dBomb_c* bomb = bomb_check(i_this); if (bomb == NULL) { + int _; // needed to force dbg stack into r31 i_this->mAction = ACTION_FIGHT_RUN; i_this->mMode = 0; return; @@ -2439,7 +2608,7 @@ static void e_rd_bomb_action(e_rd_class* i_this) { } } - sVar1 += 0x8000; + ADD_ANGLE_2(sVar1, 0x8000); fVar1 = l_HIO.dash_speed; if (JMAFastSqrt(sp48.x * sp48.x + sp48.z * sp48.z) > 600.0f) { i_this->mMode = 3; @@ -2508,7 +2677,7 @@ static void e_rd_s_damage(e_rd_class* i_this) { if (i_this->field_0x9be != 0) { e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); if (bullbo != NULL) { - bullbo->mStatusFlags &= ~i_this->field_0x9be; + UNSET_FLAG(bullbo->mStatusFlags, i_this->field_0x9be); } i_this->field_0x9be = 0; @@ -2518,15 +2687,16 @@ static void e_rd_s_damage(e_rd_class* i_this) { case 1: if (i_this->field_0x990[1] != 0) { - a_this->onHeadLockFlg(); + i_this->actor.onHeadLockFlg(); } if (i_this->mpModelMorf->isStop()) { + fopAc_ac_c* pla_p; if (i_this->field_0x974 == 7) { i_this->mAction = ACTION_BOW2; } else if (i_this->field_0x974 == 26) { i_this->mAction = ACTION_BOW3; - } else if (!other_bg_check(i_this, dComIfGp_getPlayer(0))) { + } else if (!other_bg_check(i_this, pla_p = dComIfGp_getPlayer(0))) { i_this->mAction = ACTION_FIGHT_RUN; i_this->field_0x990[0] = 40; } else { @@ -2555,18 +2725,18 @@ static int kado_check(e_rd_class* i_this) { cXyz sp9c, spa8, spb4; BOOL rv = FALSE; - cMtx_YrotS(*calc_mtx, i_this->field_0xa0e); + cMtx_YrotS(*calc_mtx, i_this->field_0xa0c.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; + spa8.y += 100.0f + JREG_F(0); + sp9c.x = JREG_F(1); + sp9c.y = JREG_F(2); + sp9c.z = 70.0f + JREG_F(3); MtxPosition(&sp9c, &spb4); spa8 += spb4; - sp9c.y = 50.0f; - sp9c.z = -150.0f; - sp9c.x = 1.0f * kado_check_x[i]; + sp9c.y = 50.0f + JREG_F(4); + sp9c.z = -150.0f + JREG_F(5); + sp9c.x = (1.0f + JREG_F(6)) * kado_check_x[i]; MtxPosition(&sp9c, &spb4); spb4 += spa8; lin_chk.Set(&spa8, &spb4, a_this); @@ -2590,16 +2760,16 @@ static void rd_disappear(e_rd_class* i_this) { sp1c.set(0.0f, 0.0f, 0.0f); MtxPosition(&sp1c, &sp28); - fopAc_ac_c* actor = fopAcM_SearchByName(PROC_NPC_COACH); - if (actor != NULL) { - fopAcM_createDisappear(a_this, &sp28, 10, 0, 51); + u8 reg_r27 = 0; + if (fopAcM_SearchByName(PROC_NPC_COACH) != NULL) { + fopAcM_createDisappear(a_this, &sp28, 10, reg_r27, 51); } else { - fopAcM_createDisappear(a_this, &sp28, 10, 0, 11); + fopAcM_createDisappear(a_this, &sp28, 10, reg_r27, 11); } fopAcM_delete(a_this); - int swBit = fopAcM_GetParam(a_this) >> 24; + int swBit = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; if (swBit != 0xFF) { dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(a_this)); } @@ -2607,7 +2777,7 @@ static void rd_disappear(e_rd_class* i_this) { if (i_this->field_0x9be != 0) { e_wb_class* bullbo = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); if (bullbo != NULL) { - bullbo->mStatusFlags &= ~i_this->field_0x9be; + UNSET_FLAG(bullbo->mStatusFlags, i_this->field_0x9be); if (bullbo->mActionID == 1) { bullbo->mActionID = 0; } @@ -2616,12 +2786,12 @@ static void rd_disappear(e_rd_class* i_this) { } static BOOL body_gake(e_rd_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; J3DModel* model = i_this->mpModelMorf->getModel(); + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; cXyz sp7c, sp88; MTXCopy(model->getAnmMtx(11), *calc_mtx); - sp7c.set(40.0f, 0.0f, 0.0f); + sp7c.set(40.0f + BREG_F(10), BREG_F(11), BREG_F(12)); MtxPosition(&sp7c, &sp88); dBgS_ObjGndChk gnd_chk; @@ -2637,7 +2807,8 @@ static BOOL body_gake(e_rd_class* i_this) { } static void e_rd_damage(e_rd_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* a_this = &i_this->actor; + fopEn_enemy_c* rd_enemy_p = (fopEn_enemy_c*) a_this; cXyz sp34, sp40; if (a_this->health <= 0) { @@ -2648,7 +2819,7 @@ static void e_rd_damage(e_rd_class* i_this) { i_this->field_0x6d0 = 0.0f; if (daPy_py_c::checkNowWolf() != 0) { - if (i_this->field_0xafa == 0 && a_this->checkWolfDownStartFlg()) { + if (i_this->field_0xafa == 0 && rd_enemy_p->checkWolfDownStartFlg()) { if (i_this->field_0x990[0] > 40) { i_this->field_0x990[0] = 90; OS_REPORT(" RD WOLFHIT LONG \n"); @@ -2664,8 +2835,8 @@ static void e_rd_damage(e_rd_class* i_this) { i_this->field_0x990[1] = 16; i_this->field_0xafa = 1; } - } else if (a_this->checkCutDownHitFlg()) { - a_this->offCutDownHitFlg(); + } else if (rd_enemy_p->checkCutDownHitFlg()) { + rd_enemy_p->offCutDownHitFlg(); i_this->mMode = 3; i_this->field_0x990[0] = 100; i_this->field_0x990[1] = 45; @@ -2673,8 +2844,8 @@ static void e_rd_damage(e_rd_class* i_this) { i_this->mSound.startCreatureVoice(Z2SE_EN_RD_V_DEATH, -1); i_this->field_0x968 = 1; daPy_getPlayerActorClass()->onEnemyDead(); - i_this->field_0xadc = 15; - a_this->offDownFlg(); + i_this->field_0xadc = 15 + TREG_S(7); + rd_enemy_p->offDownFlg(); } s16 sVar1; @@ -2684,14 +2855,14 @@ static void e_rd_damage(e_rd_class* i_this) { i_this->mMode = 1; a_this->speedF = 0.0f; ride_off(i_this); - i_this->field_0xab8 = 8000.0f; + i_this->field_0xab8 = 8000.0f + BREG_F(10); if (a_this->health <= 0) { i_this->mSound.startCreatureVoice(Z2SE_EN_RD_V_DEATH, -1); i_this->field_0x968 = 1; daPy_getPlayerActorClass()->onEnemyDead(); - if (data_80519200 != 0) { + if (desert_substage != 0) { i_this->field_0x5ba = 0; } } else { @@ -2703,37 +2874,38 @@ static void e_rd_damage(e_rd_class* i_this) { case 1: if (i_this->mObjAcch.ChkWallHit() != 0 && i_this->field_0x990[0] == 0) { - int iVar1 = kado_check(i_this); - if (iVar1 != 0) { - OS_REPORT(" ..KADO KABE ..%x\n", iVar1); - if (iVar1 == 2) { + int kado_kabe; + if ((kado_kabe = kado_check(i_this)) != 0) { + OS_REPORT(" ..KADO KABE ..%x\n", kado_kabe); + if (kado_kabe == 2) { i_this->field_0x9f6 = 0x1000; - i_this->field_0xa0e += -7000; + i_this->field_0xa0c.y += (s16) (TREG_S(8) - 7000); } else { i_this->field_0x9f6 = -0x1000; - i_this->field_0xa0e += 7000; + i_this->field_0xa0c.y += (s16) -(TREG_S(8) - 7000); } - i_this->field_0xab8 = 8000.0f; - i_this->field_0xa24 = 100.0f; - i_this->field_0xa2c = 100.0f; + i_this->field_0xab8 = 8000.0f + BREG_F(10); + i_this->field_0xa24 = 100.0f + BREG_F(4); + i_this->field_0xa2c = 100.0f + BREG_F(5); i_this->field_0x990[0] = 60; - } else { - i_this->mMode = 10; - a_this->speed.y = 0.0f; - i_this->field_0x9ec *= 0.2f; - i_this->field_0xa0e += 0x8000; - i_this->field_0xaf0 = 5; - i_this->field_0xa24 = 100.0f; - i_this->field_0xa2c = 100.0f; - i_this->field_0x9f6 = 0; + break; } + + i_this->mMode = 10; + a_this->speed.y = 0.0f; + i_this->field_0x9ec *= 0.2f; + ADD_ANGLE_2(i_this->field_0xa0c.y, 0x8000); + i_this->field_0xaf0 = 5 + BREG_S(7); + i_this->field_0xa24 = 100.0f + BREG_F(4); + i_this->field_0xa2c = 100.0f + BREG_F(5); + i_this->field_0x9f6 = 0; } else { - cLib_addCalcAngleS2(&i_this->field_0xa0c, -0x4000, 1, 0x300); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, -0x4000, 1, 0x300 + BREG_S(4)); a_this->current.angle.y += i_this->field_0x9f6; a_this->shape_angle.y = a_this->current.angle.y; - if (i_this->field_0xa0c <= -0x3000 && i_this->mObjAcch.ChkGroundHit()) { + if (i_this->field_0xa0c.x <= -0x3000 && i_this->mObjAcch.ChkGroundHit()) { i_this->field_0xa1e = 10; if (i_this->field_0x1294 != 0) { @@ -2746,31 +2918,31 @@ static void e_rd_damage(e_rd_class* i_this) { if (i_this->field_0xa1f == 0) { anm_init(i_this, BCK_RD_DIEA, 3.0f, 0, 1.0f); - sVar1 = i_this->field_0xa0e; + sVar1 = (s16) i_this->field_0xa0c.y; } else { - sVar1 = i_this->field_0xa0e + 0x8000; + sVar1 = i_this->field_0xa0c.y + 0x8000; } a_this->current.angle.y = sVar1; if (i_this->field_0x9f8 != 0) { i_this->field_0x9ec = 0.0f; - i_this->field_0xab8 = 2000.0f; + i_this->field_0xab8 = 2000.0f + BREG_F(12); } else { if (i_this->field_0xa1f == 0) { - i_this->field_0xa24 = -100.0f; - i_this->field_0xa2c = -100.0f; + i_this->field_0xa24 = -100.0f - BREG_F(6); + i_this->field_0xa2c = -100.0f - BREG_F(7); } else { - i_this->field_0xa24 = 100.0f; - i_this->field_0xa2c = 100.0f; + i_this->field_0xa24 = 100.0f + BREG_F(4); + i_this->field_0xa2c = 100.0f + BREG_F(5); } i_this->field_0xa28 = -0x5000; i_this->field_0xa30 = -0x4000; i_this->field_0x9ec *= 0.5f; - a_this->speed.y = 20.0f; + a_this->speed.y = 20.0f + TREG_F(6); i_this->field_0x9f6 /= 2; - i_this->field_0xab8 = 8000.0f; + i_this->field_0xab8 = 8000.0f + BREG_F(12); i_this->field_0x125d = 1; } } @@ -2780,14 +2952,14 @@ static void e_rd_damage(e_rd_class* i_this) { case 2: a_this->current.angle.y += i_this->field_0x9f6; a_this->shape_angle.y = a_this->current.angle.y; - cLib_addCalcAngleS2(&i_this->field_0xa0c, -0x4000, 1, 0x300); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, -0x4000, 1, 0x300 + BREG_S(4)); if (i_this->mObjAcch.ChkGroundHit()) { if (a_this->health > 0 && daPy_py_c::checkNowWolf() == 0) { - a_this->onDownFlg(); + rd_enemy_p->onDownFlg(); } - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 5); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 5); i_this->field_0xa1e = 10; if (i_this->field_0xa1f == 0) { @@ -2797,15 +2969,15 @@ static void e_rd_damage(e_rd_class* i_this) { } i_this->field_0x9ec = 0.0f; - i_this->field_0xa0c = -0x4000; + i_this->field_0xa0c.x = -0x4000; if (i_this->field_0xa1f == 0) { - sVar1 = i_this->field_0xa0e; + sVar1 = s16(i_this->field_0xa0c.y); for (int i = 0; i < 4; i++) { i_this->field_0xad2[i] = cM_rndF(10.0f); } } else { - sVar1 = i_this->field_0xa0e + 0x8000; + sVar1 = i_this->field_0xa0c.y + 0x8000; } a_this->current.angle.y = sVar1; @@ -2818,15 +2990,15 @@ static void e_rd_damage(e_rd_class* i_this) { } i_this->mMode = 3; - i_this->field_0xab8 = 1500.0f; + i_this->field_0xab8 = 1500.0f + BREG_F(13); i_this->field_0x125d = 1; } break; case 3: if (body_gake(i_this)) { - i_this->field_0x9ec = -20.0f; - i_this->field_0xa0c -= 0x300; + i_this->field_0x9ec = -20.0f + VREG_F(8); + i_this->field_0xa0c.x -= s16(0x300 + VREG_S(7)); } else { i_this->field_0x9ec = 0.0f; } @@ -2837,8 +3009,8 @@ static void e_rd_damage(e_rd_class* i_this) { } if (daPy_getPlayerActorClass()->getCutType() != daPy_py_c::CUT_TYPE_DOWN && i_this->field_0x990[0] == 0) { - i_this->field_0xa0c = -0x4000; - a_this->offDownFlg(); + i_this->field_0xa0c.x = -0x4000; + rd_enemy_p->offDownFlg(); i_this->mMode = 20; if (i_this->field_0xa1f == 0) { @@ -2851,51 +3023,49 @@ static void e_rd_damage(e_rd_class* i_this) { case 10: if (i_this->field_0xaf0 != 0) { - cLib_addCalcAngleS2(&i_this->field_0xa0c, 0, 1, 0x300); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, 0, 1, 0x300 + BREG_S(4)); } else { - cLib_addCalcAngleS2(&i_this->field_0xa0c, -0x4000, 1, 0x800); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, -0x4000, 1, 0x800 + BREG_S(5)); if (i_this->mObjAcch.ChkGroundHit()) { i_this->mMode = 2; if (i_this->field_0xa1f == 0) { anm_init(i_this, BCK_RD_DIEA, 3.0f, 0, 1.0f); - i_this->field_0xa24 = -100.0f; - i_this->field_0xa2c = -100.0f; + i_this->field_0xa24 = -100.0f - BREG_F(6); + i_this->field_0xa2c = -100.0f - BREG_F(7); } else { - i_this->field_0xa24 = 100.0f; - i_this->field_0xa2c = 100.0f; + i_this->field_0xa24 = 100.0f + BREG_F(4); + i_this->field_0xa2c = 100.0f + BREG_F(5); } i_this->field_0xa28 = -0x5000; i_this->field_0xa30 = -0x4000; i_this->field_0x9ec *= 0.5f; - a_this->speed.y = 20.0f; + a_this->speed.y = 20.0f + TREG_F(6); if (i_this->field_0xa1f == 0) { - sVar1 = i_this->field_0xa0e; + sVar1 = s16(i_this->field_0xa0c.y); } else { - sVar1 = i_this->field_0xa0e + 0x8000; + sVar1 = i_this->field_0xa0c.y + 0x8000; } a_this->current.angle.y = sVar1; - i_this->field_0xab8 = 8000.0f; + i_this->field_0xab8 = 8000.0f + BREG_F(12); } } break; case 20: if (i_this->mpModelMorf->getFrame() >= 35.0f) { - i_this->field_0xa1c = 0; - i_this->field_0xa18 = 0; + i_this->field_0xa18.x = i_this->field_0xa18.z = 0; } if (i_this->mpModelMorf->isStop()) { - i_this->field_0xa0e = 0; - i_this->field_0xa0c = 0; + i_this->field_0xa0c.x = i_this->field_0xa0c.y = 0; anm_init(i_this, BCK_RD_WAIT01, 0.0f, 2, 1.0f); i_this->field_0x990[0] = 5; i_this->mMode = 21; - a_this->offDownFlg(); + rd_enemy_p->offDownFlg(); } break; @@ -2923,7 +3093,7 @@ static void e_rd_damage(e_rd_class* i_this) { break; case 30: - if (!a_this->checkWolfDownPullFlg()) { + if (!rd_enemy_p->checkWolfDownPullFlg()) { i_this->field_0x990[1] = 0; } @@ -2937,8 +3107,8 @@ static void e_rd_damage(e_rd_class* i_this) { i_this->field_0x990[0] = 10; } else if (i_this->field_0x990[1] == 1) { - a_this->onWolfDownPullEndFlg(); - a_this->offCutDownHitFlg(); + rd_enemy_p->onWolfDownPullEndFlg(); + rd_enemy_p->offCutDownHitFlg(); a_this->health = 0; i_this->field_0x990[0] = 1000; i_this->field_0x990[1] = 35; @@ -2948,23 +3118,23 @@ static void e_rd_damage(e_rd_class* i_this) { case 31: if (i_this->field_0x990[0] == 0) { - a_this->offDownFlg(); + rd_enemy_p->offDownFlg(); i_this->mMode = 20; i_this->field_0xafa = 0; } } - if (a_this->checkDownFlg()) { + if (rd_enemy_p->checkDownFlg()) { MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(11), *calc_mtx); sp34.set(BREG_F(0), BREG_F(1), BREG_F(2)); MtxPosition(&sp34, &sp40); - a_this->setDownPos(&sp40); + rd_enemy_p->setDownPos(&sp40); i_this->field_0x9ad = 0; } if (i_this->field_0xadc != 0) { i_this->field_0xadc--; - i_this->field_0xada = i_this->field_0xadc * cM_ssin(i_this->field_0xadc * 0x3800) * 100.0f; + i_this->field_0xada = i_this->field_0xadc * cM_ssin(i_this->field_0xadc * (0x3800 + TREG_S(9))) * (100.0f + TREG_F(5)); } } @@ -2975,7 +3145,7 @@ static s16 gake_check(e_rd_class* i_this, f32 param_2) { cXyz spf8, sp104, start, end; s16 sVar1 = a_this->shape_angle.y; - for (int i = 0; i < 16; i++, sVar1 += 0x1000) { + for (int i = 0; i < 16; i++) { cMtx_YrotS(*calc_mtx, sVar1); start.x = 0.0f; start.y = 100.0f; @@ -2992,13 +3162,15 @@ static s16 gake_check(e_rd_class* i_this, f32 param_2) { return sVar1; } } + + sVar1 += (s16) 0x1000; } return a_this->shape_angle.y; } static void* s_bikkuri_sub(void* i_actor, void* i_data) { - if (fopAc_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && i_actor != i_data) { + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && i_actor != i_data) { if (((e_rd_class*)i_actor)->mAction == ACTION_BOW3 && ((e_rd_class*)i_actor)->mMode <= 2) { cXyz sp28 = ((fopAc_ac_c*)i_actor)->current.pos - ((fopAc_ac_c*)i_data)->current.pos; if (sp28.abs() < KREG_F(11) + 350.0f) { @@ -3013,7 +3185,7 @@ static void* s_bikkuri_sub(void* i_actor, void* i_data) { } static void* s_saku_sub(void* i_actor, void* i_data) { - if (fopAc_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_Obj_H_Saku) { + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_Obj_H_Saku) { cXyz sp14 = ((daObjH_Saku_c*)i_actor)->field_0x5e0 - ((fopAc_ac_c*)i_data)->current.pos; if (sp14.abs() < 200.0f) { return i_actor; @@ -3033,7 +3205,7 @@ static void e_rd_drop(e_rd_class* i_this) { anm_init(i_this, BCK_RD_DAMAGE_S, 2.0f, 0, 1.0f); i_this->mMode = 1; - if (data_80519200 != 0) { + if (desert_substage != 0) { i_this->mDemoMode = 10; } break; @@ -3072,8 +3244,8 @@ static void e_rd_drop(e_rd_class* i_this) { if (move_gake_check(i_this, KREG_F(6) + 30.0f)) { i_this->mMode = 3; - i_this->field_0xa0e = a_this->shape_angle.y + 0x8000; - i_this->field_0xa0c = 0; + i_this->field_0xa0c.y = a_this->shape_angle.y + 0x8000; + i_this->field_0xa0c.x = 0; i_this->mpModelMorf->setPlaySpeed(0.3f); i_this->field_0xaf8 = 0; i_this->field_0x990[0] = 20; @@ -3090,31 +3262,31 @@ static void e_rd_drop(e_rd_class* i_this) { fVar1 = 3.0f; - if (i_this->field_0xa0c > -0x4000) { + if (i_this->field_0xa0c.x > -0x4000) { a_this->speed.y = 0.0f; i_this->mSound.startCreatureVoiceLevel(Z2SE_EN_RD_V_SNIPED_DAMAGE, -1); } else { - if (i_this->field_0xa0c > -0x6800) { - a_this->speed.y = -fabsf(cM_scos(i_this->field_0xa0c) * (TREG_F(8) + 70.0f)); + if (i_this->field_0xa0c.x > -0x6800) { + a_this->speed.y = -fabsf(cM_scos(i_this->field_0xa0c.x) * (TREG_F(8) + 70.0f)); i_this->mSound.startCreatureVoiceLevel(Z2SE_EN_RD_V_SNIPED_FALLING, -1); } else { i_this->mSound.startCreatureVoiceLevel(Z2SE_EN_RD_V_SNIPED_FALLING, -1); } } - cLib_addCalcAngleS2(&i_this->field_0xa0c, -0x7000, 2, i_this->field_0xaf8); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, -0x7000, 2, i_this->field_0xaf8); cLib_addCalcAngleS2(&i_this->field_0xaf8, 0x800, 1, 0x50); i_this->field_0x9ab = 2; - if (i_this->field_0x990[0] == 0 && a_this->current.pos.y <= (KREG_F(17) + i_this->mObjAcch.GetGroundH() + 100.0f)) { + if (i_this->field_0x990[0] == 0 && a_this->current.pos.y <= i_this->mObjAcch.GetGroundH() + 100.0f + KREG_F(17)) { if (i_this->field_0x5b7 == 13 || i_this->field_0x5b7 == 14) { i_this->mAction = ACTION_REG; i_this->mMode = 1; i_this->field_0xafb = 1; i_this->field_0xaf2 = 0; } else { - a_this->current.pos.y = KREG_F(17) + i_this->mObjAcch.GetGroundH() + 100.0f; - i_this->field_0xa0c = -0x4000; + a_this->current.pos.y = i_this->mObjAcch.GetGroundH() + 100.0f + KREG_F(17); + i_this->field_0xa0c.x = -0x4000; i_this->mAction = ACTION_DAMAGE; i_this->mMode = 0; i_this->field_0x9ec = 0.0f; @@ -3140,11 +3312,11 @@ static void e_rd_a_damage(e_rd_class* i_this) { anm_init(i_this, BCK_RD_DEAD_ARROW, 5.0f, 0, 1.0f); i_this->field_0x990[0] = 80; - if (data_80519200 != 0) { + if (desert_substage != 0) { i_this->field_0x5ba = 0; } - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 5); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 5); break; case 1: @@ -3191,12 +3363,23 @@ static void e_rd_stand(e_rd_class* i_this) { } if ((i_this->field_0x970 & 7) == 0 && fopAcM_GetRoomNo(a_this) == 0) { - if ((S_find == 0 || (wb_check(i_this, sVar1), i_this->field_0x9be == 0)) && pl_check(i_this, 500.0f, 0x4000)) { + if (S_find != 0) { + wb_check(i_this, sVar1); + if (i_this->field_0x9be != 0) { + return; + } + } + + if (pl_check(i_this, 500.0f, 0x4000)) { i_this->mAction = ACTION_FIGHT_RUN; i_this->mMode = -10; i_this->field_0x990[0] = 60; } - } else if (((i_this->field_0x970 & 7) == 0 || bVar1) && pl_check(i_this, fVar1, sVar1) && i_this->field_0x5bc == 1) { + + return; + } + + if (((i_this->field_0x970 & 7) == 0 || bVar1) && pl_check(i_this, fVar1, sVar1) && i_this->field_0x5bc == 1) { OS_REPORT(" <<<<<<<<<<<<<< RD RIDE 4\n"); i_this->mAction = ACTION_FIGHT_RUN; i_this->mMode = -10; @@ -3213,8 +3396,10 @@ static s8 e_rd_bow3(e_rd_class* i_this) { i_this->field_0x990[0] = cM_rndF(20.0f) + 80.0f; } + cXyz unused_vec_0, unused_vec_1; int frame = i_this->mpModelMorf->getFrame(); s8 bVar1 = 1; + s8 retval = 0; switch (i_this->mMode) { case 0: @@ -3251,7 +3436,8 @@ static s8 e_rd_bow3(e_rd_class* i_this) { case 10: if (i_this->field_0x990[0] == 0) { anm_init(i_this, BCK_RD_SHOOT_READY, 5.0f, 0, 1.0f); - i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), 0, 5.0f, 0.9f, 0.0f, -1.0f); + i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), + 0, 5.0f, 0.9f + TREG_F(3), 0.0f, -1.0f); i_this->mMode = 11; a_this->speedF = 0.0f; } @@ -3259,7 +3445,6 @@ static s8 e_rd_bow3(e_rd_class* i_this) { case 11: i_this->field_0x9c8 = 4; - if (frame >= 10) { i_this->field_0x9a2 = 1; } @@ -3288,12 +3473,12 @@ static s8 e_rd_bow3(e_rd_class* i_this) { break; case 13: - if (frame <= 3) { + if (frame <= 3 + XREG_S(5)) { i_this->field_0x9a2 = 1; i_this->field_0x9c8 = 4; } - if (frame == 2) { + if (frame == 2 + XREG_S(7)) { i_this->field_0x9a3 = 1; } @@ -3312,11 +3497,13 @@ static s8 e_rd_bow3(e_rd_class* i_this) { i_this->field_0x1295 = 0; } - return 0; + return retval; } static void* s_command2_sub(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->mAction == ACTION_BOW3 && ((e_rd_class*)i_actor)->mMode < 10) { + UNUSED(i_data); + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD + && ((e_rd_class*)i_actor)->mAction == ACTION_BOW3 && ((e_rd_class*)i_actor)->mMode < 10) { ((e_rd_class*)i_actor)->field_0x990[0] = cM_rndF(10.0f) + 10.0f; ((e_rd_class*)i_actor)->mMode = 10; } @@ -3379,7 +3566,7 @@ static void e_rd_commander(e_rd_class* i_this) { i_this->mMode = 7; if (dComIfGp_event_runCheck()) { - i_this->field_0x990[0] = l_HIO.field_0x24 + 2; + i_this->field_0x990[0] = l_HIO.command_to_ready_stance + 2; } else { i_this->field_0x990[0] = 10; } @@ -3471,7 +3658,7 @@ static void e_rd_excite(e_rd_class* i_this) { } sp40 = i_this->field_0x5c0 - a_this->current.pos; - i_this->field_0x5cc = cM_atan2s(sp40.x, sp40.z); + i_this->field_0x5cc = (s16) cM_atan2s(sp40.x, sp40.z); } break; @@ -3510,13 +3697,12 @@ static void e_rd_excite(e_rd_class* i_this) { static void e_rd_water(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - cXyz sp28; i_this->field_0x998 = 10; switch (i_this->mMode) { case 0: - case 1: + case 1: { a_this->speed.y = 0.0f; if (i_this->field_0xa1f == 0) { anm_init(i_this, BCK_RD_DROWNEDA, 3.0f, 2, 1.0f); @@ -3525,11 +3711,8 @@ static void e_rd_water(e_rd_class* i_this) { } i_this->field_0x990[0] = 60; - a_this->speedF = 0.0f; - i_this->field_0x9ec = 0.0f; - i_this->field_0x9f0 = 0.0f; - - sp28 = a_this->current.pos; + i_this->field_0x9f0 = i_this->field_0x9ec = a_this->speedF = 0.0f; + cXyz sp28 = a_this->current.pos; sp28.y = i_this->field_0x984; if (i_this->mMode == 0) { fopKyM_createWpillar(&sp28, 1.5f, 0); @@ -3540,11 +3723,12 @@ static void e_rd_water(e_rd_class* i_this) { i_this->mMode = 10; break; + } case 10: a_this->speed.y = 0.0f; cLib_addCalc2(&a_this->current.pos.y, i_this->field_0x984, 0.5f, 5.0f); - cLib_addCalcAngleS2(&i_this->field_0xa0c, -0x4000, 4, 0x400); + cLib_addCalcAngleS2(&i_this->field_0xa0c.x, -0x4000, 4, 0x400 + BREG_S(4)); if (i_this->field_0x990[0] == 0) { rd_disappear(i_this); @@ -3594,6 +3778,7 @@ static void e_rd_kiba_start(e_rd_class* i_this) { if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_WB_RUN; i_this->mMode = 0; + fopAcM_OnStatus(a_this, 0); // statement does nothing. a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; } } @@ -3655,7 +3840,7 @@ static void e_rd_kiba_end(e_rd_class* i_this) { sp28.y = BREG_F(9) + 20.0f; sp28.z = BREG_F(10) + 57.0f; MtxPosition(&sp28, &i_this->field_0x6b0); - i_this->field_0x6be = a_this->shape_angle.y; + i_this->field_0x6bc.y = a_this->shape_angle.y + BREG_S(0); sp28.x = BREG_F(11) + 80.0f; sp28.y = BREG_F(12); sp28.z = BREG_F(13); @@ -3714,7 +3899,7 @@ static void e_rd_ikki_end(e_rd_class* i_this) { fopAcM_OffStatus(a_this, 0); a_this->attention_info.flags = 0; i_this->field_0x998 = 10; - bullbo->field_0x1434 = fopAcM_GetID(a_this); + bullbo->field_0x1434 = fopAcM_GetID(i_this); switch (i_this->mMode) { case 0: @@ -3723,7 +3908,7 @@ static void e_rd_ikki_end(e_rd_class* i_this) { i_this->field_0x9bc = 0; if (daPy_getPlayerActorClass()->checkHorseRide() && bullbo != NULL) { - bullbo->mStatusFlags &= ~i_this->field_0x9be; + UNSET_FLAG(bullbo->mStatusFlags, i_this->field_0x9be); i_this->field_0x9be = 0; bullbo->mActionID = 16; bullbo->mActionMode = 0; @@ -3731,13 +3916,13 @@ static void e_rd_ikki_end(e_rd_class* i_this) { } a_this->speedF = 0.0f; - a_this->speed.y = 40.0f; - i_this->field_0x9ec = 70.0f; + a_this->speed.y = 40.0f + KREG_F(7); + i_this->field_0x9ec = 70.0f + KREG_F(8); if (fopAcM_searchPlayerAngleY(a_this) < 0) { - i_this->field_0xa0e = 0x4000; + i_this->field_0xa0c.y = 0x4000; } else { - i_this->field_0xa0e = -0x4000; + i_this->field_0xa0c.y = -0x4000; } i_this->mSound.startCreatureVoice(Z2SE_EN_RDB_V_DEATH, -1); @@ -3751,7 +3936,7 @@ static void e_rd_ikki_end(e_rd_class* i_this) { } if (a_this->speed.y < 0.0f) { - cLib_addCalc2(&i_this->field_0x9ec, 0.0f, 0.1f, 1.0f); + cLib_addCalc2(&i_this->field_0x9ec, KREG_F(9), 0.1f, 1.0f); a_this->current.angle.y += i_this->field_0x9f6; } break; @@ -3765,7 +3950,7 @@ static void e_rd_ikki2_end(e_rd_class* i_this) { fopAcM_OffStatus(a_this, 0); a_this->attention_info.flags = 0; i_this->field_0x998 = 10; - bullbo->field_0x1434 = fopAcM_GetID(a_this); + bullbo->field_0x1434 = fopAcM_GetID(i_this); switch (i_this->mMode) { case 0: @@ -3791,27 +3976,28 @@ static void e_rd_ikki2_end(e_rd_class* i_this) { i_this->field_0x9bc = 0; if (bullbo != NULL) { - bullbo->mStatusFlags &= ~i_this->field_0x9be; + UNSET_FLAG(bullbo->mStatusFlags, i_this->field_0x9be); i_this->field_0x9be = 0; } a_this->speedF = 0.0f; - a_this->speed.y = 50.0f; - i_this->field_0x9ec = 60.0f; - i_this->field_0xa0e = 0x4000; + a_this->speed.y = 50.0f + KREG_F(7); + i_this->field_0x9ec = 60.0f + KREG_F(8); + i_this->field_0xa0c.y = 0x4000; i_this->mSound.startCreatureVoice(Z2SE_EN_RDB_V_DEATH, -1); break; case 11: if (a_this->speed.y < 0.0f) { - cLib_addCalc2(&i_this->field_0x9ec, 0.0f, 0.1f, 1.0f); + cLib_addCalc2(&i_this->field_0x9ec, KREG_F(9), 0.1f, 1.0f); } break; } } static void* s_rdb_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RDB) { return i_actor; } @@ -3874,8 +4060,12 @@ static void e_rd_lv9_end(e_rd_class* i_this) { } static void* s_boom_sub(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->field_0x99a != 0) { - return i_actor; + UNUSED(i_data); + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD) { + e_rd_class* i_this = (e_rd_class*) i_actor; + if (i_this->field_0x99a != 0) { + return i_this; + } } return NULL; @@ -3887,7 +4077,7 @@ static void wolfkick_damage(e_rd_class* i_this) { i_this->mAction = ACTION_DAMAGE; i_this->mMode = 0; - i_this->field_0xa0e = player->shape_angle.y + 0x8000; + i_this->field_0xa0c.y = player->shape_angle.y + 0x8000; a_this->speed.y = l_HIO.wolf_falling_power_y; i_this->field_0x9ec = -l_HIO.wolf_falling_power_z; i_this->mSound.startCollisionSE(Z2SE_HIT_WOOD_WEAPON, 31); @@ -3910,12 +4100,12 @@ static void big_damage(e_rd_class* i_this) { i_this->field_0x9ec = 40.0f; } } else { - i_this->field_0x9ec = -l_HIO.field_0x48; + i_this->field_0x9ec = -l_HIO.jump_z_suspended; } - i_this->field_0xa0e = a_this->shape_angle.y + (s16)cM_rndFX(3000.0f); + i_this->field_0xa0c.y = a_this->shape_angle.y + (s16)cM_rndFX(3000.0f); } else { - i_this->field_0xa0e = i_this->mAtInfo.mHitDirection.y; + i_this->field_0xa0c.y = i_this->mAtInfo.mHitDirection.y; i_this->field_0x9ec = -l_HIO.jump_z; } @@ -3931,7 +4121,7 @@ static void big_damage(e_rd_class* i_this) { } else { if (fopAcM_GetName(i_this->mAtInfo.mpActor) == PROC_E_WB) { i_this->field_0x9f6 = cM_rndFX(8000.0f); - a_this->speed.y = cM_rndF(15.0f) + 35.0f; + a_this->speed.y = cM_rndF(15.0f) + (35.0f + TREG_F(17)); i_this->field_0x9ec = -(i_this->mAtInfo.mpActor->speedF * 0.5f); } else { i_this->field_0x9f6 = cM_rndFX(1000.0f); @@ -3968,12 +4158,13 @@ static void small_damage(e_rd_class* i_this, int param_2) { anm_init(i_this, BCK_RD_DAMAGE_W, 2.0f, 0, 1.0f); } - i_this->field_0x9f0 = 20.0f; + i_this->field_0x9f0 = 20.0f + TREG_F(10); i_this->field_0x9f4 = i_this->mAtInfo.mHitDirection.y; } static void part_break(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz unused_vec_0, unused_vec_1; for (int i = 0; i < 14; i++) { if (i_this->field_0x70c[i] == 0) { @@ -3990,7 +4181,7 @@ static void part_break(e_rd_class* i_this) { i_this->field_0x86c[i].y = cM_rndF(65536.0f); i_this->field_0x86c[i].x = cM_rndF(65536.0f); - u16 uVar1 = 1; + u16 uVar1; if (i_this->mAtInfo.mHitStatus != 0) { uVar1 = 3; } else { @@ -4008,35 +4199,38 @@ static void damage_check(e_rd_class* i_this) { daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); fopAc_ac_c* bullbo = fopAcM_SearchByID(i_this->mWbActorID); e_wb_class* bullbo_p = (e_wb_class*)bullbo; - int iVar1; - if (i_this->field_0x9bc == 2 && bullbo != NULL && (bullbo_p->mStatusFlags & 0xC0) != 0) { + if (i_this->field_0x9bc == 2 && bullbo_p != NULL && (bullbo_p->mStatusFlags & 0xC0) != 0) { if (i_this->mAction == ACTION_IKKI2_END) { i_this->mMode = 10; - return; - } - - i_this->mAction = ACTION_DAMAGE; - i_this->mMode = 0; - i_this->field_0x998 = 1000; - - if ((bullbo_p->mStatusFlags & 0x80) != 0) { - i_this->field_0xa0e = a_this->shape_angle.y + 0x8000 + (s16)cM_rndFX(3000.0f); - i_this->field_0x9f6 = (s16)cM_rndFX(1000.0f); } else { - i_this->field_0xa0e = a_this->shape_angle.y + (s16)cM_rndFX(8000.0f); - i_this->field_0x9f6 = (s16)cM_rndFX(3000.0f); + i_this->mAction = ACTION_DAMAGE; + i_this->mMode = 0; + i_this->field_0x998 = 1000; + + if ((bullbo_p->mStatusFlags & 0x80) != 0) { + i_this->field_0xa0c.y = a_this->shape_angle.y + 0x8000 + (s16)cM_rndFX(3000.0f); + i_this->field_0x9f6 = (s16)cM_rndFX(1000.0f); + } else { + i_this->field_0xa0c.y = a_this->shape_angle.y + (s16)cM_rndFX(8000.0f); + i_this->field_0x9f6 = (s16)cM_rndFX(3000.0f); + } + + a_this->speed.y = cM_rndF(15.0f) + (25.0f + TREG_F(13)); + i_this->field_0x9ec = -20.0f + TREG_F(18); } - a_this->speed.y = cM_rndF(15.0f) + 25.0f; - i_this->field_0x9ec = -20.0f; return; } i_this->mStts.Move(); if (i_this->field_0x998 == 0) { - if (i_this->mBossMode != 0) { + if (i_this->mBossMode != 0 +#if DEBUG + || l_HIO.invulnerable +#endif + ) { a_this->health = 100; } @@ -4080,12 +4274,7 @@ static void damage_check(e_rd_class* i_this) { sp40 += a_this->current.pos; cXyz sp4c(2.0f, 2.0f, 2.0f); dComIfGp_setHitMark(uVar1, a_this, &sp40, NULL, &sp4c, 0); - return; - } else { - if (i_this->mAtInfo.mHitType != 1) { - return; - } - + } else if (i_this->mAtInfo.mHitType == 1) { anm_init(i_this, e_rdb_class::BCK_RB_RGUARD_F, 2.0f, 0, 1.0f); bullbo_p->field_0x169e = 25; dScnPly_c::setPauseTimer(0); @@ -4093,7 +4282,8 @@ static void damage_check(e_rd_class* i_this) { cXyz sp58, sp64; cMtx_YrotS(*calc_mtx, bullbo->shape_angle.y); - if ((s16)(a_this->shape_angle.y - i_this->mPlayerAngleY) < 0) { + s16 angle_diff = a_this->shape_angle.y - i_this->mPlayerAngleY; + if (angle_diff < 0) { sp58.set(100.0f, nREG_F(9) + 150.0f, nREG_F(10) + 400.0f); } else { sp58.set(-100.0f, nREG_F(9) + 150.0f, nREG_F(10) + 400.0f); @@ -4107,8 +4297,9 @@ static void damage_check(e_rd_class* i_this) { i_this->mSound.startCollisionSE(Z2SE_HIT_SWORD, 40); i_this->field_0x998 = 30; - return; } + + return; } i_this->field_0x129c = 3; @@ -4133,6 +4324,8 @@ static void damage_check(e_rd_class* i_this) { i_this->field_0x99a = 5; } + s16 cur_health = a_this->health; // unused + OS_REPORT(" HIT AT %d\n", i_this->mAtInfo.mAttackPower); if (i_this->field_0x1295 != 0 && (i_this->mAtInfo.mpCollider->ChkAtType(AT_TYPE_SLINGSHOT) || (i_this->mAtInfo.mHitType != 1 && i_this->mAtInfo.mHitType != 16 && i_this->mAtInfo.mHitType != 2))) { i_this->field_0x998 = 1000; @@ -4167,7 +4360,7 @@ static void damage_check(e_rd_class* i_this) { } if (i_this->mAtInfo.mAttackPower <= 1) { - i_this->field_0x998 = 10; + i_this->field_0x998 = 10 + KREG_S(8); } i_this->field_0xa20 |= i_this->mAtInfo.mHitBit; @@ -4179,9 +4372,9 @@ static void damage_check(e_rd_class* i_this) { if (a_this->health <= 0 || i_this->mAtInfo.mHitStatus != 0 || i_this->field_0x9bc != 0) { if (player->getCutType() == daPy_py_c::CUT_TYPE_JUMP && player->checkCutJumpCancelTurn()) { small_damage(i_this, i); - i_this->field_0x998 = 3; + i_this->field_0x998 = 3 + NREG_S(7); } else { - if (i_this->mBossMode != 0 && bullbo != NULL) { + if (i_this->mBossMode != 0 && bullbo_p != NULL) { i_this->field_0x998 = 20; if (i_this->mBossMode == 2) { bullbo_p->mLapCount++; @@ -4198,25 +4391,25 @@ static void damage_check(e_rd_class* i_this) { mDoAud_bgmStop(30); i_this->mAction = ACTION_IKKI_END; i_this->mMode = 0; - + if ((i_this->mAtInfo.mHitBit & 0x80) != 0) { - i_this->field_0x9f6 = 0x300; + i_this->field_0x9f6 = 0x300 + YREG_S(0); } else { i_this->field_0x9f6 = cM_rndFX(100.0f); } dScnPly_c::setPauseTimer(10); - return; } else { if (i_this->field_0x680 == 0) { - iVar1 = i_this->mAnmID; + int anm_idx = i_this->mAnmID; anm_init(i_this, e_rdb_class::BCK_RB_RDOWNB, 2.0f, 0, 1.0f); - i_this->field_0x680 = iVar1; + i_this->field_0x680 = anm_idx; } i_this->mSound.startCreatureVoice(Z2SE_EN_RDB_V_DAMAGE_L, -1); - return; } + + return; } bullbo_p->mLapCount++; @@ -4257,15 +4450,16 @@ static void damage_check(e_rd_class* i_this) { if (i_this->field_0x680 == 0) { i_this->field_0x990[3] = cM_rndF(100.0f) + 200.0f; - iVar1 = i_this->mAnmID; + int anm_id = i_this->mAnmID; - if ((s16)(a_this->shape_angle.y - i_this->mPlayerAngleY) < 0) { + s16 angle_diff = a_this->shape_angle.y - i_this->mPlayerAngleY; + if (angle_diff < 0) { anm_init(i_this, e_rdb_class::BCK_RB_RDAMAGEL, 2.0f, 0, 1.0f); } else { anm_init(i_this, e_rdb_class::BCK_RB_RDAMAGER, 2.0f, 0, 1.0f); } - i_this->field_0x680 = iVar1; + i_this->field_0x680 = anm_id; } if (i_this->mAction != ACTION_WB_RUN) { @@ -4303,15 +4497,16 @@ static void damage_check(e_rd_class* i_this) { } } - for (int i = 0; i < 3; i++) { + for (int j = 0; j <= 2; j++) { if (a_this->health <= 1) { - i_this->field_0xd58[i].SetTgHitMark((CcG_Tg_HitMark)3); + i_this->field_0xd58[j].SetTgHitMark(CcG_Tg_UNK_MARK_3); } } } } static void* s_other_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->field_0x5b7 != 6) { return i_actor; } @@ -4320,11 +4515,12 @@ static void* s_other_sub(void* i_actor, void* i_data) { } static void* s_ep_sub(void* i_actor, void* i_data) { + UNUSED(i_data); fopAc_ac_c* player = dComIfGp_getPlayer(0); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_Obj_Lv1Cdl00) { if (!fopAcM_isSwitch((fopAc_ac_c*)i_actor, fopAcM_GetParam(i_actor) & 0xFF)) { - f32 fVar1, fVar2; + f32 fVar2, fVar1; fVar2 = ((fopAc_ac_c*)i_actor)->current.pos.x - player->current.pos.x; fVar1 = ((fopAc_ac_c*)i_actor)->current.pos.z - player->current.pos.z; if (JMAFastSqrt(fVar2 * fVar2 + fVar1 * fVar1) < NREG_F(17) + 600.0f) { @@ -4338,6 +4534,7 @@ static void* s_ep_sub(void* i_actor, void* i_data) { static s8 e_rd_yagura(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz unused_vec_0, unused_vec_1; int frame = i_this->mpModelMorf->getFrame(); s8 rv = 1; s8 bVar1 = 0; @@ -4379,14 +4576,15 @@ static s8 e_rd_yagura(e_rd_class* i_this) { anm_init(i_this, BCK_RD_SHOUT, 5.0f, 0, 1.0f); i_this->mMode = 10; i_this->mSound.startCreatureVoice(Z2SE_EN_RD_V_FIND_LINK_YELL, -1); - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 3); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 3); } break; case 10: if (i_this->mpModelMorf->isStop()) { anm_init(i_this, BCK_RD_SHOOT_READY, 5.0f, 0, 1.0f); - i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), 0, 5.0f, 0.9f, 0.0f, -1.0f); + i_this->mpMorfBowAnm->setAnm((J3DAnmTransform*)dComIfG_getObjectRes(i_this->mResName, 7), + 0, 5.0f, 0.9f + TREG_F(3), 0.0f, -1.0f); i_this->mMode = 11; a_this->speedF = 0.0f; } @@ -4423,12 +4621,12 @@ static s8 e_rd_yagura(e_rd_class* i_this) { break; case 13: - if (frame <= 3) { + if (frame <= 3 + XREG_S(5)) { i_this->field_0x9a2 = 1; i_this->field_0x9c8 = 4; } - if (frame == 2) { + if (frame == 2 + XREG_S(7)) { i_this->field_0x9a3 = 1; } @@ -4436,7 +4634,7 @@ static s8 e_rd_yagura(e_rd_class* i_this) { if (pl_check(i_this, 10000.0f, 0x7FFF)) { i_this->mMode = 10; anm_init(i_this, BCK_RD_SHOUT, 5.0f, 0, 1.0f); - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 3); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 3); } else { i_this->mMode = 0; } @@ -4450,7 +4648,7 @@ static s8 e_rd_yagura(e_rd_class* i_this) { if (fabsf(i_this->mObjAcch.GetGroundH() - a_this->home.pos.y) > 10.0f) { i_this->mAction = ACTION_DAMAGE; i_this->mMode = 0; - i_this->field_0xa0e = a_this->shape_angle.y; + i_this->field_0xa0c.y = s16(a_this->shape_angle.y); a_this->speed.y = 20.0f; i_this->field_0x9ec = -20.0f; i_this->field_0x998 = 1000; @@ -4463,8 +4661,9 @@ static s8 e_rd_yagura(e_rd_class* i_this) { anm_init(i_this, BCK_RD_WAIT01, 4.0f, 2, 1.0f); i_this->field_0x990[0] = 30; i_this->mMode = 5; - if (S_find == 0 && (u8)lbl_70_bss_AE == 0 && !daPy_getPlayerActorClass()->checkBoarRide() && !dComIfGp_event_runCheck() && - i_this->mDemoMode == 0 && fpcM_Search(s_other_sub, i_this) != NULL) { + if (S_find == 0 && !lbl_70_bss_AE && !daPy_getPlayerActorClass()->checkBoarRide() + && !dComIfGp_event_runCheck() && i_this->mDemoMode == 0 + && fpcM_Search(s_other_sub, i_this) != NULL) { i_this->mDemoMode = 1; } } @@ -4478,22 +4677,22 @@ static s8 e_rd_yagura(e_rd_class* i_this) { static void e_rd_jyunkai(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + int frame = i_this->mpModelMorf->getFrame(); // unused f32 fVar1 = 0.0f; s16 sVar1 = 0x4000; cXyz sp58, sp64; - dPnt* points; - s8 sVar3; switch (i_this->mMode) { - case 0: + case 0: { anm_init(i_this, BCK_RD_WALK, 10.0f, 2, 1.0f); i_this->mMode = 1; - points = i_this->mPath->m_points; - sVar3 = i_this->field_0xb00; - i_this->field_0x5c0.x = points[sVar3].m_position.x; - i_this->field_0x5c0.y = points[sVar3].m_position.y; - i_this->field_0x5c0.z = points[sVar3].m_position.z; - // fallthrough + dPnt* pnt_p = i_this->mPath->m_points; + pnt_p += i_this->field_0xb00; + i_this->field_0x5c0.x = pnt_p->m_position.x; + i_this->field_0x5c0.y = pnt_p->m_position.y; + i_this->field_0x5c0.z = pnt_p->m_position.z; + } + // fallthrough case 1: fVar1 = l_HIO.movement_speed; sp58 = i_this->field_0x5c0 - a_this->current.pos; @@ -4502,7 +4701,7 @@ static void e_rd_jyunkai(e_rd_class* i_this) { if (sp58.abs() < 50.0f) { i_this->field_0xb00 += i_this->field_0xb01; if (i_this->field_0xb00 >= (i_this->mPath->m_num & 0xFF)) { - if ((i_this->mPath->m_closed & 1) != 0) { + if (dPath_ChkClose(i_this->mPath)) { i_this->field_0xb00 = 0; } else { i_this->field_0xb01 = 0xFF; @@ -4518,7 +4717,7 @@ static void e_rd_jyunkai(e_rd_class* i_this) { anm_init(i_this, BCK_RD_KYORO2, 10.0f, 2, 1.0f); } break; - + case 2: sVar1 = 0x6000; @@ -4530,13 +4729,12 @@ static void e_rd_jyunkai(e_rd_class* i_this) { case 10: anm_init(i_this, BCK_RD_SHOUT, 5.0f, 0, 1.0f); i_this->mMode = 11; - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 3); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 3); S_find = 20; break; case 11: cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mPlayerAngleY, 2, 0x800); - if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_FIGHT_RUN; i_this->mMode = -10; @@ -4647,7 +4845,7 @@ static void e_rd_sleep(e_rd_class* i_this) { case 10: anm_init(i_this, BCK_RD_SHOUT, 5.0f, 0, 1.0f); i_this->mMode = 11; - dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(a_this), 3); + dKy_Sound_set(a_this->current.pos, 100, fopAcM_GetID(i_this), 3); S_find = 20; break; @@ -4665,7 +4863,8 @@ static void e_rd_sleep(e_rd_class* i_this) { if (i_this->mMode < 5) { for (int i = 0; i <= 2; i++) { if (i_this->field_0xd58[i].ChkCoHit()) { - if (daPy_getPlayerActorClass() == dCc_GetAc(i_this->field_0xd58[i].GetCoHitObj()->GetAc())) { + cCcD_Obj* co_hit_obj_p = i_this->field_0xd58[i].GetCoHitObj(); + if (daPy_getPlayerActorClass() == dCc_GetAc(co_hit_obj_p->GetAc())) { cVar1 = 2; break; } @@ -4701,6 +4900,7 @@ static void e_rd_sleep(e_rd_class* i_this) { static int rd_count; static void* s_tag_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->field_0x5ba != 0) { rd_count++; } @@ -4709,16 +4909,15 @@ static void* s_tag_sub(void* i_actor, void* i_data) { } static void e_rd_tag(e_rd_class* i_this) { - // FAKEMATCH fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); i_this->field_0x9ad = 0; i_this->field_0x998 = 10; - if (i_this->mMode) { - // Fakematch to prevent the compiler from optimizing out the unused comparison - a_this->speedF = a_this->speedF; + switch (i_this->mMode) { + case 0: + break; } if (S_find != 0 && (i_this->field_0x970 & 31) == 0 && !dComIfGp_event_runCheck() && i_this->mPlayerDistance < 3000.0f && i_this->mPlayerDistance > 500.0f && @@ -4745,6 +4944,7 @@ static void e_rd_tag(e_rd_class* i_this) { } static void e_rd_reg(e_rd_class* i_this) { + fopEn_enemy_c* a_this = &i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); i_this->field_0x9ad = 0; @@ -4765,15 +4965,13 @@ static void e_rd_reg(e_rd_class* i_this) { return; } - if (i_this->mDemoMode != 0) { - return; - } - - f32 fVar1, fVar2; - fVar1 = player->current.pos.x - -5551.0f; - fVar2 = player->current.pos.z - 5525.0f; - if (JMAFastSqrt(fVar1 * fVar1 + fVar2 * fVar2) < 600.0f) { - i_this->mDemoMode = 20; + if (i_this->mDemoMode == 0) { + f32 fVar1, fVar2; + fVar1 = player->current.pos.x - -5551.0f; + fVar2 = player->current.pos.z - 5525.0f; + if (JMAFastSqrt(fVar1 * fVar1 + fVar2 * fVar2) < 600.0f) { + i_this->mDemoMode = 20; + } } } @@ -4798,9 +4996,10 @@ static void action(e_rd_class* i_this) { i_this->field_0x980 = NREG_F(7) + 10000.0f; } - if (data_80519200 != 0) { + if (desert_substage != 0) { if (i_this->field_0x9a0 == 0) { - int iVar1 = dKy_getEnvlight()->daytime / 15.0f; + dScnKy_env_light_c* env_light_p = dKy_getEnvlight(); + int iVar1 = env_light_p->daytime / 15.0f; if (iVar1 >= 6 && iVar1 <= 17) { i_this->field_0x980 = 10000.0f; } @@ -4809,9 +5008,9 @@ static void action(e_rd_class* i_this) { } } - s16 sVar1 = i_this->mAction; + s16 sp_0x2c = i_this->mAction; damage_check(i_this); - if (sVar1 == ACTION_WB_SEARCH && i_this->mAction != ACTION_WB_SEARCH) { + if (sp_0x2c == ACTION_WB_SEARCH && i_this->mAction != ACTION_WB_SEARCH) { e_wb_class* bullbo_p = (e_wb_class*)fopAcM_SearchByID(i_this->mWbActorID); if (bullbo_p != NULL && bullbo_p->mActionID == 1) { bullbo_p->mActionID = 0; @@ -4822,7 +5021,7 @@ static void action(e_rd_class* i_this) { s8 cVar2 = 0; s8 bVar1 = 1; s8 cVar3 = 0; - a_this->offHeadLockFlg(); + i_this->actor.offHeadLockFlg(); switch (i_this->mAction) { case ACTION_NORMAL: @@ -5015,7 +5214,7 @@ static void action(e_rd_class* i_this) { if (cVar2 != 0) { i_this->mSound.setLinkSearch(true); - if (data_80519200 != 0 && (i_this->field_0x5b7 == 6 || i_this->field_0x5b7 == 7 || i_this->field_0x5b7 == 8)) { + if (desert_substage != 0 && (i_this->field_0x5b7 == 6 || i_this->field_0x5b7 == 7 || i_this->field_0x5b7 == 8)) { S_find = 20; } } else { @@ -5023,7 +5222,7 @@ static void action(e_rd_class* i_this) { } if (cVar1) { - if (data_80519200 != 0) { + if (desert_substage != 0) { if (!dComIfGp_event_runCheck() && i_this->field_0x99c == 0 && i_this->mPlayerDistance > 700.0f && i_this->field_0x5bb != 0) { fopAcM_delete(a_this); } @@ -5040,7 +5239,7 @@ static void action(e_rd_class* i_this) { if (i_this->field_0x9bc == 0) { a_this->attention_info.distances[2] = 3; if (i_this->field_0x9ec) { - cMtx_YrotS(*calc_mtx, i_this->field_0xa0e); + cMtx_YrotS(*calc_mtx, i_this->field_0xa0c.y); if (i_this->field_0xaf0 == 0) { sp25c.z = i_this->field_0x9ec; } else { @@ -5083,13 +5282,12 @@ static void action(e_rd_class* i_this) { cMtx_YrotS(*calc_mtx, i_this->field_0x9f4); MtxPosition(&sp25c, &sp268); a_this->current.pos += sp268; - cLib_addCalc0(&i_this->field_0x9f0, 1.0f, 7.0f); + cLib_addCalc0(&i_this->field_0x9f0, 1.0f, 7.0f + TREG_F(12)); } } else { a_this->attention_info.distances[fopAc_attn_BATTLE_e] = 34; fopAc_ac_c* bullboActor = fopAcM_SearchByID(i_this->mWbActorID); - e_wb_class* bullbo = (e_wb_class*)bullboActor; - if (bullbo == NULL) { + if (bullboActor == NULL) { i_this->mAction = ACTION_NORMAL; i_this->mMode = 0; return; @@ -5103,6 +5301,7 @@ static void action(e_rd_class* i_this) { a_this->speed.set(0.0f, 0.0f, 0.0f); } + e_wb_class* bullbo = (e_wb_class*)bullboActor; if (i_this->field_0x9be == 1) { MTXCopy(bullbo->mpModelMorf->getModel()->getAnmMtx(bullbo->field_0x688 + 15), *calc_mtx); } else { @@ -5118,8 +5317,7 @@ static void action(e_rd_class* i_this) { if (i_this->field_0x9bc == 2) { a_this->current.pos = i_this->field_0x9b0; - a_this->current.angle = bullboActor->shape_angle; - a_this->shape_angle = a_this->current.angle; + a_this->shape_angle = a_this->current.angle = bullboActor->shape_angle; sp25c.x = 10.0f; MtxPosition(&sp25c, &sp268); @@ -5128,7 +5326,7 @@ static void action(e_rd_class* i_this) { a_this->shape_angle.x = a_this->current.angle.x; if (i_this->field_0x9be == 1) { - bullbo->field_0x1434 = fopAcM_GetID(a_this); + bullbo->field_0x1434 = fopAcM_GetID(i_this); } } else { sp25c = i_this->field_0x9b0 - a_this->current.pos; @@ -5149,7 +5347,7 @@ static void action(e_rd_class* i_this) { } i_this->field_0x9c0 += i_this->field_0x9c4; - i_this->field_0x9c4 -= 4.5f; + i_this->field_0x9c4 -= 4.5f + TREG_F(5); if (i_this->field_0x9c0 <= 0.0f) { i_this->field_0x9c0 = 0.0f; @@ -5157,10 +5355,12 @@ static void action(e_rd_class* i_this) { } } - s16 sVar2 = 0; + s16 sp_0x2a = 0; + s16 sp_0x28 = 0; + s16 sp_0x26 = 16000; i_this->field_0x9a4 = 0; cXyz sp274; - s16 sVar3 = 0x1000; + s16 sp_0x24 = 0x1000; if (i_this->field_0x9c8 == -1) { cMtx_YrotS(*calc_mtx, a_this->shape_angle.y); @@ -5171,58 +5371,59 @@ static void action(e_rd_class* i_this) { sp274 += a_this->current.pos; i_this->field_0x9c8 = 2; - sVar3 = KREG_S(7) + 0x800; + sp_0x24 = KREG_S(7) + 0x800; } else if (i_this->field_0x9c8 >= 11) { - i_this->field_0x9c8 -= 10; + i_this->field_0x9c8 -= (s8) 10; sp274 = i_this->field_0x9d4; } else { sp274 = actor->eyePos; } if (i_this->field_0x9bc == 2) { - sVar3 = 0x1000; + sp_0x24 = 0x1000; } if (i_this->field_0x9c8 != 0) { sp25c = sp274 - a_this->current.pos; sp25c.y += TREG_F(2) + -150.0f; - s16 sVar4 = cM_atan2s(sp25c.x, sp25c.z) - a_this->shape_angle.y; - sVar2 = a_this->shape_angle.x + cM_atan2s(sp25c.y, JMAFastSqrt(sp25c.x * sp25c.x + sp25c.z * sp25c.z)); + sp_0x2a = cM_atan2s(sp25c.x, sp25c.z) - a_this->shape_angle.y; + sp_0x28 = a_this->shape_angle.x + cM_atan2s(sp25c.y, JMAFastSqrt(sp25c.x * sp25c.x + sp25c.z * sp25c.z)); if (i_this->field_0x9c8 <= 2) { - if (sVar4 > 0x3E80) { - sVar4 = 16000; - } else if (sVar4 < -16000) { - sVar4 = -16000; + if (sp_0x2a > sp_0x26) { + sp_0x2a = sp_0x26; + } else if (sp_0x2a < (s16) -sp_0x26) { + sp_0x2a = -sp_0x26; } - if (sVar2 > 0x3E80) { - sVar2 = 16000; - } else if (sVar2 < -16000) { - sVar2 = -16000; + if (sp_0x28 > sp_0x26) { + sp_0x28 = sp_0x26; + } else if (sp_0x28 < (s16) -sp_0x26) { + sp_0x28 = -sp_0x26; } - cLib_addCalcAngleS2(&i_this->field_0x9ca, sVar4, 2, sVar3); + cLib_addCalcAngleS2(&i_this->field_0x9ca, sp_0x2a, 2, sp_0x24); } else if (i_this->field_0x9c8 == 5) { if ((i_this->field_0x970 & 15) == 0 && cM_rndF2(1.0f) < 0.3f) { i_this->field_0x9d0 = cM_rndFX2(2000.0f); } } else { - sVar1 = XREG_S(5) + 30000; - if (sVar1 < sVar4) { - sVar4 = sVar1; + sp_0x26 = XREG_S(5) + 30000; + s16 sp_0x22 = (XREG_S(6) + 25000); + if (sp_0x2a > sp_0x26) { + sp_0x2a = sp_0x26; i_this->field_0x9a4 = 1; - } else if (sVar4 < -(XREG_S(6) + 25000)) { - sVar4 = -(XREG_S(6) + 25000); + } else if (sp_0x2a < (s16) -sp_0x22) { + sp_0x2a = -sp_0x22; i_this->field_0x9a4 = 1; } - cLib_addCalcAngleS2(&i_this->field_0x9ca, sVar4 / 2, 2, 0x1000); - sVar2 = -cM_atan2s(sp25c.y, JMAFastSqrt(sp25c.x * sp25c.x + sp25c.z * sp25c.z)); - if (sVar2 > 0x2AF8) { - sVar2 = 11000; + cLib_addCalcAngleS2(&i_this->field_0x9ca, sp_0x2a / 2, 2, 0x1000); + sp_0x28 = -cM_atan2s(sp25c.y, JMAFastSqrt(sp25c.x * sp25c.x + sp25c.z * sp25c.z)); + if (sp_0x28 > 0x2AF8) { + sp_0x28 = 11000; i_this->field_0x9a4 = 1; - } else if (sVar2 < -8000) { - sVar2 = -8000; + } else if (sp_0x28 < -8000) { + sp_0x28 = -8000; i_this->field_0x9a4 = 1; } } @@ -5231,20 +5432,20 @@ static void action(e_rd_class* i_this) { i_this->field_0x9d0 = 0; } - cLib_addCalcAngleS2(&i_this->field_0x9cc, sVar2, 2, sVar3); + cLib_addCalcAngleS2(&i_this->field_0x9cc, sp_0x28, 2, sp_0x24); cLib_addCalcAngleS2(&i_this->field_0x9ce, i_this->field_0x9d0, 4, 0x500); if (fabsf(i_this->field_0xa2c) > 1.0f) { i_this->field_0xa74[1].x = i_this->field_0xa2c * cM_scos(i_this->field_0xa30) * (BREG_F(0) + 70.0f); i_this->field_0xa74[2].x += i_this->field_0xa74[1].x; - cLib_addCalc0(&i_this->field_0xa2c, 1.0f, 3.0f); - i_this->field_0xa30 += 4000; + cLib_addCalc0(&i_this->field_0xa2c, 1.0f, 3.0f + BREG_F(1)); + i_this->field_0xa30 += s16(4000 + BREG_S(0)); } if (fabsf(i_this->field_0xa24) > 1.0f) { i_this->field_0xa74[0].x = i_this->field_0xa24 * cM_scos(i_this->field_0xa28) * (BREG_F(2) + 70.0f); - cLib_addCalc0(&i_this->field_0xa24, 1.0f, 3.0f); - i_this->field_0xa28 += 4000; + cLib_addCalc0(&i_this->field_0xa24, 1.0f, 3.0f + BREG_F(3)); + i_this->field_0xa28 += s16(4000 + BREG_S(1)); } if (a_this->speed.y < 0.0f && i_this->mObjAcch.ChkGroundHit()) { @@ -5253,45 +5454,45 @@ static void action(e_rd_class* i_this) { } if (i_this->field_0x9ec) { - sVar1 = i_this->field_0xa0e - a_this->shape_angle.y; - i_this->field_0xa74[3].y = 0x4000 - sVar1; + sp_0x2a = i_this->field_0xa0c.y - a_this->shape_angle.y; + i_this->field_0xa74[3].y = -sp_0x2a + 0x4000; if (i_this->field_0xa74[3].y > 0x1770) { i_this->field_0xa74[3].y = 6000; } else if (i_this->field_0xa74[3].y < -12000) { i_this->field_0xa74[3].y = -12000; } - i_this->field_0xa74[4].y = 0x4000 - sVar1; + i_this->field_0xa74[4].y = -sp_0x2a + 0x4000; if (i_this->field_0xa74[4].y > 0x3A98) { i_this->field_0xa74[4].y = 15000; } else if (i_this->field_0xa74[4].y < 0) { i_this->field_0xa74[4].y = 0; } - i_this->field_0xa74[5].y = sVar1 + 0x4000; + i_this->field_0xa74[5].y = sp_0x2a + 0x4000; if (i_this->field_0xa74[5].y > 0x1770) { i_this->field_0xa74[5].y = 6000; } else if (i_this->field_0xa74[5].y < -12000) { i_this->field_0xa74[5].y = -12000; } - i_this->field_0xa74[6].y = sVar1 + 0x4000; + i_this->field_0xa74[6].y = sp_0x2a + 0x4000; if (i_this->field_0xa74[6].y > 0x3A98) { i_this->field_0xa74[6].y = 15000; } else if (i_this->field_0xa74[6].y < 0) { i_this->field_0xa74[6].y = 0; } - cMtx_YrotS(*calc_mtx, sVar1); + cMtx_YrotS(*calc_mtx, sp_0x2a); sp25c.x = 0.0f; sp25c.y = 0.0f; sp25c.z = 12000.0f; MtxPosition(&sp25c, &sp268); - i_this->field_0xae6 = -sp268.x; - i_this->field_0xae4 = -sp268.z * 1.3f; + i_this->field_0xae4.y = -sp268.x; + i_this->field_0xae4.x = -sp268.z * 1.3f; - if (i_this->field_0xae4 > 10000) { - i_this->field_0xae4 = 10000; + if (i_this->field_0xae4.x > 10000) { + i_this->field_0xae4.x = 10000; } } @@ -5306,19 +5507,20 @@ static void action(e_rd_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0xa32[i].x, i_this->field_0xa74[i].x, 2, j_spd[i]); cLib_addCalcAngleS2(&i_this->field_0xa32[i].y, i_this->field_0xa74[i].y, 2, j_spd[i]); cLib_addCalcAngleS2(&i_this->field_0xa32[i].z, i_this->field_0xa74[i].z, 2, j_spd[i]); - i_this->field_0xa74[i].z = 0; - i_this->field_0xa74[i].x = 0; + i_this->field_0xa74[i].x = i_this->field_0xa74[i].z = 0; if (i >= 3 && i <= 6) { - if (i_this->field_0xacc[i] == 0) { + if (i_this->field_0xad2[i - 3] == 0) { + s16 sp_0x20; if (i == 4 || i == 6) { - sVar3 = 0x600; + sp_0x20 = 0x600; } else { - sVar3 = 0x800; + sp_0x20 = 0x800; } - cLib_addCalcAngleS2(&i_this->field_0xa74[i].y, 0, 1, sVar3); + + cLib_addCalcAngleS2(&i_this->field_0xa74[i].y, 0, 1, sp_0x20); } else { - i_this->field_0xacc[i]--; + --i_this->field_0xad2[i - 3]; } } else { i_this->field_0xa74[i].y = 0; @@ -5329,17 +5531,16 @@ static void action(e_rd_class* i_this) { } } - cLib_addCalc0(&i_this->field_0xab8, 1.0f, 100.0f); - cLib_addCalcAngleS2(&i_this->field_0xae0, i_this->field_0xae6, 2, 0x800); - cLib_addCalcAngleS2(&i_this->field_0xade, i_this->field_0xae4, 2, 0x800); - i_this->field_0xae4 = 0; - i_this->field_0xae6 = 0; - s32 sVar4 = 0; + cLib_addCalc0(&i_this->field_0xab8, 1.0f, 100.0f + BREG_F(11)); + cLib_addCalcAngleS2(&i_this->field_0xade.y, i_this->field_0xae4.y, 2, 0x800); + cLib_addCalcAngleS2(&i_this->field_0xade.x, i_this->field_0xae4.x, 2, 0x800); + i_this->field_0xae4.y = i_this->field_0xae4.x = 0; + s16 sVar4 = 0; s16 sVar5 = 0; if (i_this->field_0xa1e != 0) { i_this->field_0xa1e--; - if (i_this->field_0xa0c != 0) { + if (i_this->field_0xa0c.x != 0) { Vec sp280; cXyz sp28c, sp298; dBgS_GndChk gnd_chk; @@ -5360,8 +5561,11 @@ static void action(e_rd_class* i_this) { gnd_chk.SetPos(&sp280); sp280.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + f32 x_diff, y_diff, z_diff; if (sp280.y != -G_CM3D_F_INF) { - sVar5 = -cM_atan2s(sp280.y - sp28c.y, sp280.z - sp28c.z); + y_diff = sp280.y - sp28c.y; + z_diff = sp280.z - sp28c.z; + sVar5 = -cM_atan2s(y_diff, z_diff); if (sVar5 > 0x3000 || sVar5 < -0x3000) { sVar5 = 0; } @@ -5374,7 +5578,9 @@ static void action(e_rd_class* i_this) { sp280.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (sp280.y != -G_CM3D_F_INF) { - sVar4 = cM_atan2s(sp280.y - sp28c.y, sp280.x - sp28c.x); + y_diff = sp280.y - sp28c.y; + x_diff = sp280.x - sp28c.x; + sVar4 = (s16) cM_atan2s(y_diff, x_diff); if (sVar4 > 0x3000 || sVar4 < -0x3000) { sVar4 = 0; } @@ -5403,13 +5609,13 @@ static void action(e_rd_class* i_this) { a_this->current.pos += sp268; } - i_this->field_0xa18 = sVar5; - i_this->field_0xa1c = sVar4; + i_this->field_0xa18.x = sVar5; + i_this->field_0xa18.z = sVar4; } } - cLib_addCalcAngleS2(&i_this->field_0xa12, i_this->field_0xa18, 1, 0x400); - cLib_addCalcAngleS2(&i_this->field_0xa16, i_this->field_0xa1c, 1, 0x400); + cLib_addCalcAngleS2(&i_this->field_0xa12.x, i_this->field_0xa18.x, 1, 0x400); + cLib_addCalcAngleS2(&i_this->field_0xa12.z, i_this->field_0xa18.z, 1, 0x400); if (i_this->field_0x129c != 0) { i_this->field_0x129c--; @@ -5419,7 +5625,8 @@ static void action(e_rd_class* i_this) { } if (i_this->field_0x125d != 0) { - MTXCopy(i_this->mpModelMorf->getModel()->getAnmMtx(11), *calc_mtx); + J3DModel* model_p = i_this->mpModelMorf->getModel(); + MTXCopy(model_p->getAnmMtx(11), *calc_mtx); sp25c.set(0.0f, 0.0f, 0.0f); MtxPosition(&sp25c, &sp268); @@ -5434,11 +5641,12 @@ static void action(e_rd_class* i_this) { 0x825A, }; - cXyz sp2c8(1.0f, 1.0f, 1.0f); + f32 reg_f30 = 1.0f; + cXyz prtcl_scale(reg_f30, reg_f30, reg_f30); csXyz cStack_330(0, 0, 0); for (int i = 0; i < 3; i++) { i_this->field_0x1268[i] = dComIfGp_particle_set(i_this->field_0x1268[i], w_eff_name[i], &sp268, &a_this->tevStr, - &cStack_330, &sp2c8, 0xFF, 0, -1, NULL, NULL, NULL); + &cStack_330, &prtcl_scale, 0xFF, 0, -1, NULL, NULL, NULL); } } else { fopAcM_effSmokeSet1(&i_this->field_0x1260, &i_this->field_0x1264, &sp268, NULL, 1.3f, &a_this->tevStr, 1); @@ -5497,15 +5705,20 @@ static void fire_eff_set(e_rd_class* i_this) { } static void* s_wb_sub2(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_WB && target_info_count < 2) { - target_info[target_info_count] = (fopAc_ac_c*)i_actor; - target_info_count++; + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_WB) { + e_wb_class* unused_wb_p = (e_wb_class*) i_actor; + fopAc_ac_c* unused_actor_p = (fopAc_ac_c*) i_data; + if (target_info_count < 2) { + target_info[target_info_count] = (fopAc_ac_c*) i_actor; + target_info_count++; + } } return NULL; } static void* s_lv9dn_sub(void* i_actor, void* i_data) { + UNUSED(i_data); 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; @@ -5515,6 +5728,7 @@ static void* s_lv9dn_sub(void* i_actor, void* i_data) { } static void* s_lv9dn_sub2(void* i_actor, void* i_data) { + UNUSED(i_data); 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; @@ -5524,6 +5738,7 @@ static void* s_lv9dn_sub2(void* i_actor, void* i_data) { } static void* s_lv9dn_sub3(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_DN) { ((e_dn_class*)i_actor)->mode = 2; } @@ -5532,6 +5747,7 @@ static void* s_lv9dn_sub3(void* i_actor, void* i_data) { } static void* s_lv9rd_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->field_0xafb != 0) { ((e_rd_class*)i_actor)->field_0xafb = 0; } @@ -5542,25 +5758,26 @@ static void* s_lv9rd_sub(void* i_actor, void* i_data) { static u8 data_80519338; static void* s_lv9rd_sub2(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && ((e_rd_class*)i_actor)->field_0x5b7 == data_80519338 && ((e_rd_class*)i_actor)->mAction != ACTION_DROP) { - e_rd_class* i_this = (e_rd_class*)i_actor; - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - - i_this->mAction = ACTION_DROP; - i_this->mMode = 2; - anm_init(i_this, BCK_RD_FURA2, 2.0f, 2, 1.0f); - i_this->field_0x990[0] = 1000; - i_this->field_0x5cc = a_this->home.angle.y; - dComIfGp_setHitMark(1, a_this, &a_this->eyePos, NULL, NULL, 0); - i_this->mSound.startCollisionSE(Z2SE_HIT_WOOD_WEAPON, 31); + UNUSED(i_data); + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD + && ((e_rd_class*)i_actor)->field_0x5b7 == data_80519338 && ((e_rd_class*)i_actor)->mAction != ACTION_DROP) { + ((e_rd_class*)i_actor)->mAction = ACTION_DROP; + ((e_rd_class*)i_actor)->mMode = 2; + anm_init((e_rd_class*)i_actor, BCK_RD_FURA2, 2.0f, 2, 1.0f); + ((e_rd_class*)i_actor)->field_0x990[0] = 1000; + ((e_rd_class*)i_actor)->field_0x5cc = ((fopEn_enemy_c*)i_actor)->home.angle.y; + dComIfGp_setHitMark(1, ((fopEn_enemy_c*)i_actor), &((fopEn_enemy_c*)i_actor)->eyePos, NULL, NULL, 0); + ((e_rd_class*)i_actor)->mSound.startCollisionSE(Z2SE_HIT_WOOD_WEAPON, 31); return i_actor; } - + return NULL; } static void* s_lv9rd_sub3(void* i_actor, void* i_data) { - if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD && (((e_rd_class*)i_actor)->field_0x5b7 == 13 || ((e_rd_class*)i_actor)->field_0x5b7 == 14)) { + UNUSED(i_data); + if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_RD + && (((e_rd_class*)i_actor)->field_0x5b7 == 13 || ((e_rd_class*)i_actor)->field_0x5b7 == 14)) { ((e_rd_class*)i_actor)->field_0x9a4 = 1; ((e_rd_class*)i_actor)->field_0x980 = 50000.0f; } @@ -5569,6 +5786,7 @@ static void* s_lv9rd_sub3(void* i_actor, void* i_data) { } static void* s_lv9arrow_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_ARROW) { ((e_arrow_class*)i_actor)->field_0xa14 = 1; } @@ -5577,6 +5795,7 @@ static void* s_lv9arrow_sub(void* i_actor, void* i_data) { } static void* s_lv9arrow_sub2(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_E_ARROW) { ((e_arrow_class*)i_actor)->field_0xa14 = 0; ((e_arrow_class*)i_actor)->mAction = ACTION_BOW_RUN; @@ -5613,7 +5832,8 @@ static void demo_camera(e_rd_class* i_this) { daNPC_TK_c* hawk_p = (daNPC_TK_c*) fopAcM_SearchByName(PROC_NPC_TK); fopAc_ac_c* a_hwk = hawk_p; cXyz sp38, sp44, sp50, sp5c; - s8 bVar1 = 0; + bool sp_0x9 = true; // unused + s8 bVar1 = false; s16 sVar1 = 0; switch (i_this->mDemoMode + 1) { @@ -5631,23 +5851,24 @@ static void demo_camera(e_rd_class* i_this) { camera->mCamera.SetTrimSize(3); i_this->mDemoCamCenter = a_this->current.pos; - i_this->mDemoCamCenter.y = a_this->eyePos.y - 80.0f + 60.0f; + i_this->mDemoCamCenter.y = a_this->eyePos.y - 80.0f + 60.0f + TREG_F(5); i_this->field_0x1300 = 2000.0f; a_this->current.angle.y = i_this->mPlayerAngleY; // fallthrough case 3: if (i_this->field_0x12a6 < 85) { - mDoMtx_stack_c::YrotS(a_this->current.angle.y); + mDoMtx_stack_c::YrotS(s16(a_this->current.angle.y)); mDoMtx_stack_c::XrotM(0x640); sp38.x = 0.0f; sp38.y = TREG_F(3); sp38.z = i_this->field_0x1300; mDoMtx_stack_c::multVec(&sp38, &i_this->mDemoCamEye); i_this->mDemoCamEye += a_this->current.pos; - cLib_addCalc2(&i_this->mDemoCamCenter.y, a_this->eyePos.y - 80.0f + 60.0f, 0.1f, 20.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.y, a_this->eyePos.y - 80.0f + 60.0f + TREG_F(5), 0.1f, 20.0f); cLib_addCalc2(&i_this->field_0x1300, 400.0f, 0.5f, 150.0f); - } else if (data_80519200 == 124) { - lbl_70_bss_AE = 1; + } else if (desert_substage == 124) { + // main Gerudo Desert + lbl_70_bss_AE = true; target_info_count = 0; for (int i = 0; i < 2; i++) { target_info[i] = NULL; @@ -5657,16 +5878,16 @@ static void demo_camera(e_rd_class* i_this) { if (target_info[0] != NULL && target_info[1] != NULL) { i_this->mDemoCamCenter = target_info[0]->current.pos + ((target_info[1]->current.pos - target_info[0]->current.pos) * 0.5f); - i_this->mDemoCamCenter.y += 200.0f; + i_this->mDemoCamCenter.y += 200.0f + BREG_F(7); if (i_this->field_0x12a6 == 85) { i_this->mDemoCamEye = i_this->mDemoCamCenter; - i_this->mDemoCamEye.y += 100.0f; - i_this->mDemoCamEye.z += 900.0f; + i_this->mDemoCamEye.y += 100.0f + VREG_F(8); + i_this->mDemoCamEye.z += 900.0f + VREG_F(9); } else { cLib_addCalc2(&i_this->mDemoCamEye.x, i_this->mDemoCamCenter.x, 0.2f, 100.0f); - cLib_addCalc2(&i_this->mDemoCamEye.y, i_this->mDemoCamCenter.y + 100.0f, 0.2f, 100.0f); - cLib_addCalc2(&i_this->mDemoCamEye.z, i_this->mDemoCamCenter.z + 900.0f, 0.2f, 100.0f); + cLib_addCalc2(&i_this->mDemoCamEye.y, i_this->mDemoCamCenter.y + 100.0f + VREG_F(8), 0.2f, 100.0f); + cLib_addCalc2(&i_this->mDemoCamEye.z, i_this->mDemoCamCenter.z + 900.0f + VREG_F(9), 0.2f, 100.0f); } } @@ -5699,7 +5920,7 @@ static void demo_camera(e_rd_class* i_this) { i_this->field_0x1300 = 2000.0f; // fallthrough case 12: - mDoMtx_stack_c::YrotS(a_this->current.angle.y); + mDoMtx_stack_c::YrotS(s16(a_this->current.angle.y)); mDoMtx_stack_c::XrotM(0x640); sp38.x = 0.0f; sp38.y = TREG_F(3); @@ -5720,9 +5941,9 @@ static void demo_camera(e_rd_class* i_this) { cLib_addCalc2(&i_this->mDemoCamCenter.x, a_this->eyePos.x, 0.1f, 10.0f); cLib_addCalc2(&i_this->mDemoCamCenter.z, a_this->eyePos.z, 0.1f, 10.0f); - cLib_addCalc2(&i_this->mDemoCamCenter.y, a_this->eyePos.y - 80.0f + 60.0f, 0.1f, 100.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.y, a_this->eyePos.y - 80.0f + 60.0f + TREG_F(5), 0.1f, 100.0f); - if (i_this->field_0x12a6 == 100) { + if (i_this->field_0x12a6 == s16(100 + KREG_S(8))) { bVar1 = true; } break; @@ -5780,7 +6001,7 @@ static void demo_camera(e_rd_class* i_this) { if (i_this->field_0x12a6 >= 70) { sp44.set(-5182.0f, 2000.0f, 5237.0f); - daPy_getPlayerActorClass()->setPlayerPosAndAngle(&sp44, 0xFFFFE051, 0); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&sp44, -8111, 0); } if (i_this->field_0x12a6 == 120 || i_this->field_0x12a6 == 130 @@ -5863,10 +6084,10 @@ static void demo_camera(e_rd_class* i_this) { i_this->field_0x980 = 0.0f; if (i_this->field_0x12a6 >= 4) { - i_this->mBlureRate = 200; + i_this->mBlureRate = 200 + VREG_S(7); sVar1 = cM_scos(i_this->field_0x12a6 * 0x500) * 2500.0f; - i_this->field_0x130c = 0.03f; - cam_3d_morf(i_this, 0.5f); + i_this->field_0x130c = 0.03f + BREG_F(16); + cam_3d_morf(i_this, 0.5f + BREG_F(17)); if (i_this->field_0x12a6 == 4) { fpcM_Search(s_lv9arrow_sub, i_this); @@ -5953,7 +6174,7 @@ static void demo_camera(e_rd_class* i_this) { if (i_this->field_0x12a6 == 177) { sp44.set(-5821.0f, 2000.0f, 5850.0f); dBomb_c::createNormalBombExplode(&sp44); - dComIfGs_onTmpBit(dSv_event_tmp_flag_c::tempBitLabels[0x76]); + dComIfGs_onTmpBit((u16) dSv_event_tmp_flag_c::tempBitLabels[0x76]); } if (i_this->field_0x12a6 == 180) { @@ -6074,7 +6295,7 @@ static void demo_camera(e_rd_class* i_this) { i_this->mDemoCamEye.set(-4274.0f, 272.0f, 7969.0f); i_this->mDemoMode = 33; i_this->field_0x12a6 = 0; - dComIfGs_onTmpBit(dSv_event_tmp_flag_c::tempBitLabels[0x75]); + dComIfGs_onTmpBit((u16) dSv_event_tmp_flag_c::tempBitLabels[0x75]); } break; @@ -6100,7 +6321,7 @@ static void demo_camera(e_rd_class* i_this) { i_this->mDemoCamFovy = 55.0f; i_this->mDemoMode = 35; i_this->field_0x12a6 = 0; - dComIfGs_onTmpBit(dSv_event_tmp_flag_c::tempBitLabels[0x74]); + dComIfGs_onTmpBit((u16) dSv_event_tmp_flag_c::tempBitLabels[0x74]); } break; @@ -6219,7 +6440,7 @@ static int daE_RD_Execute(e_rd_class* i_this) { if (i_this->field_0x9bc != 2 && i_this->field_0xaf0 == 0 && i_this->mAction != ACTION_IKKI_END) { spa4.set(0.0f, 0.0f, 0.0f); if (i_this->field_0x9ec) { - cMtx_YrotS(*calc_mtx, i_this->field_0xa0e); + cMtx_YrotS(*calc_mtx, i_this->field_0xa0c.y); sp98.x = 0.0f; sp98.y = TREG_F(8); sp98.z = i_this->field_0xaec; @@ -6229,7 +6450,7 @@ static int daE_RD_Execute(e_rd_class* i_this) { cLib_addCalc0(&i_this->field_0xaec, 1.0f, TREG_F(17) + 5.0f); } - if (i_this->mAnmID == BCK_RD_DIEB && i_this->field_0xa0c != 0 && i_this->field_0xa1f == 0) { + if (i_this->mAnmID == BCK_RD_DIEB && i_this->field_0xa0c.x != 0 && i_this->field_0xa1f == 0) { spa4.y += KREG_F(0) + -20.0f; } @@ -6252,7 +6473,7 @@ static int daE_RD_Execute(e_rd_class* i_this) { i_this->mMode = 0; a_this->speed.y = 0.0f; i_this->field_0x9ec = -1.0f; - i_this->field_0xa0c = -0x3000; + i_this->field_0xa0c.x = -0x3000; i_this->field_0x998 = 1000; a_this->health = 0; } @@ -6269,18 +6490,18 @@ static int daE_RD_Execute(e_rd_class* i_this) { if (i_this->field_0xafb == 0) { mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y + i_this->field_0x9c0, a_this->current.pos.z); - mDoMtx_stack_c::XrotM((s16) i_this->field_0xa12); - mDoMtx_stack_c::ZrotM((s16) i_this->field_0xa16); - mDoMtx_stack_c::YrotM((s16) i_this->field_0xa0e); - mDoMtx_stack_c::XrotM((s16) i_this->field_0xa0c); - mDoMtx_stack_c::YrotM(-i_this->field_0xa0e); + mDoMtx_stack_c::XrotM((s16) i_this->field_0xa12.x); + mDoMtx_stack_c::ZrotM((s16) i_this->field_0xa12.z); + mDoMtx_stack_c::YrotM((s16) i_this->field_0xa0c.y); + mDoMtx_stack_c::XrotM((s16) i_this->field_0xa0c.x); + mDoMtx_stack_c::YrotM(-i_this->field_0xa0c.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); f32 fVar1 = l_HIO.model_size * a_this->scale.x; if (i_this->mBossMode != 0) { - fVar1 *= l_HIO.field_0xc; + fVar1 *= l_HIO.leader_size_ratio; } mDoMtx_stack_c::scaleM(fVar1, fVar1, fVar1); @@ -6429,10 +6650,10 @@ static int daE_RD_Execute(e_rd_class* i_this) { if (i_this->field_0x9bc == 2) { a_this->attention_info.position = a_this->current.pos; - a_this->attention_info.position.y += 190.0f; + a_this->attention_info.position.y += 190.0f + JREG_F(8); if (i_this->mBossMode != 0) { - a_this->attention_info.position.y += 120.0f; + a_this->attention_info.position.y += 120.0f + JREG_F(9); } } else { a_this->attention_info.position = a_this->eyePos; @@ -6488,7 +6709,7 @@ static int daE_RD_Execute(e_rd_class* i_this) { } if (i_this->mBossMode == 3) { - for (int j = 0; j < 3; j++) { + for (int j = 0; j <= 2; j++) { i_this->field_0xd58[j].SetTgType(0x2022); i_this->field_0xd58[j].OnTgNoHitMark(); } @@ -6691,13 +6912,13 @@ static int daE_RD_Execute(e_rd_class* i_this) { } else { i_this->field_0x71c[i] += i_this->field_0x7c4[i]; i_this->field_0x7c4[i].y -= 3.0f; - i_this->field_0x86c[i].y += 0x900; - i_this->field_0x86c[i].x += 0xB00; + i_this->field_0x86c[i].y += (s16) 0x900; + i_this->field_0x86c[i].x += (s16) 0xB00; mDoMtx_stack_c::transS(i_this->field_0x71c[i].x, i_this->field_0x71c[i].y, i_this->field_0x71c[i].z); mDoMtx_stack_c::YrotM(i_this->field_0x86c[i].y); mDoMtx_stack_c::XrotM(i_this->field_0x86c[i].x); - f32 my_scale = l_HIO.field_0xc * (l_HIO.model_size * a_this->scale.x); + f32 my_scale = l_HIO.leader_size_ratio * (l_HIO.model_size * a_this->scale.x); mDoMtx_stack_c::scaleM(my_scale, my_scale, my_scale); i_this->mpBossArmorParts[i]->setBaseTRMtx(mDoMtx_stack_c::get()); @@ -6723,15 +6944,15 @@ static int daE_RD_Execute(e_rd_class* i_this) { i_this->field_0x6a4 += i_this->field_0x6b0; i_this->field_0x6b0.y -= 5.0f; MtxTrans(i_this->field_0x6a4.x, i_this->field_0x6a4.y, i_this->field_0x6a4.z, 0); - f32 fVar4 = l_HIO.field_0xc * ( l_HIO.model_size * a_this->scale.x); + f32 fVar4 = l_HIO.leader_size_ratio * ( l_HIO.model_size * a_this->scale.x); MtxScale(fVar4, fVar4, fVar4, 1); MtxTrans(BREG_F(5) + 80.0f, BREG_F(6) + 50.0f, BREG_F(7), 1); - cMtx_YrotM(*calc_mtx, i_this->field_0x6be); + cMtx_YrotM(*calc_mtx, i_this->field_0x6bc.y); cMtx_XrotM(*calc_mtx, 0x7FFF); - cMtx_ZrotM(*calc_mtx, i_this->field_0x6c0); + cMtx_ZrotM(*calc_mtx, i_this->field_0x6bc.z); MtxTrans(-(BREG_F(5) + 80.0f), -(BREG_F(6) + 50.0f), -(BREG_F(7) + 0.0f), 1); - i_this->field_0x6be += 0x200; - i_this->field_0x6c0 += 0xF00; + i_this->field_0x6bc.y += (s16) 0x200; + i_this->field_0x6bc.z += (s16) 0xF00; } i_this->mpMorfHornAnm->getModel()->setBaseTRMtx(*calc_mtx); @@ -6777,12 +6998,12 @@ static int daE_RD_Execute(e_rd_class* i_this) { sp98.z = (BREG_F(12) + 40.0f) - 30.0f; MtxPosition(&sp98, &spb0); spb0 += spa4; - a_this->setDownPos(&spb0); + i_this->actor.setDownPos(&spb0); } cXyz spd4(a_this->eyePos); spd4.y += NREG_F(7) + 130.0f; - a_this->setHeadLockPos(&spd4); + i_this->actor.setHeadLockPos(&spd4); demo_camera(i_this); i_this->field_0x5bb = 1; a_this->attention_info.flags |= fopAc_AttnFlag_UNK_0x200000; @@ -6794,16 +7015,18 @@ static u8 jv_offset[12] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; -static int daE_RD_IsDelete(e_rd_class* i_this) { +static int daE_RD_IsDelete(e_rd_class*) { return 1; } static int daE_RD_Delete(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAcM_RegisterDeleteID(i_this, "E_RD"); dComIfG_resDelete(&i_this->mPhase, i_this->mResName); if (i_this->field_0x125c != 0) { hio_set = 0; + mDoHIO_DELETE_CHILD(l_HIO.field_0x4); } if (a_this->heap != NULL) { @@ -6830,13 +7053,13 @@ static void ride_game_actor_set(e_rd_class* i_this) { }; dBgS_GndChk gnd_chk; + u32 i_parameters; int iVar1 = 6; if (i_this->mBossMode >= 2) { iVar1 = 1; } for (int i = 0; i < iVar1; i++) { - u32 i_parameters; if (i_this->mBossMode == 1) { cMtx_YrotS(*calc_mtx, player->shape_angle.y); sp70 = set_pos[i]; @@ -6850,7 +7073,7 @@ static void ride_game_actor_set(e_rd_class* i_this) { gnd_chk.SetPos(&i_pos); i_pos.y = dComIfG_Bgsp().GroundCross(&gnd_chk); i_angle = player->shape_angle; - i_angle.y += 0x4000; + i_angle.y += (s16) 0x4000; i_parameters = 0x80000005; } else if (i_this->mBossMode == 2) { i_pos.set(34789.0f, -290.0f, -36177.0f); @@ -6882,6 +7105,7 @@ static void ride_game_actor_set(e_rd_class* i_this) { static void coach_game_actor_set(e_rd_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); + cXyz ununsed_vec_0, ununsed_vec_1; csXyz i_angle; OS_REPORT("COATH GAME ACTOR SET \n"); @@ -6905,8 +7129,8 @@ static s8 instanceCount; static int useHeapInit(fopAc_ac_c* a_this) { e_rd_class* i_this = (e_rd_class*)a_this; - J3DModel* model; J3DModelData* modelData; + J3DModel* model; if (i_this->mBossMode != 0) { i_this->mpModelMorf = new mDoExt_McaMorfSO((J3DModelData*)dComIfG_getObjectRes("E_rdb", e_rdb_class::BMDR_RB), NULL, NULL, @@ -6977,13 +7201,13 @@ static int useHeapInit(fopAc_ac_c* a_this) { return 0; } - model = i_this->mpModelMorf->getModel(); - model->setUserArea((uintptr_t)i_this); + J3DModel* model_2 = i_this->mpModelMorf->getModel(); + model_2->setUserArea((uintptr_t)i_this); mDoMtx_stack_c::scaleS(0.0f, 0.0f, 0.0f); - model->setBaseTRMtx(mDoMtx_stack_c::get()); + model_2->setBaseTRMtx(mDoMtx_stack_c::get()); - for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { - model->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); + for (u16 i = 0; i < model_2->getModelData()->getJointNum(); i++) { + model_2->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); } if (i_this->field_0x5bc == 1) { @@ -7009,13 +7233,13 @@ static int useHeapInit(fopAc_ac_c* a_this) { return 0; } - model = i_this->mpMorfBowAnm->getModel(); - model->setUserArea((uintptr_t)i_this); - model->setBaseTRMtx(mDoMtx_stack_c::get()); + model_2 = i_this->mpMorfBowAnm->getModel(); + model_2->setUserArea((uintptr_t)i_this); + model_2->setBaseTRMtx(mDoMtx_stack_c::get()); - for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { + for (u16 i = 0; i < model_2->getModelData()->getJointNum(); i++) { if (i == 2 || i == 3) { - model->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack_bow); + model_2->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack_bow); } } @@ -7053,11 +7277,11 @@ static int useHeapInit(fopAc_ac_c* a_this) { static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { e_rd_class* i_this = (e_rd_class*)a_this; - fopAcM_ct(a_this, e_rd_class); + fopAcM_ct(&i_this->actor, e_rd_class); i_this->field_0x5b6 = fopAcM_GetParam(a_this); i_this->field_0x5b7 = i_this->field_0x5b6; - i_this->field_0x5b8 = fopAcM_GetParam(a_this) >> 12 & 15; + i_this->field_0x5b8 = (fopAcM_GetParam(a_this) & 0xF000) >> 12; if (i_this->field_0x5b8 == 15) { i_this->field_0x5b8 = 0; } @@ -7082,17 +7306,17 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { if (phase == cPhs_COMPLEATE_e) { if (strcmp(dComIfGp_getStartStageName(), "F_SP124") == 0) { // Gerudo Desert - data_80519200 = 124; + desert_substage = 124; } else { if (strcmp(dComIfGp_getStartStageName(), "F_SP118") == 0) { - // Arbiter's Grounds Exterior - data_80519200 = 118; + // Arbiter's Grounds Exterior - a.k.a. Bulblin camp + desert_substage = 118; } else { - data_80519200 = 0; + desert_substage = 0; } } - int swBit = fopAcM_GetParam(a_this) >> 24; + int swBit = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; if (swBit != 0xFF) { if (dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(a_this))) { return cPhs_ERROR_e; @@ -7109,7 +7333,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->field_0x5b6 = 1; } - i_this->field_0x5bc = fopAcM_GetParam(a_this) >> 8 & 15; + i_this->field_0x5bc = (fopAcM_GetParam(a_this) & 0xF00) >> 8; if (i_this->field_0x5bc == 15) { i_this->field_0x5bc = 0; } @@ -7118,7 +7342,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { return cPhs_ERROR_e; } - i_this->field_0x5ba = fopAcM_GetParam(a_this) >> 16; + i_this->field_0x5ba = (fopAcM_GetParam(a_this) & 0xFF0000) >> 16; if (i_this->field_0x5ba == 0xFF) { i_this->field_0x5ba = 0; } @@ -7127,7 +7351,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { fopAcM_setStageLayer(a_this); } - i_this->field_0x5b9 = fopAcM_GetParam(a_this) >> 24; + i_this->field_0x5b9 = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; if (i_this->field_0x5b8 == 3 || i_this->field_0x5b8 == 4 || i_this->field_0x5b8 == 5 || i_this->field_0x5b8 == 6 || i_this->field_0x5b8 == 7) { if (i_this->field_0x5b8 != 5) { i_this->field_0x1295 = 1; @@ -7155,7 +7379,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->field_0x5b8 = 3; } else if (i_this->field_0x5b8 == 10) { i_this->mAction = ACTION_BOW_IKKI; - i_this->field_0x990[0] = 142; + i_this->field_0x990[0] = 142 + XREG_S(2); } else if (i_this->field_0x5b8 == 11) { fopAcM_create(PROC_E_RDY, fopAcM_GetParam(a_this), &a_this->home.pos, fopAcM_GetRoomNo(a_this), &a_this->home.angle, NULL, -1); @@ -7180,22 +7404,24 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->mAction = ACTION_YAGURA; i_this->field_0x99c = 30; S_find = 0; - lbl_70_bss_AE = 0; + lbl_70_bss_AE = false; if (fopAcM_GetRoomNo(a_this) == 0) { fopAcM_setCullSizeFar(a_this, 30000.0f); } } else if (i_this->field_0x5b6 == 7) { i_this->mAction = ACTION_NORMAL; - if ((u32)(a_this->home.angle.x & 0xFF) != 0xFF) { - i_this->mPath = dPath_GetRoomPath(a_this->home.angle.x & 0xFF, fopAcM_GetRoomNo(a_this)); + u8 path_idx = a_this->home.angle.x & 0xFF; + if ((u32)(path_idx) != 0xFF) { + i_this->mPath = dPath_GetRoomPath(path_idx, fopAcM_GetRoomNo(a_this)); OS_REPORT("//////////////E_RD PPD %x!!\n", i_this->mPath); if (i_this->mPath == NULL) { OS_REPORT("......RD NONONONONONO PATH !!!!\n"); return cPhs_ERROR_e; } - OS_REPORT("//////////////E_RD P0.y %f\n", i_this->mPath->m_points->m_position.y); + dPnt* pnt_p = i_this->mPath->m_points; + OS_REPORT("//////////////E_RD P0.y %f\n", pnt_p->m_position.y); } } else if (i_this->field_0x5b6 == 8) { i_this->mAction = ACTION_SLEEP; @@ -7228,12 +7454,8 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->field_0x5b6 = 0; } - a_this->shape_angle.x = 0; - a_this->current.angle.x = 0; - a_this->home.angle.x = 0; - a_this->shape_angle.z = 0; - a_this->current.angle.z = 0; - a_this->home.angle.z = 0; + a_this->home.angle.z = a_this->current.angle.z = a_this->shape_angle.z + = a_this->home.angle.x = a_this->current.angle.x = a_this->shape_angle.x = 0; u32 i_size; if (i_this->mBossMode == 1) { @@ -7258,7 +7480,8 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { if (hio_set == 0) { i_this->field_0x125c = 1; hio_set = 1; - l_HIO.field_0x4 = -1; + // "rider" + l_HIO.field_0x4 = mDoHIO_CREATE_CHILD("ライダー", &l_HIO); } fopAcM_SetMtx(a_this, i_this->mpModelMorf->getModel()->getBaseTRMtx()); @@ -7268,8 +7491,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { &i_this->mAcchCir, fopAcM_GetSpeed_p(a_this), NULL, NULL); i_this->mAcchCir.SetWall(50.0f, 50.0f); - a_this->health = 40; - a_this->field_0x560 = 40; + a_this->field_0x560 = a_this->health = 40; i_this->mStts.Init(150, 0, a_this); @@ -7307,7 +7529,7 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->field_0x1100.Set(at_sph_src); i_this->field_0x1100.SetStts(&i_this->mStts); - i_this->field_0x970 = instanceCount | (u16)(cM_rndF(65535.0f)) & 0xFF00; + i_this->field_0x970 = instanceCount | (u16(cM_rndF(65535.0f)) & 0xFF00); instanceCount++; i_this->mSound.init(&a_this->current.pos, &a_this->eyePos, 3, 1); @@ -7327,10 +7549,11 @@ static cPhs__Step daE_RD_Create(fopAc_ac_c* a_this) { i_this->field_0x9a0 = 5; - if (!dStage_stagInfo_GetSTType(dComIfGp_getStage()->getStagInfo())) { + stage_stag_info_class* stage_info = dComIfGp_getStage()->getStagInfo(); + if (!dStage_stagInfo_GetSTType(stage_info)) { i_this->field_0x1298 = l_HIO.eye_polygon; - if (data_80519200 != 0 || strcmp(dComIfGp_getStartStageName(), "F_SP115") == 0 || + if (desert_substage != 0 || strcmp(dComIfGp_getStartStageName(), "F_SP115") == 0 || (strcmp(dComIfGp_getStartStageName(), "F_SP121") == 0 && fopAcM_GetRoomNo(a_this) == 0)) { // Lake Hylia or Hyrule Field fopAcM_OffStatus(a_this, fopAcM_STATUS_UNK_0x4000); diff --git a/src/d/actor/d_a_e_st.cpp b/src/d/actor/d_a_e_st.cpp index 40b67695fe..77b85f7b0a 100644 --- a/src/d/actor/d_a_e_st.cpp +++ b/src/d/actor/d_a_e_st.cpp @@ -241,6 +241,18 @@ daE_ST_HIO_c::daE_ST_HIO_c() { field_0x20 = -1.0f; } +#if DEBUG +void daE_ST_HIO_c::genMessage(JORMContext* ctext) { + // "stalchura" - a.k.a. skultula + ctext->genLabel(" スタルチュラ", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genSlider("基本サイズ", &basic_size, 0.0f, 5.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genSlider("PL認識距離", &pl_recognize_dist, 0.0f, 5000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genSlider("戦闘開始距離", &combat_start_dist, 0.0f, 1000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genSlider("攻撃前間", &time_before_attack, 0, 50, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); + ctext->genSlider("ダウン時間", &down_time, 0, 300, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 24); +} +#endif + static void anm_init(e_st_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 i_rate) { i_this->mpModelMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("E_st", i_index), i_attr, i_morf, i_rate, 0.0f, -1.0f); i_this->mAnm = i_index; @@ -248,29 +260,31 @@ static void anm_init(e_st_class* i_this, int i_index, f32 i_morf, u8 i_attr, f32 static int nodeCallBack(J3DJoint* i_joint, int param_2) { if (param_2 == 0) { - int jntNo = i_joint->getJntNo(); + J3DJoint* my_joint = i_joint; + int jntNo = my_joint->getJntNo(); J3DModel* model = j3dSys.getModel(); e_st_class* i_this = (e_st_class*)model->getUserArea(); + fopAc_ac_c* sp_0x10 = &i_this->actor; if (i_this != NULL) { MTXCopy(model->getAnmMtx(jntNo), *calc_mtx); if (jntNo >= JNT_LLEGA_1 && jntNo <= JNT_LLEGA_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[0].mAngles[jntNo - 2]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[0].mAngles[jntNo - JNT_LLEGA_1]); } else if (jntNo >= JNT_LLEGB_1 && jntNo <= JNT_LLEGB_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[0].mAngles[jntNo + 7]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[1].mAngles[jntNo - JNT_LLEGB_1]); } else if (jntNo >= JNT_LLEGC_1 && jntNo <= JNT_LLEGC_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[1].mAngles[jntNo + 4]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[2].mAngles[jntNo - JNT_LLEGC_1]); } else if (jntNo >= JNT_LLEGD_1 && jntNo <= JNT_LLEGD_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[2].mAngles[jntNo + 1]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[3].mAngles[jntNo - JNT_LLEGD_1]); } else if (jntNo >= JNT_RLEGA_1 && jntNo <= JNT_RLEGA_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[3].mAngles[jntNo - 2]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[4].mAngles[jntNo - JNT_RLEGA_1]); } else if (jntNo >= JNT_RLEGB_1 && jntNo <= JNT_RLEGB_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[3].mAngles[jntNo + 7]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[5].mAngles[jntNo - JNT_RLEGB_1]); } else if (jntNo >= JNT_RLEGC_1 && jntNo <= JNT_RLEGC_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[4].mAngles[jntNo + 4]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[6].mAngles[jntNo - JNT_RLEGC_1]); } else if (jntNo >= JNT_RLEGD_1 && jntNo <= JNT_RLEGD_3) { - cMtx_ZrotM(*calc_mtx, i_this->mStFeet[5].mAngles[jntNo + 1]); + cMtx_ZrotM(*calc_mtx, i_this->mStFeet[7].mAngles[jntNo - JNT_RLEGD_1]); } if (jntNo == TREG_S(0)) { @@ -371,9 +385,9 @@ static BOOL pl_check(e_st_class* i_this, f32 i_distance) { if (player->current.pos.y - a_this->current.pos.y >= 750.0f || dComIfGp_event_runCheck()) { return FALSE; } - + if (i_this->mPlayerDistance < i_distance) { - player = (fopAc_ac_c*)dComIfGp_getPlayer(0); + daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); pos_delta = player->current.pos - a_this->current.pos; cMtx_XrotS(*calc_mtx, -i_this->field_0x69c.x); cMtx_YrotM(*calc_mtx, -i_this->field_0x69c.y); @@ -497,9 +511,9 @@ static void damage_check(e_st_class* i_this) { static int move_bg_check(e_st_class* i_this) { dBgS_LinChk lin_chk; + int rv = 0; cXyz spa0, spac; - int rv = 0; lin_chk.Set(&i_this->field_0x6bc, &i_this->field_0x6c8, NULL); if (dComIfG_Bgsp().LineCross(&lin_chk)) { rv = 1; @@ -671,7 +685,6 @@ static void e_st_wait(e_st_class* i_this) { i_this->mAction = ACTION_MOVE; i_this->mActionPhase = PHASE_INIT; } - break; } if (i_this->mTimers[1] == 0 && pl_check(i_this, l_HIO.pl_recognize_dist)) { @@ -821,8 +834,7 @@ static void e_st_pl_search(e_st_class* i_this) { } if (move_bg_check(i_this)) { - target = 0.0f; - a_this->speedF = 0.0f; + a_this->speedF = target = 0.0f; i_this->mAction = ACTION_WAIT; i_this->mActionPhase = PHASE_INIT; } @@ -868,7 +880,8 @@ static void e_st_shoot(e_st_class* i_this) { break; } - case SHOOT_PHASE_WAIT02: + case SHOOT_PHASE_WAIT02: { + int _; // needed to force b statement at end of case in dbg asm if (i_this->mTimers[0] == 0) { if (daPy_getPlayerActorClass()->getStCaught() && fopAcM_GetParam(a_this) == 1) { i_this->mAction = ACTION_JUMP_ATTACK; @@ -880,6 +893,7 @@ static void e_st_shoot(e_st_class* i_this) { } } break; + } } cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mAngleFromPlayer, 4, 0x1000); @@ -1002,7 +1016,8 @@ static void e_st_jump_attack(e_st_class* i_this) { pos = i_this->field_0x5bc - a_this->current.pos; f32 fVar2 = pos.abs(); - i_this->field_0x71c = cM_ssin((s16)((fVar2 / fVar1) * 32768.0f)) * 100.0f; + s16 sp_0xa = fVar2 / fVar1 * 32768.0f; + i_this->field_0x71c = cM_ssin(sp_0xa) * 100.0f; if (unk_flag == 1) { cLib_addCalcAngleS2(&i_this->field_0x69c.y, 0, 4, 0x800); @@ -1020,6 +1035,7 @@ static void e_st_jump_attack(e_st_class* i_this) { } static void roof_line_calc(e_st_class* i_this) { + fopAc_ac_c* a_this = &i_this->actor; cXyz sp40, sp4c; sp40 = (i_this->field_0x744 - i_this->field_0x710) * (1.0f / 19.0f); @@ -1036,9 +1052,9 @@ static void roof_line_calc(e_st_class* i_this) { i_this->mAction = ACTION_HANG_DROP; i_this->mActionPhase = PHASE_INIT; def_se_set(&i_this->mSound, i_this->mLineCyl.GetTgHitObj(), 0x21, NULL); - pos_p = i_this->mLineCyl.GetTgHitPosP(); + cXyz* tg_hit_pos_p = i_this->mLineCyl.GetTgHitPosP(); i_this->field_0x750 = i_this->field_0x744; - i_this->field_0x750.y = pos_p->y; + i_this->field_0x750.y = tg_hit_pos_p->y; i_this->field_0x764 = i_this->field_0x750.y - i_this->field_0x710.y; if (i_this->field_0x764 < 0.0f) { @@ -1062,6 +1078,7 @@ static void roof_line_calc(e_st_class* i_this) { } static void roof_line_calc2(e_st_class* i_this) { + fopAc_ac_c* a_this = &i_this->actor; cXyz sp50, sp5c; sp50 = (i_this->field_0x744 - i_this->field_0x750) * 0.05263158f; @@ -1163,8 +1180,10 @@ static void e_st_hang(e_st_class* i_this) { cLib_addCalcAngleS2(&a_this->current.angle.y, fopAcM_searchPlayerAngleY(a_this), 0x10, 0x200); if (i_this->arg1 == 0 && i_this->mTimers[1] == 0) { + int _; if (!daPy_getPlayerActorClass()->getStCaught() && fopAcM_searchPlayerDistanceXZ(a_this) < 300.0f && a_this->current.pos.y - player->current.pos.y > 0.0f) { - if (a_this->current.pos.y - dComIfGp_getPlayer(0)->current.pos.y > 1000.0f) { + fopAc_ac_c* pla_2_p = dComIfGp_getPlayer(0); + if (a_this->current.pos.y - pla_2_p->current.pos.y > 1000.0f) { i_this->mAction = ACTION_HANG_DROP; i_this->field_0x750 = i_this->field_0x710; i_this->field_0x720 = 2; @@ -1308,9 +1327,7 @@ static void e_st_hang_drop(e_st_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0x69c.x, 0, 1, 0x1000); if (i_this->mpModelMorf->isStop()) { - i_this->field_0x69c.y = 0; - i_this->field_0x69c.x = 0; - a_this->current.angle.x = 0; + a_this->current.angle.x =i_this->field_0x69c.x = i_this->field_0x69c.y = 0; i_this->mAction = ACTION_G_NORMAL; i_this->mActionPhase = PHASE_INIT; i_this->arg0 = 2; @@ -1371,7 +1388,7 @@ static s8 e_st_hang_2(e_st_class* i_this) { pos.set(a_this->current.pos.x, a_this->current.pos.y, a_this->current.pos.z); if (fopAcM_gc_c::gndCheck(&pos)) { - pos.y = TREG_F(7) + fopAcM_gc_c::getGroundY() + 120.0f + 20.0f; + pos.y = fopAcM_gc_c::getGroundY() + 120.0f + TREG_F(7) + 20.0f; if (i_this->mBgPos.y < pos.y) { i_this->mBgPos.y = pos.y; @@ -1566,8 +1583,7 @@ static void e_st_damage(e_st_class* i_this) { MtxPosition(&sp54, &a_this->speed); } - i_this->field_0x6a2 = 0; - i_this->field_0x6a4 = 0; + i_this->field_0x6a4 = i_this->field_0x6a2 = 0; i_this->mTimers[2] = 10; break; @@ -1634,10 +1650,8 @@ static void e_st_damage(e_st_class* i_this) { } f32 fVar2 = i_this->mTimers[1] * (TREG_F(14) + 150.0f); - f32 fVar3 = cM_ssin(i_this->mTimers[1] * 4000); - s16 target = fVar2 * fVar3 + 32768.0f; - cLib_addCalcAngleS2(&a_this->current.angle.x, target, 4, maxStep); - cLib_addCalcAngleS2(&a_this->current.angle.z, (s16)(fVar2 * cM_scos(i_this->mTimers[1] * 3000)), 4, maxStep); + cLib_addCalcAngleS2(&a_this->current.angle.x, fVar2 * cM_ssin(i_this->mTimers[1] * 4000) + 32768.0f, 4, maxStep); + cLib_addCalcAngleS2(&a_this->current.angle.z, fVar2 * cM_scos(i_this->mTimers[1] * 3000), 4, maxStep); if (i_this->mActionPhase == DAMAGE_PHASE_4) { cLib_addCalc0(&i_this->field_0x7f4, 1.0f, 0.1f); @@ -1653,7 +1667,6 @@ static void e_st_damage(e_st_class* i_this) { if (i_this->mActionPhase >= DAMAGE_PHASE_4) { cLib_addCalcAngleS2(&i_this->field_0x7d4, 0, 1, 0x50); } - break; } cLib_addCalcAngleS2(&i_this->field_0x69c.y, 0, 4, maxStep); @@ -1670,6 +1683,7 @@ static void e_st_damage(e_st_class* i_this) { static void e_st_water(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; cXyz pos_delta, sp58; + f32 reg_f30 = 0.0f; pos_delta = a_this->home.pos - a_this->current.pos; @@ -1692,7 +1706,8 @@ static void e_st_water(e_st_class* i_this) { } if (i_this->mTimers[0] == 0) { - fopAcM_createDisappear(a_this, &a_this->current.pos, l_HIO.basic_size * 10.0f, 0, 6); + u8 size = l_HIO.basic_size * 10.0f; + fopAcM_createDisappear(a_this, &a_this->current.pos, size, 0, 6); fopAcM_delete(a_this); if (i_this->mSwBit != 0xFF) { @@ -1736,7 +1751,11 @@ static BOOL water_check(e_st_class* i_this) { i_this->mGroundCross = dComIfG_Bgsp().GroundCross(&gnd_chk_spl); } - return i_this->mGroundCross > a_this->current.pos.y + 10.0f + WREG_F(11) ? TRUE : FALSE; + if (i_this->mGroundCross > a_this->current.pos.y + 10.0f + WREG_F(11)) { + return TRUE; + } else { + return FALSE; + } } static BOOL gr_check(e_st_class* i_this) { @@ -1748,7 +1767,8 @@ static BOOL gr_check(e_st_class* i_this) { pos.z = a_this->current.pos.z; gnd_chk.SetPos(&pos); - if (a_this->current.pos.y - dComIfG_Bgsp().GroundCross(&gnd_chk) > 200.0f) { + f32 gnd_cross = dComIfG_Bgsp().GroundCross(&gnd_chk); + if (a_this->current.pos.y - gnd_cross > 200.0f) { return TRUE; } @@ -1759,6 +1779,8 @@ static void e_st_g_normal(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; cXyz pos, sp58; f32 target = 0.0f; + f32 reg_f30 = 1.0f; + s16 angle_delta; switch (i_this->mActionPhase) { case PHASE_INIT: @@ -1772,16 +1794,15 @@ static void e_st_g_normal(e_st_class* i_this) { if (i_this->mTimers[0] == 0) { i_this->mActionPhase = G_NORMAL_PHASE_TURN; pos.x = a_this->home.pos.x + cM_rndFX(700.0f); - f32 rndValue = cM_rndFX(700.0f); - pos.z = a_this->home.pos.z + rndValue; + pos.z = a_this->home.pos.z + cM_rndFX(700.0f); pos.x -= a_this->current.pos.x; pos.z -= a_this->current.pos.z; - i_this->mAngleFromPlayer = cM_atan2s(pos.x, pos.z); + i_this->mAngleFromPlayer = cM_atan2s(pos.x, pos.z); } break; - + case G_NORMAL_PHASE_TURN: { - s16 angle_delta = i_this->mAngleFromPlayer - a_this->current.angle.y; + angle_delta = i_this->mAngleFromPlayer - a_this->current.angle.y; if (angle_delta < 0x800 && angle_delta > -0x800) { anm_init(i_this, BCK_ST_MOVE, 5.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); i_this->mActionPhase = G_NORMAL_PHASE_MOVE; @@ -1801,7 +1822,7 @@ static void e_st_g_normal(e_st_class* i_this) { break; } - cLib_addCalc2(&a_this->speedF, target, 1.0f, 1.0f); + cLib_addCalc2(&a_this->speedF, target, 1.0f, reg_f30); cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mAngleFromPlayer, 2, 0x100); if (pl_check(i_this, l_HIO.pl_recognize_dist)) { @@ -1815,6 +1836,7 @@ static s8 e_st_g_fight(e_st_class* i_this) { cXyz sp64, sp70; int frame = i_this->mpModelMorf->getFrame(); f32 target = 0.0f; + f32 reg_f29 = 2.0f; s16 maxStep = 0x200; s8 isStop = false; s8 isPreparingAttack = false; @@ -1885,7 +1907,7 @@ static s8 e_st_g_fight(e_st_class* i_this) { break; } - cLib_addCalc2(&a_this->speedF, target, 1.0f, 2.0f); + cLib_addCalc2(&a_this->speedF, target, 1.0f, reg_f29); cLib_addCalcAngleS2(&a_this->current.angle.y, i_this->mAngleFromPlayer, 2, maxStep); if (isPreparingAttack && i_this->mPlayerDistance > combat_start_dist + 100.0f) { @@ -1899,7 +1921,8 @@ static s8 e_st_g_fight(e_st_class* i_this) { } if (i_this->mAtSph.ChkAtHit()) { - fopAc_ac_c* actor_p = dCc_GetAc(i_this->mAtSph.GetAtHitObj()->GetAc()); + cCcD_Obj* at_hit_obj_p = i_this->mAtSph.GetAtHitObj(); + fopAc_ac_c* actor_p = dCc_GetAc(at_hit_obj_p->GetAc()); if (actor_p != NULL && fopAcM_GetName(actor_p) == PROC_ALINK) { dComIfGp_getVibration().StartShock(VIBMODE_S_POWER4, 31, cXyz(0.0f, 1.0f, 0.0f)); } @@ -1911,6 +1934,9 @@ static s8 e_st_g_fight(e_st_class* i_this) { static s8 e_st_g_def(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; cXyz sp48, sp54; + f32 reg_f31 = 0.0f; + f32 reg_f30 = 2.0f; + s8 rv = 1; i_this->field_0xcf4 = 1; @@ -1920,7 +1946,7 @@ static s8 e_st_g_def(e_st_class* i_this) { i_this->mSound.startCreatureVoice(Z2SE_EN_ST_V_DEFENSE, -1); i_this->mActionPhase = G_DEF_PHASE_DEFENSE; break; - + case G_DEF_PHASE_DEFENSE: if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_G_FIGHT; @@ -1929,16 +1955,18 @@ static s8 e_st_g_def(e_st_class* i_this) { break; } - cLib_addCalc2(&a_this->speedF, 0.0f, 1.0f, 2.0f); - return 1; + cLib_addCalc2(&a_this->speedF, reg_f31, 1.0f, reg_f30); + return rv; } static void e_st_g_damage(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + f32 reg_f31 = 0.0f; + f32 reg_f30 = 2.0f; switch (i_this->mActionPhase) { case PHASE_INIT: - if ((i_this->mHorizHitDir & 1) != 0) { + if ((s8(i_this->mHorizHitDir) & 1) != 0) { anm_init(i_this, BCK_ST_HITL, 2.0f, J3DFrameCtrl::EMode_NONE, 1.0f); } else { anm_init(i_this, BCK_ST_HITR, 2.0f, J3DFrameCtrl::EMode_NONE, 1.0f); @@ -1948,7 +1976,7 @@ static void e_st_g_damage(e_st_class* i_this) { i_this->mHorizHitDir++; i_this->mActionPhase = G_DAMAGE_PHASE_HIT; break; - + case G_DAMAGE_PHASE_HIT: if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_G_FIGHT; @@ -1957,11 +1985,13 @@ static void e_st_g_damage(e_st_class* i_this) { break; } - cLib_addCalc2(&a_this->speedF, 0.0f, 1.0f, 2.0f); + cLib_addCalc2(&a_this->speedF, reg_f31, 1.0f, reg_f30); } static void e_st_g_s_damage(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + f32 reg_f31 = 0.0f; + f32 reg_f30 = 2.0f; switch (i_this->mActionPhase) { case PHASE_INIT: @@ -1969,7 +1999,7 @@ static void e_st_g_s_damage(e_st_class* i_this) { anm_init(i_this, BCK_ST_DAMAGE, 2.0f, J3DFrameCtrl::EMode_NONE, 1.0f); i_this->mSound.startCreatureVoice(Z2SE_EN_ST_V_NODAMAGE, -1); break; - + case G_S_DAMAGE_PHASE_NODAMAGE: if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_G_FIGHT; @@ -1978,7 +2008,7 @@ static void e_st_g_s_damage(e_st_class* i_this) { break; } - cLib_addCalc2(&a_this->speedF, 0.0f, 1.0f, 2.0f); + cLib_addCalc2(&a_this->speedF, reg_f31, 1.0f, reg_f30); } static void e_st_g_wind(e_st_class* i_this) { @@ -2004,8 +2034,11 @@ static void e_st_g_wind(e_st_class* i_this) { } static void e_st_g_chance(e_st_class* i_this) { - fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* a_this = &i_this->actor; + fopEn_enemy_c* enemy_a_this = (fopEn_enemy_c*) a_this; cXyz sp3c, sp48; + f32 reg_f31 = 0.0f; + f32 reg_f30 = 4.0f; i_this->field_0xcf4 = 2; @@ -2014,7 +2047,7 @@ static void e_st_g_chance(e_st_class* i_this) { anm_init(i_this, BCK_ST_DAWNA, 3.0f, J3DFrameCtrl::EMode_NONE, 1.0f); i_this->mSound.startCreatureVoice(Z2SE_EN_ST_V_DAWNA, -1); i_this->mActionPhase = G_CHANCE_PHASE_DAWNA; - a_this->onDownFlg(); + enemy_a_this->onDownFlg(); break; case G_CHANCE_PHASE_DAWNA: @@ -2029,7 +2062,7 @@ static void e_st_g_chance(e_st_class* i_this) { i_this->mTimers[0] = l_HIO.down_time; } break; - + case G_CHANCE_PHASE_DAWNB: if (i_this->mAnm == BCK_ST_DAWNC && i_this->mpModelMorf->isStop()) { anm_init(i_this, BCK_ST_DAWNB, 3.0f, J3DFrameCtrl::EMode_LOOP, 1.0f); @@ -2046,19 +2079,19 @@ static void e_st_g_chance(e_st_class* i_this) { if (i_this->mpModelMorf->isStop()) { i_this->mAction = ACTION_G_FIGHT; i_this->mActionPhase = PHASE_INIT; - a_this->offDownFlg(); + enemy_a_this->offDownFlg(); } break; } - cLib_addCalc2(&a_this->speedF, 0.0f, 1.0f, 4.0f); - a_this->setDownPos(&a_this->current.pos); + cLib_addCalc2(&a_this->speedF, reg_f31, 1.0f, reg_f30); + enemy_a_this->setDownPos(&a_this->current.pos); - if (a_this->checkCutDownHitFlg()) { + if (enemy_a_this->checkCutDownHitFlg()) { i_this->mAction = ACTION_G_END; i_this->mActionPhase = PHASE_INIT; - a_this->offCutDownHitFlg(); - a_this->offDownFlg(); + enemy_a_this->offCutDownHitFlg(); + enemy_a_this->offDownFlg(); i_this->mDeathFlag = 1; daPy_getPlayerActorClass()->onEnemyDead(); } @@ -2066,11 +2099,13 @@ static void e_st_g_chance(e_st_class* i_this) { static s8 e_st_g_end(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* base_a_this = a_this; cXyz sp58, sp64; + f32 reg_f31 = 0.0f; + f32 reg_f30 = 4.0f; s8 rv = 1; - - i_this->mDefTimer = 10; - i_this->mInvulnerabilityTimer = 10; + + i_this->mInvulnerabilityTimer = i_this->mDefTimer = 10; switch (i_this->mActionPhase) { case PHASE_INIT: @@ -2078,14 +2113,15 @@ static s8 e_st_g_end(e_st_class* i_this) { i_this->mSound.startCreatureVoice(Z2SE_EN_ST_V_DEATH2, -1); i_this->mActionPhase = G_END_PHASE_DEATH2; break; - + case G_END_PHASE_DEATH2: if (i_this->mpModelMorf->checkFrame(36.5f)) { i_this->mSound.startCreatureSound(Z2SE_CM_BODYFALL_S, 0, -1); } if (i_this->mpModelMorf->isStop()) { - fopAcM_createDisappear(a_this, &a_this->current.pos, l_HIO.basic_size * 10.0f, 0, 6); + u8 size = l_HIO.basic_size * 10.0f; + fopAcM_createDisappear(a_this, &a_this->current.pos, size, 0, 6); fopAcM_delete(a_this); if (i_this->mSwBit != 0xFF) { @@ -2108,7 +2144,8 @@ static s8 e_st_g_end(e_st_class* i_this) { } if (i_this->mpModelMorf->isStop()) { - fopAcM_createDisappear(a_this, &a_this->current.pos, l_HIO.basic_size * 10.0f, 0, 6); + u8 size = l_HIO.basic_size * 10.0f; + fopAcM_createDisappear(a_this, &a_this->current.pos, size, 0, 6); fopAcM_delete(a_this); if (i_this->mSwBit != 0xFF) { @@ -2122,7 +2159,7 @@ static s8 e_st_g_end(e_st_class* i_this) { a_this->speedF = 0.0f; } - cLib_addCalc2(&a_this->speedF, 0.0f, 1.0f, 4.0f); + cLib_addCalc2(&a_this->speedF, reg_f31, 1.0f, reg_f30); return rv; } @@ -2196,7 +2233,7 @@ static void damage_check_g(e_st_class* i_this) { def_se_set(&i_this->mSound, i_this->mDefSph.GetTgHitObj(), 0x34, NULL); dScnPly_c::setPauseTimer(4); i_this->mDefTimer = 10; - cMtx_YrotS(*calc_mtx, a_this->shape_angle.y); + cMtx_YrotS(*calc_mtx, s16(a_this->shape_angle.y)); sp24.x = KREG_F(0); sp24.y = KREG_F(1) + 100.0f; sp24.z = KREG_F(2) + 50.0f; @@ -2215,15 +2252,16 @@ static void damage_check_g(e_st_class* i_this) { static void ground_angle_set(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; - dComIfGp_getPlayer(0); + fopAc_ac_c* player = dComIfGp_getPlayer(0); // unused s16 sVar1 = 0; s16 sVar2 = 0; + Vec spbc; cXyz spc8, spd4; dBgS_GndChk gnd_chk; f32 scale = (VREG_F(11) + 58.0f) * l_HIO.basic_size; + f32 reg_f31, reg_f29, reg_f28; if (i_this->mBgc.GetGroundH() != -1e9f) { - Vec spbc; spbc.x = a_this->current.pos.x; spbc.y = a_this->current.pos.y + 100.0f; spbc.z = a_this->current.pos.z + scale; @@ -2231,7 +2269,9 @@ static void ground_angle_set(e_st_class* i_this) { spbc.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (spbc.y != -1e9f) { - sVar2 = -cM_atan2s(spbc.y - a_this->current.pos.y, spbc.z - a_this->current.pos.z); + reg_f31 = spbc.y - a_this->current.pos.y; + reg_f28 = spbc.z - a_this->current.pos.z; + sVar2 = -cM_atan2s(reg_f31, reg_f28); if (sVar2 > 0x2000 || sVar2 < -0x2000) { sVar2 = 0; } @@ -2244,7 +2284,9 @@ static void ground_angle_set(e_st_class* i_this) { spbc.y = dComIfG_Bgsp().GroundCross(&gnd_chk); if (spbc.y != -1e9f) { - sVar1 = (s16)cM_atan2s(spbc.y - a_this->current.pos.y, spbc.x - a_this->current.pos.x); + reg_f31 = spbc.y - a_this->current.pos.y; + reg_f29 = spbc.x - a_this->current.pos.x; + sVar1 = (s16)cM_atan2s(reg_f31, reg_f29); if (sVar1 > 0x2000 || sVar1 < -0x2000) { sVar1 = 0; } @@ -2279,8 +2321,7 @@ static BOOL foot_control(e_st_class* i_this, st_foot* foot_p) { foot_p->mAngles[1] = foot_p->field_0x0 * l_HIO.field_0x1c; foot_p->mAngles[2] = foot_p->field_0x0 * l_HIO.field_0x20; } else { - foot_p->mAngles[2] = 0; - foot_p->mAngles[1] = 0; + foot_p->mAngles[1] = foot_p->mAngles[2] = 0; } return rv; @@ -2543,7 +2584,7 @@ static void action(e_st_class* i_this) { if (dComIfG_Bgsp().LineCross(&lin_chk)) { sp9c.x = 0.0f; sp9c.y = 0.0f; - sp9c.z = TREG_F(11) + fabsf(a_this->speedF) + 30.0f; + sp9c.z = fabsf(a_this->speedF) + 30.0f + TREG_F(11); MtxPosition(&sp9c, &spa8); a_this->current.pos += spa8; } @@ -2687,11 +2728,7 @@ static int daE_ST_Execute(e_st_class* i_this) { cMtx_YrotS(*calc_mtx, i_this->field_0x7f2); pos.x = 0.0f; pos.y = 0.0f; -#if VERSION == VERSION_WII_USA_R0 pos.z = i_this->field_0x7ec * -cM_ssin(i_this->field_0x7f0 * (TREG_S(4) + 900)); -#else - pos.z = i_this->field_0x7ec * -cM_ssin(i_this->field_0x7f0 * (TREG_F(4) + 900)); -#endif MtxPosition(&pos, &offset); i_this->field_0x7f0++; cLib_addCalc0(&i_this->field_0x7ec, 1.0f, 0.1f); @@ -2841,17 +2878,19 @@ static int daE_ST_Execute(e_st_class* i_this) { return 1; } -static int daE_ST_IsDelete(e_st_class* i_this) { +static int daE_ST_IsDelete(e_st_class*) { return 1; } static int daE_ST_Delete(e_st_class* i_this) { fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAcM_RegisterDeleteID(i_this, "E_ST"); dComIfG_resDelete(&i_this->mPhase, "E_st"); - + if (i_this->mIsFirstSpawn) { hio_set = false; + mDoHIO_DELETE_CHILD(l_HIO.id); } if (a_this->heap != NULL) { @@ -2899,7 +2938,7 @@ static int useHeapInit(fopAc_ac_c* a_this) { } J3DModel* model = i_this->mpModelMorf->getModel(); - model->setUserArea((uintptr_t)a_this); + model->setUserArea((uintptr_t)i_this); for (u16 i = 0; i < model->getModelData()->getJointNum(); i++) { model->getModelData()->getJointNodePointer(i)->setCallBack(nodeCallBack); @@ -2968,7 +3007,7 @@ static BOOL roof_initial_pos_set(e_st_class* i_this) { static cPhs__Step daE_ST_Create(fopAc_ac_c* a_this) { e_st_class* i_this = (e_st_class*)a_this; - fopAcM_ct(a_this, e_st_class); + fopAcM_ct(&i_this->actor, e_st_class); cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->mPhase, "E_st"); if (phase == cPhs_COMPLEATE_e) { @@ -2983,17 +3022,17 @@ static cPhs__Step daE_ST_Create(fopAc_ac_c* a_this) { i_this->arg1 = 0; } - i_this->arg2 = fopAcM_GetParam(a_this) >> 8; + i_this->arg2 = (fopAcM_GetParam(a_this) & 0xFF00) >> 8; if (i_this->arg2 == 0xFF) { i_this->arg2 = 0; } - i_this->arg3 = fopAcM_GetParam(a_this) >> 16; + i_this->arg3 = (fopAcM_GetParam(a_this) & 0xFF0000) >> 16; if (i_this->arg3 == 0xFF) { i_this->arg3 = 0; } - i_this->mSwBit = fopAcM_GetParam(a_this) >> 24; + i_this->mSwBit = (fopAcM_GetParam(a_this) & 0xFF000000) >> 24; if (i_this->mSwBit != 0xFF) { if (dComIfGs_isSwitch(i_this->mSwBit, fopAcM_GetRoomNo(a_this))) { return cPhs_ERROR_e; @@ -3049,9 +3088,9 @@ static cPhs__Step daE_ST_Create(fopAc_ac_c* a_this) { if (!hio_set) { i_this->mIsFirstSpawn = true; hio_set = true; - l_HIO.id = -1; + l_HIO.id = mDoHIO_CREATE_CHILD("スタルチュラ", &l_HIO); } - + a_this->attention_info.flags = fopAc_AttnFlag_BATTLE_e; fopAcM_SetMtx(a_this, i_this->mpModelMorf->getModel()->getBaseTRMtx()); fopAcM_SetMin(a_this, -200.0f, -4000.0f, -200.0f); @@ -3141,11 +3180,9 @@ static cPhs__Step daE_ST_Create(fopAc_ac_c* a_this) { i_this->mAcchCir.SetWall(60.0f, 60.0f); if (small) { - a_this->health = 0; - a_this->field_0x560 = 0; + a_this->field_0x560 = a_this->health = 0; } else { - a_this->health = 80; - a_this->field_0x560 = 80; + a_this->field_0x560 = a_this->health = 80; } i_this->mFrameCounter = cM_rndF(65535.0f); diff --git a/src/d/actor/d_a_e_wb.cpp b/src/d/actor/d_a_e_wb.cpp index 8a332e117d..f18148632d 100644 --- a/src/d/actor/d_a_e_wb.cpp +++ b/src/d/actor/d_a_e_wb.cpp @@ -3884,7 +3884,7 @@ static void demo_camera(e_wb_class* i_this) { i_this->field_0x1714 = 55.0f + KREG_F(7); i_this->field_0x16a0 = 0; s16 sp16 = local_194->actor.shape_angle.y + - (local_194->field_0xa0e - local_194->actor.shape_angle.y) / 2; + (local_194->field_0xa0c.y - local_194->actor.shape_angle.y) / 2; mDoMtx_stack_c::YrotS(sp16); local_3c.x = NREG_F(0); local_3c.y = NREG_F(1) + 500.0f; diff --git a/src/d/actor/d_a_npc_ks.cpp b/src/d/actor/d_a_npc_ks.cpp index 0ddaae6de8..73402448f0 100644 --- a/src/d/actor/d_a_npc_ks.cpp +++ b/src/d/actor/d_a_npc_ks.cpp @@ -326,29 +326,11 @@ static void* s_b_sub(void* i_actor, void* i_data) { static int target_bgc[10]; +// FIXME: possible fakematch? #if DEBUG - -// fakematch to get proper casting -#define NPC_KS_18DEG_ROT (s16) 0x800 -#define NPC_KS_36DEG_ROT (s16) 0x1600 -#define NPC_KS_45DEG_ROT (s16) 0x2000 -#define NPC_KS_90DEG_ROT (s16) 0x4000 -#define NPC_KS_180DEG_ROT (s16) 0x8000 -#define NPC_KS_NEG_180DEG_ROT (s16) -0x8000 - #define NPC_KS_FABSF fabsf - #else - -#define NPC_KS_18DEG_ROT 0x800 -#define NPC_KS_36DEG_ROT 0x1600 -#define NPC_KS_45DEG_ROT 0x2000 -#define NPC_KS_90DEG_ROT 0x4000 -#define NPC_KS_180DEG_ROT 0x8000 -#define NPC_KS_NEG_180DEG_ROT -0x8000 - #define NPC_KS_FABSF std::fabsf - #endif static fopAc_ac_c* search_bomb(npc_ks_class* i_this, int param_2) { @@ -706,7 +688,7 @@ static int npc_ks_ori(npc_ks_class* i_this) { if (i_this->timer[0] == 1) { anm_init(i_this, 32, 2.0f, 0, 1.0f); if (fopAcM_GetRoomNo(actor) == 11) { - actor->current.angle.y += NPC_KS_36DEG_ROT; + ADD_ANGLE_2(actor->current.angle.y, 0x1600); } } @@ -854,7 +836,7 @@ static int npc_ks_ori2(npc_ks_class* i_this) { break; case 2: - sVar1 += NPC_KS_NEG_180DEG_ROT; + ADD_ANGLE_2(sVar1, -0x8000); if (i_this->timer[0] == 0) { if (cage_p->partBreak()) { anm_init(i_this, 22, 5.0f, 2, 1.0f); @@ -926,7 +908,7 @@ static int npc_ks_ori2(npc_ks_class* i_this) { case 6: i_this->field_0x5fc = 0; fVar1 = -20.0f; - sVar1 += NPC_KS_45DEG_ROT; + ADD_ANGLE_2(sVar1, 0x2000); if (i_this->model->isStop()) { anm_init(i_this, 33, 1.0f, 0, 1.0f); actor->speedF = 40.0f; @@ -941,7 +923,7 @@ static int npc_ks_ori2(npc_ks_class* i_this) { case 7: i_this->field_0x5fc = 0; - sVar1 += NPC_KS_90DEG_ROT; + ADD_ANGLE_2(sVar1, 0x4000); actor->gravity = -5.0f; break; @@ -1115,7 +1097,7 @@ static path move_path_02[5] = { static int npc_ks_demo_02(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; - fopAc_ac_c* unused_p = dComIfGp_getPlayer(0); + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); cXyz mae, ato; f32 speed = 0.0f; int rv = 1; @@ -2187,7 +2169,7 @@ static void npc_ks_hang_s(npc_ks_class* i_this) { s16 sVar2 = i_this->field_0x602; cLib_addCalcAngleS2(&i_this->field_0x602, i_this->field_0x60c * cM_ssin(i_this->field_0x5fa), 4, 0x1000); i_this->field_0x604 = i_this->field_0x602 - sVar2; - i_this->field_0x5fa += NPC_KS_18DEG_ROT; + ADD_ANGLE_2(i_this->field_0x5fa, 0x800); actor->current.angle.z = -(i_this->field_0x602 / 4); if (i_this->field_0x620 != 2) { @@ -2267,7 +2249,7 @@ static void npc_ks_e_hang(npc_ks_class* i_this) { actor->current.pos = sw_p->field_0x920[i_this->field_0x630]; cLib_addCalcAngleS2(&i_this->field_0x602, i_this->field_0x60c * cM_ssin(i_this->field_0x5fa), 4, 0x1000); - i_this->field_0x5fa += NPC_KS_18DEG_ROT; + ADD_ANGLE_2(i_this->field_0x5fa, 0x800); actor->current.angle.z = -(i_this->field_0x602 / 4); cLib_addCalc0(&i_this->field_0x60c, 0.5f, 100.0f + TREG_F(3)); } @@ -3229,8 +3211,10 @@ static void demo_camera(npc_ks_class* i_this) { if (midna_p->checkShadowReturnEnd() != 0) { i_this->demo_mode = 100; } - break; } + // fallthrough intentional + default: + break; case 300: if (!actor->eventInfo.checkCommandDemoAccrpt()) { @@ -3439,14 +3423,15 @@ static void demo_camera(npc_ks_class* i_this) { i_this->msg_flow.doFlow(actor, NULL, 0); break; - case 363: + case 363: { + int _; // force b asm at end of case in dbg asm cam_3d_morf(i_this, 0.1f + BREG_F(17)); cLib_addCalc2(&i_this->field_0xbc4, 0.3f + BREG_F(18), 1.0f, 0.01f + BREG_F(19)); if (i_this->msg_flow.doFlow(actor, NULL, 0) != 0) { i_this->demo_mode = 100; } break; - + } } if (i_this->demo_mode == 99 || i_this->demo_mode == 98) { @@ -3899,7 +3884,7 @@ static int npc_ks_option(npc_ks_class* i_this) { case 30: target_speed = l_HIO.holding_speed_h; - i_this->current_angle.y += NPC_KS_180DEG_ROT; + ADD_ANGLE_2(i_this->current_angle.y, 0x8000); if (fVar2 > 400.0f) { i_this->mode = 31; anm_init(i_this, 51, 5.0f, 2, 1.0f); @@ -3920,8 +3905,7 @@ static int npc_ks_option(npc_ks_class* i_this) { anm_init(i_this, 39, 5.0f, 2, 1.0f); i_this->mode = 41; i_this->timer[0] = cM_rndF(80.0f) + 100.0f; - // ditto. - i_this->current_angle.y += NPC_KS_180DEG_ROT; + ADD_ANGLE_2(i_this->current_angle.y, 0x8000); break; case 41: @@ -4247,7 +4231,7 @@ static int npc_ks_guide_00(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (i_this->dis > 700.0f || guide_path_00[i_this->path_no].field_0x0 < 0) { + if (i_this->dis > 700.0f + YREG_F(16) || guide_path_00[i_this->path_no].field_0x0 < 0) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -4285,7 +4269,7 @@ static int npc_ks_guide_00(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle; } - if (i_this->dis < 550.0f && guide_path_00[i_this->path_no].field_0x0 >= 0) { + if (i_this->dis < 550.0f + YREG_F(17) && guide_path_00[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } else { if (i_this->dis < 150.0f && i_this->res_id != 51) { @@ -4301,7 +4285,7 @@ static int npc_ks_guide_00(npc_ks_class* i_this) { mae.y = player->current.pos.y - (i_this->child_no->field_0x904[0].y - 450.0f); mae.z = player->current.pos.z - i_this->child_no->field_0x904[0].z; - if (mae.abs() < 300.0f) { + if (mae.abs() < 300.0f + YREG_F(11)) { i_this->field_0xbd9 = 1; i_this->action = 20; i_this->mode = 0; @@ -4390,6 +4374,7 @@ static int npc_ks_guide_00(npc_ks_class* i_this) { static int npc_ks_guide_00_2(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); cXyz mae, ato; int rv = 1; int frame = i_this->model->getFrame(); @@ -4402,7 +4387,7 @@ static int npc_ks_guide_00_2(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (i_this->dis > 900.0f || guide_path_00_2[i_this->path_no].field_0x0 < 0) { + if (i_this->dis > 900.0f + YREG_F(16) || guide_path_00_2[i_this->path_no].field_0x0 < 0) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -4444,7 +4429,7 @@ static int npc_ks_guide_00_2(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle + 0x8000; } - if (i_this->dis < 750.0f && guide_path_00_2[i_this->path_no].field_0x0 >= 0) { + if (i_this->dis < 750.0f + YREG_F(17) && guide_path_00_2[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } } @@ -4468,6 +4453,8 @@ static int npc_ks_guide_00_2(npc_ks_class* i_this) { static int npc_ks_guide_00_3(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); + cXyz mae, ato; int rv = 1; int frame = i_this->model->getFrame(); @@ -4480,7 +4467,7 @@ static int npc_ks_guide_00_3(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (i_this->dis > 500.0f || guide_path_00_3[i_this->path_no].field_0x0 < 0) { + if (i_this->dis > 500.0f + YREG_F(16) || guide_path_00_3[i_this->path_no].field_0x0 < 0) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -4505,7 +4492,7 @@ static int npc_ks_guide_00_3(npc_ks_class* i_this) { mae.x = i_this->guide_path.x - actor->current.pos.x; mae.z = i_this->guide_path.z - actor->current.pos.z; i_this->current_angle.y = cM_atan2s(mae.x, mae.z); - if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < actor->speedF * 1.2f) { + if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < actor->speedF * (1.2f + JREG_F(12))) { i_this->path_no++; i_this->mode = 1; } @@ -4518,7 +4505,7 @@ static int npc_ks_guide_00_3(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle; } - if (i_this->dis < 400.0f && guide_path_00_3[i_this->path_no].field_0x0 >= 0) { + if (i_this->dis < 400.0f + YREG_F(17) && guide_path_00_3[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } else { if (i_this->dis < 150.0f && i_this->res_id != 51) { @@ -4599,6 +4586,7 @@ static int npc_ks_guide_00_3(npc_ks_class* i_this) { static int npc_ks_guide_01(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); cXyz mae, ato; int rv = 1; int frame = i_this->model->getFrame(); @@ -4617,7 +4605,7 @@ static int npc_ks_guide_01(npc_ks_class* i_this) { // fallthrough case 1: case 101: - if (i_this->mode == 1 && (i_this->dis > 900.0f || guide_path_01[i_this->path_no].field_0x0 < 0)) { + if (i_this->mode == 1 && (i_this->dis > 900.0f + YREG_F(16) || guide_path_01[i_this->path_no].field_0x0 < 0)) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -4651,7 +4639,7 @@ static int npc_ks_guide_01(npc_ks_class* i_this) { rv = 2; if (i_this->res_id == 32 && i_this->model->isStop()) { anm_init(i_this, 33, 1.0f, 0, 1.0f); - actor->speedF = 40.0f; + actor->speedF = 40.0f + TREG_F(9); i_this->sound.startCreatureVoice(Z2SE_KOSARU_V_JUMP, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_START, 0, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_WIND, 0, -1); @@ -4687,7 +4675,7 @@ static int npc_ks_guide_01(npc_ks_class* i_this) { } if (guide_path_01[i_this->path_no].field_0x0 >= 0) { - if (i_this->dis < 600.0f) { + if (i_this->dis < 600.0f + YREG_F(17)) { i_this->mode = 1; } @@ -4703,7 +4691,7 @@ static int npc_ks_guide_01(npc_ks_class* i_this) { } else if (i_this->dis < 150.0f) { i_this->action = 100; i_this->mode = 0; - return 1; + return rv; } break; @@ -4871,7 +4859,8 @@ static int npc_ks_guide_02(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle + 0x8000; } - if (((player->current.pos.y - actor->current.pos.y) > 10.0f || i_this->dis < (fVar1 - 150.0f)) && guide_path_02[i_this->path_no].field_0x0 >= 0) { + if (((player->current.pos.y - actor->current.pos.y) > 10.0f || i_this->dis < (fVar1 - 150.0f + YREG_F(7))) + && guide_path_02[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } @@ -4937,6 +4926,7 @@ static path guide_path_22[6] = { static int npc_ks_guide_22(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); i_this->dis = fopAcM_searchPlayerDistance(actor); cXyz mae, ato; int rv = 1; @@ -4950,7 +4940,7 @@ static int npc_ks_guide_22(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (i_this->dis > 500.0f || guide_path_22[i_this->path_no].field_0x0 < 0) { + if (i_this->dis > 500.0f + YREG_F(16) || guide_path_22[i_this->path_no].field_0x0 < 0) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -5008,7 +4998,7 @@ static int npc_ks_guide_22(npc_ks_class* i_this) { mae.z = i_this->guide_path.z - actor->current.pos.z; i_this->current_angle.y = cM_atan2s(mae.x, mae.z); - if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < actor->speedF * 1.2f) { + if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < actor->speedF * (1.2f + JREG_F(12))) { i_this->path_no++; i_this->mode = 1; } @@ -5021,7 +5011,7 @@ static int npc_ks_guide_22(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle; } - if (i_this->dis < 300.0f && guide_path_22[i_this->path_no].field_0x0 >= 0) { + if (i_this->dis < 300.0f + YREG_F(17) && guide_path_22[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } @@ -5121,7 +5111,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { cXyz mae, ato; int rv = 1; int frame = i_this->model->getFrame(); - f32 fVar1 = 0.0f; + f32 fVar1 = 0.0f; // used but not changed switch (i_this->mode) { case 0: @@ -5131,7 +5121,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (i_this->dis > 900.0f || guide_path_09[i_this->path_no].field_0x0 < 0) { + if (i_this->dis > 900.0f + YREG_F(16) || guide_path_09[i_this->path_no].field_0x0 < 0) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -5166,7 +5156,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { rv = 2; if (i_this->res_id == 32 && i_this->model->isStop()) { anm_init(i_this, 33, 1.0f, 0, 1.0f); - actor->speedF = 40.0f; + actor->speedF = 40.0f + TREG_F(9); i_this->sound.startCreatureVoice(Z2SE_KOSARU_V_JUMP, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_START, 0, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_WIND, 0, -1); @@ -5202,14 +5192,14 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { } if (guide_path_09[i_this->path_no].field_0x0 >= 0) { - if (i_this->dis < 600.0f) { + if (i_this->dis < 600.0f + YREG_F(17)) { i_this->mode = 1; } } else { if (i_this->dis < 150.0f && i_this->res_id != 51) { anm_init(i_this, 51, 5.0f, 2, 1.0f); } - + if (i_this->res_id == 51) { i_this->field_0x5fc = 1; } @@ -5249,7 +5239,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { } } - cLib_addCalcAngleS2(&actor->current.angle.x, 0, 1, 0x800); + cLib_addCalcAngleS2(&actor->current.angle.x, 0, 1, 0x800); if (checkDoorDemo()) { i_this->action = 100; @@ -5266,7 +5256,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { } if (i_this->mode >= 40 && i_this->mode <= 41) { - fopAc_ac_c* enemy_p = enemy_check(i_this, 700.0f); + fopAc_ac_c* enemy_p = enemy_check(i_this, 700.0f + fVar1); if (enemy_p == NULL) { i_this->mode = 42; i_this->timer[0] = 30; @@ -5275,7 +5265,7 @@ static int npc_ks_guide_09(npc_ks_class* i_this) { mae.z = enemy_p->current.pos.z - actor->current.pos.z; i_this->current_angle.y = cM_atan2s(mae.x, mae.z) + 0x8000; } - } else if (enemy_view_check(i_this, 600.0f) != NULL) { + } else if (enemy_view_check(i_this, 600.0f + fVar1) != NULL) { i_this->mode = 40; actor->speedF = 0.0f; } @@ -5299,6 +5289,7 @@ static int npc_ks_demo_12(npc_ks_class* i_this) { cXyz mae, ato; int rv = 1; int frame = i_this->model->getFrame(); + f32 reg_f31 = 0.0f; // unused switch (i_this->mode) { case 0: @@ -5337,7 +5328,7 @@ static int npc_ks_demo_12(npc_ks_class* i_this) { rv = 2; if (i_this->res_id == 32 && i_this->model->isStop()) { anm_init(i_this, 33, 1.0f, 0, 1.0f); - actor->speedF = 40.0f; + actor->speedF = 40.0f + TREG_F(9); i_this->sound.startCreatureVoice(Z2SE_KOSARU_V_JUMP, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_START, 0, -1); i_this->sound.startCreatureSound(Z2SE_KOSARU_JUMP_WIND, 0, -1); @@ -5399,7 +5390,7 @@ static path guide_path_0409[5] = { static int npc_ks_guide_0409(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; fopAc_ac_c* player = dComIfGp_getPlayer(0); - cXyz mae; + cXyz mae, unused_vec; int rv = 1; int frame = i_this->model->getFrame(); @@ -5411,7 +5402,8 @@ static int npc_ks_guide_0409(npc_ks_class* i_this) { actor->speedF = 0.0f; // fallthrough case 1: - if (player->current.pos.z > actor->current.pos.z && (i_this->dis > 700.0f || guide_path_0409[i_this->path_no].field_0x0 < 0)) { + if (player->current.pos.z > actor->current.pos.z + && (i_this->dis > 700.0f + YREG_F(16) || guide_path_0409[i_this->path_no].field_0x0 < 0)) { if ((call_pt & 1) != 0) { anm_init(i_this, 8, 5.0f, 2, 1.0f); } else { @@ -5451,7 +5443,7 @@ static int npc_ks_guide_0409(npc_ks_class* i_this) { i_this->current_angle.y = i_this->target_angle; } - if ((i_this->dis < 550.0f || player->current.pos.z < actor->current.pos.z) + if ((i_this->dis < 550.0f + YREG_F(17) || player->current.pos.z < actor->current.pos.z) && guide_path_0409[i_this->path_no].field_0x0 >= 0) { i_this->mode = 1; } else { @@ -5492,7 +5484,8 @@ static int path_search(npc_ks_class* i_this) { while (path_index < 255) { dPath* path_p = dPath_GetRoomPath(path_index, fopAcM_GetRoomNo(actor)); if (path_p != NULL) { - cXyz sp28 = actor->current.pos - path_p->m_points->m_position; + dPnt* pnt_p = path_p->m_points; + cXyz sp28 = actor->current.pos - pnt_p->m_position; if (sp28.abs() < 200.0f) { OS_REPORT(" サルがが%d番のレール発見しました。\n", path_index); i_this->field_0xc18 = path_p; @@ -5524,7 +5517,7 @@ static int npc_ks_mori(npc_ks_class* i_this) { if (!dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[226])) { i_this->mode = 302; i_this->field_0xc17 = 3; - dComIfGp_setItemOilCount(-(dComIfGs_getMaxOil() & 0xFFFF)); + dComIfGp_setItemOilCount(-dComIfGs_getMaxOil()); } } else { i_this->field_0xaec = 1; @@ -5546,7 +5539,7 @@ static int npc_ks_mori(npc_ks_class* i_this) { mae.set(-27426.0f, player->current.pos.y, -20000.0f); mae -= player->current.pos; - if (mae.abs() < 7500.0f) { + if (mae.abs() < 7500.0f + NREG_F(17)) { i_this->mode = 1; i_this->timer[0] = 10; } @@ -5571,8 +5564,8 @@ static int npc_ks_mori(npc_ks_class* i_this) { case 2: cMtx_YrotS(*calc_mtx, player->shape_angle.y); mae.x = i_this->field_0xbb4; - mae.y = 0.0f; - mae.z = 100.0f; + mae.y = AREG_F(1); + mae.z = 100.0f + AREG_F(2); MtxPosition(&mae, &ato); actor->current.pos = player->current.pos + ato; actor->current.angle.y = player->shape_angle.y - 0x4000; @@ -5681,7 +5674,7 @@ static int npc_ks_mori(npc_ks_class* i_this) { mae.x = -30900.0f - player->current.pos.x; mae.z = -15756.0f - player->current.pos.z; - if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < 1300.0f || i_this->dis < fVar1) { + if (JMAFastSqrt(mae.x * mae.x + mae.z * mae.z) < 1300.0f + YREG_F(13) || i_this->dis < fVar1) { i_this->demo_mode = 300; i_this->mode = 300; } @@ -5879,7 +5872,7 @@ static int npc_ks_fsdemo(npc_ks_class* i_this) { if (i_this->path_no == 0) { anm_init(i_this, 45, 3.0f, 0, 1.0f); i_this->mode = 3; - i_this->current_angle.y += 0x8000; + ADD_ANGLE_2(i_this->current_angle.y, 0x8000); actor->speedF = 0.0f; } else { i_this->mode = 1; @@ -5892,7 +5885,7 @@ static int npc_ks_fsdemo(npc_ks_class* i_this) { case 3: if (i_this->model->isStop()) { - i_this->current_angle.y += 0x8000; + ADD_ANGLE_2(i_this->current_angle.y, 0x8000); i_this->mode = 1; } break; @@ -5941,9 +5934,10 @@ static int npc_ks_fsdemo(npc_ks_class* i_this) { i_this->mode = 22; i_this->sound.startCreatureVoice(Z2SE_KOSARU_V_WALK, -1); } - - break; } + // falthrough intentional + default: + break; case 22: sVar1 = 0x800; @@ -6025,6 +6019,8 @@ static int npc_ks_fsdemo(npc_ks_class* i_this) { static void npc_ks_kago(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; + fopAc_ac_c* unused_pla_p = dComIfGp_getPlayer(0); + cXyz unused_xyz_0, unused_xyz_1; i_this->field_0x5fc = 0; @@ -6179,7 +6175,7 @@ static void anm_se_set(npc_ks_class* i_this) { } } else if (i_this->res_id == 34) { if (i_this->model->checkFrame(1.0f)) { - f32 fVar1 = i_this->dis * 0.0215f; + f32 fVar1 = i_this->dis * (0.0215f + XREG_F(17)); if (fVar1 > 127.0f) { fVar1 = 127.0f; } @@ -6599,6 +6595,7 @@ static void action(npc_ks_class* i_this) { } static void* s_kago_sub(void* i_actor, void* i_data) { + UNUSED(i_data); if (fopAcM_IsActor(i_actor) && fopAcM_GetName(i_actor) == PROC_OBJ_KAGO) { if (((daObj_Kago_c*)i_actor)->getType() == 0) { return i_actor; @@ -6715,9 +6712,9 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { f32 fVar1 = mae.abs(); mae = i_this->field_0x91c - actor->current.pos; f32 fVar2 = mae.abs(); - f32 fVar3 = fVar1 * 0.2f; - if (fVar3 > 200.0f) { - fVar3 = 200.0f; + f32 fVar3 = fVar1 * (0.2f + BREG_F(19)); + if (fVar3 > 200.0f + BREG_F(18)) { + fVar3 = 200.0f + BREG_F(18); } i_this->field_0x908 = fVar3 * cM_ssin((fVar2 / fVar1) * 32768.0f); i_this->field_0x90c = 0; @@ -6726,8 +6723,8 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { } mDoMtx_stack_c::transS(actor->current.pos.x, actor->current.pos.y + i_this->field_0x908, actor->current.pos.z); - mDoMtx_stack_c::YrotM(actor->shape_angle.y); - mDoMtx_stack_c::XrotM(actor->shape_angle.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::transM(0.0f, i_this->field_0x928, 0.0f); mDoMtx_stack_c::scaleM(l_HIO.basic_size, l_HIO.basic_size, l_HIO.basic_size); @@ -6749,13 +6746,13 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { daObj_Kago_c* kago = (daObj_Kago_c*)fpcM_Search(s_kago_sub, i_this); if (kago != NULL) { MTXCopy(i_this->model->getModel()->getAnmMtx(14), mDoMtx_stack_c::get()); - mDoMtx_stack_c::YrotM(-2000); - mDoMtx_stack_c::XrotM(-0x3638); - mDoMtx_stack_c::ZrotM(-0x2E68); - mDoMtx_stack_c::transM(-60.0f, 0.0f, 0.0f); - mDoMtx_stack_c::YrotM(0); - mDoMtx_stack_c::XrotM(0); - mDoMtx_stack_c::ZrotM(0); + mDoMtx_stack_c::YrotM(VREG_S(0) - 2000); + mDoMtx_stack_c::XrotM(VREG_S(1) - 13880); + mDoMtx_stack_c::ZrotM(VREG_S(2) - 11880); + mDoMtx_stack_c::transM(-60.0f + VREG_F(7), VREG_F(8), VREG_F(9)); + mDoMtx_stack_c::YrotM(s16(VREG_S(3))); + mDoMtx_stack_c::XrotM(s16(VREG_S(4))); + mDoMtx_stack_c::ZrotM(s16(VREG_S(5))); kago->setMtx(mDoMtx_stack_c::get()); if (fopAcM_checkHawkCarryNow(kago) != 0) { @@ -6780,11 +6777,11 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { } MTXCopy(model->getAnmMtx(10), *calc_mtx); - mae.set(30.0f, 0.0f, 0.0f); + mae.set(30.0f + BREG_F(0), BREG_F(1), BREG_F(2)); MtxPosition(&mae, &i_this->field_0x614); MTXCopy(model->getAnmMtx(14), *calc_mtx); - mae.set(30.0f, -0.0f, 0.0f); + mae.set(30.0f + BREG_F(0), -BREG_F(1), BREG_F(2)); MtxPosition(&mae, &ato); i_this->field_0x614 += (ato - i_this->field_0x614) * 0.5f; @@ -6797,7 +6794,7 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { mae.z = obj_pos.z - i_this->field_0x614.z; if ((mae.x * mae.x + mae.z * mae.z) <= 15.0f) { i_this->field_0x620 = 2; - i_this->field_0x621 = 10; + i_this->field_0x621 = 10 + AREG_S(9); leader->field_0x92c = 0; dComIfGp_getVibration().StartShock(2, 31, cXyz(0.0f, 1.0f, 0.0f)); } @@ -6808,7 +6805,7 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { } i_this->field_0x638 += i_this->field_0x634; - i_this->field_0x634 += -3.0f; + i_this->field_0x634 += -3.0f + BREG_F(11); if (i_this->field_0x638 < 0.0f) { i_this->field_0x638 = 0.0f; @@ -6828,10 +6825,10 @@ static int daNpc_Ks_Execute(npc_ks_class* i_this) { } player->changeDemoParam0(1); - cLib_addCalcAngleS2(&i_this->field_0x610, i_this->field_0x602 << 1, 1, 4000); + cLib_addCalcAngleS2(&i_this->field_0x610, i_this->field_0x602 << 1, 1, 4000 + TREG_S(7)); } else { player->changeDemoParam0(0); - cLib_addCalcAngleS2(&i_this->field_0x610, 10000, 4, 4000); + cLib_addCalcAngleS2(&i_this->field_0x610, 10000 + TREG_S(6), 4, 4000 + TREG_S(7)); } if (i_this->field_0x620 != 0) { diff --git a/src/d/actor/d_a_obj_hb.cpp b/src/d/actor/d_a_obj_hb.cpp index 331bb831af..5bb7aa2b54 100644 --- a/src/d/actor/d_a_obj_hb.cpp +++ b/src/d/actor/d_a_obj_hb.cpp @@ -411,13 +411,12 @@ static void action(obj_hb_class* i_this) { if (cc_move_p != NULL) { a_this->current.pos.x += cc_move_p->x * 0.5f; a_this->current.pos.z += cc_move_p->z * 0.5f; - if (fabsf(cc_move_p->x) >= 2.0f || fabsf(cc_move_p->z) >= 2.0f) { cLib_addCalc2(&i_this->field_0x688, NREG_F(5) + 1000.0f, 0.1f, NREG_F(6) + 200.0f); s16 target = fopAcM_searchPlayerAngleY(a_this); s16 angle_delta = i_this->field_0x676.y - target; if (angle_delta > 0x4000 || angle_delta < -0x4000) { - target -= 0x8000; + ADD_ANGLE(target, 0x8000); } cLib_addCalcAngleS2(&i_this->field_0x676.y, target, 4, 0x100); } @@ -427,7 +426,7 @@ static void action(obj_hb_class* i_this) { i_this->mBgc.CrrPos(dComIfG_Bgsp()); sVar1 = 1; break; - + case ACTION_FLOAT: obj_hb_float(i_this); i_this->mBgc.CrrPos(dComIfG_Bgsp()); @@ -449,8 +448,9 @@ static void action(obj_hb_class* i_this) { i_this->field_0x6b0 = 0; if (i_this->mAtInfo.mHitType == HIT_TYPE_LINK_NORMAL_ATTACK) { - if (daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_TURN_RIGHT || daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_UNK_9) { - a_this->speedF = WREG_F(16) + cM_rndF(10.0f) + 40.0f; + if (daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_TURN_RIGHT + || daPy_getPlayerActorClass()->getCutType() == daPy_py_c::CUT_TYPE_UNK_9) { + a_this->speedF = cM_rndF(10.0f) + 40.0f + WREG_F(16); i_this->field_0x690 = cM_rndF(2000.0f) + 5500.0f; i_this->field_0x688 = (s16)(cM_rndF(1000.0f) + 5000.0f); } else { @@ -477,8 +477,8 @@ static void action(obj_hb_class* i_this) { cLib_addCalcAngleS2(&i_this->field_0x68e, 0, 8, 0x100); cLib_addCalcAngleS2(&i_this->field_0x690, 0, 1, WREG_S(6) + 0x96); } else { - i_this->field_0x68c = i_this->field_0x688 * cM_ssin(i_this->field_0x650 * (NREG_F(3) + 3000)); - i_this->field_0x68e = i_this->field_0x688 * cM_ssin(i_this->field_0x650 * (NREG_F(4) + 4000)); + i_this->field_0x68c = i_this->field_0x688 * cM_ssin(i_this->field_0x650 * (NREG_S(3) + 3000)); + i_this->field_0x68e = i_this->field_0x688 * cM_ssin(i_this->field_0x650 * (NREG_S(4) + 4000)); cLib_addCalc0(&i_this->field_0x688, 0.1f, NREG_F(1) + 50.0f); cLib_addCalcAngleS2(&i_this->field_0x690, 0, 1, WREG_S(5) + 0x32); } @@ -503,7 +503,8 @@ static void action(obj_hb_class* i_this) { } a_this->speedF = 0.0f; - cXyz scale(a_this->scale.x, a_this->scale.x, a_this->scale.x); + f32 val_scale = a_this->scale.x; + cXyz scale(val_scale, val_scale, val_scale); cXyz pos(a_this->current.pos); pos.y = i_this->mGroundCross; @@ -522,7 +523,8 @@ static void action(obj_hb_class* i_this) { if (i_this->field_0x6a4 != 0) { i_this->field_0x6a4--; if (i_this->field_0x6a4 != 0) { - cLib_addCalc2(&a_this->scale.x, i_this->field_0x6a4 * (BREG_F(2) + 0.01f) * cM_ssin(i_this->field_0x6a4 * (KREG_S(3) + 15000)) + 1.0f, 1.0f, 0.2f); + f32 reg_f30 = i_this->field_0x6a4 * (BREG_F(2) + 0.01f); + cLib_addCalc2(&a_this->scale.x, reg_f30 * cM_ssin(i_this->field_0x6a4 * (KREG_S(3) + 15000)) + 1.0f, 1.0f, 0.2f); } else { a_this->scale.x = 1.0f; } diff --git a/src/d/actor/d_a_obj_ita.cpp b/src/d/actor/d_a_obj_ita.cpp index d163fe19a3..47c8c9e643 100644 --- a/src/d/actor/d_a_obj_ita.cpp +++ b/src/d/actor/d_a_obj_ita.cpp @@ -15,13 +15,7 @@ public: daObj_ITA_HIO_c(); virtual ~daObj_ITA_HIO_c() {} - void genMessage(JORMContext* ctx) { - ctx->genLabel("ヒメクジ", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); - ctx->genSlider("サーチエリア", &search_area, 0.0f, 2000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); - ctx->genSlider("飛ばし方向スピード", &launch_dir_spd, 0.0f, -100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); - ctx->genSlider("飛ばし方向Yスピード", &launch_dir_y_spd, 0.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); - ctx->genSlider("重力設定", &gravity_settings, 0.0f, -20.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); - } + void genMessage(JORMContext* ctx); /* ヒメクジ */ /* 0x04 */ s8 id; @@ -31,8 +25,6 @@ public: /* 0x14 */ f32 gravity_settings; }; -static char* l_arcName = "M_Ita"; - daObj_ITA_HIO_c::daObj_ITA_HIO_c() { id = -1; search_area = 600.0f; @@ -41,6 +33,18 @@ daObj_ITA_HIO_c::daObj_ITA_HIO_c() { gravity_settings = -9.0f; } +#if DEBUG +void daObj_ITA_HIO_c::genMessage(JORMContext* ctx) { + ctx->genLabel("ヒメクジ", 0x80000001, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("サーチエリア", &search_area, 0.0f, 2000.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("飛ばし方向スピード", &launch_dir_spd, 0.0f, -100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("飛ばし方向Yスピード", &launch_dir_y_spd, 0.0f, 100.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + ctx->genSlider("重力設定", &gravity_settings, 0.0f, -20.0f, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); +} +#endif + +static char* l_arcName = "M_Ita"; + static f32 dummy() { return 0.0f; } @@ -59,16 +63,15 @@ namespace { } // namespace void daObjIta_c::Search_Ymb() { - f32 zero = 0.0f; + f32 speed_f = 0.0f; cXyz pos(e_ymb_Pos->x - current.pos.x, e_ymb_Pos->y - current.pos.y, e_ymb_Pos->z - current.pos.z); mDoMtx_stack_c::YrotS(-shape_angle.y); mDoMtx_stack_c::multVec(&pos, &pos); if (pos.x < BREG_F(0) + 750.0f && pos.x > -750.0f - BREG_F(0) && pos.z < 450.0f + BREG_F(1) && pos.z > -450.0f - BREG_F(1) && pos.y < BREG_F(7) + 600.0f) { - f32 speed_f = fopAcM_GetSpeedF(e_ymb); - zero = 0.0f; - if (speed_f > zero) { + speed_f = fopAcM_GetSpeedF(e_ymb); + if (speed_f > 0.0f) { field_0x5b0 = speed_f * (BREG_F(6) + 16.0f) + 256.0f; e_ymb->setHitBoardSe(); field_0x5a0 = speed_f * (BREG_F(5) + 31.0f); @@ -98,15 +101,21 @@ void daObjIta_c::Search_Ymb() { BOOL daObjIta_c::Check_RideOn() { daPy_py_c* player = daPy_getPlayerActorClass(); cXyz& pos = fopAcM_GetPosition(player); + f32 speed_f = 0.0f; + int reg_r26 = 0; // unused field_0x6c0 = 1; cXyz vecTrans(pos.x - current.pos.x, pos.y - current.pos.y, pos.z - current.pos.z); mDoMtx_stack_c::YrotS(-shape_angle.y); mDoMtx_stack_c::multVec(&vecTrans, &vecTrans); - if (vecTrans.x < 1000.0f && vecTrans.x > -1000.0f && vecTrans.z < 700.0f && vecTrans.z > -700.0f && fopAcM_GetSpeedF(player) > 0.0f) { - cLib_addCalcAngleS(&field_0x5b0, 0x150, 11, 0x100, 0); - field_0x5c8 = 0x400; + if (vecTrans.x < 1000.0f && vecTrans.x > -1000.0f && vecTrans.z < 700.0f && vecTrans.z > -700.0f) { + f32 reg_f30 = 0.0f; + speed_f = fopAcM_GetSpeedF(player); + if (speed_f > 0.0f) { + cLib_addCalcAngleS(&field_0x5b0, 0x150, 11, 0x100, 0); + field_0x5c8 = 0x400; + } } return FALSE; @@ -123,16 +132,18 @@ void daObjIta_c::setBaseMtx() { mDoMtx_stack_c::XrotM(shape_angle.z); mDoMtx_stack_c::ZrotM(shape_angle.x); mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); - MTXCopy(mDoMtx_stack_c::get(), mBgMtx); + cMtx_copy(mDoMtx_stack_c::get(), mBgMtx); } static void rideCallBack(dBgW* param_1, fopAc_ac_c* a_this, fopAc_ac_c* i_player) { + UNUSED(param_1); + (void) a_this; // it is used, but this is needed for dbg matching daObjIta_c* i_this = (daObjIta_c*)a_this; if (fopAcM_GetName(i_player) == PROC_ALINK) { daPy_py_c* player = daPy_getPlayerActorClass(); if (i_this->field_0x5ac < 0.0f) { - i_this->field_0x5a8 = i_this->field_0x5ac * 0.8f; + i_this->field_0x5a8 = (0.8f + HREG_F(2)) * i_this->field_0x5ac; i_this->field_0x5ac = 0.0f; } @@ -148,20 +159,19 @@ static int daObjIta_Execute(daObjIta_c* i_this) { return i_this->MoveBGExecute(); } -static int daObjIta_IsDelete(daObjIta_c* i_this) { +static int daObjIta_IsDelete(daObjIta_c*) { return 1; } static int daObjIta_Delete(daObjIta_c* i_this) { - fpc_ProcID id = fopAcM_GetID(i_this); + fopAcM_RegisterDeleteID(i_this, "Obj_Ita"); i_this->MoveBGDelete(); return 1; } -static int daObjIta_Create(fopAc_ac_c* a_this) { - daObjIta_c* i_this = (daObjIta_c*)a_this; - fpc_ProcID id = fopAcM_GetID(a_this); - return i_this->create(); +static int daObjIta_Create(fopAc_ac_c* i_this) { + fopAcM_RegisterCreateID(daObjIta_c, i_this, "Obj_Ita"); + return a_this->create(); } int daObjIta_c::CreateHeap() { @@ -196,7 +206,7 @@ cPhs__Step daObjIta_c::create() { cXyz pos(current.pos.x, current.pos.y + 300.0f, current.pos.z); if (fopAcM_wt_c::waterCheck(&pos)) { - current.pos.y = oREG_F(0) + HREG_F(0) + fopAcM_wt_c::getWaterY() + 50.0f; + current.pos.y = fopAcM_wt_c::getWaterY() + 50.0f + HREG_F(0) + oREG_F(0); } return phase; @@ -218,6 +228,7 @@ int daObjIta_c::Execute(Mtx** mtx) { } daPy_py_c* player = daPy_getPlayerActorClass(); + cXyz& unused_pos = fopAcM_GetPosition(player); cXyz& playerSpeed = fopAcM_GetSpeed(player); if (fopAcM_SearchByName(PROC_E_YMB, (fopAc_ac_c**)&e_ymb) != 0 && e_ymb != NULL) { @@ -242,7 +253,7 @@ int daObjIta_c::Execute(Mtx** mtx) { } cLib_addCalc(¤t.pos.y, field_0x5d4 + (posY + 60.0f + field_0x5a8 * (HREG_F(0) + 5.0f) + cM_ssin(field_0x5cc) * 20.0f), 0.1f, 15.0f, 0.1f); - cLib_addCalcAngleS(&shape_angle.x, field_0x5ce.x + (nREG_F(0) + 1.0f) * field_0x5b0 * cM_ssin(field_0x5ca + oREG_F(1) + 0x2000), 2, 0x1000, 1); + cLib_addCalcAngleS(&shape_angle.x, field_0x5ce.x + (nREG_F(0) + 1.0f) * field_0x5b0 * cM_ssin(field_0x5ca + oREG_S(1) + 0x2000), 2, 0x1000, 1); cLib_addCalcAngleS(&shape_angle.z, field_0x5ce.z + (nREG_F(1) + 1.0f) * field_0x5b0 * cM_ssin(field_0x5cc), 2, 0x1000, 1); cLib_addCalc(&field_0x5a4, field_0x5c8, HREG_F(13) + 0.05f, 100.0f, 0.0f); cLib_addCalc2(&field_0x5a8, 0.0f, HREG_F(1) + 0.1f, 10.0f); diff --git a/src/d/actor/d_a_obj_ladder.cpp b/src/d/actor/d_a_obj_ladder.cpp index 9f49f2b73c..abeb80afaf 100644 --- a/src/d/actor/d_a_obj_ladder.cpp +++ b/src/d/actor/d_a_obj_ladder.cpp @@ -10,40 +10,50 @@ #include "SSystem/SComponent/c_math.h" #include "d/d_com_inf_game.h" #include "d/d_bg_s.h" -#include "d/d_bg_w.h" #include "f_op/f_op_actor_mng.h" namespace daObjLadder { namespace { -struct Attr { - /* 0x00 */ f32 field_0x00; - /* 0x04 */ f32 field_0x04; - /* 0x08 */ f32 field_0x08; - /* 0x0C */ f32 field_0x0c; - /* 0x10 */ u8 field_0x10; - /* 0x11 */ u8 field_0x11; - /* 0x12 */ u8 field_0x12; - /* 0x13 */ u8 field_0x13; - /* 0x14 */ u8 field_0x14; - /* 0x16 */ s16 field_0x16; - /* 0x18 */ s16 field_0x18; - /* 0x1A */ s16 vibrationTimer; - /* 0x1C */ f32 field_0x1c; - /* 0x20 */ f32 field_0x20; +struct Attr_c { + /* 0x00 */ f32 gravity; + /* 0x04 */ f32 viscous_resistance; + /* 0x08 */ f32 inertia_resistance; + /* 0x0C */ f32 reflectance; + /* 0x10 */ u8 num_of_bounces; + /* 0x11 */ u8 bound_vol_0; + /* 0x12 */ u8 bound_vol_1; + /* 0x13 */ u8 bound_vol_2; + /* 0x14 */ u8 bound_vol_3; + /* 0x16 */ s16 vibration_speed_x; + /* 0x18 */ s16 vibration_speed_y; + /* 0x1A */ s16 vibration_timer; + /* 0x1C */ f32 vibration_amp_x; + /* 0x20 */ f32 vibration_amp_y; }; -static Attr const L_attr = { - -3.0f, 0.005f, 0.0005f, - 0.5f, 0x03, 0x4B, 0x32, 0x2D, 0x28, 0x4E20, - 0x3CC3, 0x0F, 2.0f, 1.0f, +static Attr_c const L_attr = { + -3.0f, + 0.005f, + 0.0005f, + 0.5f, + // + 3, + 75, + 50, + 45, + 40, + // + 20000, + 15555, + 15, + 2.0f, + 1.0f, }; -inline static const Attr& attr() { +inline static const Attr_c& attr() { return L_attr; } -char const Act_c::M_arcname[5] = "Mhsg"; - struct AttrType { /* 0x0 */ s16 field_0x0; /* 0x2 */ s16 field_0x2; @@ -59,10 +69,110 @@ static AttrType L_attr_type[6] = { { 0x06, 0x0E, 300.0f}, }; -static inline const AttrType& attr_type(Act_c::Type_e type) { +static inline const AttrType& attr_type(Type_e type) { return L_attr_type[type]; } +#if DEBUG +class Hio_c : public JORReflexible { +public: + Hio_c(); + virtual ~Hio_c() {} + + void default_set(); + void ct(); + void dt(); + void listenPropertyEvent(const JORPropertyEvent*); + void genMessage(JORMContext*); + + Attr_c attr; + int mCount; + bool field_0x2c; + bool field_0x2d; +}; + +Hio_c::Hio_c() { + mCount = 0; + field_0x2c = false; + field_0x2d = false; + default_set(); +} + +void Hio_c::default_set() { + attr = L_attr; +} + +void Hio_c::ct() { + if (mCount++ == 0) { + // ladder + daObj::HioVarious_c::init(this, "はしご"); + } +} + +void Hio_c::dt() { + if (--mCount == 0) { + daObj::HioVarious_c::clean(this); + } +} + +void Hio_c::genMessage(JORMContext* ctx) { + // ladder + ctx->genLabel("§ はしご §\n", 0, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // reset to initial position + ctx->genButton("初期位置に", 1, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + // attack + ctx->genButton("アタック", 2, 0, NULL, 0xFFFF, 0xFFFF, 0x200, 0x18); + // gravity + ctx->genSlider("重力", &attr.gravity, -30.0f, 0.0f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // viscous resistance + ctx->genSlider("粘性抵抗", &attr.viscous_resistance, 0.0f, 0.1f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // inertia resistance + ctx->genSlider("慣性抵抗", &attr.inertia_resistance, 0.0f, 0.1f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // reflectance + ctx->genSlider("反射率", &attr.reflectance, 0.0f, 1.0f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // + // number of bounces + ctx->genSlider("バウンド回数", &attr.num_of_bounces, 0, 10, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // Bound Vol_0, 1, 2, 3 + ctx->genSlider("バウンド Vol_0", &attr.bound_vol_0, 0, 100, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + ctx->genSlider("バウンド Vol_1", &attr.bound_vol_1, 0, 100, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + ctx->genSlider("バウンド Vol_2", &attr.bound_vol_2, 0, 100, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + ctx->genSlider("バウンド Vol_3", &attr.bound_vol_3, 0, 100, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // + // vibration speed x, y + ctx->genSlider("vib 速度 x", &attr.vibration_speed_x, 0, 0x7fff, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + ctx->genSlider("vib 速度 y", &attr.vibration_speed_y, 0, 0x7fff, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // vibration time + ctx->genSlider("vib 時間", &attr.vibration_timer, 0, 50, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + // vibration amplitude x, y + ctx->genSlider("vib 振幅 x", &attr.vibration_amp_x, 0.0f, 5.0f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); + ctx->genSlider("vib 振幅 y", &attr.vibration_amp_y, 0.0f, 5.0f, 0, NULL, 0xffff, 0xffff, 0x200, 0x18); +} + +void Hio_c::listenPropertyEvent(const JORPropertyEvent* property) { + JORReflexible::listenPropertyEvent(property); + + switch ((u32)property->id) { + case 1: { + field_0x2c = true; + break; + } + + case 2: { + field_0x2d = true; + break; + } + } + // TODO. +} + +Hio_c L_hio; +#endif + +} + +char const Act_c::M_arcname[5] = "Mhsg"; + int Act_c::CreateHeap() { J3DModelData* model_data = (J3DModelData*)dComIfG_getObjectRes(M_arcname, attr_type(mType).field_0x0); JUT_ASSERT(382, model_data != NULL); @@ -94,7 +204,12 @@ int Act_c::Create() { } else { mode_wait_init(); } - + + if (mHeight <= -G_CM3D_F_INF) { + // "The ladder is falling <%s %d>\n" + OS_REPORT_ERROR("はしごは落ちる<%s %d>\n", "d_a_obj_ladder.cpp", 459); + } + return 1; } @@ -106,6 +221,9 @@ int Act_c::Mthd_Create() { phase_state = MoveBGCreate(M_arcname, attr_type(mType).field_0x2, dBgS_MoveBGProc_Trans, 0xcb0, NULL); JUT_ASSERT(486, (phase_state == cPhs_COMPLEATE_e) || (phase_state == cPhs_ERROR_e)); +#if DEBUG + L_hio.ct(); +#endif } return phase_state; } @@ -115,6 +233,9 @@ int Act_c::Delete() { } int Act_c::Mthd_Delete() { +#if DEBUG + L_hio.dt(); +#endif int rv = MoveBGDelete(); dComIfG_resDelete(&mPhase, M_arcname); return rv; @@ -161,17 +282,17 @@ void Act_c::mode_demoreq() { } void Act_c::mode_vib_init() { - mVibrationTimer = attr().vibrationTimer; + mVibrationTimer = attr().vibration_timer; field_0x610 = 0; field_0x612 = 0; mMode = MODE_VIB; } void Act_c::mode_vib() { - field_0x610 += attr().field_0x16; - field_0x612 += attr().field_0x18; - field_0x614 = cM_scos(field_0x610) * attr().field_0x1c; - field_0x618 = cM_scos(field_0x612) * attr().field_0x20; + field_0x610 += attr().vibration_speed_x; + field_0x612 += attr().vibration_speed_y; + field_0x614 = cM_scos(field_0x610) * attr().vibration_amp_x; + field_0x618 = cM_scos(field_0x612) * attr().vibration_amp_y; if (--mVibrationTimer <= 0) { mode_drop_init(); } @@ -180,27 +301,27 @@ void Act_c::mode_vib() { void Act_c::mode_drop_init() { gravity = -5.0f; speed.set(cXyz::Zero); - field_0x5b6 = attr().field_0x10; + field_0x5b6 = attr().num_of_bounces; mMode = MODE_DROP; } void Act_c::mode_drop() { - daObj::posMoveF_stream(this, NULL, &cXyz::Zero, attr().field_0x04, attr().field_0x08); + daObj::posMoveF_stream(this, NULL, &cXyz::Zero, attr().viscous_resistance, attr().inertia_resistance); if (current.pos.y < mHeight) { - if (field_0x5b6 == attr().field_0x10) { + if (field_0x5b6 == attr().num_of_bounces) { fopAcM_seStart(this, Z2SE_SY_DUMMY, dComIfG_Bgsp().GetMtrlSndId(mGndChk)); dComIfGp_getVibration().StartShock(4, 0x1f, cXyz(0.0f, 1.0f, 0.0f)); } else { int uVar7; - int iVar5 = attr().field_0x10 - field_0x5b6; + int iVar5 = attr().num_of_bounces - field_0x5b6; if (iVar5 == 1) { - uVar7 = attr().field_0x11; + uVar7 = attr().bound_vol_0; } else if (iVar5 == 2) { - uVar7 = attr().field_0x12; + uVar7 = attr().bound_vol_1; } else if (iVar5 == 3) { - uVar7 = attr().field_0x13; + uVar7 = attr().bound_vol_2; } else { - uVar7 = attr().field_0x14; + uVar7 = attr().bound_vol_3; } fopAcM_seStart(this, Z2SE_SY_DUMMY, uVar7); } @@ -263,35 +384,36 @@ int Act_c::Draw() { return 1; } -static int Mthd_Create(void* i_this) { - return ((Act_c*)i_this)->Mthd_Create(); +namespace { + static int Mthd_Create(void* i_this) { + return ((Act_c*)i_this)->Mthd_Create(); + } + + static int Mthd_Delete(void* i_this) { + return ((Act_c*)i_this)->Mthd_Delete(); + } + + static int Mthd_Execute(void* i_this) { + return ((Act_c*)i_this)->MoveBGExecute(); + } + + static int Mthd_Draw(void* i_this) { + return ((Act_c*)i_this)->MoveBGDraw(); + } + + static int Mthd_IsDelete(void* i_this) { + return ((Act_c*)i_this)->MoveBGIsDelete(); + } + + static actor_method_class Mthd_Table = { + (process_method_func)Mthd_Create, + (process_method_func)Mthd_Delete, + (process_method_func)Mthd_Execute, + (process_method_func)Mthd_IsDelete, + (process_method_func)Mthd_Draw, + }; } -static int Mthd_Delete(void* i_this) { - return ((Act_c*)i_this)->Mthd_Delete(); -} - -static int Mthd_Execute(void* i_this) { - return ((Act_c*)i_this)->MoveBGExecute(); -} - -static int Mthd_Draw(void* i_this) { - return ((Act_c*)i_this)->MoveBGDraw(); -} - -static int Mthd_IsDelete(void* i_this) { - return ((Act_c*)i_this)->MoveBGIsDelete(); -} - -static actor_method_class Mthd_Table = { - (process_method_func)Mthd_Create, - (process_method_func)Mthd_Delete, - (process_method_func)Mthd_Execute, - (process_method_func)Mthd_IsDelete, - (process_method_func)Mthd_Draw, -}; - -} } actor_process_profile_definition g_profile_Obj_Ladder = {