1
0
KF2-Dev-Scripts/KFGame/Classes/KFAffliction_Knockdown.uc

55 lines
2.3 KiB
Ucode
Raw Permalink Normal View History

2020-12-13 15:01:13 +00:00
//=============================================================================
// KFAffliction_MediumRecovery
//=============================================================================
//
//=============================================================================
// Killing Floor 2
// Copyright (C) 2015 Tripwire Interactive LLC
//=============================================================================
class KFAffliction_Knockdown extends KFAfflictionBase;
/** */
2022-11-27 21:49:25 +00:00
function Activate(KFPerk InstigatorPerk, optional class<KFDamageType> DamageType = none)
2020-12-13 15:01:13 +00:00
{
2022-05-11 15:13:25 +00:00
ActivateKnockdown(DamageType,
2020-12-13 15:01:13 +00:00
PawnOwner.HitFxInfo.HitLocation,
PawnOwner.DecodeUnitVector( PawnOwner.HitFxInfo.EncodedHitDirection ),
PawnOwner.HitFxInfo.HitBoneIndex);
2022-11-27 21:49:25 +00:00
Super.Activate(InstigatorPerk, DamageType);
2020-12-13 15:01:13 +00:00
}
/** Apply a knockdown (on hit) to this character */
protected function ActivateKnockdown(class<KFDamageType> DamageType, vector HitLoc, vector HitDir, byte HitZoneIdx)
{
local vector Impulse;
// Handle explosive damage types as radial impulses
if ( DamageType.default.RadialDamageImpulse > 0 && !DamageType.default.bPointImpulseTowardsOrigin )
{
Impulse = DamageType.default.RadialDamageImpulse * HitDir;
// If we have a cached RadiusDamageScale, assume it's from this hit and use it to calc the radius impulse falloff
if ( PawnOwner.HitFxInfo.bRadialDamage && PawnOwner.HitFxRadialInfo.RadiusDamageScale != 255 )
{
Impulse *= ByteToFloat(PawnOwner.HitFxRadialInfo.RadiusDamageScale);
}
// Add the deathUpKick here for extra oomph
Impulse += Vect(0,0,1) * DamageType.default.KDeathUpKick;
// Since we don't have the proper Origin, Radius, and Falloff in TakeDamage use a
// point impulse, but fake it to to look like a radial impulse. This is done by:
// 1) Zeroing the Position. This causes AddImpulse to call addForce (same as with RadialImpulse) instead of addForceAtPos
// 2) Zeroing the BoneName. With AddRadialImpulse, GetNxActor() has no BoneName so addForce will use the root body
PawnOwner.Knockdown(, vect(1,1,1),,,, Impulse);
}
else
{
// An artifical RBAngularVelocity is used for replication, see NEQ()
PawnOwner.Knockdown(, vect(1,1,1),,,, DamageType.default.KDamageImpulse * HitDir, HitLoc, HitZoneIdx);
}
}
defaultproperties
{
}