diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 0fe9c9443..77e55b491 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -110,7 +110,7 @@ public: cM3dGAab const& GetWorkAab() const { return mAab; } static cXyz m_virtual_center; -}; +}; // Size: 0x20 STATIC_ASSERT(0x20 == sizeof(cCcD_ShapeAttr)); @@ -155,6 +155,9 @@ struct cCcD_SrcCpsAttr { class cCcD_CpsAttr : public cCcD_ShapeAttr, public cM3dGCps { public: + /* 0x00 */ /* cCcD_ShapeAttr */ + /* 0x20 */ /* cM3dGCps */ + cCcD_CpsAttr() {} void Set(const cCcD_SrcCpsAttr& pSrc) { cM3dGCps::Set(pSrc.mCps); diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index 1a2380136..dc9f0ef11 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -24,6 +24,9 @@ public: cM3dGTri(const Vec *pA, const Vec *pB, const Vec *pC); bool cross(const cM3dGCyl* cyl, Vec* out) const; + bool cross(const cM3dGLin* line, Vec* vec, bool param_3, bool param_4) const { + return cM3d_Cross_LinTri(line, this, vec, param_3, param_4); + } bool Cross(const cM3dGCps& cps, Vec* out) const { return cM3d_Cross_CpsTri(cps, *this, out); } bool Cross(const cM3dGCyl& cyl, Vec* out) const { return cross(&cyl, out); } diff --git a/include/d/actor/d_a_npc_md.h b/include/d/actor/d_a_npc_md.h index 6b05d7fd4..80b73b642 100644 --- a/include/d/actor/d_a_npc_md.h +++ b/include/d/actor/d_a_npc_md.h @@ -214,6 +214,14 @@ public: void onXYTalk() { cLib_onBit(m30F0, 0x100UL); } void offXYTalk() { cLib_offBit(m30F0, 0x100UL); } bool isXYTalk() { return cLib_checkBit(m30F0, 0x100UL); } + void noCarryAction() { cLib_onBit(m30F0, 0x800UL); } + void offNoCarryAction() { cLib_offBit(m30F0, 0x800UL); } + bool isNoCarryAction() { return cLib_checkBit(m30F0, 0x800UL); } + void onLightHit() { cLib_onBit(m30F0, 0x2000UL); } + void offLightHit() { cLib_offBit(m30F0, 0x2000UL); } + bool isLightHit() { return cLib_checkBit(m30F0, 0x2000UL); } + void onLightBodyHit() { cLib_onBit(m30F0, 0x8000UL); } + void offLightBodyHit() { cLib_offBit(m30F0, 0x8000UL); } bool isOldLightBodyHit() { return cLib_checkBit(m30F0, 0x8000UL); } void onDefaultTalkXY() { cLib_onBit(m30F0, 0x10000UL); } void offDefaultTalkXY() { cLib_offBit(m30F0, 0x10000UL); } @@ -275,23 +283,15 @@ public: void getPiyo2TalkCNT() {} void getTalkType() {} void isLightBodyHit() {} - void isLightHit() {} void isMirror() {} - void isNoCarryAction() {} void isShipRide() {} - void noCarryAction() {} void offBitCamTagIn() {} void offFlying() {} - void offLightBodyHit() {} - void offLightHit() {} void offMirror() {} - void offNoCarryAction() {} void offPlayerRoom() {} void offShipRide() {} void onBitCamTagIn() {} void onFlying() {} - void onLightBodyHit() {} - void onLightHit() {} void onMirror() {} void onPlayerRoom() {} void onShipRide() {} @@ -327,10 +327,10 @@ public: void setHane03Emitter(); void deleteHane03Emitter(); void returnLinkPlayer(); - void shipRideCheck(); + BOOL shipRideCheck(); BOOL isFallAction(); - void returnLinkCheck(); - void lightHitCheck(); + BOOL returnLinkCheck(); + BOOL lightHitCheck(); int wallHitCheck(); void NpcCall(int*); void checkCollision(int); diff --git a/include/d/d_attention.h b/include/d/d_attention.h index 0a6c0a7b0..6d8679b54 100644 --- a/include/d/d_attention.h +++ b/include/d/d_attention.h @@ -166,7 +166,7 @@ public: BOOL chkFlag(u32 flag) { return (mFlags & flag) ? TRUE : FALSE; } void setFlag(u32 flag) { mFlags |= flag; } void clrFlag(u32 flag) { mFlags &= ~flag; } - bool Lockon() { return LockonTruth() || chkFlag(0x20000000); } + bool Lockon() { return LockonTruth() || chkFlag(0x20000000); } // regswap void CatchRequest(fopAc_ac_c* param_0, u8 param_1, f32 param_2, f32 param_3, f32 param_4, s16 param_5, int param_6) { mCatch.request(param_0, param_1, param_2, param_3, param_4, param_5, param_6); diff --git a/include/d/d_camera.h b/include/d/d_camera.h new file mode 100644 index 000000000..6fb1074f1 --- /dev/null +++ b/include/d/d_camera.h @@ -0,0 +1,8 @@ +#ifndef D_CAMERA_H +#define D_CAMERA_H + +#include "f_op/f_op_camera.h" + +s16 dCam_getControledAngleY(camera_class*); + +#endif /* D_CAMERA_H */ diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index f12f1fbb4..c3cf6db02 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -388,6 +388,9 @@ STATIC_ASSERT(sizeof(dCcD_GObjInf) == 0xF8); // Cylinder class dCcD_Cyl : public dCcD_GObjInf, public cCcD_CylAttr { public: + /* 0x00 */ /* dCcD_GObjInf */ + /* 0xF8 */ /* cCcD_CylAttr */ + void Set(dCcD_SrcCyl const&); cCcD_ShapeAttr* GetShapeAttr() { return this; } void StartCAt(cXyz&); @@ -413,6 +416,9 @@ public: // Capsule class dCcD_Cps : public dCcD_GObjInf, public cCcD_CpsAttr { public: + /* 0x00 */ /* dCcD_GObjInf */ + /* 0xF8 */ /* cCcD_CpsAttr */ + void Set(dCcD_SrcCps const&); cCcD_ShapeAttr* GetShapeAttr() { return (cCcD_ShapeAttr*)this; } void CalcAtVec() { diff --git a/include/m_Do/m_Do_mtx.h b/include/m_Do/m_Do_mtx.h index 82994d7ca..3cf818dad 100644 --- a/include/m_Do/m_Do_mtx.h +++ b/include/m_Do/m_Do_mtx.h @@ -25,7 +25,7 @@ void mDoMtx_ZrotM(Mtx mtx, s16 z); bool mDoMtx_inverseTranspose(f32 const (*param_0)[4], f32 (*param_1)[4]); void mDoMtx_QuatConcat(Quaternion const* param_0, Quaternion const* param_1, Quaternion* param_2); -inline void mDoMtx_multVecSR(Mtx m, const Vec* src, Vec* dst) { +inline void mDoMtx_multVecSR(const Mtx m, const Vec* src, Vec* dst) { MTXMultVecSR(m, src, dst); } @@ -103,6 +103,10 @@ inline void mDoMtx_multVecZero(MtxP param_0, Vec* param_1) { param_1->z = param_0[2][3]; } +inline void cMtx_multVecSR(const Mtx m, const Vec* src, Vec* dst) { + mDoMtx_multVecSR(m, src, dst); +} + inline void mDoMtx_quatMultiply(const Quaternion* a, const Quaternion* b, Quaternion* ab) { QUATMultiply(a,b,ab); } diff --git a/src/d/actor/d_a_npc_kamome.cpp b/src/d/actor/d_a_npc_kamome.cpp index 2dc6eacc3..11fd08839 100644 --- a/src/d/actor/d_a_npc_kamome.cpp +++ b/src/d/actor/d_a_npc_kamome.cpp @@ -13,8 +13,7 @@ #include "m_Do/m_Do_controller_pad.h" #include "d/d_npc.h" #include "d/d_snap.h" - -s16 dCam_getControledAngleY(camera_class*); +#include "d/d_camera.h" // Needed for the .data section to match. static f32 dummy1[3] = {1.0f, 1.0f, 1.0f}; diff --git a/src/d/actor/d_a_npc_md.cpp b/src/d/actor/d_a_npc_md.cpp index 4cf2ae5c3..b8977a753 100644 --- a/src/d/actor/d_a_npc_md.cpp +++ b/src/d/actor/d_a_npc_md.cpp @@ -13,6 +13,8 @@ #include "d/d_snap.h" #include "d/actor/d_a_ship.h" #include "d/d_kankyo_wether.h" +#include "d/d_camera.h" +#include "d/d_detect.h" // Needed for the .data section to match. static f32 dummy1[3] = {1.0f, 1.0f, 1.0f}; @@ -978,13 +980,52 @@ void daNpc_Md_c::setPlayerAction(ActionFunc actionFunc, void* arg) { } /* 000033C4-00003430 .text getStickAngY__10daNpc_Md_cFi */ -s16 daNpc_Md_c::getStickAngY(int) { - /* Nonmatching */ +s16 daNpc_Md_c::getStickAngY(BOOL param_1) { + if (param_1) { + return g_mDoCPd_cpadInfo[0].mMainStickAngle + 0x8000; + } else { + s16 angleY = dCam_getControledAngleY(dComIfGp_getCamera(0)); + return g_mDoCPd_cpadInfo[0].mMainStickAngle + 0x8000 + angleY; + } } /* 00003430-00003588 .text calcStickPos__10daNpc_Md_cFsP4cXyz */ -int daNpc_Md_c::calcStickPos(s16, cXyz*) { - /* Nonmatching */ +int daNpc_Md_c::calcStickPos(s16 param_1, cXyz* param_2) { + /* Nonmatching - dAttention_c::Lockon regswap */ + dAttList_c* attList = dComIfGp_getAttention().GetLockonList(0); + + bool r26 = dComIfGp_getAttention().Lockon(); + + int r31; + if (!r26) { + r31 = 0; + } else { + BOOL lockon = dComIfGp_getAttention().LockonTruth(); + r31 = -1; + if (lockon) { + r31 = 1; + } + } + + if (attList == NULL) { + attList = dComIfGp_getAttention().GetActionList(0); + } + if (attList) { + *param_2 = attList->getActor()->mEyePos; + return r31; + } + + if (r26) { + param_1 = shape_angle.y; + } + + param_2->set( + current.pos.x + 100.0f * cM_ssin(param_1), + current.pos.y, + current.pos.z + 100.0f * cM_scos(param_1) + ); + + return r31; } /* 00003588-0000362C .text flyCheck__10daNpc_Md_cFv */ @@ -1012,32 +1053,42 @@ void daNpc_Md_c::setWingEmitter() { /* 00003674-000036C0 .text setHane02Emitter__10daNpc_Md_cFv */ void daNpc_Md_c::setHane02Emitter() { - /* Nonmatching */ + particle_set(&m0508[2], 0x8217); + particle_set(&m0508[3], 0x8217); } /* 000036C0-000036FC .text deleteHane02Emitter__10daNpc_Md_cFv */ void daNpc_Md_c::deleteHane02Emitter() { - /* Nonmatching */ + emitterDelete(&m0508[2]); + emitterDelete(&m0508[3]); } /* 000036FC-00003748 .text setHane03Emitter__10daNpc_Md_cFv */ void daNpc_Md_c::setHane03Emitter() { - /* Nonmatching */ + particle_set(&m0508[4], 0x827D); + particle_set(&m0508[5], 0x827D); } /* 00003748-00003784 .text deleteHane03Emitter__10daNpc_Md_cFv */ void daNpc_Md_c::deleteHane03Emitter() { - /* Nonmatching */ + emitterDelete(&m0508[4]); + emitterDelete(&m0508[5]); } /* 00003784-000037C4 .text returnLinkPlayer__10daNpc_Md_cFv */ void daNpc_Md_c::returnLinkPlayer() { - /* Nonmatching */ + changePlayer(dComIfGp_getLinkPlayer()); + m_flying = false; + m_mirror = false; } /* 000037C4-00003824 .text shipRideCheck__10daNpc_Md_cFv */ -void daNpc_Md_c::shipRideCheck() { - /* Nonmatching */ +BOOL daNpc_Md_c::shipRideCheck() { + if (isTypeShipRide()) { + setNpcAction(&shipNpcAction, NULL); + return TRUE; + } + return FALSE; } /* 00003824-00003908 .text isFallAction__10daNpc_Md_cFv */ @@ -1046,13 +1097,83 @@ BOOL daNpc_Md_c::isFallAction() { } /* 00003908-00003958 .text returnLinkCheck__10daNpc_Md_cFv */ -void daNpc_Md_c::returnLinkCheck() { - /* Nonmatching */ +BOOL daNpc_Md_c::returnLinkCheck() { + if (!dComIfGp_event_runCheck()) { + if (CPad_CHECK_TRIG_R(0) || CPad_CHECK_TRIG_START(0)) { + if (mAcch.ChkGroundHit()) { + return TRUE; + } + } + } + return FALSE; } /* 00003958-00003D20 .text lightHitCheck__10daNpc_Md_cFv */ -void daNpc_Md_c::lightHitCheck() { - /* Nonmatching */ +BOOL daNpc_Md_c::lightHitCheck() { + BOOL lightHit = FALSE; + cXyz lightVec; + cMtx_multVecSR(mpHarpModel->getBaseTRMtx(), &l_ms_light_local_vec, &lightVec); + offLightBodyHit(); + + if (dComIfGp_getDetect().chk_light(¤t.pos)) { + onLightBodyHit(); + lightHit = TRUE; + } else { + cCcD_Obj* hitObj = mCyl3.GetTgHitObj(); + if (hitObj && hitObj->ChkAtType(AT_TYPE_LIGHT)) { + onLightBodyHit(); + if (mCyl3.GetTgRVecP()->inprod(lightVec) < 0.0f) { + lightHit = TRUE; + } + } + } + + if (lightHit) { + onLightHit(); + + if (mCps.ChkAtHit()) { + fopAc_ac_c* hitActor = mCps.GetAtHitAc(); + if (fopAcM_checkStatus(this, fopAcStts_CARRY_e) && !isNoCarryAction()) { + if (hitActor != dComIfGp_getLinkPlayer() && m3058.getEmitter() == NULL) { + dComIfGp_particle_set(0x8232, ¤t.pos, NULL, NULL, 0xFF, &m3058); + } + } else if (m3058.getEmitter() == NULL) { + dComIfGp_particle_set(0x8232, ¤t.pos, NULL, NULL, 0xFF, &m3058); + } + + cM3d_lineVsPosSuisenCross(mCps.GetStart(), mCps.GetEnd(), *mCps.GetAtHitPosP(), &m3058.getPos()); + s16 angleY = cM_atan2s(lightVec.x, lightVec.z); + s16 angleX = cM_atan2s(-lightVec.y, lightVec.absXZ()); + m3058.setAngle(angleX, angleY, 0); + } else { + m3058.end(); + } + + if (!mCps.ChkAtSet()) { + fopAcM_seStartCurrent(this, JA_SE_OBJ_MIRROR_REFLECT, 0); + } else { + fopAcM_seStartCurrent(this, JA_SE_OBJ_MIRROR_LIGHT, 0); + } + + if (m304C.getEmitter() == NULL) { + m304C.makeEmitter(0x8226, mpHarpLightModel->getBaseTRMtx(), ¤t.pos, NULL); + JPABaseEmitter* emitter = m304C.getEmitter(); + JGeometry::TVec3 temp; + temp.set(1.0f, 1.0f, 1.0f); + emitter->setEmitterScale(temp); + temp.set(0.0f, 4.0f, 0.0f); + emitter->setEmitterTranslation(temp); + } + } else { + offLightHit(); + m3058.end(); + if (m304C.getEmitter()) { + m304C.getEmitter()->setGlobalAlpha(0); + m304C.end(); + } + } + + return lightHit; } /* 00003D20-00003D68 .text wallHitCheck__10daNpc_Md_cFv */