From f3134dbdc14805d88b3adbf32eb53e2a456db9fa Mon Sep 17 00:00:00 2001 From: Yanis002 <35189056+Yanis002@users.noreply.github.com> Date: Sat, 8 Feb 2025 00:49:06 +0100 Subject: [PATCH] match `LinkStateItem::func_ov059_021990a4` --- include/Actor/Navi/ActorNaviBase.hpp | 2 +- include/Player/EquipHammer.hpp | 9 ++++ include/Player/LinkStateBase.hpp | 2 +- src/00_Core/Player/LinkStateBase.cpp | 2 +- src/59_Hammer/Player/EquipHammer.cpp | 74 +++++++++++++++++++++++++++- 5 files changed, 85 insertions(+), 4 deletions(-) diff --git a/include/Actor/Navi/ActorNaviBase.hpp b/include/Actor/Navi/ActorNaviBase.hpp index d42a82b3..6fae5e7e 100644 --- a/include/Actor/Navi/ActorNaviBase.hpp +++ b/include/Actor/Navi/ActorNaviBase.hpp @@ -48,7 +48,7 @@ public: /* 3b4 */ EquipHammer *mHammer; /* 3b8 */ unk32 mUnk_3b8; /* 3bc */ unk32 mUnk_3bc; - /* 3c0 */ unk8 mUnk_3c0[0x8]; + /* 3c0 */ u8 mUnk_3c0[0x8]; /* 3c8 */ /* 00 */ virtual ~ActorNaviBase() override; diff --git a/include/Player/EquipHammer.hpp b/include/Player/EquipHammer.hpp index a367090d..b65bbcbf 100644 --- a/include/Player/EquipHammer.hpp +++ b/include/Player/EquipHammer.hpp @@ -42,6 +42,15 @@ public: void func_ov059_02198f10(Vec3p *vec, unk32 param2, s32 param3); void func_ov059_02198fa8(unk32 param1); bool func_ov059_02198fe0(); + + inline s32 GetUnk_18(void) { + return mUnk_18; + } + + inline unk32 GetUnk_20(void) { + return mUnk_20; + } }; extern LinkStateItem *GetLinkStateItem(); +extern EquipHammer *GetEquipHammer(); diff --git a/include/Player/LinkStateBase.hpp b/include/Player/LinkStateBase.hpp index 470f6096..3fa02e4e 100644 --- a/include/Player/LinkStateBase.hpp +++ b/include/Player/LinkStateBase.hpp @@ -95,7 +95,7 @@ public: void func_ov00_020a8ab0(unk32 param1); void func_ov00_020a8ad0(unk32 param1); void func_ov00_020a8b04(s32 param1, bool param2); - void func_ov00_020a8b3c(s32 param1); + unk32 func_ov00_020a8b3c(s32 param1); bool func_ov00_020a8b80(); bool HasFlags_PlayerLinkBase_Unk48(u16 flags); unk8 Get_PlayerLinkBase_Unk5e(); diff --git a/src/00_Core/Player/LinkStateBase.cpp b/src/00_Core/Player/LinkStateBase.cpp index 70946bd2..d82f334c 100644 --- a/src/00_Core/Player/LinkStateBase.cpp +++ b/src/00_Core/Player/LinkStateBase.cpp @@ -51,7 +51,7 @@ void LinkStateBase::func_ov00_020a8a90(unk32 param1) {} void LinkStateBase::func_ov00_020a8ab0(unk32 param1) {} void LinkStateBase::func_ov00_020a8ad0(unk32 param1) {} void LinkStateBase::func_ov00_020a8b04(s32 param1, bool param2) {} -void LinkStateBase::func_ov00_020a8b3c(s32 param1) {} +unk32 LinkStateBase::func_ov00_020a8b3c(s32 param1) {} bool LinkStateBase::func_ov00_020a8b80() {} bool LinkStateBase::HasFlags_PlayerLinkBase_Unk48(u16 flags) {} unk8 LinkStateBase::Get_PlayerLinkBase_Unk5e() {} diff --git a/src/59_Hammer/Player/EquipHammer.cpp b/src/59_Hammer/Player/EquipHammer.cpp index 947f3132..21f5696b 100644 --- a/src/59_Hammer/Player/EquipHammer.cpp +++ b/src/59_Hammer/Player/EquipHammer.cpp @@ -1,6 +1,7 @@ #include "Player/EquipHammer.hpp" #include "Player/LinkStateItem.hpp" #include "Player/PlayerLink.hpp" +#include "Player/PlayerControl.hpp" #include "Map/MapManager.hpp" #include "Item/ItemManager.hpp" #include "DTCM/UnkStruct_027e0fd4.hpp" @@ -8,7 +9,24 @@ extern "C" void ApproachAngle_thunk(s16* src, s16* dst, u32 param3); extern "C" void func_ov000_020b853c(void); + +struct EquipHammer_UnkStruct { + /* 00 */ unk8 mUnk_00[0x20]; + /* 20 */ unk32 mUnk_20; + /* 24 */ unk8 mUnk_24[0xC]; + /* 30 */ unk32 mUnk_30; + /* 34 */ unk8 mUnk_34[0xC]; + /* 40 */ unk32 mUnk_40; + /* 44 */ unk8 mUnk_44[0xC]; + /* 50 */ unk32 mUnk_50; + /* 54 */ +}; + +extern EquipHammer_UnkStruct data_ov059_0219b160; extern unk32 data_ov059_0219b180; +extern unk32 data_ov059_0219b190; +extern unk32 data_ov059_0219b1a0; +extern unk32 data_ov059_0219b1b0; ARM bool EquipHammer::IsUsable(unk32 param1) const { ActorNavi *pAVar3; @@ -166,7 +184,61 @@ ARM void LinkStateItem::func_ov059_0219907c() { this->mUnk_25[3] = 0; } -ARM void LinkStateItem::func_ov059_021990a4() {} +#define CHECK_0219b160(field) ((field) == this->Get_PlayerControlData_Unk100()) + +ARM void LinkStateItem::func_ov059_021990a4() { + EquipHammer *pEVar4; + ActorNavi *pAVar5; + + if (this->mUnk_25[0x2] != 0 && this->mUnk_25[0x3] == 0) { + return; + } + + pEVar4 = GetEquipHammer(); + pAVar5 = gItemManager->GetFairy(FairyId_Courage); + + if (CHECK_0219b160(data_ov059_0219b160.mUnk_20)) { + this->mUnk_38 = gPlayerControl->mAimWorld; + + if (pAVar5->mUnk_3c0[0] != 0 && gPlayerControl->UpdateAimWorld(&this->mUnk_38) && pEVar4->GetUnk_18() <= 0) { + pEVar4->func_ov059_02198e90(); + + if (this->mUnk_25[2] != 0 && this->mUnk_25[3] != 0) { + this->LookAt(&this->mUnk_38); + } + + this->func_ov00_020a89bc(&data_ov059_0219b190, 1); + } + } else { + if (CHECK_0219b160(data_ov059_0219b160.mUnk_50)) { + if (this->func_ov00_020a8b3c(1) != 0 || gPlayerControl->UpdateAimWorld(&this->mUnk_38)) { + this->func_ov00_020a89bc(&data_ov059_0219b180, 1); + } + } else if (CHECK_0219b160(data_ov059_0219b160.mUnk_30) || CHECK_0219b160(data_ov059_0219b160.mUnk_40)) { + gPlayerControl->UpdateAimWorld(&this->mUnk_38); + pEVar4->func_ov059_02198e90(); + + if (this->mUnk_25[0x2] != 0 && this->mUnk_25[0x3] != 0) { + this->LookAt(&this->mUnk_38); + } + + if (gPlayerControl->CheckTouching(1) ? false : true) { + if (pEVar4->GetUnk_18() > 0) { + pEVar4->func_ov059_02198ebc(); + this->func_ov00_020a89bc(&data_ov059_0219b1b0, 1); + } + } else if (!CHECK_0219b160(data_ov059_0219b160.mUnk_40) && pEVar4->GetUnk_20() <= 0) { + this->func_ov00_020a89bc(&data_ov059_0219b1a0, 1); + } + } else { + this->func_ov00_020a89bc(&data_ov059_0219b180, 1); + } + } + + if (this->mUnk_25[0x2] == 0 || this->mUnk_25[0x3] == 0) { + this->func_ov059_02198ffc(); + } +} ARM EquipHammer *GetEquipHammer() { return (EquipHammer*)ItemManager::GetEquipItemUnchecked(ItemFlag_Hammer);