From 56d31254cd2713ae5b6df034d2ba98a1a4e4238f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 21 May 2020 11:32:48 -0400 Subject: [PATCH] CKnockBackController: Fix EKnockBackType --- Runtime/MP1/World/CBabygoth.cpp | 2 +- Runtime/MP1/World/CElitePirate.cpp | 2 +- Runtime/MP1/World/CMetroidBeta.cpp | 2 +- Runtime/MP1/World/CRidley.cpp | 2 +- Runtime/World/CKnockBackController.cpp | 51 +++++++++++--------------- Runtime/World/CKnockBackController.hpp | 2 +- Runtime/World/CPatterned.cpp | 14 ++++--- 7 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Runtime/MP1/World/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp index 7562a5ff0..6306aca84 100644 --- a/Runtime/MP1/World/CBabygoth.cpp +++ b/Runtime/MP1/World/CBabygoth.cpp @@ -183,7 +183,7 @@ void CBabygoth::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM CrackShell(mgr, xa38_intermediateCrackParticle, xf, x570_babyData.GetShellCrackSfx(), false); } } - KnockBack(GetTransform().frontVector(), mgr, wp->GetDamageInfo(), EKnockBackType::Radius, false, + KnockBack(GetTransform().frontVector(), mgr, wp->GetDamageInfo(), EKnockBackType::Direct, false, wp->GetDamageInfo().GetKnockBackPower()); } } diff --git a/Runtime/MP1/World/CElitePirate.cpp b/Runtime/MP1/World/CElitePirate.cpp index 8d3602796..18cf6a398 100644 --- a/Runtime/MP1/World/CElitePirate.cpp +++ b/Runtime/MP1/World/CElitePirate.cpp @@ -217,7 +217,7 @@ void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta x428_damageCooldownTimer = 0.33f; const auto& damageInfo = projectile->GetDamageInfo(); KnockBack(projectile->GetTranslation() - projectile->GetPreviousPos(), mgr, damageInfo, - EKnockBackType::Radius, false, damageInfo.GetKnockBackPower()); + EKnockBackType::Direct, false, damageInfo.GetKnockBackPower()); CPatterned::AcceptScriptMsg(msg, uid, mgr); } else if (uid == x79c_energyAttractorId && x760_energyAbsorbDesc->IsLoaded()) { CreateEnergyAbsorb(mgr, projectile->GetTransform()); diff --git a/Runtime/MP1/World/CMetroidBeta.cpp b/Runtime/MP1/World/CMetroidBeta.cpp index 2109323cf..011c0d509 100644 --- a/Runtime/MP1/World/CMetroidBeta.cpp +++ b/Runtime/MP1/World/CMetroidBeta.cpp @@ -118,7 +118,7 @@ void CMetroidBeta::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta x840_31_ = true; x83c_ += 1.f; } - KnockBack(proj->GetTranslation() - proj->GetPreviousPos(), mgr, dInfo, EKnockBackType::Radius, false, + KnockBack(proj->GetTranslation() - proj->GetPreviousPos(), mgr, dInfo, EKnockBackType::Direct, false, dInfo.GetKnockBackPower()); } if (x840_25_) diff --git a/Runtime/MP1/World/CRidley.cpp b/Runtime/MP1/World/CRidley.cpp index 9df3433c2..d48f7d8d1 100644 --- a/Runtime/MP1/World/CRidley.cpp +++ b/Runtime/MP1/World/CRidley.cpp @@ -525,7 +525,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan if (!dontKnockback) { if (TCastToConstPtr proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) { - KnockBack(proj->GetTranslation() - proj->GetPreviousPos(), mgr, proj->GetDamageInfo(), EKnockBackType::Radius, + KnockBack(proj->GetTranslation() - proj->GetPreviousPos(), mgr, proj->GetDamageInfo(), EKnockBackType::Direct, false, proj->GetDamageInfo().GetKnockBackPower()); } } diff --git a/Runtime/World/CKnockBackController.cpp b/Runtime/World/CKnockBackController.cpp index fb349cb66..a46f566ab 100644 --- a/Runtime/World/CKnockBackController.cpp +++ b/Runtime/World/CKnockBackController.cpp @@ -417,16 +417,14 @@ void CKnockBackController::ValidateState(const CPatterned& parent) { x80_availableStates.test(1) && x4_activeParms.x0_animState >= EKnockBackAnimationState::Flinch) { useState = EKnockBackAnimationState::Flinch; } - } else { - if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Fall) && x80_availableStates.test(4) && - (x4_activeParms.x0_animState >= EKnockBackAnimationState::Fall || - (!parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && - x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled))) { - useState = EKnockBackAnimationState::Fall; - } else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && x80_availableStates.test(3) && - x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled) { - useState = EKnockBackAnimationState::Hurled; - } + } else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Fall) && x80_availableStates.test(4) && + (x4_activeParms.x0_animState >= EKnockBackAnimationState::Fall || + (!parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && + x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled))) { + useState = EKnockBackAnimationState::Fall; + } else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && x80_availableStates.test(3) && + x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled) { + useState = EKnockBackAnimationState::Hurled; } x4_activeParms.x0_animState = @@ -444,8 +442,6 @@ void CKnockBackController::ValidateState(const CPatterned& parent) { disableFollowup = !x81_27_enableBurn; break; case EKnockBackAnimationFollowUp::ExplodeDeath: - disableFollowup = !x81_29_enableExplodeDeath; - break; case EKnockBackAnimationFollowUp::IceDeath: disableFollowup = !x81_29_enableExplodeDeath; break; @@ -514,16 +510,17 @@ void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec, void CKnockBackController::ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec, float magnitude) { - if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack && - x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) { - x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1]; - if (x60_impulseRemTime <= 0.f) { - x5c_impulseMag = magnitude; - } else { - x5c_impulseMag += magnitude * (1.f - x60_impulseRemTime / ImpulseDurationTable[x20_impulseDurationIdx]); - } - x60_impulseRemTime = ImpulseDurationTable[x20_impulseDurationIdx]; + if (!x81_24_autoResetImpulse || x4_activeParms.x0_animState != EKnockBackAnimationState::KnockBack || + x4_activeParms.x4_animFollowup == EKnockBackAnimationFollowUp::Freeze) { + return; } + x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().frontVector(); + if (x60_impulseRemTime <= 0.f) { + x5c_impulseMag = magnitude; + } else { + x5c_impulseMag += magnitude * (1.f - x60_impulseRemTime / ImpulseDurationTable[x20_impulseDurationIdx]); + } + x60_impulseRemTime = ImpulseDurationTable[x20_impulseDurationIdx]; } void CKnockBackController::DoDeferredKnockBack(CStateManager& mgr, CPatterned& parent) { @@ -537,7 +534,7 @@ void CKnockBackController::DoDeferredKnockBack(CStateManager& mgr, CPatterned& p ResetKnockBackImpulse(parent, backVec, 2.f); x82_25_inDeferredKnockBack = true; parent.KnockBack(backVec, mgr, CDamageInfo(CWeaponMode{x14_deferWeaponType, false, true, false}, 0.f, 0.f, 10.f), - EKnockBackType::Radius, x82_25_inDeferredKnockBack, 10.f); + EKnockBackType::Direct, x82_25_inDeferredKnockBack, 10.f); x82_25_inDeferredKnockBack = false; } } @@ -584,15 +581,11 @@ EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageI stacking = 2; } - if (wType > EWeaponType::Phazon) { - return EKnockBackWeaponType::Invalid; - } - switch (wType) { case EWeaponType::Power: - return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking : stacking + 1); + return EKnockBackWeaponType(type != EKnockBackType::Radius ? stacking : stacking + 1); case EWeaponType::Ice: - return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking + 8 : stacking + 9); + return EKnockBackWeaponType(type != EKnockBackType::Radius ? stacking + 8 : stacking + 9); case EWeaponType::Wave: return EKnockBackWeaponType(stacking + 4); case EWeaponType::Plasma: @@ -632,7 +625,7 @@ void CKnockBackController::KnockBack(const zeus::CVector3f& backVec, CStateManag zeus::CVector3f vec(backVec.toVec2f()); if (!vec.isMagnitudeSafe()) { - vec = -parent.GetTransform().basis[1]; + vec = -parent.GetTransform().frontVector(); } SelectDamageState(parent, info, info.GetWeaponMode().GetType(), type); diff --git a/Runtime/World/CKnockBackController.hpp b/Runtime/World/CKnockBackController.hpp index e48a48dca..82a0f500a 100644 --- a/Runtime/World/CKnockBackController.hpp +++ b/Runtime/World/CKnockBackController.hpp @@ -13,7 +13,7 @@ namespace urde { class CDamageInfo; class CPatterned; -enum class EKnockBackType { Direct, Radius }; +enum class EKnockBackType { Radius, Direct }; enum class EKnockBackVariant { Small, Medium, Large }; diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 36a68c024..2cfffdf3e 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -152,19 +152,22 @@ void CPatterned::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState if (TCastToConstPtr proj = mgr.GetObjectById(uid)) { const CDamageInfo& info = proj->GetDamageInfo(); if (info.GetWeaponMode().GetType() == EWeaponType::Wave) { - if (x460_knockBackController.x81_26_enableShock && info.GetWeaponMode().IsComboed() && HealthInfo(mgr)) { + if (x460_knockBackController.x81_26_enableShock && info.GetWeaponMode().IsComboed() && + HealthInfo(mgr) != nullptr) { x401_31_nextPendingShock = true; - KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Radius, false, info.GetKnockBackPower()); + KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Direct, false, info.GetKnockBackPower()); x460_knockBackController.DeferKnockBack(EWeaponType::Wave); } } else if (info.GetWeaponMode().GetType() == EWeaponType::Plasma) { - if (x460_knockBackController.x81_27_enableBurn && info.GetWeaponMode().IsCharged() && HealthInfo(mgr)) { - KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Radius, false, info.GetKnockBackPower()); + if (x460_knockBackController.x81_27_enableBurn && info.GetWeaponMode().IsCharged() && + HealthInfo(mgr) != nullptr) { + KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Direct, false, info.GetKnockBackPower()); x460_knockBackController.DeferKnockBack(EWeaponType::Plasma); } } - if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) + if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) { x400_24_hitByPlayerProjectile = true; + } } break; } @@ -1725,5 +1728,4 @@ bool CPatterned::ApplyBoneTracking() const { return false; } - } // namespace urde