diff --git a/configure.py b/configure.py index f395903d..401ab535 100755 --- a/configure.py +++ b/configure.py @@ -406,7 +406,7 @@ config.libs = [ Object(NonMatching, "MetroidPrime/CRippleManager.cpp"), Object(NonMatching, "MetroidPrime/Player/CGrappleArm.cpp"), Object(NonMatching, "MetroidPrime/Enemies/CSpacePirate.cpp"), - Object(NonMatching, "MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp"), + Object(Matching, "MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp"), Object(NonMatching, "MetroidPrime/Cameras/CPathCamera.cpp"), Object(NonMatching, "MetroidPrime/CFluidPlane.cpp"), Object(NonMatching, "MetroidPrime/CFluidPlaneManager.cpp"), diff --git a/include/MetroidPrime/ScriptObjects/CScriptCoverPoint.hpp b/include/MetroidPrime/ScriptObjects/CScriptCoverPoint.hpp index 5869fdeb..0ee70ea4 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptCoverPoint.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptCoverPoint.hpp @@ -24,7 +24,7 @@ public: bool ShouldLandHere() const; void SetInUse(bool inUse); bool GetInUse(TUniqueId uid) const; - bool Blown(const CVector3f& pos) const; + const bool Blown(const CVector3f& pos) const; float GetSinSqVerticalAngle() const; float GetCosHorizontalAngle() const; pas::ECoverDirection GetAttackDirection() const; diff --git a/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp b/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp index 72f7d3ef..f524d0cf 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp @@ -2,6 +2,8 @@ #include "MetroidPrime/CActorParameters.hpp" +#include "Kyoto/Math/CUnitVector3f.hpp" + CScriptCoverPoint::CScriptCoverPoint(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, const CTransform4f& xf, bool active, uint flags, bool crouch, float horizontalAngle, @@ -27,7 +29,8 @@ void CScriptCoverPoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, switch (msg) { case kSM_InitializedInArea: - for (rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin(); conn != GetConnectionList().end(); ++conn) { + for (rstl::vector< SConnection >::const_iterator conn = GetConnectionList().begin(); + conn != GetConnectionList().end(); ++conn) { if (conn->x0_state == kSS_Retreat) { xfc_retreating = mgr.GetIdForScript(conn->x8_objId); break; @@ -56,7 +59,7 @@ float CScriptCoverPoint::GetSinSqVerticalAngle() const { return xf0_sinVerticalAngle * xf0_sinVerticalAngle; } -bool CScriptCoverPoint::Blown(const CVector3f& point) const { +const bool CScriptCoverPoint::Blown(const CVector3f& point) const { bool result = true; if (GetActive()) { @@ -67,12 +70,9 @@ bool CScriptCoverPoint::Blown(const CVector3f& point) const { float magnitude = posDif.Magnitude(); posDif *= 1.f / magnitude; if (magnitude > 8.0f) { - CVector3f normDif(posDif.DropZ()); - normDif.Normalize(); - - CVector3f frontVec(GetTransform().GetForward().DropZ()); - frontVec.Normalize(); - + CUnitVector3f normDif(posDif.GetX(), posDif.GetY(), 0.f, CUnitVector3f::kN_Yes); + CUnitVector3f frontVec(GetTransform().GetColumn(kDY).GetX(), + GetTransform().GetColumn(kDY).GetY(), 0.f, CUnitVector3f::kN_Yes); if (CVector3f::Dot(frontVec, normDif) > GetCosHorizontalAngle() && (posDif.GetZ() * posDif.GetZ()) < GetSinSqVerticalAngle()) result = false; @@ -83,28 +83,8 @@ bool CScriptCoverPoint::Blown(const CVector3f& point) const { } bool CScriptCoverPoint::GetInUse(TUniqueId uid) const { - // bool result = false; - // do { - // if (!xf8_25_inUse && !(x11c_timeLeft > 0.f)) { - // if (xfa_occupant == kInvalidUniqueId) - // break; - // if (uid == kInvalidUniqueId) - // break; - // if (xfa_occupant == uid) - // break; - // } - // result = true; - // } while (false); - // return result; - - bool result = false; - if (!xf8_25_inUse && !(x11c_timeLeft > 0.f)) { - if (xfa_occupant != kInvalidUniqueId && uid != kInvalidUniqueId && xfa_occupant != uid) - result = true; - } else { - result = true; - } - return result; + return xf8_25_inUse || x11c_timeLeft > 0.f || + (xfa_occupant != kInvalidUniqueId && uid != kInvalidUniqueId && uid != xfa_occupant); } void CScriptCoverPoint::SetInUse(bool inUse) {