diff --git a/configure.py b/configure.py index 210533f17..91e61ff68 100755 --- a/configure.py +++ b/configure.py @@ -1505,7 +1505,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_tag_md_cb"), ActorRel(NonMatching, "d_a_tag_mk"), ActorRel(Matching, "d_a_tag_so"), - ActorRel(NonMatching, "d_a_tornado"), + ActorRel(Matching, "d_a_tornado", extra_cflags=['-pragma "nosyminline on"']), ActorRel(NonMatching, "d_a_warpf"), ActorRel(NonMatching, "d_a_wind_tag"), ActorRel(NonMatching, "d_a_acorn_leaf"), diff --git a/include/d/actor/d_a_ship.h b/include/d/actor/d_a_ship.h index 7714633c9..38bb9a104 100644 --- a/include/d/actor/d_a_ship.h +++ b/include/d/actor/d_a_ship.h @@ -23,7 +23,7 @@ public: u32 getTactWarpID() { return mTactWarpID; } void setTactWarpID(u32 warpID) { mTactWarpID = warpID; } - bool unknown_inline_TODO() const { return m041C || m0424; } + bool unknown_inline_TODO() const { return mTornadoActor || m0424; } void checkCraneMode() const {} void checkCraneUpEnd() const {} @@ -58,12 +58,15 @@ public: void getTactJntMtx() {} void getTillerAngleRate() {} void getTillerTopPosP() {} - void getTornadoActor() {} + fopAc_ac_c* getTornadoActor() { return mTornadoActor; } void getWhirlActor() {} void offCraneHookFlg() {} void offFantomGanonBattle() {} void offStateFlg(daSHIP_SFLG) {} - void offTornadoFlg() {} + void offTornadoFlg() { + mTornadoID = fpcM_ERROR_PROCESS_ID_e; + mTornadoActor = NULL; + } void offWhirlFlg() {} void onCb1Ride() {} void onCraneHookFlg() {} @@ -74,7 +77,7 @@ public: void onSceneChange() {} void onShortHitFlg() {} void onStateFlg(daSHIP_SFLG) {} - void onTornadoFlg(unsigned long) {} + void onTornadoFlg(u32 tornadoID) { mTornadoID = tornadoID; } void onWhirlFlg(unsigned long, short) {} void onWhirlFlgDirect(unsigned long, short) {} void setAtnPos(const cXyz*) {} @@ -238,8 +241,8 @@ public: /* 0x040C */ f32 m040C; /* 0x0410 */ int mGridId; /* 0x0414 */ daGrid_c* mpGrid; - /* 0x0418 */ int m0418; - /* 0x041C */ fopAc_ac_c* m041C; + /* 0x0418 */ u32 mTornadoID; + /* 0x041C */ fopAc_ac_c* mTornadoActor; /* 0x0420 */ u32 m0420; /* 0x0424 */ fopAc_ac_c* m0424; /* 0x0428 */ u8 m0428[0x042C - 0x0428]; diff --git a/include/d/actor/d_a_tornado.h b/include/d/actor/d_a_tornado.h index 05cd3f73c..dde5ce040 100644 --- a/include/d/actor/d_a_tornado.h +++ b/include/d/actor/d_a_tornado.h @@ -2,6 +2,15 @@ #define D_A_TORNADO_H #include "f_op/f_op_actor.h" +#include "SSystem/SComponent/c_phase.h" +#include "m_Do/m_Do_ext.h" +#include "d/d_particle.h" + +class daTornado_HIO_c0 { + public: + static const float move_dis; + static const float start_dis; +}; class daTornado_c : public fopAc_ac_c { public: @@ -12,15 +21,36 @@ public: void getSmallScaleEnd() {} void setScaleOn() {} - void jointCallBack(int); + BOOL jointCallBack(int); BOOL draw(); BOOL execute(); - void tornado_delete(); - void createHeap(); + BOOL tornado_delete(); + BOOL createHeap(); s32 create(); public: - /* Place member variables here */ + /* 0x290 */ request_of_phase_process_class mPhs; + /* 0x298 */ J3DModel* mpModel; + /* 0x29c */ mDoExt_bckAnm mBck; + /* 0x2ac */ mDoExt_btkAnm mBtk; + /* 0x2c0 */ mDoExt_brkAnm mBrk; + /* 0x2d8 */ J3DModel* mpModelUnder; + /* 0x2dc */ mDoExt_bckAnm mBckUnder; + /* 0x2ec */ mDoExt_btkAnm mBtkUnder; + /* 0x300 */ mDoExt_brkAnm mBrkUnder; + /* 0x318 */ short mAngle1; + /* 0x31a */ short mAngle2; + /* 0x31c */ short m31c; + /* 0x31e */ short mPtclTimer; + /* 0x320 */ float mBtkFrame; + /* 0x324 */ float mBtkUnderFrame; + /* 0x328 */ float mBrkFrame; + /* 0x32c */ float m32c; + /* 0x330 */ float mJointX[11]; + /* 0x35c */ float mJointZ[11]; + /* 0x388 */ float mJointScale[11]; + /* 0x3b4 */ cXyz mCenter; + /* 0x3c0 */ dPa_followEcallBack mPtclCb; }; #endif /* D_A_TORNADO_H */ diff --git a/include/d/d_kankyo_wether.h b/include/d/d_kankyo_wether.h index 660d16bce..cd505e646 100644 --- a/include/d/d_kankyo_wether.h +++ b/include/d/d_kankyo_wether.h @@ -370,5 +370,6 @@ void dKyw_evt_wind_set_go(); void dKyw_get_AllWind_vec(cXyz* param_0, cXyz* i_direction, f32* i_power); cXyz dKyw_get_AllWind_vecpow(cXyz* param_0); BOOL dKyw_gbwind_use_check(); +void dKyw_tornado_Notice(cXyz* param_0); #endif /* D_KANKYO_WETHER_H */ diff --git a/src/d/actor/d_a_tornado.cpp b/src/d/actor/d_a_tornado.cpp index 769cfb641..20220c7f9 100644 --- a/src/d/actor/d_a_tornado.cpp +++ b/src/d/actor/d_a_tornado.cpp @@ -4,72 +4,342 @@ // #include "d/actor/d_a_tornado.h" +#include "d/res/res_trnd.h" +#include "f_op/f_op_actor_mng.h" #include "m_Do/m_Do_ext.h" #include "d/d_procname.h" +#include "d/d_com_inf_game.h" +#include "d/actor/d_a_ship.h" +#include "d/d_kankyo_wether.h" + +#include "weak_bss_936_to_1036.h" // IWYU pragma: keep + +static char l_arcName[] = "Trnd"; + +const float daTornado_HIO_c0::move_dis = 7500.0f; +const float daTornado_HIO_c0::start_dis = 10000.0f; /* 000000EC-00000260 .text jointCallBack__11daTornado_cFi */ -void daTornado_c::jointCallBack(int) { - /* Nonmatching */ +BOOL daTornado_c::jointCallBack(int jntNo) { + int jntIdx = jntNo - 1; + if ((jntIdx < 0) || (jntIdx >= 11)) { + return TRUE; + } + + mDoMtx_stack_c::transS(mJointX[jntIdx], 0.0f, mJointZ[jntIdx]); + if (jntIdx != 10 && jntIdx != 0) { + mDoMtx_stack_c::ZXYrotM(-mJointZ[jntIdx] * 3572.0f * 0.001f, 0.0f, mJointX[jntIdx] * 3572.0f * 0.001f); + } + + if (fopAcM_GetParam(this) != 0) { + float scale = mJointScale[jntIdx]; + mDoMtx_stack_c::scaleM(scale, scale, scale); + } + mDoMtx_stack_c::revConcat(mpModel->getAnmMtx(jntNo)); + mpModel->setAnmMtx(jntNo, mDoMtx_stack_c::get()); + mDoMtx_stack_c::transS(mJointX[jntIdx], 0.0f, mJointZ[jntIdx]); + mDoMtx_stack_c::revConcat(J3DSys::mCurrentMtx); + cMtx_copy(mDoMtx_stack_c::get(), J3DSys::mCurrentMtx); + return TRUE; } +static const float l_joint_scale[11] = { 0.1, 0.4, 0.7, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; +static const float joint_offset[11] = { 100.0, 200.0, 300.0, 400.0, 300.0, 300.0, 400.0, 500.0, 400.0, 500.0, 600.0 }; + +static daTornado_HIO_c0 l_HIO; + /* 00000260-000002A4 .text daTornado_jointCallBack__FP7J3DNodei */ -static BOOL daTornado_jointCallBack(J3DNode*, int) { - /* Nonmatching */ +static BOOL daTornado_jointCallBack(J3DNode* node, int param_1) { + if (!param_1) { + J3DJoint* joint = (J3DJoint*)node; + s32 jntNo = joint->getJntNo(); + J3DModel* model = j3dSys.getModel(); + daTornado_c* i_this = reinterpret_cast(model->getUserArea()); + i_this->jointCallBack(jntNo); + } + return TRUE; } /* 000002A4-00000464 .text draw__11daTornado_cFv */ BOOL daTornado_c::draw() { - /* Nonmatching */ + g_env_light.settingTevStruct(TEV_TYPE_ACTOR, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(mpModel, &tevStr); + + mBck.entry(mpModel->getModelData()); + mBtk.entry(mpModel->getModelData(), mBtkFrame); + mBrk.entry(mpModel->getModelData(), mBrkFrame); + + if (dComIfGs_isTmpBit(0x404)) { + dComIfGd_setListMaskOff(); + mDoExt_modelUpdateDL(mpModel); + dComIfGd_setList(); + } else { + mDoExt_modelUpdateDL(mpModel); + } + + if (fopAcM_GetParam(this) == 0) { + g_env_light.settingTevStruct(TEV_TYPE_BG1, ¤t.pos, &tevStr); + g_env_light.setLightTevColorType(mpModelUnder, &tevStr); + + mBckUnder.entry(mpModelUnder->getModelData(), mBck.getFrame()); + mBtkUnder.entry(mpModelUnder->getModelData(), mBtkUnderFrame); + mBrkUnder.entry(mpModelUnder->getModelData(), mBrkFrame); + + dComIfGd_setListMaskOff(); + mDoExt_modelUpdateDL(mpModelUnder); + dComIfGd_setList(); + } + + return TRUE; } /* 00000464-00000484 .text daTornado_Draw__FP11daTornado_c */ -static BOOL daTornado_Draw(daTornado_c*) { - /* Nonmatching */ +static BOOL daTornado_Draw(daTornado_c* i_this) { + return i_this->draw(); } /* 00000484-00000C4C .text execute__11daTornado_cFv */ BOOL daTornado_c::execute() { - /* Nonmatching */ + static cXyz wind_scale(20.0f,20.0f,20.0f); + + float fVar8; + + mBck.play(); + mBtkFrame += 1.0f; + if (mBtkFrame >= mBtk.getBtkAnm()->getFrameMax()) { + mBtkFrame -= mBtk.getBtkAnm()->getFrameMax(); + } + + mBtkUnderFrame += 1.0f; + if (mBtkUnderFrame >= mBtkUnder.getBtkAnm()->getFrameMax()) { + mBtkUnderFrame -= mBtkUnder.getBtkAnm()->getFrameMax(); + } + mAngle2 += 250; + mAngle1 += 500; + m32c = 10000.0f; + u32 param = fopAcM_GetParam(this); + if (param == 1) { + if (dComIfGp_getShipActor() != NULL) { + fVar8 = (dComIfGp_getShipActor()->current.pos.y - home.pos.y) / 500.0f; + if (fVar8 < 0.0f) { + fVar8 = 0.0f; + } else { + if (fVar8 > 1.0f) { + fVar8 = 1.0f; + } + } + } else { + fVar8 = 1.0f; + } + } else if (param == 0 && dComIfGp_getShipActor() != NULL && dComIfGp_getShipActor()->getTornadoActor() != NULL) { + fVar8 = 0.25f; + } else { + fVar8 = 1.0f; + } + + for (s32 i = 0; i < 11; i++) { + float sin = cM_ssin(mAngle1 - 0x1000 * i); + float tmp1 = fVar8 * joint_offset[i]; + float fVar1 = tmp1 * (sin + 1.0f); + short angle2 = mAngle2 - 0x1800 * i; + mJointX[i] = cM_ssin(angle2) * fVar1 * scale.x; + mJointZ[i] = cM_scos(angle2) * fVar1 * scale.x; + } + + param = fopAcM_GetParam(this); + if (param == 0) { + if (!dComIfGp_event_runCheck()) { + short target = fopAcM_searchActorAngleY(this, dComIfGp_getLinkPlayer()); + cLib_addCalcAngleS(¤t.angle.y, target, 10, 0x1000, 0x100); + cLib_chaseF(&speedF, 20.0f, 0.2f); + } + if (dComIfGp_checkPlayerStatus0(0, daPyStts0_SHIP_RIDE_e) && dComIfGp_getShipActor() != NULL) { + daShip_c* ship = dComIfGp_getShipActor(); + cXyz diff = ship->current.pos - current.pos; + if (diff.abs2XZ() < 10000.0f*10000.0f) { + ship->onTornadoFlg(fopAcM_GetID(this)); + speedF = 0.0f; + } + } + + if (!dComIfGp_event_runCheck()) { + fopAcM_posMoveF(this, NULL); + cXyz diff = current.pos - home.pos; + diff.y = 0; + if (diff.abs2XZ() > 7500.0f*7500.0f) { + diff.normalize(); + current.pos = home.pos + diff * 7500.0f; + } + } + + if (mPtclTimer != 0) { + mPtclTimer -= 1; + } else { + mPtclTimer = 10; + dComIfGp_particle_set(0x8213, ¤t.pos, NULL, (cXyz*)&wind_scale); + } + + fopAcM_seStartCurrent(this, JA_SE_OBJ_TORNADE_SUS, 100); + + if (dComIfGs_isEventBit(0x2710)) { + mPtclCb.end(); + daShip_c* ship = dComIfGp_getShipActor(); + if (ship != NULL) { + ship->offTornadoFlg(); + } + mBrkFrame += 0.3f; + if (mBrkFrame >= mBrk.getBrkAnm()->getFrameMax()) { + fopAcM_delete(this); + } + } else { + dKyw_tornado_Notice(¤t.pos); + } + } else if (param == 1) { + if (m31c != 0) { + for (int i = 0; i < 11; i++) { + cLib_chaseF(&mJointScale[i], l_joint_scale[i], (11-i)*0.007f); + mJointX[i] *= mJointScale[i]; + mJointZ[i] *= mJointScale[i]; + } + } + } else if (m31c != 0) { + for (int i = 0; i < 11; i++) { + cLib_chaseF(&mJointScale[i], 0.0f, (i + 1) * 0.001f); + mJointX[i] *= mJointScale[i]; + mJointZ[i] *= mJointScale[i]; + } + if (mJointScale[10] < 1e-06f) { + fopAcM_delete(this); + return TRUE; + } + } + mDoMtx_stack_c::transS(current.pos); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + attention_info.position = current.pos; + eyePos = current.pos; + mCenter.set(current.pos.x + mJointX[0], current.pos.y, current.pos.z + mJointZ[0]); + if (mPtclCb.getEmitter() != NULL) { + GXColor colorAmb, colorDif; + dKy_get_seacolor(&colorAmb, &colorDif); + mPtclCb.getEmitter()->setGlobalPrmColor(colorAmb.r, colorAmb.g, colorAmb.b); + } + mDoMtx_stack_c::transS(mCenter); + mpModelUnder->setBaseTRMtx(mDoMtx_stack_c::get()); + + return TRUE; } /* 00000C88-00000CA8 .text daTornado_Execute__FP11daTornado_c */ -static BOOL daTornado_Execute(daTornado_c*) { - /* Nonmatching */ +static BOOL daTornado_Execute(daTornado_c* i_this) { + return i_this->execute(); } /* 00000CA8-00000CB0 .text daTornado_IsDelete__FP11daTornado_c */ static BOOL daTornado_IsDelete(daTornado_c*) { - /* Nonmatching */ + return TRUE; } /* 00000CB0-00000D30 .text tornado_delete__11daTornado_cFv */ -void daTornado_c::tornado_delete() { - /* Nonmatching */ +BOOL daTornado_c::tornado_delete() { + mPtclCb.end(); + if (fopAcM_GetParam(this) == 0 && dComIfGp_getShipActor() != NULL) { + dComIfGp_getShipActor()->offTornadoFlg(); + } + dComIfG_resDelete(&mPhs, l_arcName); + return TRUE; } /* 00000D30-00000D54 .text daTornado_Delete__FP11daTornado_c */ -static BOOL daTornado_Delete(daTornado_c*) { - /* Nonmatching */ +static BOOL daTornado_Delete(daTornado_c* i_this) { + i_this->tornado_delete(); + return TRUE; } /* 00000D54-0000109C .text createHeap__11daTornado_cFv */ -void daTornado_c::createHeap() { - /* Nonmatching */ +BOOL daTornado_c::createHeap() { + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, TRND_BDL_YTRND00); + JUT_ASSERT(0x1fe, modelData != NULL); + mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000202); + if (!mpModel) + return FALSE; + if (!mBck.init(modelData, (J3DAnmTransform*)dComIfG_getObjectRes(l_arcName, TRND_BCK_YTRND00), true, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false)) + return FALSE; + if (!mBtk.init(modelData, (J3DAnmTextureSRTKey*)dComIfG_getObjectRes(l_arcName, TRND_BTK_YTRND00), false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, 0)) + return FALSE; + if (!mBrk.init(modelData, (J3DAnmTevRegKey*)dComIfG_getObjectRes(l_arcName, TRND_BRK_YTRND00), false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, 0)) + return FALSE; + + modelData = (J3DModelData*)dComIfG_getObjectRes(l_arcName, TRND_BDL_YWUWT00); + JUT_ASSERT(0x226, modelData != NULL); + mpModelUnder = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000202); + if (!mpModelUnder) + return FALSE; + if (!mBckUnder.init(modelData, (J3DAnmTransform*)dComIfG_getObjectRes(l_arcName, TRND_BCK_YWUWT00), false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false)) + return FALSE; + if (!mBtkUnder.init(modelData, (J3DAnmTextureSRTKey*)dComIfG_getObjectRes(l_arcName, TRND_BTK_YWUWT00), false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, 0)) + return FALSE; + if (!mBrkUnder.init(modelData, (J3DAnmTevRegKey*)dComIfG_getObjectRes(l_arcName, TRND_BRK_YWUWT00), false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, 0)) + return FALSE; + + return TRUE; } /* 0000109C-000010BC .text daTornado_createHeap__FP10fopAc_ac_c */ -static BOOL daTornado_createHeap(fopAc_ac_c*) { - /* Nonmatching */ +static BOOL daTornado_createHeap(fopAc_ac_c* i_this) { + return ((daTornado_c*)i_this)->createHeap(); } /* 000010BC-000014D0 .text create__11daTornado_cFv */ s32 daTornado_c::create() { - /* Nonmatching */ + static cXyz small_scale(0.25f, 0.175f, 0.25f); + static cXyz under_small_scale(0.251f, 0.25f, 0.251f); + static cXyz under_scale(1.01f, 1.0f, 1.01f); + + s32 rt = dComIfG_resLoad(&mPhs, l_arcName); + fopAcM_SetupActor(this, daTornado_c); + + if (rt == cPhs_COMPLEATE_e) { + if (!fopAcM_entrySolidHeap(this, daTornado_createHeap, 0x8000)) { + return cPhs_ERROR_e; + } + + u32 param = fopAcM_GetParam(this); + if (param == 1) { + current.pos.y -= 2000.0f; + mpModel->setBaseScale(small_scale); + mpModelUnder->setBaseScale(under_small_scale); + } else if (param == 2) { + mpModel->setBaseScale(small_scale); + mpModelUnder->setBaseScale(under_small_scale); + for (int i=0; i<11; i++) { + mJointScale[i] = l_joint_scale[i]; + } + } else { + fopAcM_SetParam(this, 0); + if (dComIfGs_isEventBit(0x2710)) { + return cPhs_ERROR_e; + } + dKyw_tornado_Notice(¤t.pos); + mpModelUnder->setBaseScale(under_scale); + mCenter = current.pos; + dComIfGp_particle_set(0x81bb, &mCenter, NULL, NULL, 0xFF, &mPtclCb); + fopAcM_OnStatus(this, fopAcStts_SHOWMAP_e); + } + mDoMtx_stack_c::transS(current.pos); + mpModel->setBaseTRMtx(mDoMtx_stack_c::get()); + mpModelUnder->setBaseTRMtx(mDoMtx_stack_c::get()); + J3DModelData* modelData = mpModel->getModelData(); + for (u16 i = 1; i < modelData->getJointNum(); i++) { + modelData->getJointNodePointer(i)->setCallBack(daTornado_jointCallBack); + } + mpModel->setUserArea((u32) this); + } + return rt; } /* 0000162C-0000164C .text daTornado_Create__FP10fopAc_ac_c */ -static s32 daTornado_Create(fopAc_ac_c*) { - /* Nonmatching */ +static s32 daTornado_Create(fopAc_ac_c* i_this) { + return ((daTornado_c*)i_this)->create(); } static actor_method_class l_daTornado_Method = {