KF2-Server-Extension/ServerExt/Classes/Ext_T_AmmoRegHelp.uc

49 lines
818 B
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class Ext_T_AmmoRegHelp extends Info
transient;
var Pawn PawnOwner;
var float RegCount;
function PostBeginPlay()
{
PawnOwner = Pawn(Owner);
2020-11-28 20:04:55 +00:00
if(PawnOwner==None)
2017-10-20 02:00:49 +00:00
Destroy();
else SetTimer(29+FRand(),true);
}
function Timer()
{
local KFWeapon W;
local byte i;
2020-10-13 07:31:49 +00:00
local int ExtraAmmo;
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
if(PawnOwner==None || PawnOwner.Health<=0 || PawnOwner.InvManager==None)
2017-10-20 02:00:49 +00:00
Destroy();
else
{
foreach PawnOwner.InvManager.InventoryActors(class'KFWeapon',W)
{
2020-11-28 20:04:55 +00:00
for(i=0; i<2; ++i)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:04:55 +00:00
if(W.SpareAmmoCount[i] < W.SpareAmmoCapacity[i])
2017-10-20 02:00:49 +00:00
{
ExtraAmmo = FMax(float(W.SpareAmmoCapacity[i] + W.MagazineCapacity[i])*RegCount,1.f);
2020-11-28 20:04:55 +00:00
if (i==0)
2020-10-13 07:31:49 +00:00
{
W.AddAmmo(ExtraAmmo);
}
else
{
W.AddSecondaryAmmo(ExtraAmmo);
2020-10-13 07:45:12 +00:00
}
2017-10-20 02:00:49 +00:00
W.bNetDirty = true;
}
}
}
}
}
defaultproperties
{
2020-10-13 07:31:49 +00:00
}