much better way to bleed pawns

This commit is contained in:
Shtoyan 2022-01-23 16:33:31 +04:00
parent 81347335ad
commit 1fd77f1c15
2 changed files with 120 additions and 9 deletions

View File

@ -0,0 +1,87 @@
class MeanBleedInventory extends Inventory;
const dmtype_bleed=class'NiceDamTypeStalkerBleed';
var private int maxBleedCount;
var private float fBleedPeriod;
var private float fNextBleedTime;
var float bleedLevel;
var MeanZombieCrawler stalker;
function Tick(float DeltaTime)
{
fNextBleedTime = Level.TimeSeconds;
// start the timer
SetTimer(0.1, true);
// disable me, coz im too fast and resource hungry
Disable('Tick');
}
event Timer()
{
local pawn locpawn;
local bool amAlive;
local float bleedDamage;
locpawn = Pawn(Owner);
amAlive = locpawn != none && locpawn.Health > 0;
// if pawn owner is dead or bleed count is done - destroy
if (!amAlive || maxBleedCount < 0)
Destroy();
if (fNextBleedTime < Level.TimeSeconds)
{
maxBleedCount--;
fNextBleedTime += fBleedPeriod;
bleedDamage = calcBleedDamage(bleedLevel, rand(7));
if (bleedDamage < 1.0)
{
maxBleedCount = 0;
return;
}
if (stalker != none)
locpawn.TakeDamage(bleedDamage, stalker, locpawn.Location,
vect(0, 0, 0), dmtype_bleed);
else
locpawn.TakeDamage(bleedDamage, locpawn, locpawn.Location,
vect(0, 0, 0), dmtype_bleed);
if (locpawn.isA('KFPawn'))
{
KFPawn(locpawn).HealthToGive -= 2 * bleedLevel;
}
}
}
// Returns bleed damage, corresponding to given bleed level and damage scale.
// Rand(7) should be used as a scale.
// Separate function created to allow for lowest/highest damage value computing.
final private function int calcBleedDamage(float level, int scale)
{
return level * (3 + scale);
}
// cleanup
function Destroyed()
{
if (stalker != none)
stalker = none;
super.Destroyed();
}
defaultproperties
{
maxBleedCount=7
fBleedPeriod=1.500000
}

View File

@ -197,13 +197,37 @@ function bool MeleeDamageTarget(int hitdamage, vector pushdir)
else
effectStrenght = (100 - targetPawn.ShieldStrength) * 0.01;
class'MeanReplicationInfo'.static
.findSZri(targetPawn.PlayerReplicationInfo)
.setBleeding(Self, effectStrenght);
MakeBleed(targetPawn, effectStrenght);
}
return result;
}
final private function MakeBleed(NiceHumanPawn poorpawn, float effectStrenght)
{
local Inventory I;
local bool bFoundPoison;
if (poorpawn.Inventory != none)
{
for (I = poorpawn.Inventory; I != none; I = I.Inventory)
{
if (MeanBleedInventory(I) != none)
{
bFoundPoison = true;
MeanBleedInventory(I).stalker = self;
MeanBleedInventory(I).bleedLevel = effectStrenght;
}
}
}
if (!bFoundPoison)
{
I = Controller.Spawn(class<Inventory>(DynamicLoadObject(string(class'MeanBleedInventory'), class'Class')));
MeanBleedInventory(I).stalker = self;
MeanBleedInventory(I).bleedLevel = effectStrenght;
I.GiveTo(poorpawn);
}
}
function RemoveHead()
{
Super(NiceMonster).RemoveHead();