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);
}
}
KnockBack(GetTransform().frontVector(), mgr, wp->GetDamageInfo(), EKnockBackType::Radius, false,
KnockBack(GetTransform().frontVector(), mgr, wp->GetDamageInfo(), EKnockBackType::Direct, false,
wp->GetDamageInfo().GetKnockBackPower());
}
}

View File

@ -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());

View File

@ -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_)

View File

@ -525,7 +525,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
if (!dontKnockback) {
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());
}
}

View File

@ -417,8 +417,7 @@ 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) &&
} 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))) {
@ -427,7 +426,6 @@ void CKnockBackController::ValidateState(const CPatterned& parent) {
x4_activeParms.x0_animState >= EKnockBackAnimationState::Hurled) {
useState = EKnockBackAnimationState::Hurled;
}
}
x4_activeParms.x0_animState =
(useState != EKnockBackAnimationState::Invalid) ? useState : EKnockBackAnimationState::None;
@ -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 (!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);

View File

@ -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 };

View File

@ -152,20 +152,23 @@ void CPatterned::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState
if (TCastToConstPtr<CGameProjectile> 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;
}
case EScriptObjectMessage::InvulnDamage: {
@ -1725,5 +1728,4 @@ bool CPatterned::ApplyBoneTracking() const {
return false;
}
} // namespace urde