From c059b527ecd41a4df6333edecc5c9d146a142e28 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 6 Oct 2022 19:57:29 +0300 Subject: [PATCH] Almost match CPlayerGun::GetTargetId --- include/MetroidPrime/Player/CPlayer.hpp | 4 ++++ src/MetroidPrime/Player/CPlayerGun.cpp | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index 294cf0ab..2eec3b5a 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -167,6 +167,10 @@ public: CPlayerGun* PlayerGun() { return x490_gun.get(); } const CPlayerGun* GetPlayerGun() const { return x490_gun.get(); } + + TUniqueId GetOrbitTargetId() const { return x310_orbitTargetId; } + TUniqueId GetOrbitNextTargetId() const { return x33c_orbitNextTargetId; } + TUniqueId GetScanningObjectId() const { return x3b4_scanningObject; } private: struct CVisorSteam { diff --git a/src/MetroidPrime/Player/CPlayerGun.cpp b/src/MetroidPrime/Player/CPlayerGun.cpp index 635d4f12..0112f138 100644 --- a/src/MetroidPrime/Player/CPlayerGun.cpp +++ b/src/MetroidPrime/Player/CPlayerGun.cpp @@ -570,7 +570,22 @@ float CPlayerGun::GetBeamVelocity() const { return 10.f; } -TUniqueId CPlayerGun::GetTargetId(CStateManager&) { return TUniqueId(0, 0); } +TUniqueId CPlayerGun::GetTargetId(CStateManager& mgr) { + TUniqueId ret = mgr.GetPlayer()->GetOrbitTargetId(); + if (x832_26_comboFiring && ret == kInvalidUniqueId && x310_currentBeam == CPlayerState::kBI_Wave) + ret = mgr.GetPlayer()->GetOrbitNextTargetId(); + + if (ret != kInvalidUniqueId) { + const CActor* act = TCastToConstPtr(mgr.GetObjectById(ret)); + if (act != nullptr) { + if (!act->GetMaterialList().HasMaterial(kMT_Target)) { + ret = kInvalidUniqueId; + } + } + } + + return ret; + } CPlayerGun::CGunMorph::CGunMorph(float gunTransformTime, float holoHoldTime) : x4_gunTransformTime(gunTransformTime), x10_holoHoldTime(fabs(holoHoldTime)) {}