From 716492b7b989090a9303ca22bc3c090dd2f4ed2a Mon Sep 17 00:00:00 2001 From: SuperDude88 <82904174+SuperDude88@users.noreply.github.com> Date: Sat, 19 Oct 2024 13:03:32 -0400 Subject: [PATCH] First Person Item Procs (#680) * First Person Item Procs Match a couple of Link's proc functions * Cleanup --- include/d/actor/d_a_boomerang.h | 2 +- include/d/actor/d_a_himo2.h | 2 +- include/d/actor/d_a_player_main.h | 22 ++++++++- include/d/d_com_inf_game.h | 4 ++ src/d/actor/d_a_boomerang.cpp | 2 +- src/d/actor/d_a_himo2.cpp | 2 +- src/d/actor/d_a_player_boomerang.inc | 50 ++++++++++++++++++++- src/d/actor/d_a_player_bow.inc | 31 ++++++++++++- src/d/actor/d_a_player_hook.inc | 46 ++++++++++++++++++- src/d/actor/d_a_player_main.cpp | 55 ++++++++++++++++++++--- src/d/actor/d_a_player_particle.inc | 6 +-- src/d/actor/d_a_player_rope.inc | 67 +++++++++++++++++++++++++++- 12 files changed, 265 insertions(+), 24 deletions(-) diff --git a/include/d/actor/d_a_boomerang.h b/include/d/actor/d_a_boomerang.h index d133cc13..6dbbcf06 100644 --- a/include/d/actor/d_a_boomerang.h +++ b/include/d/actor/d_a_boomerang.h @@ -12,7 +12,7 @@ public: s32 create(); BOOL draw(); BOOL execute(); - void getFlyMax(); + float getFlyMax(); void rockLineCallback(fopAc_ac_c*); void setAimActor(fopAc_ac_c*); void setLockActor(fopAc_ac_c*, int); diff --git a/include/d/actor/d_a_himo2.h b/include/d/actor/d_a_himo2.h index d3452b5b..4c4dbcaf 100644 --- a/include/d/actor/d_a_himo2.h +++ b/include/d/actor/d_a_himo2.h @@ -9,7 +9,7 @@ struct himo2_s { class himo2_class : public fopAc_ac_c { public: - void setTargetPos(cXyz*, float*, float*); + BOOL setTargetPos(cXyz*, float*, float*); public: /* Place member variables here */ diff --git a/include/d/actor/d_a_player_main.h b/include/d/actor/d_a_player_main.h index 6f3ed1df..be1e28a2 100644 --- a/include/d/actor/d_a_player_main.h +++ b/include/d/actor/d_a_player_main.h @@ -43,11 +43,29 @@ public: void setSightTex(void* sightTex) { mpSightTex = sightTex; } void setLockTex(void* lockTex) { mpLockTex = lockTex; } void setImage(ResTIMG* image) { mpImg = image; } + u8 checkSEFrame() { return mFrame; } + void incFrame() { + if(getLockFlg()) { + mFrame++; + if(checkSEFrame() == 26) { + mFrame = 0; + } + + if(checkSEFrame() == 0) { + mDoAud_seStart(JA_SE_INDICATOR_1); + } + } + else { + onLockFlg(); + mFrame = 0; + mDoAud_seStart(JA_SE_INDICATOR_1); + } + } private: /* 0x04 */ bool mDrawFlag; /* 0x05 */ bool mLockFlag; - /* 0x06 */ u8 field_0x6; + /* 0x06 */ u8 mFrame; /* 0x07 */ u8 mLockAlpha; /* 0x08 */ cXyz mPos; /* 0x14 */ Mtx mMtx; @@ -908,7 +926,7 @@ public: void setShapeAngleToAtnActor(); void cancelItemUpperReadyAnime(); BOOL checkBodyAngleX(s16); - void setBodyAngleToCamera(); + BOOL setBodyAngleToCamera(); void setBodyAngleXReadyAnime(); void setSpeedAndAngleNormal(s16); void setSpeedAndAngleAtn(); diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index 82570898..64ce65b1 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -41,8 +41,12 @@ enum daPy__PlayerStatus0 { daPyStts0_UNK80_e = 0x00000080, daPyStts0_UNK100_e = 0x00000100, daPyStts0_BOW_AIM_e = 0x00001000, + daPyStts0_UNK2000_e = 0x00002000, + daPyStts0_HOOKSHOT_AIM_e = 0x00004000, daPyStts0_SWORD_SWING_e = 0x00008000, daPyStts0_SHIP_RIDE_e = 0x00010000, + daPyStts0_ROPE_AIM_e = 0x00020000, + daPyStts0_UNK40000_e = 0x00040000, daPyStts0_BOOMERANG_AIM_e = 0x00080000, daPyStts0_SWIM_e = 0x00100000, daPyStts0_TELESCOPE_LOOK_e = 0x00200000, diff --git a/src/d/actor/d_a_boomerang.cpp b/src/d/actor/d_a_boomerang.cpp index dfcae777..36171a57 100644 --- a/src/d/actor/d_a_boomerang.cpp +++ b/src/d/actor/d_a_boomerang.cpp @@ -47,7 +47,7 @@ static BOOL daBoomerang_Draw(daBoomerang_c*) { } /* 800E19B8-800E1A14 .text getFlyMax__13daBoomerang_cFv */ -void daBoomerang_c::getFlyMax() { +float daBoomerang_c::getFlyMax() { /* Nonmatching */ } diff --git a/src/d/actor/d_a_himo2.cpp b/src/d/actor/d_a_himo2.cpp index 33e14ad5..6615fd45 100644 --- a/src/d/actor/d_a_himo2.cpp +++ b/src/d/actor/d_a_himo2.cpp @@ -52,7 +52,7 @@ void search_target(himo2_class*, cXyz) { } /* 800ED19C-800ED2E0 .text setTargetPos__11himo2_classFP4cXyzPfPf */ -void himo2_class::setTargetPos(cXyz*, float*, float*) { +BOOL himo2_class::setTargetPos(cXyz*, float*, float*) { /* Nonmatching */ } diff --git a/src/d/actor/d_a_player_boomerang.inc b/src/d/actor/d_a_player_boomerang.inc index e47e7b5c..2365a9bd 100644 --- a/src/d/actor/d_a_player_boomerang.inc +++ b/src/d/actor/d_a_player_boomerang.inc @@ -10,7 +10,9 @@ * based on the original names of the functions it contains. */ +#include "d/actor/d_a_boomerang.h" #include "d/actor/d_a_player_main.h" +#include "d/actor/d_a_player_HIO.h" /* 8014956C-80149590 .text checkBoomerangAnime__9daPy_lk_cCFv */ BOOL daPy_lk_c::checkBoomerangAnime() const { @@ -49,12 +51,56 @@ void daPy_lk_c::changeBoomerangCatchProc() { /* 80149A44-80149AF0 .text procBoomerangSubject_init__9daPy_lk_cFv */ BOOL daPy_lk_c::procBoomerangSubject_init() { - /* Nonmatching */ + if(mCurProc == daPyProc_BOOMERANG_SUBJECT_e) { + return false; + } + + commonProcInit(daPyProc_BOOMERANG_SUBJECT_e); + + mVelocity = 0.0f; + + setActAnimeUpper(LKANM_BCK_BOOMWAIT, UPPER_MOVE2_e, 0.0f, 0.0f, -1, -1.0f); + setSingleMoveAnime(ANM_ATNRS, 0.0f, 0.0f, -1, daPy_HIO_basic_c0::m.field_0xC); + + dComIfGp_setPlayerStatus0(0, daPyStts0_BOOMERANG_AIM_e); + + current.angle.y = shape_angle.y; + + return true; } /* 80149AF0-80149C00 .text procBoomerangSubject__9daPy_lk_cFv */ BOOL daPy_lk_c::procBoomerangSubject() { - /* Nonmatching */ + if(!checkItemModeActorPointer()) { + return true; + } + + if(checkBoomerangReadyAnime()) { + dComIfGp_setDoStatus(7); + } + + setShapeAngleToAtnActor(); + + if(mpAttention->Lockon()) { + setSpeedAndAngleAtn(); + } + + if(checkNextMode(0) == 0) { + if(setBodyAngleToCamera()) { + daBoomerang_c* boomerang = (daBoomerang_c*)mActorKeepEquip.getActor(); + if(boomerang != NULL) { + cXyz sight; + checkSightLine(boomerang->getFlyMax(), &sight); + mSightPacket.setPos(&sight); + mSightPacket.onDrawFlg(); + } + } + } + else { + mSightPacket.offDrawFlg(); + } + + return true; } /* 80149C00-80149CC8 .text procBoomerangMove_init__9daPy_lk_cFv */ diff --git a/src/d/actor/d_a_player_bow.inc b/src/d/actor/d_a_player_bow.inc index f9d89fe1..96e28b4a 100644 --- a/src/d/actor/d_a_player_bow.inc +++ b/src/d/actor/d_a_player_bow.inc @@ -11,6 +11,7 @@ */ #include "d/actor/d_a_player_main.h" +#include "d/actor/d_a_player_HIO.h" /* 80149ECC-80149F88 .text bowJointCB__9daPy_lk_cFi */ void daPy_lk_c::bowJointCB(int) { @@ -79,12 +80,38 @@ void daPy_lk_c::setBowModel() { /* 8014A834-8014A8D4 .text procBowSubject_init__9daPy_lk_cFv */ BOOL daPy_lk_c::procBowSubject_init() { - /* Nonmatching */ + if(mCurProc == daPyProc_BOW_SUBJECT_e) { + return false; + } + + commonProcInit(daPyProc_BOW_SUBJECT_e); + + if(!checkBowAnime()) { + setBowReadyAnime(); + } + setSingleMoveAnime(ANM_ATNRS, 0.0f, 0.0f, -1, daPy_HIO_basic_c0::m.field_0xC); + + mVelocity = 0.0f; + + dComIfGp_setPlayerStatus0(0, daPyStts0_BOW_AIM_e); + + return true; } /* 8014A8D4-8014A974 .text procBowSubject__9daPy_lk_cFv */ BOOL daPy_lk_c::procBowSubject() { - /* Nonmatching */ + dComIfGp_setDoStatus(7); + + if(mpAttention->Lockon()) { + setSpeedAndAngleAtn(); + } + + if(checkNextMode(0) == 0) { + setBodyAngleToCamera(); + m35EC = mFrameCtrlUpper[UPPER_MOVE2_e].getFrame(); + } + + return true; } /* 8014A974-8014AA2C .text procBowMove_init__9daPy_lk_cFv */ diff --git a/src/d/actor/d_a_player_hook.inc b/src/d/actor/d_a_player_hook.inc index e1547930..52d4ecda 100644 --- a/src/d/actor/d_a_player_hook.inc +++ b/src/d/actor/d_a_player_hook.inc @@ -10,7 +10,10 @@ * a function from this file. */ +#include "d/actor/d_a_hookshot.h" +#include "d/actor/d_a_player_HIO.h" #include "d/actor/d_a_player_main.h" +#include "f_op/f_op_actor_mng.h" /* 8014AB5C-8014ABA0 .text checkHookshotReturn__9daPy_lk_cFv */ BOOL daPy_lk_c::checkHookshotReturn() { @@ -52,12 +55,51 @@ BOOL daPy_lk_c::checkNextHookshotMode() { /* 8014B350-8014B3F4 .text procHookshotSubject_init__9daPy_lk_cFv */ BOOL daPy_lk_c::procHookshotSubject_init() { - /* Nonmatching */ + if(mCurProc == daPyProc_HOOKSHOT_SUBJECT_e) { + return false; + } + + commonProcInit(daPyProc_HOOKSHOT_SUBJECT_e); + + mVelocity = 0.0f; + + setActAnimeUpper(LKANM_BCK_HOOKSHOTWAIT, UPPER_MOVE2_e, 0.0f, 0.0f, -1, -1.0f); + setSingleMoveAnime(ANM_ATNLS, 0.0f, 0.0f, -1, daPy_HIO_basic_c0::m.field_0xC); + + dComIfGp_setPlayerStatus0(0, daPyStts0_HOOKSHOT_AIM_e); + + return true; } /* 8014B3F4-8014B518 .text procHookshotSubject__9daPy_lk_cFv */ BOOL daPy_lk_c::procHookshotSubject() { - /* Nonmatching */ + if(!checkItemModeActorPointer()) { + return true; + } + + daHookshot_c* hookshot = (daHookshot_c*)mActorKeepEquip.getActor(); + if(fopAcM_GetParam(hookshot) == 0) { + dComIfGp_setDoStatus(7); + } + + if(mpAttention->Lockon()) { + setSpeedAndAngleAtn(); + } + + mSightPacket.offDrawFlg(); + + if(checkNextMode(0) == 0 && fopAcM_GetParam(hookshot) == 0 && setBodyAngleToCamera() && fopAcM_GetParam(hookshot) == 0) { + setHookshotSight(); + } + + if(fopAcM_GetParam(hookshot) == 0) { + dComIfGp_clearPlayerStatus0(0, daPyStts0_UNK40000_e); + } + else { + dComIfGp_setPlayerStatus0(0, daPyStts0_UNK40000_e); + } + + return true; } /* 8014B518-8014B5E8 .text procHookshotMove_init__9daPy_lk_cFv */ diff --git a/src/d/actor/d_a_player_main.cpp b/src/d/actor/d_a_player_main.cpp index 02689d3b..56c93050 100644 --- a/src/d/actor/d_a_player_main.cpp +++ b/src/d/actor/d_a_player_main.cpp @@ -19,6 +19,7 @@ #include "d/actor/d_a_itembase.h" #include "d/d_item_data.h" #include "d/d_item.h" +#include "m_Do/m_Do_audio.h" #include "m_Do/m_Do_mtx.h" #include "m_Do/m_Do_lib.h" #include "d/d_material.h" @@ -1193,7 +1194,7 @@ BOOL daPy_lk_c::checkBodyAngleX(s16) { } /* 8010A204-8010A2F4 .text setBodyAngleToCamera__9daPy_lk_cFv */ -void daPy_lk_c::setBodyAngleToCamera() { +BOOL daPy_lk_c::setBodyAngleToCamera() { /* Nonmatching */ } @@ -2086,7 +2087,8 @@ BOOL daPy_lk_c::checkScopeEnd() { /* 80112100-8011215C .text setSubjectMode__9daPy_lk_cFv */ void daPy_lk_c::setSubjectMode() { - /* Nonmatching */ + dComIfGp_setPlayerStatus0(0, daPyStts0_UNK2000_e); + mDoAud_seStart(JA_SE_SUBJ_VIEW_IN); } /* 8011215C-801121C8 .text checkMaskDraw__9daPy_lk_cFv */ @@ -2095,8 +2097,17 @@ BOOL daPy_lk_c::checkMaskDraw() { } /* 801121C8-80112280 .text checkSubjectEnd__9daPy_lk_cFi */ -BOOL daPy_lk_c::checkSubjectEnd(int) { - /* Nonmatching */ +BOOL daPy_lk_c::checkSubjectEnd(int param_1) { + if(dComIfGp_event_runCheck() || (mPressedButtons & 3) || (m34C9 & 0x20) || dComIfGp_checkCameraAttentionStatus(mCameraInfoIdx, 0x2000)) { + if(param_1) { + mDoAud_seStart(JA_SE_SUBJ_VIEW_OUT); + } + + onResetFlg0(daPyRFlg0_UNK10000000); + return true; + } + + return false; } /* 80112280-80112330 .text checkGuardAccept__9daPy_lk_cFv */ @@ -2305,13 +2316,43 @@ BOOL daPy_lk_c::procScope() { } /* 80112AA8-80112B18 .text procSubjectivity_init__9daPy_lk_cFi */ -BOOL daPy_lk_c::procSubjectivity_init(int) { - /* Nonmatching */ +BOOL daPy_lk_c::procSubjectivity_init(int param_1) { + commonProcInit(daPyProc_SUBJECTIVITY_e); + + mVelocity = 0.0f; + + setSubjectMode(); + + if(param_1 == 0) { + setBlendMoveAnime(daPy_HIO_basic_c0::m.field_0xC); + } + + m3570 = param_1; + + return true; } /* 80112B18-80112BEC .text procSubjectivity__9daPy_lk_cFv */ BOOL daPy_lk_c::procSubjectivity() { - /* Nonmatching */ + dComIfGp_setAStatus(7); + + if(checkSubjectEnd(0) || (m3570 != 0 && (m34C9 & 0x40) == 0)) { + mDoAud_seStart(JA_SE_SUBJ_VIEW_OUT); + if(m3570 != 0) { + if(mEquipItem == daPyItem_NONE_e) { + return procCrouch_init(); + } + + return procCrouchDefense_init(); + } + + changeWaitProc(); + } + else { + setBodyAngleToCamera(); + } + + return true; } /* 80112BEC-80112C90 .text procCall_init__9daPy_lk_cFv */ diff --git a/src/d/actor/d_a_player_particle.inc b/src/d/actor/d_a_player_particle.inc index 941af4bd..a1b2922a 100644 --- a/src/d/actor/d_a_player_particle.inc +++ b/src/d/actor/d_a_player_particle.inc @@ -185,11 +185,11 @@ void daPy_sightPacket_c::setSight() { if (mLockFlag) { f32 var_f2; f32 var_f31; - if (field_0x6 < 13) { - var_f2 = 1.0f - ((s16)field_0x6 / 13.0f); + if (mFrame < 13) { + var_f2 = 1.0f - ((s16)mFrame / 13.0f); var_f31 = -var_f2; } else { - var_f2 = (field_0x6 - 13) / 13.0f; + var_f2 = (mFrame - 13) / 13.0f; var_f31 = var_f2; } diff --git a/src/d/actor/d_a_player_rope.inc b/src/d/actor/d_a_player_rope.inc index bb3d1c6e..d0ea0f78 100644 --- a/src/d/actor/d_a_player_rope.inc +++ b/src/d/actor/d_a_player_rope.inc @@ -11,6 +11,11 @@ */ #include "d/actor/d_a_player_main.h" +#include "d/actor/d_a_player_HIO.h" +#include "d/actor/d_a_himo2.h" +#include "d/d_attention.h" +#include "f_op/f_op_actor_mng.h" +#include "m_Do/m_Do_audio.h" /* 80142D08-80142D68 .text checkRopeAnime__9daPy_lk_cCFv */ BOOL daPy_lk_c::checkRopeAnime() const { @@ -81,12 +86,70 @@ BOOL daPy_lk_c::checkHangRopeActorNull() { /* 80143F3C-80144038 .text procRopeSubject_init__9daPy_lk_cFv */ BOOL daPy_lk_c::procRopeSubject_init() { - /* Nonmatching */ + if(mCurProc == daPyProc_ROPE_SUBJECT_e) { + return false; + } + + commonProcInit(daPyProc_ROPE_SUBJECT_e); + + mVelocity = 0.0f; + + if(fopAcM_GetParam(mActorKeepEquip.getActor()) == 0) { + setActAnimeUpper(LKANM_BCK_ROPETHROWWAIT, UPPER_MOVE2_e, 0.0f, 0.0f, -1, -1.0f); + setSingleMoveAnime(ANM_ATNRS, 0.0f, 0.0f, -1, daPy_HIO_rope_c0::m.field_0x54); + } + + dComIfGp_setPlayerStatus0(0, daPyStts0_ROPE_AIM_e); + + current.angle.y = shape_angle.y; + + mDoAud_seStart(JA_SE_CAMERA_L_MOVE); + + m3570 = 0; + m3600 = -1.0f; + m3604 = -1.0f; + + return true; } /* 80144038-8014422C .text procRopeSubject__9daPy_lk_cFv */ BOOL daPy_lk_c::procRopeSubject() { - /* Nonmatching */ + if(!checkItemModeActorPointer()) { + return true; + } + + himo2_class* grapple = (himo2_class*)mActorKeepEquip.getActor(); + if(fopAcM_GetParam(grapple) == 0) { + dComIfGp_clearPlayerStatus0(0, daPyStts0_UNK40000_e); + } + else { + dComIfGp_setPlayerStatus0(0, daPyStts0_UNK40000_e); + } + + if(mpAttention->Lockon()) { + setSpeedAndAngleAtn(); + } + + if(checkNextMode(0) == 0 && setBodyAngleToCamera()) { + if(mBodyAngle.x > 0) { + mBodyAngle.x = 0; + } + + cXyz sight; + checkSightLine(2200.0f, &sight); + mSightPacket.onDrawFlg(); + mSightPacket.setPos(&sight); + + if(grapple->setTargetPos(&sight, &m3600, &m3604)) { + mSightPacket.onDrawFlg(); + mSightPacket.incFrame(); + } + else { + mSightPacket.offLockFlg(); + } + } + + return true; } /* 8014422C-80144464 .text procRopeReady_init__9daPy_lk_cFv */