Skip to content

Commit

Permalink
cleanup daPy_sightPacket_c inlines, match setHookshotSight
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Oct 19, 2024
1 parent a356035 commit 55ad93a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 18 deletions.
27 changes: 11 additions & 16 deletions include/d/actor/d_a_player_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
55 changes: 54 additions & 1 deletion src/d/actor/d_a_player_hook.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 */
Expand Down
12 changes: 11 additions & 1 deletion src/d/actor/d_a_player_rope.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 55ad93a

Please sign in to comment.