From 26ae8beb74a3342e5ca65dd07d036c0b76002371 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 13 Mar 2020 16:22:39 -0400 Subject: [PATCH] CFlyingPirate: Small fixes --- Runtime/Character/CBodyStateCmdMgr.hpp | 1 - Runtime/MP1/World/CBabygoth.cpp | 2 +- Runtime/MP1/World/CChozoGhost.cpp | 2 +- Runtime/MP1/World/CFlaahgra.cpp | 8 +++--- Runtime/MP1/World/CFlyingPirate.cpp | 35 +++++++++++++------------- Runtime/MP1/World/CJellyZap.cpp | 6 ++--- Runtime/MP1/World/CMetaree.cpp | 2 +- Runtime/MP1/World/CSpacePirate.cpp | 18 ++++++------- 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Runtime/Character/CBodyStateCmdMgr.hpp b/Runtime/Character/CBodyStateCmdMgr.hpp index 35448520a..717c686cd 100644 --- a/Runtime/Character/CBodyStateCmdMgr.hpp +++ b/Runtime/Character/CBodyStateCmdMgr.hpp @@ -459,7 +459,6 @@ public: const zeus::CVector3f& GetMoveVector() const { return x0_move; } const zeus::CVector3f& GetFaceVector() const { return xc_face; } const zeus::CVector3f& GetTargetVector() const { return x18_target; } - void SetTargetVector(const zeus::CVector3f& target) { x18_target = target; } const zeus::CVector3f& GetAdditiveTargetVector() const { return x24_additiveTarget; } }; diff --git a/Runtime/MP1/World/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp index 2dd760946..1a831d151 100644 --- a/Runtime/MP1/World/CBabygoth.cpp +++ b/Runtime/MP1/World/CBabygoth.cpp @@ -708,7 +708,7 @@ void CBabygoth::FollowPattern(CStateManager& mgr, EStateMsg msg, float) { CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal)); } else if (x568_stateProg == 3) { if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Step) - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); else x568_stateProg = 4; } diff --git a/Runtime/MP1/World/CChozoGhost.cpp b/Runtime/MP1/World/CChozoGhost.cpp index 56ead1af0..d267e7703 100644 --- a/Runtime/MP1/World/CChozoGhost.cpp +++ b/Runtime/MP1/World/CChozoGhost.cpp @@ -446,7 +446,7 @@ void CChozoGhost::Attack(CStateManager& mgr, EStateMsg msg, float dt) { xfc_constantForce.zeroOut(); } else if (msg == EStateMsg::Update) { TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, x67c_attackType); - GetBodyController()->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + GetBodyController()->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); if (x67c_attackType != 2) FloatToLevel(x678_floorLevel, dt); } else if (msg == EStateMsg::Deactivate) { diff --git a/Runtime/MP1/World/CFlaahgra.cpp b/Runtime/MP1/World/CFlaahgra.cpp index 1ca620638..2261d7e6b 100644 --- a/Runtime/MP1/World/CFlaahgra.cpp +++ b/Runtime/MP1/World/CFlaahgra.cpp @@ -785,7 +785,7 @@ void CFlaahgra::Growth(CStateManager& mgr, EStateMsg msg, float arg) { UpdateScale((x7c4_ > 0.f ? 1.f - (GetEndActionTime() / x7c4_) : 1.f), x81c_, x56c_.x4_); } - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); } } else if (msg == EStateMsg::Deactivate) { UpdateScale(1.f, x81c_, x56c_.x4_); @@ -983,7 +983,7 @@ void CFlaahgra::Attack(CStateManager& mgr, EStateMsg msg, float arg) { if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) x568_ = 4; else - x450_bodyController->GetCommandMgr().SetTargetVector(x78c_); + x450_bodyController->GetCommandMgr().DeliverTargetVector(x78c_); } } else if (msg == EStateMsg::Deactivate) { SetCollisionActorBounds(mgr, x79c_leftArmCollision, {}); @@ -1100,7 +1100,7 @@ void CFlaahgra::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float) { if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack) { x568_ = 4; } else { - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); } } } @@ -1135,7 +1135,7 @@ void CFlaahgra::Cover(CStateManager& mgr, EStateMsg msg, float) { if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) x568_ = 4; else if (TCastToConstPtr wp = mgr.GetObjectById(x77c_)) { - x450_bodyController->GetCommandMgr().SetTargetVector(wp->GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(wp->GetTranslation() - GetTranslation()); } } } else if (msg == EStateMsg::Deactivate) { diff --git a/Runtime/MP1/World/CFlyingPirate.cpp b/Runtime/MP1/World/CFlyingPirate.cpp index ac108e1ca..b5a3ef545 100644 --- a/Runtime/MP1/World/CFlyingPirate.cpp +++ b/Runtime/MP1/World/CFlyingPirate.cpp @@ -567,7 +567,7 @@ void CFlyingPirate::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& nod x6a1_26_isAttackingObject ? x568_data.x60_altProjectileInfo2 : x568_data.x38_altProjectileInfo1; if (pInfo.Token().IsLoaded() && mgr.CanCreateProjectile(x8_uid, EWeaponType::AI, 16)) { const zeus::CTransform& xf = GetLctrTransform(node.GetLocatorName()); - TUniqueId& target = x6a1_26_isAttackingObject ? x85c_attackObjectId : x8_uid; + TUniqueId target = x6a1_26_isAttackingObject ? x85c_attackObjectId : mgr.GetPlayer().GetUniqueId(); CEnergyProjectile* projectile = new CEnergyProjectile( true, pInfo.Token(), EWeaponType::AI, xf, EMaterialTypes::Floor, pInfo.GetDamage(), mgr.AllocateUniqueId(), x4_areaId, x8_uid, target, EProjectileAttrib::None, false, zeus::skOne3f, std::nullopt, -1, false); @@ -928,7 +928,9 @@ void CFlyingPirate::Lurk(CStateManager& mgr, EStateMsg msg, float arg) { } if (x32c_animState != EAnimState::Repeat) { x2e0_destPos = GetTargetPos(mgr); - if (x34_transform.frontVector().dot((x2e0_destPos - GetTranslation()).normalized()) < 0.8f) { + zeus::CVector3f dist = x2e0_destPos - GetTranslation(); + dist.z() = 0.f; + if (x34_transform.frontVector().dot(dist.normalized()) < 0.8f) { x32c_animState = EAnimState::Ready; } } @@ -1020,7 +1022,7 @@ void CFlyingPirate::Patrol(CStateManager& mgr, EStateMsg msg, float arg) { x870_ += x87c_; } if (x30c_behaviourOrient == EBehaviourOrient::Constant) { - x450_bodyController->GetCommandMgr().SetTargetVector(GetTargetPos(mgr) - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(GetTargetPos(mgr) - GetTranslation()); } UpdateCanSeePlayer(mgr); } else if (msg == EStateMsg::Deactivate) { @@ -1331,7 +1333,7 @@ void CFlyingPirate::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) { x870_ += x87c_; } if (x30c_behaviourOrient == EBehaviourOrient::Constant) { - x450_bodyController->GetCommandMgr().SetTargetVector(GetTargetPos(mgr) - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(GetTargetPos(mgr) - GetTranslation()); } UpdateCanSeePlayer(mgr); } @@ -1341,7 +1343,8 @@ void CFlyingPirate::Taunt(CStateManager& mgr, EStateMsg msg, float arg) { if (msg == EStateMsg::Activate) { x6a0_28_ = true; x7a0_boneTracking.SetActive(true); - x7a0_boneTracking.SetTarget(x8_uid); + const TUniqueId& playerUid = mgr.GetPlayer().GetUniqueId(); + x7a0_boneTracking.SetTarget(playerUid); bool foundPirate = false; for (const auto& obj : *mgr.ObjectListById(EGameObjectList::AiWaypoint)) { if (const CSpacePirate* const pirate = CPatterned::CastTo(obj)) { @@ -1354,7 +1357,7 @@ void CFlyingPirate::Taunt(CStateManager& mgr, EStateMsg msg, float arg) { } x79c_ = foundPirate ? 0 : 1; if (x7e8_targetId == kInvalidUniqueId) { - x7e8_targetId = mgr.GetPlayer().GetUniqueId(); + x7e8_targetId = playerUid; } } else if (msg == EStateMsg::Deactivate) { if (x79c_ == 0) { @@ -1526,25 +1529,24 @@ LAB_801f7bb8: x34_transform.transposeRotate(GetTargetPos(mgr) - GetTranslation())); } if (0.f < x870_.magSquared()) { - float fVar27 = x870_.magnitude(); - float fVar4 = 1.f / fVar27; - float fVar5 = 0.2; + float mag = x870_.magnitude(); + float fVar5 = 0.2f; if (0.f == x87c_.magSquared()) { fVar5 = 0.2f * 3.f; } - float mul = -(dt * fVar27 * fVar5 * fVar27 - fVar27); - x870_ = mul * fVar4 * x870_; + float mul = -(dt * mag * fVar5 * mag - mag); + x870_ = mul * (1.f / mag) * x870_; } pas::EAnimationState state = x450_bodyController->GetCurrentStateId(); - if (!x400_25_alive || state == pas::EAnimationState::LoopReaction || state == pas::EAnimationState::LieOnGround || - state == pas::EAnimationState::Getup) { + if (!x400_25_alive || state == pas::EAnimationState::LoopReaction || state == pas::EAnimationState::Hurled || + state == pas::EAnimationState::LieOnGround || state == pas::EAnimationState::Getup) { x870_.zeroOut(); x87c_.zeroOut(); } else { ApplyImpulseWR(xe8_mass * x870_, {}); } - if (auto& handle = GetSfxHandle()) { + if (const auto& handle = GetSfxHandle()) { x898_ = std::clamp(x898_, 1.f, 1.999f); x894_ += std::clamp(x898_ - x894_, -dt, dt); CSfxManager::PitchBend(handle, x894_); // TODO * 8192.f? @@ -1569,10 +1571,7 @@ LAB_801f7bb8: zeus::CVector3f v128 = x34_transform.frontVector().cross(v1dc); zeus::CVector3f v20c = v1dc.cross(v128).normalized(); zeus::CVector3f v128_2 = v20c.cross(v1dc); - x34_transform = zeus::CTransform(v128_2, v20c, v1dc, GetTranslation()); - xe4_27_notInSortedLists = true; - xe4_28_transformDirty = true; - xe4_29_actorLightsDirty = true; + SetTransform({v128_2, v20c, v1dc, x34_transform.origin}); } if (!x450_bodyController->IsFrozen()) { diff --git a/Runtime/MP1/World/CJellyZap.cpp b/Runtime/MP1/World/CJellyZap.cpp index fc333b99a..ec6e4fc4d 100644 --- a/Runtime/MP1/World/CJellyZap.cpp +++ b/Runtime/MP1/World/CJellyZap.cpp @@ -107,7 +107,7 @@ void CJellyZap::Suck(CStateManager& mgr, EStateMsg msg, float arg) { RemoveAllAttractors(mgr); } else if (msg == EStateMsg::Update) { TryCommand(mgr, pas::EAnimationState::LoopReaction, &CPatterned::TryLoopReaction, 0); - x450_bodyController->GetCommandMgr().SetTargetVector( + x450_bodyController->GetCommandMgr().DeliverTargetVector( (mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, 1.f)) - GetTranslation()); float intensity = mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit) ? 0.1f : 1.f; @@ -133,7 +133,7 @@ void CJellyZap::Active(CStateManager& mgr, EStateMsg msg, float arg) { } else if (msg == EStateMsg::Update) { zeus::CVector3f targetVector = GetTranslation() - (zeus::CVector3f(0.f, 0.f, 1.f) + mgr.GetPlayer().GetTranslation()); - x450_bodyController->GetCommandMgr().SetTargetVector(targetVector); + x450_bodyController->GetCommandMgr().DeliverTargetVector(targetVector); if (x5b8_26_) { zeus::CVector3f moveToImpulse = GetMoveToORImpulseWR(GetTransform().transposeRotate(arg * (zeus::CVector3f(0.f, 1.f, 0.f) * x598_)), arg); @@ -233,4 +233,4 @@ const CDamageVulnerability* CJellyZap::GetDamageVulnerability(const zeus::CVecto const CDamageInfo& info) const { return CActor::GetDamageVulnerability(pos, dir, info); } -} // namespace urde::MP1 \ No newline at end of file +} // namespace urde::MP1 diff --git a/Runtime/MP1/World/CMetaree.cpp b/Runtime/MP1/World/CMetaree.cpp index 69a5622aa..55697d0b6 100644 --- a/Runtime/MP1/World/CMetaree.cpp +++ b/Runtime/MP1/World/CMetaree.cpp @@ -144,7 +144,7 @@ void CMetaree::Active(CStateManager& mgr, EStateMsg msg, float) { x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero, x584_lookPos)); SetMomentumWR({0.f, 0.f, -GetGravityConstant() * GetMass()}); } else if (msg == EStateMsg::Update) { - x450_bodyController->GetCommandMgr().SetTargetVector( + x450_bodyController->GetCommandMgr().DeliverTargetVector( (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized()); } else if (msg == EStateMsg::Deactivate) { SetMomentumWR({}); diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index e2af68c1d..92a857060 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -1497,7 +1497,7 @@ void CSpacePirate::TargetPatrol(CStateManager& mgr, EStateMsg msg, float dt) { } } if (r28) - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); } x828_patrolDestPos = x2e0_destPos; break; @@ -1553,7 +1553,7 @@ void CSpacePirate::Generate(CStateManager& mgr, EStateMsg msg, float dt) { TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, x634_25_ceilingAmbush ? 2 : 0); if (x32c_animState == EAnimState::Repeat) x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat); - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); break; case EStateMsg::Deactivate: x32c_animState = EAnimState::NotReady; @@ -1609,7 +1609,7 @@ void CSpacePirate::Attack(CStateManager& mgr, EStateMsg msg, float dt) { case EStateMsg::Update: if (x636_26_enableMeleeAttack) { TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 1); - x450_bodyController->GetCommandMgr().SetTargetVector(x648_targetDelta); + x450_bodyController->GetCommandMgr().DeliverTargetVector(x648_targetDelta); CheckBlade(mgr); if (x635_27_shadowPirate) { if (x32c_animState == EAnimState::Over) { @@ -1668,7 +1668,7 @@ void CSpacePirate::JumpBack(CStateManager& mgr, EStateMsg msg, float dt) { if (!x639_25_useJumpBackJump) { x450_bodyController->GetCommandMgr().DeliverCmd( CBCStepCmd(pas::EStepDirection::Backward, pas::EStepType::Normal)); - x450_bodyController->GetCommandMgr().SetTargetVector(GetTargetPos(mgr) - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(GetTargetPos(mgr) - GetTranslation()); } else { TryCommand(mgr, pas::EAnimationState::Jump, &CPatterned::TryJump, 0); } @@ -1713,7 +1713,7 @@ void CSpacePirate::DoubleSnap(CStateManager& mgr, EStateMsg msg, float dt) { } if (x639_30_closeMelee) x648_targetDelta = GetTargetPos(mgr) - GetTranslation(); - x450_bodyController->GetCommandMgr().SetTargetVector(x648_targetDelta); + x450_bodyController->GetCommandMgr().DeliverTargetVector(x648_targetDelta); if (x635_27_shadowPirate) { if (x32c_animState == EAnimState::Over) { x3e8_alphaDelta = -0.4f; @@ -1829,7 +1829,7 @@ void CSpacePirate::Crouch(CStateManager& mgr, EStateMsg msg, float dt) { x79c_coverDir = pas::ECoverDirection::Invalid; break; case EStateMsg::Update: - x450_bodyController->GetCommandMgr().SetTargetVector(x648_targetDelta); + x450_bodyController->GetCommandMgr().DeliverTargetVector(x648_targetDelta); UpdateCantSeePlayer(mgr); break; default: @@ -2089,7 +2089,7 @@ void CSpacePirate::Cover(CStateManager& mgr, EStateMsg msg, float dt) { case EStateMsg::Update: TryCommand(mgr, pas::EAnimationState::Cover, &CPatterned::TryCover, int(x79c_coverDir)); if (CScriptCoverPoint* cp = GetCoverPoint(mgr, x640_coverPoint)) - x450_bodyController->GetCommandMgr().SetTargetVector(-cp->GetTransform().basis[1]); + x450_bodyController->GetCommandMgr().DeliverTargetVector(-cp->GetTransform().basis[1]); UpdateCantSeePlayer(mgr); break; case EStateMsg::Deactivate: @@ -2134,7 +2134,7 @@ void CSpacePirate::WallHang(CStateManager& mgr, EStateMsg msg, float dt) { break; case EStateMsg::Update: TryCommand(mgr, pas::EAnimationState::WallHang, &CSpacePirate::TryWallHang, 0); - x450_bodyController->GetCommandMgr().SetTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); + x450_bodyController->GetCommandMgr().DeliverTargetVector(mgr.GetPlayer().GetTranslation() - GetTranslation()); x7c4_burstFire.SetBurstType(1); break; case EStateMsg::Deactivate: @@ -2173,7 +2173,7 @@ void CSpacePirate::SpecialAttack(CStateManager& mgr, EStateMsg msg, float dt) { case EStateMsg::Update: TryCommand(mgr, pas::EAnimationState::ProjectileAttack, &CPatterned::TryProjectileAttack, int(pas::ESeverity::One)); if (x32c_animState == EAnimState::Ready) - x450_bodyController->GetCommandMgr().SetTargetVector(x648_targetDelta); + x450_bodyController->GetCommandMgr().DeliverTargetVector(x648_targetDelta); break; case EStateMsg::Deactivate: x32c_animState = EAnimState::NotReady;