diff --git a/include/d/actor/d_a_player_main.h b/include/d/actor/d_a_player_main.h index be1e28a2..908b84f4 100644 --- a/include/d/actor/d_a_player_main.h +++ b/include/d/actor/d_a_player_main.h @@ -9,7 +9,7 @@ #include "d/d_drawlist.h" #include "d/d_bg_w.h" #include "d/actor/d_a_player.h" -#include "d/res/res_link.h" +#include "d/res/res_link.h" // IWYU pragma: export #include "d/res/res_lkanm.h" class mDoExt_MtxCalcOldFrame; @@ -37,28 +37,23 @@ class daPy_sightPacket_c : public dDlst_base_c { void onDrawFlg() { mDrawFlag = true; } void offDrawFlg() { mDrawFlag = false; } bool getLockFlg() { return mLockFlag; } - void onLockFlg() { mLockFlag = true; } + void onLockFlg() { + mLockFlag = true; + mFrame = 0; + } void offLockFlg() { mLockFlag = false; } void setPos(const cXyz* i_pos) { mPos = *i_pos; } void setSightTex(void* sightTex) { mpSightTex = sightTex; } void setLockTex(void* lockTex) { mpLockTex = lockTex; } void setImage(ResTIMG* image) { mpImg = image; } - u8 checkSEFrame() { return mFrame; } + bool checkSEFrame() { + // This implementation might be incomplete, debug map says it's 0x18 bytes but this line is only 0x10 bytes. + return mFrame == 0; + } void incFrame() { - if(getLockFlg()) { - mFrame++; - if(checkSEFrame() == 26) { - mFrame = 0; - } - - if(checkSEFrame() == 0) { - mDoAud_seStart(JA_SE_INDICATOR_1); - } - } - else { - onLockFlg(); + mFrame++; + if(mFrame == 26) { mFrame = 0; - mDoAud_seStart(JA_SE_INDICATOR_1); } } diff --git a/src/d/actor/d_a_player_hook.inc b/src/d/actor/d_a_player_hook.inc index 52d4ecda..9ae08e1f 100644 --- a/src/d/actor/d_a_player_hook.inc +++ b/src/d/actor/d_a_player_hook.inc @@ -10,6 +10,7 @@ * a function from this file. */ +#include "SSystem/SComponent/c_math.h" #include "d/actor/d_a_hookshot.h" #include "d/actor/d_a_player_HIO.h" #include "d/actor/d_a_player_main.h" @@ -32,7 +33,59 @@ void daPy_lk_c::setHookshotModel() { /* 8014ACCC-8014B02C .text setHookshotSight__9daPy_lk_cFv */ void daPy_lk_c::setHookshotSight() { - /* Nonmatching */ + cXyz sp50( + cM_ssin(shape_angle.y) * cM_scos(mBodyAngle.x), + -cM_ssin(mBodyAngle.x), + cM_scos(shape_angle.y) * cM_scos(mBodyAngle.x) + ); + cXyz sp44; + cXyz sp38; + sp38 = mHookshotRootPos + sp50 * 1500.0f; + sp44 = mHookshotRootPos - sp50 * 60.0f; + mRopeLinChk.Set(&sp44, &sp38, this); + daHookshot_c* hookshot = (daHookshot_c*)mActorKeepEquip.getActor(); + BOOL r30 = dComIfG_Bgsp()->LineCross(&mRopeLinChk); + mSightPacket.onDrawFlg(); + if (r30 || hookshot->mCps.ChkAtHit()) { + BOOL r3; + if (r30 && mHookshotRootPos.abs2(current.pos) > mRopeLinChk.GetCross().abs2(current.pos)) { + mSightPacket.setPos(&mHookshotRootPos); + r3 = FALSE; + } else if (!r30) { + mSightPacket.setPos(&hookshot->m2CC); + r3 = TRUE; + } else if (!hookshot->mCps.ChkAtHit()) { + mSightPacket.setPos(&mRopeLinChk.GetCross()); + r3 = FALSE; + } else if (mRopeLinChk.GetCross().abs2(mHookshotRootPos) > hookshot->m2CC.abs2(mHookshotRootPos)) { + mSightPacket.setPos(&hookshot->m2CC); + r3 = TRUE; + } else { + mSightPacket.setPos(&mRopeLinChk.GetCross()); + r3 = FALSE; + } + + if ( + (r3 && hookshot->m2B0) || + (!r3 && dComIfG_Bgsp()->ChkPolyHSStick(mRopeLinChk)) + ) { + if(mSightPacket.getLockFlg()) { + mSightPacket.incFrame(); + if(mSightPacket.checkSEFrame()) { + mDoAud_seStart(JA_SE_INDICATOR_1); + } + } + else { + mSightPacket.onLockFlg(); + mDoAud_seStart(JA_SE_INDICATOR_1); + } + } else { + mSightPacket.offLockFlg(); + } + } else { + mSightPacket.setPos(&sp38); + mSightPacket.offLockFlg(); + } } /* 8014B02C-8014B05C .text freeHookshotItem__9daPy_lk_cFv */ diff --git a/src/d/actor/d_a_player_rope.inc b/src/d/actor/d_a_player_rope.inc index d0ea0f78..bcaf2b2d 100644 --- a/src/d/actor/d_a_player_rope.inc +++ b/src/d/actor/d_a_player_rope.inc @@ -142,7 +142,17 @@ BOOL daPy_lk_c::procRopeSubject() { if(grapple->setTargetPos(&sight, &m3600, &m3604)) { mSightPacket.onDrawFlg(); - mSightPacket.incFrame(); + if(mSightPacket.getLockFlg()) { + mSightPacket.incFrame(); + + if(mSightPacket.checkSEFrame()) { + mDoAud_seStart(JA_SE_INDICATOR_1); + } + } + else { + mSightPacket.onLockFlg(); + mDoAud_seStart(JA_SE_INDICATOR_1); + } } else { mSightPacket.offLockFlg();