diff --git a/configure.py b/configure.py index de1fc5c0f1..75ccdb0ab2 100755 --- a/configure.py +++ b/configure.py @@ -2028,8 +2028,8 @@ config.libs = [ ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hakai_brl"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hakai_ftr"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hasu2"), - ActorRel(NonMatching, "d_a_obj_hata"), - ActorRel(NonMatching, "d_a_obj_hb"), + ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hata"), + ActorRel(MatchingFor("GZ2E01"), "d_a_obj_hb"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hbombkoya"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_heavySw"), ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_hfuta"), diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 7694407de4..cdb2343361 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -376,6 +376,8 @@ public: u32 ChkAtSPrm(u32 prm) { return mObjAt.ChkSPrm(prm); } u32 ChkCoSPrm(u32 prm) const { return mObjCo.ChkSPrm(prm); } void OnTgNoSlingHitInfSet() { mObjTg.OnSPrmBit(0x40); } + void OnAtVsBitSet(u32 prm) { mObjAt.OnSPrmBit(prm); } + void OffAtVsBitSet(u32 prm) { mObjAt.OffSPrmBit(prm); } }; // Size = 0x40 diff --git a/include/d/actor/d_a_obj_hata.h b/include/d/actor/d_a_obj_hata.h index a54edb59b9..13920664c6 100644 --- a/include/d/actor/d_a_obj_hata.h +++ b/include/d/actor/d_a_obj_hata.h @@ -1,6 +1,44 @@ #ifndef D_A_OBJ_HATA_H #define D_A_OBJ_HATA_H +#include "SSystem/SComponent/c_phase.h" #include "dolphin/types.h" +#include "f_op/f_op_actor.h" + +/** + * @ingroup actors-objects + * @class daObjHata_c + * @brief Flag ??? + * + * @details + * +*/ + +class daObjHata_c : public fopAc_ac_c, request_of_phase_process_class { +public: + /* 80C18D08 */ daObjHata_c(); + /* 80C18D68 */ virtual ~daObjHata_c(); + /* 80C18E00 */ int createHeap(); + /* 80C18E70 */ cPhs__Step create(); + /* 80C18F88 */ int Delete(); + /* 80C18FBC */ int draw(); + /* 80C19060 */ int execute(); + /* 80C19098 */ void setModelMtx(); + /* 80C190FC */ void init(); + /* 80C1919C */ void moveSwing(); + + void getJntAngle(csXyz* angle, int idx) { *angle = jnt_angle[idx]; } + + /* 0x574 */ csXyz jnt_angle[3]; + /* 0x588 */ J3DModel* model; + /* 0x58C */ f32 field_0x58c[3]; + /* 0x598 */ f32 field_0x598[3]; + /* 0x5A4 */ f32 field_0x5a4[3]; + /* 0x5B0 */ f32 field_0x5b0[3]; + /* 0x5BC */ s8 field_0x5bc[3]; + /* 0x5BF */ s8 field_0x5bf[3]; +}; + +STATIC_ASSERT(sizeof(daObjHata_c) == 0x5C4); #endif /* D_A_OBJ_HATA_H */ diff --git a/include/d/actor/d_a_obj_hb.h b/include/d/actor/d_a_obj_hb.h index 9b10a8a6ad..17c7889c96 100644 --- a/include/d/actor/d_a_obj_hb.h +++ b/include/d/actor/d_a_obj_hb.h @@ -1,6 +1,9 @@ #ifndef D_A_OBJ_HB_H #define D_A_OBJ_HB_H +#include "d/d_bg_s_acch.h" +#include "d/d_cc_d.h" +#include "d/d_cc_uty.h" #include "f_op/f_op_actor_mng.h" /** @@ -10,10 +13,52 @@ * * @details * - */ -class obj_hb_class : public fopAc_ac_c { -private: - /* 0x568 */ u8 field_0x568[0xa8c - 0x568]; +*/ + +class obj_hb_class { +public: + /* 0x000 */ fopEn_enemy_c actor; + /* 0x5AC */ request_of_phase_process_class mPhase; + /* 0x5B4 */ u8 arg0; + /* 0x5B8 */ J3DModel* mpModel; + /* 0x5BC */ u32 mShadowKey; + /* 0x5C0 */ Z2Creature mSound; + /* 0x650 */ s16 field_0x650; + /* 0x652 */ s16 mAction; + /* 0x654 */ s16 mMode; + /* 0x658 */ cXyz field_0x658; + /* 0x664 */ u8 field_0x664[0x670 - 0x664]; + /* 0x670 */ s16 mTimers[2]; + /* 0x674 */ s16 mInvulnerabilityTimer; + /* 0x676 */ csXyz field_0x676; + /* 0x67C */ s16 field_0x67c; + /* 0x67E */ s16 field_0x67e; + /* 0x680 */ f32 mGroundCross; + /* 0x684 */ s16 mShapeAngleXOffset; + /* 0x688 */ f32 field_0x688; + /* 0x68C */ s16 field_0x68c; + /* 0x68E */ s16 field_0x68e; + /* 0x690 */ s16 field_0x690; + /* 0x694 */ f32 field_0x694; + /* 0x698 */ f32 field_0x698; + /* 0x69C */ fpc_ProcID field_0x69c; + /* 0x6A0 */ f32 mCurrentPosStep; + /* 0x6A4 */ s16 field_0x6a4; + /* 0x6A8 */ fpc_ProcID mChildActorID; + /* 0x6AC */ f32 mChildPlaySpeed; + /* 0x6B0 */ s8 field_0x6b0; + /* 0x6B1 */ s8 field_0x6b1; + /* 0x6B4 */ f32 field_0x6b4; + /* 0x6B8 */ dBgS_AcchCir mAcchCir; + /* 0x6F8 */ dBgS_ObjAcch mBgc; + /* 0x8D0 */ dCcD_Stts mStts; + /* 0x90C */ dCcD_Sph mSph; + /* 0xA44 */ dCcU_AtInfo mAtInfo; + /* 0xA68 */ u32 field_0xa68; + /* 0xA6C */ u32 field_0xa6c; + /* 0xA70 */ u32 mPrtcls[4]; + /* 0xA80 */ u32 mHamonPrtcl; + /* 0xA84 */ u8 field_0xa84[0xa8c - 0xa84]; }; STATIC_ASSERT(sizeof(obj_hb_class) == 0xa8c); diff --git a/src/d/actor/d_a_obj_hata.cpp b/src/d/actor/d_a_obj_hata.cpp index 48ef167fab..60d0f71973 100644 --- a/src/d/actor/d_a_obj_hata.cpp +++ b/src/d/actor/d_a_obj_hata.cpp @@ -7,281 +7,216 @@ #include "d/actor/d_a_obj_hata.h" #include "f_op/f_op_actor.h" -#include "dol2asm.h" - -struct daObjHata_c { - /* 80C18D08 */ daObjHata_c(); - /* 80C18D68 */ ~daObjHata_c(); - /* 80C18E00 */ void createHeap(); - /* 80C18E70 */ void create(); - /* 80C18F88 */ void Delete(); - /* 80C18FBC */ void draw(); - /* 80C19060 */ void execute(); - /* 80C19098 */ void setModelMtx(); - /* 80C190FC */ void init(); - /* 80C1919C */ void moveSwing(); -}; - -// -// Forward References: -// - -extern "C" static void daObjHata_c_createHeap__FP10fopAc_ac_c(); -extern "C" static void nodeCallBack__FP8J3DJointi(); -extern "C" void __dt__5csXyzFv(); -extern "C" void __ct__11daObjHata_cFv(); -extern "C" void __ct__5csXyzFv(); -extern "C" void __dt__11daObjHata_cFv(); -extern "C" void createHeap__11daObjHata_cFv(); -extern "C" void create__11daObjHata_cFv(); -extern "C" void Delete__11daObjHata_cFv(); -extern "C" void draw__11daObjHata_cFv(); -extern "C" void execute__11daObjHata_cFv(); -extern "C" void setModelMtx__11daObjHata_cFv(); -extern "C" void init__11daObjHata_cFv(); -extern "C" void moveSwing__11daObjHata_cFv(); -extern "C" static void daObjHata_create__FP11daObjHata_c(); -extern "C" static void daObjHata_Delete__FP11daObjHata_c(); -extern "C" static void daObjHata_execute__FP11daObjHata_c(); -extern "C" static void daObjHata_draw__FP11daObjHata_c(); -extern "C" extern char const* const d_a_obj_hata__stringBase0; - -// -// External References: -// - -extern "C" void mDoMtx_YrotM__FPA4_fs(); -extern "C" void ZXYrotM__14mDoMtx_stack_cFRC5csXyz(); -extern "C" void mDoExt_modelUpdateDL__FP8J3DModel(); -extern "C" void mDoExt_J3DModel__create__FP12J3DModelDataUlUl(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void __dt__10fopAc_ac_cFv(); -extern "C" void fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl(); -extern "C" void fopAcM_setCullSizeBox2__FP10fopAc_ac_cP12J3DModelData(); -extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfG_resDelete__FP30request_of_phase_process_classPCc(); -extern "C" void getRes__14dRes_control_cFPCclP11dRes_info_ci(); -extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c(); -extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c(); -extern "C" void cM_rndF__Ff(); -extern "C" void cM_rndFX__Ff(); -extern "C" void cLib_chaseF__FPfff(); -extern "C" void __dl__FPv(); -extern "C" void __destroy_arr(); -extern "C" void __construct_array(); -extern "C" void _savegpr_21(); -extern "C" void _savegpr_26(); -extern "C" void _restgpr_21(); -extern "C" void _restgpr_26(); -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" u8 mCurrentMtx__6J3DSys[48]; - -// -// Declarations: -// /* 80C18BB8-80C18BD8 000078 0020+00 1/1 0/0 0/0 .text daObjHata_c_createHeap__FP10fopAc_ac_c */ -static void daObjHata_c_createHeap(fopAc_ac_c* param_0) { - // NONMATCHING +static int daObjHata_c_createHeap(fopAc_ac_c* a_this) { + return static_cast(a_this)->createHeap(); } /* 80C18BD8-80C18CCC 000098 00F4+00 1/1 0/0 0/0 .text nodeCallBack__FP8J3DJointi */ -static void nodeCallBack(J3DJoint* param_0, int param_1) { - // NONMATCHING -} +static int nodeCallBack(J3DJoint* i_joint, int param_2) { + if (param_2 != 0) { + return 1; + } -/* ############################################################################################## */ -/* 80C194C0-80C194C0 000048 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80C194C0 = "Hata"; -#pragma pop + int jntNo = i_joint->getJntNo(); + if (jntNo < 0 || jntNo >= 3) { + return 1; + } + + J3DModel* model = j3dSys.getModel(); + daObjHata_c* i_this = (daObjHata_c*)model->getUserArea(); + if (model == NULL || i_this == NULL) { + return 1; + } + + csXyz angle; + i_this->getJntAngle(&angle, jntNo); + MTXCopy(model->getAnmMtx(jntNo), mDoMtx_stack_c::get()); + mDoMtx_stack_c::ZXYrotM(angle); + model->setAnmMtx(jntNo, mDoMtx_stack_c::get()); + mDoMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); + + return 1; +} /* 80C194C8-80C194CC -00001 0004+00 3/3 0/0 0/0 .data l_arcName */ -SECTION_DATA static void* l_arcName = (void*)&d_a_obj_hata__stringBase0; - -/* 80C194CC-80C194EC -00001 0020+00 1/0 0/0 0/0 .data daObjHata_METHODS */ -SECTION_DATA static void* daObjHata_METHODS[8] = { - (void*)daObjHata_create__FP11daObjHata_c, - (void*)daObjHata_Delete__FP11daObjHata_c, - (void*)daObjHata_execute__FP11daObjHata_c, - (void*)NULL, - (void*)daObjHata_draw__FP11daObjHata_c, - (void*)NULL, - (void*)NULL, - (void*)NULL, -}; - -/* 80C194EC-80C1951C -00001 0030+00 0/0 0/0 1/0 .data g_profile_Obj_Hata */ -SECTION_DATA extern void* g_profile_Obj_Hata[12] = { - (void*)0xFFFFFFFD, (void*)0x0007FFFD, - (void*)0x01A80000, (void*)&g_fpcLf_Method, - (void*)0x000005C4, (void*)NULL, - (void*)NULL, (void*)&g_fopAc_Method, - (void*)0x02EB0000, (void*)&daObjHata_METHODS, - (void*)0x00040180, (void*)0x030E0000, -}; - -/* 80C1951C-80C19528 000054 000C+00 2/2 0/0 0/0 .data __vt__11daObjHata_c */ -SECTION_DATA extern void* __vt__11daObjHata_c[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__11daObjHata_cFv, -}; +static char* l_arcName = "Hata"; /* 80C18D08-80C18D64 0001C8 005C+00 2/2 0/0 0/0 .text __ct__11daObjHata_cFv */ -daObjHata_c::daObjHata_c() { - // NONMATCHING -} +daObjHata_c::daObjHata_c() {} /* 80C18D68-80C18E00 000228 0098+00 1/0 0/0 0/0 .text __dt__11daObjHata_cFv */ daObjHata_c::~daObjHata_c() { - // NONMATCHING + dComIfG_resDelete(this, l_arcName); } /* 80C18E00-80C18E70 0002C0 0070+00 1/1 0/0 0/0 .text createHeap__11daObjHata_cFv */ -void daObjHata_c::createHeap() { - // NONMATCHING +int daObjHata_c::createHeap() { + J3DModelData* a_model_data_p = (J3DModelData*)dComIfG_getObjectRes(l_arcName, 3); + JUT_ASSERT(109, a_model_data_p != NULL); + model = mDoExt_J3DModel__create(a_model_data_p, 0x80000, 0x11000084); + if (model == NULL) { + return 0; + } + + return 1; } /* 80C18E70-80C18F88 000330 0118+00 1/1 0/0 0/0 .text create__11daObjHata_cFv */ -void daObjHata_c::create() { - // NONMATCHING +cPhs__Step daObjHata_c::create() { + fopAcM_ct(this, daObjHata_c); + + cPhs__Step phase_step = (cPhs__Step)dComIfG_resLoad(this, l_arcName); + if (phase_step == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, daObjHata_c_createHeap, 0x870)) { + return cPhs_ERROR_e; + } + + init(); + setModelMtx(); + fopAcM_SetMtx(this, model->getBaseTRMtx()); + fopAcM_setCullSizeBox2(this, model->getModelData()); + + for (int i = 0; i < 3; i++) { + J3DJoint* jnt_node_p = model->getModelData()->getJointNodePointer(i); + if (jnt_node_p != NULL) { + jnt_node_p->setCallBack(nodeCallBack); + model->setUserArea((uintptr_t)this); + } + } + } + + return phase_step; } /* 80C18F88-80C18FBC 000448 0034+00 1/1 0/0 0/0 .text Delete__11daObjHata_cFv */ -void daObjHata_c::Delete() { - // NONMATCHING +int daObjHata_c::Delete() { + this->~daObjHata_c(); + return 1; } /* 80C18FBC-80C19060 00047C 00A4+00 1/1 0/0 0/0 .text draw__11daObjHata_cFv */ -void daObjHata_c::draw() { - // NONMATCHING +int daObjHata_c::draw() { + g_env_light.settingTevStruct(16, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType_MAJI(model, &tevStr); + dComIfGd_setListBG(); + mDoExt_modelUpdateDL(model); + dComIfGd_setList(); + return 1; } /* 80C19060-80C19098 000520 0038+00 1/1 0/0 0/0 .text execute__11daObjHata_cFv */ -void daObjHata_c::execute() { - // NONMATCHING +int daObjHata_c::execute() { + moveSwing(); + setModelMtx(); + return 1; } /* 80C19098-80C190FC 000558 0064+00 2/2 0/0 0/0 .text setModelMtx__11daObjHata_cFv */ void daObjHata_c::setModelMtx() { - // NONMATCHING + mDoMtx_stack_c::transS(current.pos.x, current.pos.y, current.pos.z); + mDoMtx_stack_c::YrotM(shape_angle.y); + model->setBaseTRMtx(mDoMtx_stack_c::get()); } -/* ############################################################################################## */ -/* 80C19478-80C1947C 000000 0004+00 2/2 0/0 0/0 .rodata @3788 */ -SECTION_RODATA static f32 const lit_3788 = 1280.0f; -COMPILER_STRIP_GATE(0x80C19478, &lit_3788); - -/* 80C1947C-80C19480 000004 0004+00 1/2 0/0 0/0 .rodata @3789 */ -SECTION_RODATA static f32 const lit_3789 = 1.0f; -COMPILER_STRIP_GATE(0x80C1947C, &lit_3789); - /* 80C190FC-80C1919C 0005BC 00A0+00 1/1 0/0 0/0 .text init__11daObjHata_cFv */ void daObjHata_c::init() { - // NONMATCHING + for (int i = 0; i < 3; i++) { + field_0x58c[i] = cM_rndFX(1280.0f); + field_0x598[i] = cM_rndFX(1280.0f); + field_0x5bc[i] = 1; + field_0x5bf[i] = -1; + field_0x5a4[i] = cM_rndF(1.0f); + field_0x5b0[i] = cM_rndF(1.0f); + } } -/* ############################################################################################## */ -/* 80C19480-80C1948C 000008 000C+00 0/1 0/0 0/0 .rodata SING$3793 */ -#pragma push -#pragma force_active on -#define SING_BAK SING -#undef SING -SECTION_RODATA static u8 const SING[12] = { - 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, -}; -COMPILER_STRIP_GATE(0x80C19480, &SING); -#define SING SING_BAK -#undef SING_BAK -#pragma pop - -/* 80C1948C-80C19498 000014 000C+00 0/1 0/0 0/0 .rodata AIM_ANGLE_X$3794 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const AIM_ANGLE_X[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xBC, 0x00, 0x00, 0x02, 0xBC, -}; -COMPILER_STRIP_GATE(0x80C1948C, &AIM_ANGLE_X); -#pragma pop - -/* 80C19498-80C194A4 000020 000C+00 0/1 0/0 0/0 .rodata STEP_ANGLE_X$3795 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const STEP_ANGLE_X[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x5A, -}; -COMPILER_STRIP_GATE(0x80C19498, &STEP_ANGLE_X); -#pragma pop - -/* 80C194A4-80C194A8 00002C 0004+00 0/1 0/0 0/0 .rodata @3823 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3823 = 50.0f; -COMPILER_STRIP_GATE(0x80C194A4, &lit_3823); -#pragma pop - -/* 80C194A8-80C194AC 000030 0004+00 0/1 0/0 0/0 .rodata @3824 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3824 = 1500.0f; -COMPILER_STRIP_GATE(0x80C194A8, &lit_3824); -#pragma pop - -/* 80C194AC-80C194B0 000034 0004+00 0/1 0/0 0/0 .rodata @3825 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3825 = 1.0f / 10.0f; -COMPILER_STRIP_GATE(0x80C194AC, &lit_3825); -#pragma pop - -/* 80C194B0-80C194B8 000038 0004+04 0/1 0/0 0/0 .rodata @3826 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3826[1 + 1 /* padding */] = { - 0.5f, - /* padding */ - 0.0f, -}; -COMPILER_STRIP_GATE(0x80C194B0, &lit_3826); -#pragma pop - -/* 80C194B8-80C194C0 000040 0008+00 0/1 0/0 0/0 .rodata @3828 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_3828[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80C194B8, &lit_3828); -#pragma pop - /* 80C1919C-80C193BC 00065C 0220+00 1/1 0/0 0/0 .text moveSwing__11daObjHata_cFv */ void daObjHata_c::moveSwing() { - // NONMATCHING + #undef SING + static int const SING[3] = { + 1, -1, 1, + }; + + static int const AIM_ANGLE_X[3] = { + 0, 0x2BC, 0x2BC, + }; + + static int const STEP_ANGLE_X[3] = { + 0, 0x3C, 0x5A, + }; + + for (int i = 0; i < 3; i++) { + f32 fVar1 = jnt_angle[i].x; + f32 fVar2 = jnt_angle[i].z; + if (cLib_chaseF(&fVar2, field_0x598[i] * (field_0x5bc[i] * SING[i]), field_0x5a4[i] * 50.0f) != 0) { + field_0x598[i] = cM_rndF(1500.0f); + + if (i == 2) { + field_0x5bc[i] *= -1; + field_0x5a4[i] = cM_rndF(1.0f) + 0.1f; + } + } + + if (cLib_chaseF(&fVar1, field_0x58c[i] * (field_0x5bf[i] * SING[i]), field_0x5b0[i] * STEP_ANGLE_X[i]) != 0) { + field_0x58c[i] = cM_rndF(AIM_ANGLE_X[i]); + + if (i == 2) { + field_0x5bf[i] *= -1; + field_0x5b0[i] = cM_rndF(1.0f) + 0.5f; + } + } + + jnt_angle[i].x = fVar1; + jnt_angle[i].z = fVar2; + } } -/* 80C193BC-80C19410 00087C 0054+00 1/0 0/0 0/0 .text daObjHata_create__FP11daObjHata_c - */ -static void daObjHata_create(daObjHata_c* param_0) { - // NONMATCHING +/* 80C193BC-80C19410 00087C 0054+00 1/0 0/0 0/0 .text daObjHata_create__FP11daObjHata_c */ +static int daObjHata_create(daObjHata_c* i_this) { + fopAcM_ct(i_this, daObjHata_c); + return i_this->create(); } -/* 80C19410-80C19430 0008D0 0020+00 1/0 0/0 0/0 .text daObjHata_Delete__FP11daObjHata_c - */ -static void daObjHata_Delete(daObjHata_c* param_0) { - // NONMATCHING +/* 80C19410-80C19430 0008D0 0020+00 1/0 0/0 0/0 .text daObjHata_Delete__FP11daObjHata_c */ +static int daObjHata_Delete(daObjHata_c* i_this) { + return i_this->Delete(); } -/* 80C19430-80C19450 0008F0 0020+00 1/0 0/0 0/0 .text daObjHata_execute__FP11daObjHata_c - */ -static void daObjHata_execute(daObjHata_c* param_0) { - // NONMATCHING +/* 80C19430-80C19450 0008F0 0020+00 1/0 0/0 0/0 .text daObjHata_execute__FP11daObjHata_c */ +static int daObjHata_execute(daObjHata_c* i_this) { + return i_this->execute(); } /* 80C19450-80C19470 000910 0020+00 1/0 0/0 0/0 .text daObjHata_draw__FP11daObjHata_c */ -static void daObjHata_draw(daObjHata_c* param_0) { - // NONMATCHING +static int daObjHata_draw(daObjHata_c* i_this) { + return i_this->draw(); } -/* 80C194C0-80C194C0 000048 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ +/* 80C194CC-80C194EC -00001 0020+00 1/0 0/0 0/0 .data daObjHata_METHODS */ +static actor_method_class daObjHata_METHODS = { + (process_method_func)daObjHata_create, + (process_method_func)daObjHata_Delete, + (process_method_func)daObjHata_execute, + (process_method_func)NULL, + (process_method_func)daObjHata_draw, +}; + +/* 80C194EC-80C1951C -00001 0030+00 0/0 0/0 1/0 .data g_profile_Obj_Hata */ +extern actor_process_profile_definition g_profile_Obj_Hata = { + fpcLy_CURRENT_e, // mLayerID + 7, // mListID + fpcPi_CURRENT_e, // mListPrio + PROC_Obj_Hata, // mProcName + &g_fpcLf_Method.base, // sub_method + sizeof(daObjHata_c), // mSize + 0, // mSizeOther + 0, // mParameters + &g_fopAc_Method.base, // sub_method + 747, // mPriority + &daObjHata_METHODS, // sub_method + 0x00040180, // mStatus + fopAc_ENV_e, // mActorType + fopAc_CULLBOX_CUSTOM_e, // cullType +}; diff --git a/src/d/actor/d_a_obj_hb.cpp b/src/d/actor/d_a_obj_hb.cpp index 956b6492f4..6af9aaeca7 100644 --- a/src/d/actor/d_a_obj_hb.cpp +++ b/src/d/actor/d_a_obj_hb.cpp @@ -7,665 +7,729 @@ #include "d/actor/d_a_obj_hb.h" #include "d/d_cc_d.h" -#include "dol2asm.h" +#include "d/actor/d_a_player.h" +#include "d/actor/d_a_e_hb_leaf.h" +#include "d/d_s_play.h" - -// -// Forward References: -// - -extern "C" static void daOBJ_HB_Draw__FP12obj_hb_class(); -extern "C" static void obj_hb_carry__FP12obj_hb_class(); -extern "C" static void wall_angle_get__FP12obj_hb_class(); -extern "C" static void water_check__FP12obj_hb_class(); -extern "C" static void obj_hb_set__FP12obj_hb_class(); -extern "C" static void getGroundAngle__FP10fopAc_ac_cP5csXyz(); -extern "C" static void obj_hb_drop__FP12obj_hb_class(); -extern "C" static void obj_hb_float__FP12obj_hb_class(); -extern "C" static void action__FP12obj_hb_class(); -extern "C" static void daOBJ_HB_Execute__FP12obj_hb_class(); -extern "C" static bool daOBJ_HB_IsDelete__FP12obj_hb_class(); -extern "C" static void daOBJ_HB_Delete__FP12obj_hb_class(); -extern "C" static void useHeapInit__FP10fopAc_ac_c(); -extern "C" static void daOBJ_HB_Create__FP10fopAc_ac_c(); -extern "C" void __dt__8cM3dGSphFv(); -extern "C" void __dt__8cM3dGAabFv(); -extern "C" void __dt__12dBgS_ObjAcchFv(); -extern "C" static void func_80C1B5E8(); -extern "C" static void func_80C1B5F0(); -extern "C" extern char const* const d_a_obj_hb__stringBase0; - -// -// External References: -// - -extern "C" void mDoMtx_XrotS__FPA4_fs(); -extern "C" void mDoMtx_XrotM__FPA4_fs(); -extern "C" void mDoMtx_YrotS__FPA4_fs(); -extern "C" void mDoMtx_YrotM__FPA4_fs(); -extern "C" void mDoMtx_ZrotM__FPA4_fs(); -extern "C" void transM__14mDoMtx_stack_cFfff(); -extern "C" void scaleM__14mDoMtx_stack_cFfff(); -extern "C" void mDoExt_modelUpdateDL__FP8J3DModel(); -extern "C" void play__14mDoExt_McaMorfFP3VecUlSc(); -extern "C" void mDoExt_J3DModel__create__FP12J3DModelDataUlUl(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopAcIt_Judge__FPFPvPv_PvPv(); -extern "C" void fopAcM_createChild__FsUiUlPC4cXyziPC5csXyzPC4cXyzScPFPv_i(); -extern "C" void fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl(); -extern "C" void fopAcM_searchActorAngleY__FPC10fopAc_ac_cPC10fopAc_ac_c(); -extern "C" void fopAcM_searchActorDistance__FPC10fopAc_ac_cPC10fopAc_ac_c(); -extern "C" void fopAcM_createDisappear__FPC10fopAc_ac_cPC4cXyzUcUcUc(); -extern "C" void fopAcM_effSmokeSet1__FPUlPUlPC4cXyzPC5csXyzfPC12dKy_tevstr_ci(); -extern "C" void fopAcM_effHamonSet__FPUlPC4cXyzff(); -extern "C" void fpcSch_JudgeByID__FPvPv(); -extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfG_resDelete__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfGp_getReverb__Fi(); -extern "C" void -dComIfGd_setShadow__FUlScP8J3DModelP4cXyzffffR13cBgS_PolyInfoP12dKy_tevstr_csfP9_GXTexObj(); -extern "C" void getRes__14dRes_control_cFPCclP11dRes_info_ci(); -extern "C" void -set__13dPa_control_cFUlUcUsPC4cXyzPC12dKy_tevstr_cPC5csXyzPC4cXyzUcP18dPa_levelEcallBackScPC8_GXColorPC8_GXColorPC4cXyzf(); -extern "C" void LockonTarget__12dAttention_cFl(); -extern "C" void LockonTruth__12dAttention_cFv(); -extern "C" void LineCross__4cBgSFP11cBgS_LinChk(); -extern "C" void GroundCross__4cBgSFP11cBgS_GndChk(); -extern "C" void __ct__12dBgS_AcchCirFv(); -extern "C" void SetWall__12dBgS_AcchCirFff(); -extern "C" void __dt__9dBgS_AcchFv(); -extern "C" void __ct__9dBgS_AcchFv(); -extern "C" void Set__9dBgS_AcchFP4cXyzP4cXyzP10fopAc_ac_ciP12dBgS_AcchCirP4cXyzP5csXyzP5csXyz(); -extern "C" void CrrPos__9dBgS_AcchFR4dBgS(); -extern "C" void __ct__11dBgS_GndChkFv(); -extern "C" void __dt__11dBgS_GndChkFv(); -extern "C" void __ct__18dBgS_ObjGndChk_SplFv(); -extern "C" void __dt__18dBgS_ObjGndChk_SplFv(); -extern "C" void __ct__11dBgS_LinChkFv(); -extern "C" void __dt__11dBgS_LinChkFv(); -extern "C" void Set__11dBgS_LinChkFPC4cXyzPC4cXyzPC10fopAc_ac_c(); -extern "C" void SetObj__16dBgS_PolyPassChkFv(); -extern "C" void __ct__10dCcD_GSttsFv(); -extern "C" void Init__9dCcD_SttsFiiP10fopAc_ac_c(); -extern "C" void __ct__12dCcD_GObjInfFv(); -extern "C" void ChkAtHit__12dCcD_GObjInfFv(); -extern "C" void ChkTgHit__12dCcD_GObjInfFv(); -extern "C" void GetTgHitObj__12dCcD_GObjInfFv(); -extern "C" void ChkCoHit__12dCcD_GObjInfFv(); -extern "C" void Set__8dCcD_SphFRC11dCcD_SrcSph(); -extern "C" void def_se_set__FP10Z2CreatureP8cCcD_ObjUlP10fopAc_ac_c(); -extern "C" void at_power_check__FP11dCcU_AtInfo(); -extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c(); -extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c(); -extern "C" void Set__4cCcSFP8cCcD_Obj(); -extern "C" void __mi__4cXyzCFRC3Vec(); -extern "C" void cM_atan2s__Fff(); -extern "C" void cM_rndF__Ff(); -extern "C" void cM_rndFX__Ff(); -extern "C" void SetPos__11cBgS_GndChkFPC3Vec(); -extern "C" void SetPos__11cBgS_GndChkFPC4cXyz(); -extern "C" void SetC__8cM3dGSphFRC4cXyz(); -extern "C" void SetR__8cM3dGSphFf(); -extern "C" void cLib_addCalc2__FPffff(); -extern "C" void cLib_addCalc0__FPfff(); -extern "C" void cLib_addCalcAngleS2__FPssss(); -extern "C" void MtxPosition__FP4cXyzP4cXyz(); -extern "C" void __ct__10Z2CreatureFv(); -extern "C" void init__10Z2CreatureFP3VecP3VecUcUc(); -extern "C" void stopAnime__10Z2CreatureFv(); -extern "C" void __dl__FPv(); -extern "C" void _savegpr_24(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_27(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_24(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_27(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" extern void* __vt__8dCcD_Sph[36]; -extern "C" extern void* __vt__9dCcD_Stts[11]; -extern "C" extern void* __vt__12cCcD_SphAttr[25]; -extern "C" extern void* __vt__14cCcD_ShapeAttr[22]; -extern "C" extern void* __vt__9cCcD_Stts[8]; -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" u8 mSimpleTexObj__21dDlst_shadowControl_c[32]; -extern "C" u8 sincosTable___5JMath[65536]; -extern "C" extern u8 data_80C1B7E0[4]; - -// -// Declarations: -// - -/* ############################################################################################## */ -/* 80C1B600-80C1B604 000000 0004+00 9/9 0/0 0/0 .rodata @3665 */ -SECTION_RODATA static f32 const lit_3665 = 100.0f; -COMPILER_STRIP_GATE(0x80C1B600, &lit_3665); - -/* 80C1B604-80C1B608 000004 0004+00 0/1 0/0 0/0 .rodata @3666 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3666 = 400.0f; -COMPILER_STRIP_GATE(0x80C1B604, &lit_3666); -#pragma pop - -/* 80C1B608-80C1B60C 000008 0004+00 1/9 0/0 0/0 .rodata @3667 */ -SECTION_RODATA static u8 const lit_3667[4] = { - 0x00, - 0x00, - 0x00, - 0x00, +enum Action { + /* 0x0 */ ACTION_SET, + /* 0x1 */ ACTION_DROP, + /* 0x2 */ ACTION_FLOAT, + /* 0x3 */ ACTION_CARRY, }; -COMPILER_STRIP_GATE(0x80C1B608, &lit_3667); - -/* 80C1B60C-80C1B610 00000C 0004+00 0/7 0/0 0/0 .rodata @3668 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3668 = 1.0f; -COMPILER_STRIP_GATE(0x80C1B60C, &lit_3668); -#pragma pop /* 80C195B8-80C19688 000078 00D0+00 1/0 0/0 0/0 .text daOBJ_HB_Draw__FP12obj_hb_class */ -static void daOBJ_HB_Draw(obj_hb_class* param_0) { - // NONMATCHING +static int daOBJ_HB_Draw(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + + g_env_light.settingTevStruct(0, &a_this->current.pos, &a_this->tevStr); + g_env_light.setLightTevColorType_MAJI(i_this->mpModel, &a_this->tevStr); + mDoExt_modelUpdateDL(i_this->mpModel); + cXyz pos(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, i_this->mpModel, &pos, 400.0f, 0.0f, a_this->current.pos.y, + i_this->mBgc.GetGroundH(), i_this->mBgc.m_gnd, &a_this->tevStr, + 0, 1.0f, dDlst_shadowControl_c::getSimpleTex()); + return 1; } -/* ############################################################################################## */ -/* 80C1B610-80C1B614 000010 0004+00 0/5 0/0 0/0 .rodata @3735 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3735 = 10.0f; -COMPILER_STRIP_GATE(0x80C1B610, &lit_3735); -#pragma pop - -/* 80C1B614-80C1B618 000014 0004+00 0/4 0/0 0/0 .rodata @3736 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3736 = 30.0f; -COMPILER_STRIP_GATE(0x80C1B614, &lit_3736); -#pragma pop - -/* 80C1B618-80C1B61C 000018 0004+00 0/2 0/0 0/0 .rodata @3737 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3737 = 0.25f; -COMPILER_STRIP_GATE(0x80C1B618, &lit_3737); -#pragma pop - -/* 80C1B61C-80C1B620 00001C 0004+00 0/2 0/0 0/0 .rodata @3738 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3738 = 1000.0f; -COMPILER_STRIP_GATE(0x80C1B61C, &lit_3738); -#pragma pop - /* 80C19688-80C1988C 000148 0204+00 1/1 0/0 0/0 .text obj_hb_carry__FP12obj_hb_class */ -static void obj_hb_carry(obj_hb_class* param_0) { - // NONMATCHING +static void obj_hb_carry(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fopAc_ac_c* player = dComIfGp_getPlayer(0); + + switch (i_this->mMode) { + case 0: { + cLib_offBit(a_this->attention_info.flags, fopAc_AttnFlag_CARRY_e); + i_this->mMode = 1; + s16 angle_delta = i_this->field_0x676.y - player->shape_angle.y; + if (angle_delta > 0x4000 || angle_delta < -0x4000) { + i_this->field_0x67e = -0x8000; + } else { + i_this->field_0x67e = 0; + } + break; + } + + case 1: + if (!fopAcM_checkCarryNow(a_this)) { + i_this->mAction = ACTION_DROP; + i_this->mSph.OnCoSetBit(); + i_this->field_0x69c = fpcM_ERROR_PROCESS_ID_e; + i_this->mCurrentPosStep = 0.0f; + + if (fopAcM_GetSpeedF(a_this) > 1.0f || fopAcM_GetSpeedF(player) > 10.0f) { + a_this->speedF = WREG_F(9) + 30.0f + (fopAcM_GetSpeedF(player) * 0.25f); + a_this->speed.y = WREG_F(10) + 30.0f; + a_this->current.angle.y = player->shape_angle.y; + i_this->mMode = 0; + + if (dComIfGp_getAttention()->Lockon()) { + i_this->field_0x69c = fopAcM_GetID(dComIfGp_getAttention()->LockonTarget(0)); + } + } else { + a_this->speedF = 0.0f; + a_this->speed.y = 0.0f; + i_this->mMode = 5; + i_this->field_0x688 = NREG_F(2) + 1000.0f; + } + } + break; + } + + a_this->eyePos = a_this->current.pos; + a_this->attention_info.position = a_this->current.pos; + cLib_addCalcAngleS2(&i_this->field_0x676.y, player->shape_angle.y + i_this->field_0x67e, 1, i_this->field_0x67c); + cLib_addCalcAngleS2(&i_this->field_0x67c, 0x2000, 1, 0x100); } -/* ############################################################################################## */ -/* 80C1B620-80C1B624 000020 0004+00 0/1 0/0 0/0 .rodata @3792 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3792 = -50.0f; -COMPILER_STRIP_GATE(0x80C1B620, &lit_3792); -#pragma pop - -/* 80C1B624-80C1B628 000024 0004+00 0/2 0/0 0/0 .rodata @3793 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3793 = 5.0f; -COMPILER_STRIP_GATE(0x80C1B624, &lit_3793); -#pragma pop - -/* 80C1B628-80C1B62C 000028 0004+00 0/2 0/0 0/0 .rodata @3794 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3794 = 200.0f; -COMPILER_STRIP_GATE(0x80C1B628, &lit_3794); -#pragma pop - -/* 80C1B62C-80C1B630 00002C 0004+00 0/1 0/0 0/0 .rodata @3795 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3795 = -1.0f; -COMPILER_STRIP_GATE(0x80C1B62C, &lit_3795); -#pragma pop - /* 80C1988C-80C19A2C 00034C 01A0+00 1/1 0/0 0/0 .text wall_angle_get__FP12obj_hb_class */ -static void wall_angle_get(obj_hb_class* param_0) { - // NONMATCHING -} +static s16 wall_angle_get(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + dBgS_LinChk lin_chk; + cXyz spa8, spb4, sp98[2]; + + cMtx_YrotS(*calc_mtx, a_this->current.angle.y); + spa8.x = 0.0f; + spa8.y = 0.0f; + spa8.z = -50.0f; + MtxPosition(&spa8, &spb4); + spb4 += a_this->current.pos; + spa8.x = 5.0f; + spa8.y = 0.0f; + spa8.z = 200.0f; -/* ############################################################################################## */ -/* 80C1B630-80C1B634 000030 0004+00 1/2 0/0 0/0 .rodata @3804 */ -SECTION_RODATA static f32 const lit_3804 = 500.0f; -COMPILER_STRIP_GATE(0x80C1B630, &lit_3804); + for (int i = 0; i < 2; i++) { + MtxPosition(&spa8, &sp98[i]); + spa8.x *= -1.0f; + sp98[i] += spb4; + lin_chk.Set(&spb4, &sp98[i], a_this); + + if (dComIfG_Bgsp().LineCross(&lin_chk)) { + sp98[i] = lin_chk.GetCross(); + } else { + OS_REPORT("E_TH_BALL WALL CHECK NON ??\n"); + return 35; + } + } + + spa8 = sp98[1] - sp98[0]; + return cM_atan2s(spa8.x, spa8.z) + 0x4000; +} /* 80C19A2C-80C19AD8 0004EC 00AC+00 1/1 0/0 0/0 .text water_check__FP12obj_hb_class */ -static void water_check(obj_hb_class* param_0) { - // NONMATCHING +static BOOL water_check(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + dBgS_ObjGndChk_Spl gnd_chk_spl; + Vec sp78; + + sp78.x = a_this->current.pos.x; + sp78.y = a_this->current.pos.y + 500.0f; + sp78.z = a_this->current.pos.z; + gnd_chk_spl.SetPos(&sp78); + i_this->mGroundCross = dComIfG_Bgsp().GroundCross(&gnd_chk_spl); + + if (i_this->mGroundCross > a_this->current.pos.y + WREG_F(11)) { + return TRUE; + } + + return FALSE; } -/* ############################################################################################## */ -/* 80C1B634-80C1B638 000034 0004+00 0/2 0/0 0/0 .rodata @3818 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3818 = 3.0f / 100.0f; -COMPILER_STRIP_GATE(0x80C1B634, &lit_3818); -#pragma pop - -/* 80C1B638-80C1B63C 000038 0004+00 0/1 0/0 0/0 .rodata @3819 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3819 = 3.0f / 5.0f; -COMPILER_STRIP_GATE(0x80C1B638, &lit_3819); -#pragma pop - -/* 80C1B63C-80C1B640 00003C 0004+00 0/2 0/0 0/0 .rodata @3820 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3820 = 1.0f / 20.0f; -COMPILER_STRIP_GATE(0x80C1B63C, &lit_3820); -#pragma pop - -/* 80C1B640-80C1B644 000040 0004+00 0/1 0/0 0/0 .rodata @3821 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3821 = 1.0f / 50.0f; -COMPILER_STRIP_GATE(0x80C1B640, &lit_3821); -#pragma pop - -/* 80C1B644-80C1B648 000044 0004+00 0/1 0/0 0/0 .rodata @3822 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3822 = 800.0f; -COMPILER_STRIP_GATE(0x80C1B644, &lit_3822); -#pragma pop - -/* 80C1B648-80C1B64C 000048 0004+00 1/3 0/0 0/0 .rodata @3823 */ -SECTION_RODATA static f32 const lit_3823 = 2000.0f; -COMPILER_STRIP_GATE(0x80C1B648, &lit_3823); - -/* 80C1B64C-80C1B650 00004C 0004+00 0/2 0/0 0/0 .rodata @3824 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3824 = 25.0f; -COMPILER_STRIP_GATE(0x80C1B64C, &lit_3824); -#pragma pop - /* 80C19AD8-80C19BEC 000598 0114+00 1/1 0/0 0/0 .text obj_hb_set__FP12obj_hb_class */ -static void obj_hb_set(obj_hb_class* param_0) { - // NONMATCHING +static void obj_hb_set(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + + switch (i_this->mMode) { + case 0: + i_this->mTimers[0] = 30; + i_this->mTimers[1] = KREG_S(0) + 90; + i_this->mMode = 1; + i_this->mChildPlaySpeed = 0.0f; + break; + + case 1: + if (i_this->mTimers[0] == 0) { + cLib_addCalc2(&i_this->mChildPlaySpeed, 1.0f, 1.0f, 0.03f); + cLib_addCalc2(&a_this->scale.x, BREG_F(0) + 0.6f, 0.05f, BREG_F(1) + 0.02f); + i_this->field_0x688 = BREG_F(6) + 800.0f; + + if (i_this->mTimers[1] == 0) { + i_this->field_0x6a4 = KREG_S(1) + 15; + i_this->mAction = ACTION_DROP; + i_this->mMode = 0; + i_this->field_0x688 = BREG_F(3) + 2000.0f; + a_this->speed.y = BREG_F(7) + 25.0f; + i_this->mSound.startCreatureSound(Z2SE_EN_FS_KUBIKASIGE, 0, -1); + } + } + break; + } } -/* ############################################################################################## */ -/* 80C1B650-80C1B654 000050 0004+00 0/4 0/0 0/0 .rodata @3855 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3855 = 50.0f; -COMPILER_STRIP_GATE(0x80C1B650, &lit_3855); -#pragma pop - -/* 80C1B654-80C1B658 000054 0004+00 0/1 0/0 0/0 .rodata @3856 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_3856 = -G_CM3D_F_INF; -COMPILER_STRIP_GATE(0x80C1B654, &lit_3856); -#pragma pop - /* 80C19BEC-80C19DA8 0006AC 01BC+00 1/1 0/0 0/0 .text getGroundAngle__FP10fopAc_ac_cP5csXyz */ -static void getGroundAngle(fopAc_ac_c* param_0, csXyz* param_1) { - // NONMATCHING +static BOOL getGroundAngle(fopAc_ac_c* a_this, csXyz* param_2) { + Vec spa8; + cXyz spb4; + dBgS_GndChk gnd_chk; + BOOL rv = TRUE; + s16 x, z; + f32 fVar1, fVar2; + + spb4 = a_this->current.pos; + spb4.y += 50.0f; + gnd_chk.SetPos(&spb4); + spb4.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + if (spb4.y != -1e9f) { + spa8.x = spb4.x; + spa8.y = spb4.y + 50.0f; + spa8.z = spb4.z + 10.0f; + gnd_chk.SetPos(&spa8); + spa8.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + if (spa8.y != -1e9f) { + fVar1 = spa8.y - spb4.y; + fVar2 = spa8.z - spb4.z; + x = -cM_atan2s(fVar1, fVar2); + } else { + rv = FALSE; + } + + spa8.x = spb4.x + 10.0f; + spa8.y = spb4.y + 50.0f; + spa8.z = spb4.z; + gnd_chk.SetPos(&spa8); + spa8.y = dComIfG_Bgsp().GroundCross(&gnd_chk); + if (spa8.y != -1e9f) { + fVar1 = spa8.y - spb4.y; + fVar2 = spa8.x - spb4.x; + z = (s16)cM_atan2s(fVar1, fVar2); + } else { + rv = false; + } + } else { + rv = false; + } + + if (rv) { + param_2->x = x; + param_2->z = z; + } + + return rv; } -/* ############################################################################################## */ -/* 80C1B658-80C1B65C 000058 0004+00 0/2 0/0 0/0 .rodata @4043 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4043 = 20.0f; -COMPILER_STRIP_GATE(0x80C1B658, &lit_4043); -#pragma pop - -/* 80C1B65C-80C1B660 00005C 0004+00 0/1 0/0 0/0 .rodata @4044 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4044 = -3.0f / 10.0f; -COMPILER_STRIP_GATE(0x80C1B65C, &lit_4044); -#pragma pop - -/* 80C1B660-80C1B664 000060 0004+00 0/3 0/0 0/0 .rodata @4045 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4045 = 0.5f; -COMPILER_STRIP_GATE(0x80C1B660, &lit_4045); -#pragma pop - -/* 80C1B664-80C1B668 000064 0004+00 0/2 0/0 0/0 .rodata @4046 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4046 = -30.0f; -COMPILER_STRIP_GATE(0x80C1B664, &lit_4046); -#pragma pop - -/* 80C1B668-80C1B66C 000068 0004+00 0/1 0/0 0/0 .rodata @4047 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4047 = 4.0f / 5.0f; -COMPILER_STRIP_GATE(0x80C1B668, &lit_4047); -#pragma pop - -/* 80C1B66C-80C1B670 00006C 0004+00 0/1 0/0 0/0 .rodata @4048 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4048 = -2.0f / 5.0f; -COMPILER_STRIP_GATE(0x80C1B66C, &lit_4048); -#pragma pop - -/* 80C1B670-80C1B674 000070 0004+00 0/1 0/0 0/0 .rodata @4049 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4049 = 0.75f; -COMPILER_STRIP_GATE(0x80C1B670, &lit_4049); -#pragma pop - -/* 80C1B674-80C1B678 000074 0004+00 0/1 0/0 0/0 .rodata @4050 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4050 = 3500.0f; -COMPILER_STRIP_GATE(0x80C1B674, &lit_4050); -#pragma pop - -/* 80C1B678-80C1B67C 000078 0004+00 0/1 0/0 0/0 .rodata @4051 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4051 = 1300.0f; -COMPILER_STRIP_GATE(0x80C1B678, &lit_4051); -#pragma pop - -/* 80C1B67C-80C1B680 00007C 0004+00 0/2 0/0 0/0 .rodata @4052 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4052 = 2.0f; -COMPILER_STRIP_GATE(0x80C1B67C, &lit_4052); -#pragma pop - -/* 80C1B680-80C1B684 000080 0004+00 0/1 0/0 0/0 .rodata @4053 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4053 = -5.0f; -COMPILER_STRIP_GATE(0x80C1B680, &lit_4053); -#pragma pop - -/* 80C1B684-80C1B688 000084 0004+00 0/2 0/0 0/0 .rodata @4054 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4054 = 60.0f; -COMPILER_STRIP_GATE(0x80C1B684, &lit_4054); -#pragma pop - -/* 80C1B688-80C1B690 000088 0008+00 0/1 0/0 0/0 .rodata @4055 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4055[8] = { - 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80C1B688, &lit_4055); -#pragma pop - -/* 80C1B690-80C1B698 000090 0008+00 0/1 0/0 0/0 .rodata @4056 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4056[8] = { - 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80C1B690, &lit_4056); -#pragma pop - -/* 80C1B698-80C1B6A0 000098 0008+00 0/1 0/0 0/0 .rodata @4057 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4057[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80C1B698, &lit_4057); -#pragma pop - -/* 80C1B6A0-80C1B6A4 0000A0 0004+00 0/1 0/0 0/0 .rodata @4058 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4058 = 300.0f; -COMPILER_STRIP_GATE(0x80C1B6A0, &lit_4058); -#pragma pop - -/* 80C1B6A4-80C1B6A8 0000A4 0004+00 0/1 0/0 0/0 .rodata @4059 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4059 = 3.0f / 10.0f; -COMPILER_STRIP_GATE(0x80C1B6A4, &lit_4059); -#pragma pop - -/* 80C1B6A8-80C1B6B0 0000A8 0004+04 0/1 0/0 0/0 .rodata @4060 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4060[1 + 1 /* padding */] = { - 8.0f, - /* padding */ - 0.0f, -}; -COMPILER_STRIP_GATE(0x80C1B6A8, &lit_4060); -#pragma pop - -/* 80C1B6B0-80C1B6B8 0000B0 0008+00 0/2 0/0 0/0 .rodata @4062 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4062[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80C1B6B0, &lit_4062); -#pragma pop - /* 80C19DA8-80C1A490 000868 06E8+00 1/1 0/0 0/0 .text obj_hb_drop__FP12obj_hb_class */ -static void obj_hb_drop(obj_hb_class* param_0) { - // NONMATCHING +static void obj_hb_drop(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz sp3c, sp48; + + cLib_addCalc0(&i_this->mChildPlaySpeed, 1.0f, 0.03f); + + switch (i_this->mMode) { + case 0: + if (a_this->speedF >= 20.0f) { + if (i_this->field_0x67e == 0) { + i_this->mShapeAngleXOffset = 4000; + } else { + i_this->mShapeAngleXOffset = -4000; + } + } + // fallthrough + case 1: + case 2: + case 3: + case 4: + if (i_this->mTimers[0] == 0 && i_this->mBgc.ChkWallHit()) { + s16 wall_angle = wall_angle_get(i_this); + if (wall_angle != 35) { + s16 angle_delta = a_this->current.angle.y - wall_angle; + i_this->field_0x690 = angle_delta * (WREG_F(6) + -0.3f); + a_this->current.angle.y += (s16)(0x8000 - (angle_delta << 1)); + a_this->speedF *= AREG_F(4) + 0.5f; + i_this->mTimers[0] = 10; + i_this->mSound.startCollisionSE(Z2SE_HIT_SWORD, 41); + } + } + + if (i_this->mBgc.ChkGroundHit()) { + if (i_this->mMode < 4) { + i_this->mMode++; + } + + if (i_this->field_0x6b4 < -30.0f) { + fopAcM_effSmokeSet1(&i_this->field_0xa68, &i_this->field_0xa6c, &a_this->current.pos, &a_this->shape_angle, NREG_F(18) + 0.8f, &a_this->tevStr, 1); + i_this->mSound.startCollisionSE(Z2SE_HIT_SWORD, 41); + a_this->speed.y = i_this->field_0x6b4 * -0.4f; + a_this->speedF *= WREG_F(14) + 0.75f; + i_this->field_0x688 = NREG_F(0) + 3500.0f; + + if (i_this->field_0x690 == 0) { + i_this->field_0x690 = cM_rndFX(1300.0f); + } + } else { + i_this->mMode = 5; + } + } + break; + + case 5: + cLib_addCalc0(&a_this->speedF, 1.0f, WREG_F(11) + 2.0f); + + if (a_this->speed.y < -30.0f) { + i_this->mMode = 0; + } + break; + } + + cMtx_YrotS(*calc_mtx, a_this->current.angle.y); + sp3c.x = 0.0f; + sp3c.y = 0.0f; + sp3c.z = a_this->speedF; + MtxPosition(&sp3c, &sp48); + a_this->speed.x = sp48.x; + a_this->speed.z = sp48.z; + a_this->current.pos.x += a_this->speed.x; + a_this->current.pos.z += a_this->speed.z; + a_this->current.pos.y += a_this->speed.y; + a_this->speed.y += -5.0f; + a_this->eyePos = a_this->current.pos; + a_this->attention_info.position = a_this->current.pos; + cLib_onBit(a_this->attention_info.flags, fopAc_AttnFlag_CARRY_e); + a_this->attention_info.distances[fopAc_attn_CARRY_e] = 7; + i_this->field_0x676.y += i_this->field_0x690; + + if (a_this->speedF >= 20.0f) { + i_this->mSph.OnAtSetBit(); + i_this->mSph.OffAtVsBitSet(12); + i_this->mSph.OnAtVsBitSet(2); + i_this->mSph.SetR((JREG_F(13) + 60.0f) * a_this->scale.x); + i_this->mSph.SetAtHitMark(1); + + if (i_this->mInvulnerabilityTimer == 0 && i_this->mSph.ChkAtHit()) { + i_this->mInvulnerabilityTimer = 4; + a_this->speedF *= 0.5f; + } + + fopAc_ac_c* actor_p = fopAcM_SearchByID(i_this->field_0x69c); + if (actor_p != NULL) { + if (((actor_p->eyePos - a_this->current.pos).abs() < 300.0f)) { + f32 fVar1 = JREG_F(15) + 0.3f; + cLib_addCalc2(&a_this->current.pos.x, actor_p->eyePos.x, fVar1, i_this->mCurrentPosStep); + cLib_addCalc2(&a_this->current.pos.y, actor_p->eyePos.y, fVar1, i_this->mCurrentPosStep); + cLib_addCalc2(&a_this->current.pos.z, actor_p->eyePos.z, fVar1, i_this->mCurrentPosStep); + cLib_addCalc2(&i_this->mCurrentPosStep, JREG_F(14) + 50.0f, 1.0f, 8.0f); + } + } + } else { + i_this->mSph.OffAtSetBit(); + } + + if (fopAcM_checkCarryNow(a_this)) { + i_this->mAction = ACTION_CARRY; + i_this->mMode = 0; + i_this->field_0x68e = 0; + i_this->field_0x68c = 0; + i_this->field_0x690 = 0; + i_this->field_0x67c = 0; + i_this->mSph.OffAtSetBit(); + i_this->field_0x6b0 = 0; + } + + csXyz ground_angle; + if (getGroundAngle(a_this, &ground_angle)) { + cMtx_XrotS(*calc_mtx, ground_angle.x); + cMtx_ZrotM(*calc_mtx, ground_angle.z); + sp3c.x = 0.0f; + sp3c.y = KREG_F(8) + 20.0f; + sp3c.z = 0.0f; + MtxPosition(&sp3c, &sp48); + sp48.y = 0.0f; + + if (sp48.abs() >= 10.0f) { + a_this->current.pos += sp48; + a_this->speed.y = -30.0f; + } + } } -/* ############################################################################################## */ -/* 80C1B6B8-80C1B6BC 0000B8 0004+00 0/1 0/0 0/0 .rodata @4122 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4122 = 19.0f / 20.0f; -COMPILER_STRIP_GATE(0x80C1B6B8, &lit_4122); -#pragma pop - -/* 80C1B6BC-80C1B6C0 0000BC 0004+00 0/2 0/0 0/0 .rodata @4123 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4123 = 1.0f / 10.0f; -COMPILER_STRIP_GATE(0x80C1B6BC, &lit_4123); -#pragma pop - -/* 80C1B6C0-80C1B6C4 0000C0 0004+00 0/2 0/0 0/0 .rodata @4124 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4124 = 40.0f; -COMPILER_STRIP_GATE(0x80C1B6C0, &lit_4124); -#pragma pop - -/* 80C1B6C4-80C1B6C8 0000C4 0004+00 0/1 0/0 0/0 .rodata @4125 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u32 const lit_4125 = 0x3B83126F; -COMPILER_STRIP_GATE(0x80C1B6C4, &lit_4125); -#pragma pop - -/* 80C1B6C8-80C1B6CC 0000C8 0004+00 0/1 0/0 0/0 .rodata @4126 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4126 = 1500.0f; -COMPILER_STRIP_GATE(0x80C1B6C8, &lit_4126); -#pragma pop - -/* 80C1B6CC-80C1B6D0 0000CC 0004+00 0/1 0/0 0/0 .rodata @4127 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4127 = 130.0f; -COMPILER_STRIP_GATE(0x80C1B6CC, &lit_4127); -#pragma pop - /* 80C1A490-80C1A748 000F50 02B8+00 1/1 0/0 0/0 .text obj_hb_float__FP12obj_hb_class */ -static void obj_hb_float(obj_hb_class* param_0) { - // NONMATCHING +static void obj_hb_float(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + + cLib_addCalc0(&a_this->speed.y, 1.0f, WREG_F(6) + 0.25f); + a_this->current.pos += a_this->speed; + a_this->speed.x *= WREG_F(13) + 0.95f; + a_this->speed.z *= WREG_F(13) + 0.95f; + + cXyz pos(a_this->current.pos); + pos.y = i_this->mGroundCross; + + f32 fVar1 = KREG_F(0) + 0.05f; + if (i_this->field_0x698) { + fVar1 = KREG_F(1) + 0.1f; + } + + if (a_this->current.pos.y + 60.0f + WREG_F(11) > i_this->mGroundCross) { + fopAcM_effHamonSet(&i_this->mHamonPrtcl, &pos, KREG_F(2) + 1.0f, fVar1); + } + + f32 fVar2 = cM_ssin(i_this->field_0x650 * (WREG_S(2) + 900)) * (i_this->field_0x694 * 0.004f); + cLib_addCalc2(&a_this->current.pos.y, (i_this->mGroundCross - 40.0f) + WREG_F(8) + fVar2, 0.1f, WREG_F(4) + 10.0f); + i_this->field_0x676.x = i_this->field_0x694 * cM_ssin(i_this->field_0x650 * (WREG_S(3) + 1000)); + i_this->field_0x676.z = i_this->field_0x694 * cM_ssin(i_this->field_0x650 * (WREG_S(4) + 1100)); + cLib_addCalc2(&i_this->field_0x694, 500.0f, 0.1f, 30.0f); + i_this->field_0x676.x += (s16)(i_this->field_0x698 * cM_ssin(i_this->field_0x650 * (WREG_S(7) + 4000))); + a_this->shape_angle.z += (s16)(i_this->field_0x698 * cM_ssin(i_this->field_0x650 * (WREG_S(8) + 4200))); + cLib_addCalc2(&i_this->field_0x698, 0.0f, 0.1f, 30.0f); + i_this->field_0x676.y += i_this->field_0x690; + + if (fopAcM_searchPlayerDistance(a_this) < JREG_F(0) + 100.0f) { + cXyz sp78, sp84; + cLib_addCalcAngleS2(&i_this->field_0x676.y, fopAcM_searchPlayerAngleY(a_this), 32, 128); + } + + if (i_this->mSph.ChkCoHit()) { + cXyz* cc_move_p = i_this->mStts.GetCCMoveP(); + if (cc_move_p != NULL) { + cLib_addCalc2(&a_this->speed.x, cc_move_p->x * (WREG_F(15) + 0.5f), 0.1f, WREG_F(14) + 1.0f); + cLib_addCalc2(&a_this->speed.z, cc_move_p->z * (WREG_F(15) + 0.5f), 0.1f, WREG_F(14) + 1.0f); + cLib_addCalc2(&i_this->field_0x694, WREG_F(16) + 1500.0f, 0.1f, 130.0f); + } + } } -/* ############################################################################################## */ -/* 80C1B6D0-80C1B6D4 0000D0 0004+00 0/1 0/0 0/0 .rodata @4293 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4293 = 5500.0f; -COMPILER_STRIP_GATE(0x80C1B6D0, &lit_4293); -#pragma pop - -/* 80C1B6D4-80C1B6D8 0000D4 0004+00 0/1 0/0 0/0 .rodata @4294 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4294 = 5000.0f; -COMPILER_STRIP_GATE(0x80C1B6D4, &lit_4294); -#pragma pop - -/* 80C1B6D8-80C1B6DC 0000D8 0004+00 0/1 0/0 0/0 .rodata @4295 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4295 = 3000.0f; -COMPILER_STRIP_GATE(0x80C1B6D8, &lit_4295); -#pragma pop - -/* 80C1B6DC-80C1B6E0 0000DC 0004+00 0/1 0/0 0/0 .rodata @4296 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4296 = 4000.0f; -COMPILER_STRIP_GATE(0x80C1B6DC, &lit_4296); -#pragma pop - -/* 80C1B6E0-80C1B6E4 0000E0 0004+00 0/1 0/0 0/0 .rodata @4297 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4297 = 7.0f / 10.0f; -COMPILER_STRIP_GATE(0x80C1B6E0, &lit_4297); -#pragma pop - -/* 80C1B6E4-80C1B6E8 0000E4 0004+00 0/1 0/0 0/0 .rodata @4298 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4298 = -2.0f; -COMPILER_STRIP_GATE(0x80C1B6E4, &lit_4298); -#pragma pop - -/* 80C1B6E8-80C1B6EC 0000E8 0004+00 0/1 0/0 0/0 .rodata @4299 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4299 = 2.5f; -COMPILER_STRIP_GATE(0x80C1B6E8, &lit_4299); -#pragma pop - -/* 80C1B6EC-80C1B6F0 0000EC 0004+00 0/1 0/0 0/0 .rodata @4300 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4300 = -12.0f; -COMPILER_STRIP_GATE(0x80C1B6EC, &lit_4300); -#pragma pop - -/* 80C1B6F0-80C1B6F4 0000F0 0004+00 0/1 0/0 0/0 .rodata @4301 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4301 = 1.0f / 100.0f; -COMPILER_STRIP_GATE(0x80C1B6F0, &lit_4301); -#pragma pop - -/* 80C1B6F4-80C1B6F8 0000F4 0004+00 0/1 0/0 0/0 .rodata @4302 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4302 = 1.0f / 5.0f; -COMPILER_STRIP_GATE(0x80C1B6F4, &lit_4302); -#pragma pop - -/* 80C1B6F8-80C1B6FC 0000F8 0004+00 0/1 0/0 0/0 .rodata @4303 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4303 = 20000.0f; -COMPILER_STRIP_GATE(0x80C1B6F8, &lit_4303); -#pragma pop - -/* 80C1B708-80C1B710 000000 0008+00 1/1 0/0 0/0 .data w_eff_id$4176 */ -SECTION_DATA static u8 w_eff_id[8] = { - 0x01, 0xB8, 0x01, 0xB9, 0x01, 0xBA, 0x01, 0xBB, -}; - /* 80C1A748-80C1AF80 001208 0838+00 1/1 0/0 0/0 .text action__FP12obj_hb_class */ -static void action(obj_hb_class* param_0) { - // NONMATCHING +static void action(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + cXyz sp5c, sp68; + s8 sVar1 = 0; + + i_this->mSph.SetR((JREG_F(3) + 25.0f) * a_this->scale.x); + + switch (i_this->mAction) { + case ACTION_SET: + obj_hb_set(i_this); + i_this->mInvulnerabilityTimer = 3; + break; + + case ACTION_DROP: + obj_hb_drop(i_this); + i_this->field_0x6b4 = a_this->speed.y; + + if (i_this->field_0x6b0 == 0 && i_this->mSph.ChkCoHit()) { + cXyz* cc_move_p = i_this->mStts.GetCCMoveP(); + 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; + } + cLib_addCalcAngleS2(&i_this->field_0x676.y, target, 4, 0x100); + } + } + } + + i_this->mBgc.CrrPos(dComIfG_Bgsp()); + sVar1 = 1; + break; + + case ACTION_FLOAT: + obj_hb_float(i_this); + i_this->mBgc.CrrPos(dComIfG_Bgsp()); + break; + + case ACTION_CARRY: + obj_hb_carry(i_this); + i_this->mInvulnerabilityTimer = 3; + i_this->mBgc.CrrPos(dComIfG_Bgsp()); + break; + } + + if (i_this->mInvulnerabilityTimer == 0 && i_this->mSph.ChkTgHit()) { + i_this->mInvulnerabilityTimer = 4; + i_this->mAtInfo.mpCollider = i_this->mSph.GetTgHitObj(); + def_se_set(&i_this->mSound, i_this->mAtInfo.mpCollider, 41, NULL); + a_this->current.angle.y = fopAcM_searchPlayerAngleY(a_this) + 0x8000; + fopAc_ac_c* actor_p = at_power_check(&i_this->mAtInfo); + 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; + i_this->field_0x690 = cM_rndF(2000.0f) + 5500.0f; + i_this->field_0x688 = (s16)(cM_rndF(1000.0f) + 5000.0f); + } else { + a_this->speedF = WREG_F(17) + 30.0f; + i_this->field_0x690 = cM_rndFX(3000.0f); + i_this->field_0x688 = NREG_F(10) + 4000.0f; + } + } else if (i_this->mAtInfo.mHitType == HIT_TYPE_BOMB) { + fopAcM_createDisappear(a_this, &a_this->current.pos, 7, 0, a_this->field_0x564); + i_this->field_0x6b1 = 1; + } else { + if (actor_p != NULL) { + a_this->speedF = actor_p->speedF * 0.7f; + a_this->current.angle.y = actor_p->current.angle.y + (s16)cM_rndFX(5000.0f); + } + + i_this->field_0x690 = cM_rndFX(3000.0f); + i_this->field_0x688 = NREG_F(10) + 4000.0f; + } + } + + if (i_this->mAction == ACTION_FLOAT) { + cLib_addCalcAngleS2(&i_this->field_0x68c, 0, 8, 0x100); + 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)); + 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); + } + + if (sVar1 && water_check(i_this)) { + i_this->mAction = ACTION_FLOAT; + i_this->mMode = 0; + i_this->mSph.OffAtSetBit(); + + if (a_this->speedF < 5.0f) { + cMtx_YrotS(*calc_mtx, a_this->current.angle.y); + sp5c.x = 0.0f; + sp5c.y = -2.0f; + sp5c.z = 2.5f; + MtxPosition(&sp5c, &a_this->speed); + } else { + a_this->current.pos.y = i_this->mGroundCross - WREG_F(11); + a_this->speed.y = WREG_F(12) + -12.0f; + a_this->speed.x *= 0.5f; + a_this->speed.z *= 0.5f; + i_this->field_0x694 = 3000.0f; + } + + a_this->speedF = 0.0f; + cXyz scale(a_this->scale.x, a_this->scale.x, a_this->scale.x); + cXyz pos(a_this->current.pos); + pos.y = i_this->mGroundCross; + + static u16 w_eff_id[4] = { + ID_ZI_J_DOWNWTRA_A, ID_ZI_J_DOWNWTRA_B, ID_ZI_J_DOWNWTRA_C, ID_ZI_J_DOWNWTRA_D, + }; + + for (int i = 0; i < 4; i++) { + i_this->mPrtcls[i] = dComIfGp_particle_set(i_this->mPrtcls[i], w_eff_id[i], &pos, &a_this->tevStr, + &a_this->shape_angle, &scale, 0xFF, NULL, -1, NULL, NULL, NULL); + } + + i_this->mSound.startCreatureSound(Z2SE_CM_BODYFALL_WATER_S, 0, -1); + } + + 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); + } else { + a_this->scale.x = 1.0f; + } + } + + mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y, a_this->current.pos.z); + mDoMtx_stack_c::YrotM(i_this->field_0x676.y); + mDoMtx_stack_c::XrotM(i_this->field_0x68c + i_this->field_0x676.x); + mDoMtx_stack_c::ZrotM(i_this->field_0x676.z + i_this->field_0x68e); + mDoMtx_stack_c::transM(0.0f, JREG_F(17) + 30.0f, 0.0f); + mDoMtx_stack_c::XrotM(a_this->shape_angle.x); + mDoMtx_stack_c::transM(0.0f, -(JREG_F(17) + 30.0f), 0.0f); + mDoMtx_stack_c::scaleM(a_this->scale.x, a_this->scale.x, a_this->scale.x); + i_this->mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + + cXyz sp8c; + cMtx_XrotS(*calc_mtx, i_this->field_0x676.z); + sp5c.x = 0.0f; + sp5c.y = a_this->scale.x * 30.0f; + sp5c.z = 0.0f; + MtxPosition(&sp5c, &sp8c); + sp8c += a_this->current.pos; + + if (i_this->mInvulnerabilityTimer != 0) { + sp8c.y += 20000.0f; + } + + i_this->mSph.SetC(sp8c); + dComIfG_Ccsp()->Set(&i_this->mSph); + + e_hb_leaf_class* hb_leaf_p = (e_hb_leaf_class*)fopAcM_SearchByID(i_this->mChildActorID); + if (hb_leaf_p != NULL) { + hb_leaf_p->mpMorf->setPlaySpeed(i_this->mChildPlaySpeed); + hb_leaf_p->mpMorf->play(NULL, 0, 0); + } + + if (i_this->mShapeAngleXOffset == 0) { + cLib_addCalcAngleS2(&a_this->shape_angle.x, 0, 4, 0x800); + } else { + a_this->shape_angle.x += i_this->mShapeAngleXOffset; + i_this->mShapeAngleXOffset = 0; + } } -/* 80C1AF80-80C1B124 001A40 01A4+00 2/1 0/0 0/0 .text daOBJ_HB_Execute__FP12obj_hb_class - */ -static void daOBJ_HB_Execute(obj_hb_class* param_0) { - // NONMATCHING +/* 80C1AF80-80C1B124 001A40 01A4+00 2/1 0/0 0/0 .text daOBJ_HB_Execute__FP12obj_hb_class */ +static int daOBJ_HB_Execute(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + + i_this->field_0x650++; + + for (int i = 0; i < 2; i++) { + if (i_this->mTimers[i] != 0) { + i_this->mTimers[i]--; + } + } + + if (i_this->mInvulnerabilityTimer != 0) { + i_this->mInvulnerabilityTimer--; + } + + action(i_this); + + i_this->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); + + if (a_this->home.pos.y - a_this->current.pos.y > 2000.0f) { + i_this->field_0x6b1 = 1; + } + + if (i_this->arg0 != 1 && i_this->field_0x6b1 != 0) { + i_this->field_0x6b1 = 0; + i_this->mAction = ACTION_SET; + i_this->mMode = 0; + a_this->scale.x = 0.0f; + a_this->current = a_this->home; + a_this->old = a_this->home; + a_this->speedF = 0.0f; + a_this->speed.set(0.0f, 0.0f, 0.0f); + i_this->field_0x694 = 0.0f; + i_this->field_0x688 = 0.0f; + i_this->field_0x690 = 0; + i_this->field_0x6b0 = 1; + } + + return 1; } -/* 80C1B124-80C1B12C 001BE4 0008+00 1/0 0/0 0/0 .text daOBJ_HB_IsDelete__FP12obj_hb_class - */ -static bool daOBJ_HB_IsDelete(obj_hb_class* param_0) { - return true; +/* 80C1B124-80C1B12C 001BE4 0008+00 1/0 0/0 0/0 .text daOBJ_HB_IsDelete__FP12obj_hb_class */ +static int daOBJ_HB_IsDelete(obj_hb_class* i_this) { + return 1; } -/* ############################################################################################## */ -/* 80C1B700-80C1B700 000100 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80C1B700 = "E_HB"; -#pragma pop +static s8 lbl_474_bss_0; -/* 80C1B12C-80C1B188 001BEC 005C+00 1/0 0/0 0/0 .text daOBJ_HB_Delete__FP12obj_hb_class - */ -static void daOBJ_HB_Delete(obj_hb_class* param_0) { - // NONMATCHING +/* 80C1B12C-80C1B188 001BEC 005C+00 1/0 0/0 0/0 .text daOBJ_HB_Delete__FP12obj_hb_class */ +static int daOBJ_HB_Delete(obj_hb_class* i_this) { + fopEn_enemy_c* a_this = (fopEn_enemy_c*)&i_this->actor; + fpc_ProcID id = fopAcM_GetID(a_this); + dComIfG_resDelete(&i_this->mPhase, "E_HB"); + i_this->mSound.stopAnime(); + + if (lbl_474_bss_0) { + lbl_474_bss_0 = 0; + } + + return 1; } /* 80C1B188-80C1B1F4 001C48 006C+00 1/1 0/0 0/0 .text useHeapInit__FP10fopAc_ac_c */ -static void useHeapInit(fopAc_ac_c* param_0) { - // NONMATCHING +static int useHeapInit(fopAc_ac_c* a_this) { + obj_hb_class* i_this = (obj_hb_class*)a_this; + + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("E_HB", 0x1A); + JUT_ASSERT(1150, modelData != NULL); + i_this->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + if (i_this->mpModel == NULL) { + return 0; + } + + return 1; } -/* ############################################################################################## */ -/* 80C1B6FC-80C1B700 0000FC 0004+00 0/1 0/0 0/0 .rodata @4457 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4457 = 65535.0f; -COMPILER_STRIP_GATE(0x80C1B6FC, &lit_4457); -#pragma pop +/* 80C1B1F4-80C1B4E8 001CB4 02F4+00 1/0 0/0 0/0 .text daOBJ_HB_Create__FP10fopAc_ac_c */ +static cPhs__Step daOBJ_HB_Create(fopAc_ac_c* a_this) { + // NONMATCHING + fopAcM_ct(a_this, obj_hb_class); + obj_hb_class* i_this = (obj_hb_class*)a_this; -/* 80C1B710-80C1B750 000008 0040+00 1/1 0/0 0/0 .data cc_sph_src$4381 */ -static dCcD_SrcSph cc_sph_src = { - { - {0x0, {{AT_TYPE_1000, 0x3, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj - {dCcD_SE_WOOD, 0x0, 0x1, 0x0, 0x0}, // mGObjAt - {dCcD_SE_STONE, 0x2, 0x0, 0x0, 0x2}, // mGObjTg - {0x0}, // mGObjCo - }, // mObjInf - { - {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph - } // mSphAttr -}; + cPhs__Step phase = (cPhs__Step)dComIfG_resLoad(&i_this->mPhase, "E_HB"); + if (phase == cPhs_COMPLEATE_e) { + OS_REPORT("OBJ_HB PARAM %x\n", fopAcM_GetParam(a_this)); + i_this->arg0 = fopAcM_GetParam(a_this); + OS_REPORT("OBJ_HB//////////////OBJ_HB SET 1 !!\n"); + + if (!fopAcM_entrySolidHeap(a_this, useHeapInit, 0x4B000)) { + OS_REPORT("//////////////OBJ_HB SET NON !!\n"); + return cPhs_ERROR_e; + } + + OS_REPORT("//////////////OBJ_HB SET 2 !!\n"); + + fopAcM_SetMtx(a_this, i_this->mpModel->getBaseTRMtx()); + a_this->health = 10; + a_this->field_0x560 = 10; + + i_this->mStts.Init(100, 0, a_this); + + static dCcD_SrcSph cc_sph_src = { + { + {0x0, {{AT_TYPE_1000, 0x3, 0xd}, {0xd8fbfdff, 0x3}, 0x75}}, // mObj + {dCcD_SE_WOOD, 0x0, 0x1, 0x0, 0x0}, // mGObjAt + {dCcD_SE_STONE, 0x2, 0x0, 0x0, 0x2}, // mGObjTg + {0x0}, // mGObjCo + }, // mObjInf + { + {{0.0f, 0.0f, 0.0f}, 40.0f} // mSph + } // mSphAttr + }; + + i_this->mSph.Set(cc_sph_src); + i_this->mSph.SetStts(&i_this->mStts); + i_this->mBgc.Set(fopAcM_GetPosition_p(a_this), fopAcM_GetOldPosition_p(a_this), a_this, 1, &i_this->mAcchCir, fopAcM_GetSpeed_p(a_this), NULL, NULL); + i_this->mAcchCir.SetWall(50.0f, 50.0f); + i_this->mSound.init(&a_this->current.pos, &a_this->eyePos, 3, 1); + a_this->attention_info.distances[fopAc_attn_CARRY_e] = 7; + i_this->field_0x650 = cM_rndF(65535.0f); + + if (i_this->arg0 == 1) { + i_this->mAction = ACTION_DROP; + a_this->speed.y = JREG_F(11) + 20.0f; + + if (a_this->current.angle.z != 0) { + a_this->speedF = 30.0f; + } + } else { + i_this->mAction = ACTION_DROP; + i_this->mMode = 0; + a_this->scale.x = 1.0f; + i_this->mChildPlaySpeed = 0.0f; + i_this->mChildActorID = fopAcM_createChild(PROC_E_HB_LEAF, fopAcM_GetID(a_this), 0, &a_this->current.pos, + fopAcM_GetRoomNo(a_this), &a_this->shape_angle, NULL, -1, NULL); + i_this->field_0x6b0 = 1; + } + + i_this->field_0x69c = fpcM_ERROR_PROCESS_ID_e; + i_this->field_0x676.y = cM_rndF(65535.0f); + daOBJ_HB_Execute(i_this); + } + + return phase; +} /* 80C1B750-80C1B770 -00001 0020+00 1/0 0/0 0/0 .data l_daOBJ_HB_Method */ static actor_method_class l_daOBJ_HB_Method = { - (process_method_func)daOBJ_HB_Create__FP10fopAc_ac_c, - (process_method_func)daOBJ_HB_Delete__FP12obj_hb_class, - (process_method_func)daOBJ_HB_Execute__FP12obj_hb_class, - (process_method_func)daOBJ_HB_IsDelete__FP12obj_hb_class, - (process_method_func)daOBJ_HB_Draw__FP12obj_hb_class, + (process_method_func)daOBJ_HB_Create, + (process_method_func)daOBJ_HB_Delete, + (process_method_func)daOBJ_HB_Execute, + (process_method_func)daOBJ_HB_IsDelete, + (process_method_func)daOBJ_HB_Draw, }; /* 80C1B770-80C1B7A0 -00001 0030+00 0/0 0/0 1/0 .data g_profile_OBJ_HB */ @@ -685,65 +749,3 @@ extern actor_process_profile_definition g_profile_OBJ_HB = { fopAc_ACTOR_e, // mActorType fopAc_CULLBOX_0_e, // cullType }; - -/* 80C1B7A0-80C1B7AC 000098 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGSph */ -SECTION_DATA extern void* __vt__8cM3dGSph[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGSphFv, -}; - -/* 80C1B7AC-80C1B7B8 0000A4 000C+00 2/2 0/0 0/0 .data __vt__8cM3dGAab */ -SECTION_DATA extern void* __vt__8cM3dGAab[3] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__8cM3dGAabFv, -}; - -/* 80C1B7B8-80C1B7DC 0000B0 0024+00 2/2 0/0 0/0 .data __vt__12dBgS_ObjAcch */ -SECTION_DATA extern void* __vt__12dBgS_ObjAcch[9] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)__dt__12dBgS_ObjAcchFv, - (void*)NULL, - (void*)NULL, - (void*)func_80C1B5F0, - (void*)NULL, - (void*)NULL, - (void*)func_80C1B5E8, -}; - -/* 80C1B1F4-80C1B4E8 001CB4 02F4+00 1/0 0/0 0/0 .text daOBJ_HB_Create__FP10fopAc_ac_c */ -static void daOBJ_HB_Create(fopAc_ac_c* param_0) { - // NONMATCHING -} - -/* 80C1B4E8-80C1B530 001FA8 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGSphFv */ -// cM3dGSph::~cM3dGSph() { -extern "C" void __dt__8cM3dGSphFv() { - // NONMATCHING -} - -/* 80C1B530-80C1B578 001FF0 0048+00 1/0 0/0 0/0 .text __dt__8cM3dGAabFv */ -// cM3dGAab::~cM3dGAab() { -extern "C" void __dt__8cM3dGAabFv() { - // NONMATCHING -} - -/* 80C1B578-80C1B5E8 002038 0070+00 3/2 0/0 0/0 .text __dt__12dBgS_ObjAcchFv */ -// dBgS_ObjAcch::~dBgS_ObjAcch() { -extern "C" void __dt__12dBgS_ObjAcchFv() { - // NONMATCHING -} - -/* 80C1B5E8-80C1B5F0 0020A8 0008+00 1/0 0/0 0/0 .text @36@__dt__12dBgS_ObjAcchFv */ -static void func_80C1B5E8() { - // NONMATCHING -} - -/* 80C1B5F0-80C1B5F8 0020B0 0008+00 1/0 0/0 0/0 .text @20@__dt__12dBgS_ObjAcchFv */ -static void func_80C1B5F0() { - // NONMATCHING -} - -/* 80C1B700-80C1B700 000100 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */