CKnockBackController: Fix EKnockBackType

This commit is contained in:
Luke Street 2020-05-21 11:32:48 -04:00
parent 8f56219900
commit 56d31254cd
7 changed files with 35 additions and 40 deletions

View File

@ -183,7 +183,7 @@ void CBabygoth::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM
CrackShell(mgr, xa38_intermediateCrackParticle, xf, x570_babyData.GetShellCrackSfx(), false); 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()); wp->GetDamageInfo().GetKnockBackPower());
} }
} }

View File

@ -217,7 +217,7 @@ void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
x428_damageCooldownTimer = 0.33f; x428_damageCooldownTimer = 0.33f;
const auto& damageInfo = projectile->GetDamageInfo(); const auto& damageInfo = projectile->GetDamageInfo();
KnockBack(projectile->GetTranslation() - projectile->GetPreviousPos(), mgr, damageInfo, KnockBack(projectile->GetTranslation() - projectile->GetPreviousPos(), mgr, damageInfo,
EKnockBackType::Radius, false, damageInfo.GetKnockBackPower()); EKnockBackType::Direct, false, damageInfo.GetKnockBackPower());
CPatterned::AcceptScriptMsg(msg, uid, mgr); CPatterned::AcceptScriptMsg(msg, uid, mgr);
} else if (uid == x79c_energyAttractorId && x760_energyAbsorbDesc->IsLoaded()) { } else if (uid == x79c_energyAttractorId && x760_energyAbsorbDesc->IsLoaded()) {
CreateEnergyAbsorb(mgr, projectile->GetTransform()); CreateEnergyAbsorb(mgr, projectile->GetTransform());

View File

@ -118,7 +118,7 @@ void CMetroidBeta::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
x840_31_ = true; x840_31_ = true;
x83c_ += 1.f; 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()); dInfo.GetKnockBackPower());
} }
if (x840_25_) if (x840_25_)

View File

@ -525,7 +525,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
if (!dontKnockback) { if (!dontKnockback) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) { if (TCastToConstPtr<CGameProjectile> 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()); false, proj->GetDamageInfo().GetKnockBackPower());
} }
} }

View File

@ -417,16 +417,14 @@ void CKnockBackController::ValidateState(const CPatterned& parent) {
x80_availableStates.test(1) && x4_activeParms.x0_animState >= EKnockBackAnimationState::Flinch) { x80_availableStates.test(1) && x4_activeParms.x0_animState >= EKnockBackAnimationState::Flinch) {
useState = EKnockBackAnimationState::Flinch; useState = EKnockBackAnimationState::Flinch;
} }
} else { } else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Fall) && x80_availableStates.test(4) &&
if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Fall) && x80_availableStates.test(4) && (x4_activeParms.x0_animState >= EKnockBackAnimationState::Fall ||
(x4_activeParms.x0_animState >= EKnockBackAnimationState::Fall || (!parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) &&
(!parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled))) {
x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled))) { useState = EKnockBackAnimationState::Fall;
useState = EKnockBackAnimationState::Fall; } else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && x80_availableStates.test(3) &&
} else if (parent.GetBodyController()->HasBodyState(pas::EAnimationState::Hurled) && x80_availableStates.test(3) && x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled) {
x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled) { useState = EKnockBackAnimationState::Hurled;
useState = EKnockBackAnimationState::Hurled;
}
} }
x4_activeParms.x0_animState = x4_activeParms.x0_animState =
@ -444,8 +442,6 @@ void CKnockBackController::ValidateState(const CPatterned& parent) {
disableFollowup = !x81_27_enableBurn; disableFollowup = !x81_27_enableBurn;
break; break;
case EKnockBackAnimationFollowUp::ExplodeDeath: case EKnockBackAnimationFollowUp::ExplodeDeath:
disableFollowup = !x81_29_enableExplodeDeath;
break;
case EKnockBackAnimationFollowUp::IceDeath: case EKnockBackAnimationFollowUp::IceDeath:
disableFollowup = !x81_29_enableExplodeDeath; disableFollowup = !x81_29_enableExplodeDeath;
break; break;
@ -514,16 +510,17 @@ void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec,
void CKnockBackController::ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec, void CKnockBackController::ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec,
float magnitude) { float magnitude) {
if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack && if (!x81_24_autoResetImpulse || x4_activeParms.x0_animState != EKnockBackAnimationState::KnockBack ||
x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) { x4_activeParms.x4_animFollowup == EKnockBackAnimationFollowUp::Freeze) {
x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1]; return;
if (x60_impulseRemTime <= 0.f) {
x5c_impulseMag = magnitude;
} else {
x5c_impulseMag += magnitude * (1.f - x60_impulseRemTime / ImpulseDurationTable[x20_impulseDurationIdx]);
}
x60_impulseRemTime = ImpulseDurationTable[x20_impulseDurationIdx];
} }
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) { void CKnockBackController::DoDeferredKnockBack(CStateManager& mgr, CPatterned& parent) {
@ -537,7 +534,7 @@ void CKnockBackController::DoDeferredKnockBack(CStateManager& mgr, CPatterned& p
ResetKnockBackImpulse(parent, backVec, 2.f); ResetKnockBackImpulse(parent, backVec, 2.f);
x82_25_inDeferredKnockBack = true; x82_25_inDeferredKnockBack = true;
parent.KnockBack(backVec, mgr, CDamageInfo(CWeaponMode{x14_deferWeaponType, false, true, false}, 0.f, 0.f, 10.f), 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; x82_25_inDeferredKnockBack = false;
} }
} }
@ -584,15 +581,11 @@ EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageI
stacking = 2; stacking = 2;
} }
if (wType > EWeaponType::Phazon) {
return EKnockBackWeaponType::Invalid;
}
switch (wType) { switch (wType) {
case EWeaponType::Power: case EWeaponType::Power:
return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking : stacking + 1); return EKnockBackWeaponType(type != EKnockBackType::Radius ? stacking : stacking + 1);
case EWeaponType::Ice: case EWeaponType::Ice:
return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking + 8 : stacking + 9); return EKnockBackWeaponType(type != EKnockBackType::Radius ? stacking + 8 : stacking + 9);
case EWeaponType::Wave: case EWeaponType::Wave:
return EKnockBackWeaponType(stacking + 4); return EKnockBackWeaponType(stacking + 4);
case EWeaponType::Plasma: case EWeaponType::Plasma:
@ -632,7 +625,7 @@ void CKnockBackController::KnockBack(const zeus::CVector3f& backVec, CStateManag
zeus::CVector3f vec(backVec.toVec2f()); zeus::CVector3f vec(backVec.toVec2f());
if (!vec.isMagnitudeSafe()) { if (!vec.isMagnitudeSafe()) {
vec = -parent.GetTransform().basis[1]; vec = -parent.GetTransform().frontVector();
} }
SelectDamageState(parent, info, info.GetWeaponMode().GetType(), type); SelectDamageState(parent, info, info.GetWeaponMode().GetType(), type);

View File

@ -13,7 +13,7 @@ namespace urde {
class CDamageInfo; class CDamageInfo;
class CPatterned; class CPatterned;
enum class EKnockBackType { Direct, Radius }; enum class EKnockBackType { Radius, Direct };
enum class EKnockBackVariant { Small, Medium, Large }; enum class EKnockBackVariant { Small, Medium, Large };

View File

@ -152,19 +152,22 @@ void CPatterned::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid)) { if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid)) {
const CDamageInfo& info = proj->GetDamageInfo(); const CDamageInfo& info = proj->GetDamageInfo();
if (info.GetWeaponMode().GetType() == EWeaponType::Wave) { 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; 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); x460_knockBackController.DeferKnockBack(EWeaponType::Wave);
} }
} else if (info.GetWeaponMode().GetType() == EWeaponType::Plasma) { } else if (info.GetWeaponMode().GetType() == EWeaponType::Plasma) {
if (x460_knockBackController.x81_27_enableBurn && info.GetWeaponMode().IsCharged() && HealthInfo(mgr)) { if (x460_knockBackController.x81_27_enableBurn && info.GetWeaponMode().IsCharged() &&
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Radius, false, info.GetKnockBackPower()); HealthInfo(mgr) != nullptr) {
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::Direct, false, info.GetKnockBackPower());
x460_knockBackController.DeferKnockBack(EWeaponType::Plasma); x460_knockBackController.DeferKnockBack(EWeaponType::Plasma);
} }
} }
if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId()) {
x400_24_hitByPlayerProjectile = true; x400_24_hitByPlayerProjectile = true;
}
} }
break; break;
} }
@ -1725,5 +1728,4 @@ bool CPatterned::ApplyBoneTracking() const {
return false; return false;
} }
} // namespace urde } // namespace urde