function TakeDamage( int Damage, Pawn InstigatedBy, Vector Hitlocation, Vector Momentum, class<DamageType> damageType, optional int HitIndex)
{
local int BlockSlip, OldHealth;
local float BlockChance;//, RageChance;
local Vector X,Y,Z, Dir;
local bool bIsHeadShot;
local float HeadShotCheckScale;
local class<KFWeaponDamageType> KFDamType;
// optimizes typecasting and make code comre compact -- PooSH
KFDamType = class<KFWeaponDamageType>(damageType);
GetAxes(Rotation, X,Y,Z);
oldHealth= Health;
if( LastDamagedTime<Level.TimeSeconds )
TwoSecondDamageTotal = 0;
LastDamagedTime = Level.TimeSeconds+2;
if ( KFDamType != none )
{
HeadShotCheckScale = 1.0;
// Do larger headshot checks if it is a melee attach
if( class<DamTypeMelee>(damageType) != none )
HeadShotCheckScale *= 1.25;
bIsHeadShot = IsHeadShot(Hitlocation, normal(Momentum), 1.0);
// He takes less damage to small arms fire (non explosives)
// Frags and LAW rockets will bring him down way faster than bullets and shells.
if ( !KFDamType.default.bIsExplosive ) // all explosives: current, future and custom -- PooSH
{
// Don't reduce the damage so much if its a high headshot damage weapon
if( bIsHeadShot && KFDamType.default.HeadShotDamageMult >= 1.5 )
{
Damage *= 0.75;
}
else if ( Level.Game.GameDifficulty >= 5.0 && bIsHeadshot
&& (ClassIsChildOf(KFDamType, class'DamTypeCrossbow')
|| ClassIsChildOf(KFDamType, class'DamTypeM99SniperRifle')) )
{
Damage *= 0.35; // 65% damage reduction from xbow/m99 headshots
}
else
{
Damage *= 0.5;
}
}
// double damage from handheld explosives or poison
// include subclasses = care about modders (c) PooSH
else if ( KFDamType == class'DamTypeFrag'
|| ClassIsChildOf(KFDamType, class'DamTypePipeBomb') )
{
Damage *= 1.25;
}
// A little extra damage from the grenade launchers, they are HE not shrapnel,
// and its shrapnel that REALLY hurts the FP ;)
// M32 and SP are subclasses of DamTypeM79Grenade, so no need to additionally check those -- PooSH
else if( ClassIsChildOf(KFDamType, class'DamTypeM79Grenade')
|| ClassIsChildOf(KFDamType, class'DamTypeM203Grenade') )
{
Damage *= 1.25;
}
}
// Shut off his "Device" when dead
if (Damage >= Health)
PostNetReceive();
// Damage Berserk responses...
// Start a charge.
// The Lower his health, the less damage needed to trigger this response.
//RageChance = (( HealthMax / Health * 300) - TwoSecondDamageTotal );
// Calculate whether the shot was coming from in front.
Dir = -Normal(Location - hitlocation);
BlockSlip = rand(5);
if (AnimAction == 'PoundBlock')
Damage *= BlockDamageReduction;
if (Dir Dot X > 0.7 || Dir == vect(0,0,0))
BlockChance = (Health / HealthMax * 100 ) - Damage * 0.25;
// We are healthy enough to block the attack, and we succeeded the blockslip.
// only 40% damage is done in this circumstance.
//TODO - bring this back?
// Log (Damage);
if (damageType == class 'DamTypeVomit')
Damage = 0; // nulled
// fixes none-reference erros when taking enviromental damage -- PooSH
if (InstigatedBy == none || KFDamType == none)
Super(Monster).TakeDamage(Damage, instigatedBy, hitLocation, momentum, damageType); // skip NONE-reference error
else
super(KFMonster).TakeDamage(Damage, instigatedBy, hitLocation, momentum, damageType);
TwoSecondDamageTotal += OldHealth - Health;
if (!bDecapitated && TwoSecondDamageTotal > RageDamageThreshold && !bChargingPlayer &&
!bZapped && (!(bCrispified && bBurnified) || bFrustrated) )
StartCharging();
totalRageAccumulator+= (oldHealth - Health);
/**
* If the fleshpound isn't raging and the accumulator
* has exceeded the threshold, rage and reset the accumulator
*/
if (!isInState('BeginRaging') && !bDecapitated && totalRageAccumulator >= totalDamageRageThreshold &&
!bChargingPlayer && (!(bCrispified && bBurnified) || bFrustrated) )
{
totalRageAccumulator= 0;
StartCharging();
}
}