Minor fixes for CMetroidPrimeExo

This commit is contained in:
Phillip Stephens 2021-10-23 14:45:03 -07:00
parent 01ee9a83b4
commit a6df91b795
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
3 changed files with 33 additions and 36 deletions

View File

@ -503,7 +503,7 @@ void CMetroidPrimeExo::Run(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) { if (msg == EStateMsg::Activate) {
x92c_ = 10; x92c_ = 10;
x1084_ = 1.9666666f; x1084_ = 1.9666666f;
TUniqueId wpId = sub802769e0(mgr, true); TUniqueId wpId = GetNextAttackWaypoint(mgr, true);
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(wpId)) { if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(wpId)) {
GetBodyController()->SetLocomotionType(sub80275e14(1)); GetBodyController()->SetLocomotionType(sub80275e14(1));
SetDestPos(wp->GetTranslation()); SetDestPos(wp->GetTranslation());
@ -686,7 +686,7 @@ void CMetroidPrimeExo::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
x92c_ = 0; x92c_ = 0;
sub802738d4(mgr); sub802738d4(mgr);
x1088_ = 1.2166667; x1088_ = 1.2166667f;
xc50_->SetParticleEmission(false); xc50_->SetParticleEmission(false);
FirePlasmaProjectile(mgr, false); FirePlasmaProjectile(mgr, false);
x1254_ = 2; x1254_ = 2;
@ -731,7 +731,7 @@ void CMetroidPrimeExo::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
x32c_animState = EAnimState::Ready; x32c_animState = EAnimState::Ready;
SendStateToRelay(EScriptObjectState::Zero, mgr); SendStateToRelay(EScriptObjectState::Zero, mgr);
if (TCastToConstPtr<CScriptWaypoint> wp = if (TCastToConstPtr<CScriptWaypoint> wp =
mgr.GetObjectById(sub80276b3c(mgr, EScriptObjectState::CloseIn, EScriptObjectMessage::Follow))) { mgr.GetObjectById(GetWaypointForBehavior(mgr, EScriptObjectState::CloseIn, EScriptObjectMessage::Follow))) {
SetTransform(wp->GetTransform()); SetTransform(wp->GetTransform());
} }
x1078_ = 1; x1078_ = 1;
@ -741,7 +741,7 @@ void CMetroidPrimeExo::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
} else if (msg == EStateMsg::Deactivate) { } else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady; x32c_animState = EAnimState::NotReady;
if (TCastToConstPtr<CScriptWaypoint> wp = if (TCastToConstPtr<CScriptWaypoint> wp =
mgr.GetObjectById(sub80276b3c(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) { mgr.GetObjectById(GetWaypointForBehavior(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
SetTransform(wp->GetTransform()); SetTransform(wp->GetTransform());
} }
++x91c_; ++x91c_;
@ -926,7 +926,7 @@ void CMetroidPrimeExo::DeactivatePatrolObjects(CStateManager& mgr) {
const TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId); const TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId);
x1058_.clear(); x1058_.clear();
if (relay) { if (relay) {
for(const auto& conn : relay->GetConnectionList()) { for (const auto& conn : relay->GetConnectionList()) {
if (conn.x0_state != EScriptObjectState::Patrol) { if (conn.x0_state != EScriptObjectState::Patrol) {
continue; continue;
} }
@ -975,7 +975,7 @@ void CMetroidPrimeExo::SetBillboardEmission(CStateManager& mgr, bool emission) {
void CMetroidPrimeExo::FreeBillboard(CStateManager& mgr) { mgr.FreeScriptObject(x1044_billboardId); } void CMetroidPrimeExo::FreeBillboard(CStateManager& mgr) { mgr.FreeScriptObject(x1044_billboardId); }
zeus::CVector3f CMetroidPrimeExo::sub8027464c(CStateManager& mgr) { zeus::CVector3f CMetroidPrimeExo::sub8027464c(CStateManager& mgr) {
TUniqueId uid = sub80276b3c(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow); TUniqueId uid = GetWaypointForBehavior(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
float dVar4 = 0.f; float dVar4 = 0.f;
zeus::CVector3f tmpVec; zeus::CVector3f tmpVec;
@ -1028,7 +1028,7 @@ void CMetroidPrimeExo::sub802749e8(float f1, float f2, float f3, const zeus::CVe
zeus::CVector3f v1 = vec1; zeus::CVector3f v1 = vec1;
auto lookAtXf = zeus::lookAt(zeus::skZero3f, diffVec); auto lookAtXf = zeus::lookAt(zeus::skZero3f, diffVec);
elemGen->SetParticleEmission(true); elemGen->SetParticleEmission(true);
s32 count = static_cast<s32>(2.f * dist + 1.f); s32 count = static_cast<s32>(2.f * dist + 1.f);
for (s32 i = 0; i < count; ++i) { for (s32 i = 0; i < count; ++i) {
float dVar14 = i * static_cast<int>(1.f / static_cast<float>(count)); float dVar14 = i * static_cast<int>(1.f / static_cast<float>(count));
float dVar11 = f1 * (dVar14 * std::cos(static_cast<float>(i) + f3)); float dVar11 = f1 * (dVar14 * std::cos(static_cast<float>(i) + f3));
@ -1195,7 +1195,7 @@ void CMetroidPrimeExo::UpdateTimers(float dt) {
} }
void CMetroidPrimeExo::sub80275800(CStateManager& mgr) { void CMetroidPrimeExo::sub80275800(CStateManager& mgr) {
TUniqueId tmpId = sub802769e0(mgr, true); TUniqueId tmpId = GetNextAttackWaypoint(mgr, true);
u32 flags = 0x13c1; u32 flags = 0x13c1;
if (tmpId != kInvalidUniqueId) { if (tmpId != kInvalidUniqueId) {
@ -1449,7 +1449,7 @@ void CMetroidPrimeExo::SendStateToRelay(EScriptObjectState state, CStateManager&
} }
} }
void CMetroidPrimeExo::sub80276754(CStateManager& mgr) { void CMetroidPrimeExo::GetRelayState(CStateManager& mgr) {
x1160_.clear(); x1160_.clear();
if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) { if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) {
x1160_ = relay->GetRoomParameters(); x1160_ = relay->GetRoomParameters();
@ -1467,8 +1467,8 @@ void CMetroidPrimeExo::sub80276754(CStateManager& mgr) {
} }
} }
TUniqueId CMetroidPrimeExo::sub802769e0(CStateManager& mgr, bool b1) { TUniqueId CMetroidPrimeExo::GetNextAttackWaypoint(CStateManager& mgr, bool b1) {
TUniqueId uid = sub80276b3c(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow); TUniqueId uid = GetWaypointForBehavior(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
float lastDot = 0.f; float lastDot = 0.f;
TUniqueId lastUid = kInvalidUniqueId; TUniqueId lastUid = kInvalidUniqueId;
while (uid != kInvalidUniqueId) { while (uid != kInvalidUniqueId) {
@ -1488,7 +1488,7 @@ TUniqueId CMetroidPrimeExo::sub802769e0(CStateManager& mgr, bool b1) {
return lastUid; return lastUid;
} }
TUniqueId CMetroidPrimeExo::sub80276b3c(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg) { TUniqueId CMetroidPrimeExo::GetWaypointForBehavior(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg) {
if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) { if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) {
rstl::reserved_vector<TUniqueId, 8> uids; rstl::reserved_vector<TUniqueId, 8> uids;
for (const auto& conn : relay->GetConnectionList()) { for (const auto& conn : relay->GetConnectionList()) {
@ -1538,7 +1538,7 @@ void CMetroidPrimeExo::UpdateRelay(CStateManager& mgr, TAreaId areaId) {
} }
} }
sub80276754(mgr); GetRelayState(mgr);
DeactivatePatrolObjects(mgr); DeactivatePatrolObjects(mgr);
} }
@ -1557,15 +1557,12 @@ bool CMetroidPrimeExo::IsRelayValid(CStateManager& mgr, TAreaId aid) {
} }
bool CMetroidPrimeExo::sub80277224(float f1, CStateManager& mgr) { bool CMetroidPrimeExo::sub80277224(float f1, CStateManager& mgr) {
TUniqueId uid = sub802769e0(mgr, f1 >= 0.f); TUniqueId uid = GetNextAttackWaypoint(mgr, f1 >= 0.f);
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(uid)) { if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(uid)) {
const float dist = (wp->GetTranslation() - GetTranslation()).magSquared(); const float scaleMag = f1 * (0.57735026 * GetModelData()->GetScale().magnitude());
const float scaleMag = f1 * (0.57735026f * GetModelData()->GetScale().magSquared()); const float dist = GetTransform().frontVector().dot(wp->GetTranslation() - GetTranslation());
if (f1 < 0.f) { return f1 < 0.f ? dist < scaleMag : dist > scaleMag;
return dist > scaleMag;
}
return dist < scaleMag;
} }
return false; return false;
} }
@ -1785,7 +1782,7 @@ void CMetroidPrimeExo::sub80278508(CStateManager& mgr, int w1, bool b1) {
x570_ = w1; x570_ = w1;
sub80278130(x588_[x570_].x6c_color); sub80278130(x588_[x570_].x6c_color);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(x8cc_headColActor)) { if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(x8cc_headColActor)) {
if (b1 == false) { if (!b1) {
colAct->SetDamageVulnerability(CDamageVulnerability::ImmuneVulnerabilty()); colAct->SetDamageVulnerability(CDamageVulnerability::ImmuneVulnerabilty());
mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr); mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
colAct->RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr); colAct->RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);

View File

@ -235,9 +235,9 @@ class CMetroidPrimeExo : public CPatterned {
void SetActorAreaId(CStateManager& mgr, TUniqueId uid, TAreaId aid); void SetActorAreaId(CStateManager& mgr, TUniqueId uid, TAreaId aid);
void UpdateAreaId(CStateManager& mgr); void UpdateAreaId(CStateManager& mgr);
void SendStateToRelay(EScriptObjectState state, CStateManager& mgr); void SendStateToRelay(EScriptObjectState state, CStateManager& mgr);
void sub80276754(CStateManager& mgr); void GetRelayState(CStateManager& mgr);
TUniqueId sub802769e0(CStateManager& mgr, bool b1); TUniqueId GetNextAttackWaypoint(CStateManager& mgr, bool b1);
TUniqueId sub80276b3c(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg); TUniqueId GetWaypointForBehavior(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg);
void UpdateRelay(CStateManager& mgr, TAreaId areaId); void UpdateRelay(CStateManager& mgr, TAreaId areaId);
bool IsRelayValid(CStateManager& mgr, TAreaId w2); bool IsRelayValid(CStateManager& mgr, TAreaId w2);
bool sub80277224(float f1, CStateManager& mgr); bool sub80277224(float f1, CStateManager& mgr);

View File

@ -41,18 +41,18 @@ public:
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override;
[[nodiscard]] TUniqueId GetMetroidPrimeExoId() const { return x34_mpUid; } [[nodiscard]] TUniqueId GetMetroidPrimeExoId() const { return x34_mpUid; }
void SetMetroidPrimeExoId(TUniqueId uid) { x34_mpUid = uid; } void SetMetroidPrimeExoId(TUniqueId uid) { x34_mpUid = uid; }
float Get_xc84() const { return xc84_f1; } [[nodiscard]] float Get_xc84() const { return xc84_f1; }
float Get_xc88() const { return xc88_f2; } [[nodiscard]] float Get_xc88() const { return xc88_f2; }
float Get_xc8c() const { return xc8c_f3; } [[nodiscard]] float Get_xc8c() const { return xc8c_f3; }
u32 Get_xc90() const { return xc90_w1; } [[nodiscard]] u32 Get_xc90() const { return xc90_w1; }
bool Get_xc94() const { return xc94_b1; } [[nodiscard]] bool Get_xc94() const { return xc94_b1; }
u32 Get_xc98() const { return xc98_w2; } [[nodiscard]] u32 Get_xc98() const { return xc98_w2; }
CHealthInfo GetHealthInfo1() const { return xc9c_hInfo1; } [[nodiscard]] CHealthInfo GetHealthInfo1() const { return xc9c_hInfo1; }
CHealthInfo GetHealthInfo2() const { return xca4_hInfo2; } [[nodiscard]] CHealthInfo GetHealthInfo2() const { return xca4_hInfo2; }
u32 Get_xcac() const { return xcac_w3; } [[nodiscard]] u32 Get_xcac() const { return xcac_w3; }
u32 Get_xcb0() const { return xcb0_w4; } [[nodiscard]] u32 Get_xcb0() const { return xcb0_w4; }
u32 Get_xcb4() const { return xcb4_w5; } [[nodiscard]] u32 Get_xcb4() const { return xcb4_w5; }
rstl::reserved_vector<SPrimeExoRoomParameters, 4> GetRoomParameters() const { return xcb8_roomParms; } [[nodiscard]] rstl::reserved_vector<SPrimeExoRoomParameters, 4> GetRoomParameters() const { return xcb8_roomParms; }
}; };
} // namespace metaforce::MP1 } // namespace metaforce::MP1