class AXEnergy expands XEnergy;

#exec TEXTURE IMPORT NAME=AXEnergy FILE=CORONAS\AXEnergy.bmp GROUP=Coronas FLAGS=2
#exec AUDIO IMPORT NAME="Cybot_AX_PickupS" FILE=SOUNDS\Cybot_AX_PickupS.wav GROUP="Cybot"

simulated function Timer()
{
local Pawn P;

	Super.Timer();

	ForEach VisibleCollidingActors(Class'Pawn', P, 80.0)
		CheckPawn(P);
}


function CheckPawn( pawn P)
{
local Inventory Inv;
local bool GaveAmmo;

	If (TeamGamePlus(Level.Game)!= None && !Level.Game.IsA('MonsterHunt'))
	{
		If (P.PlayerReplicationInfo.Team != Instigator.PlayerReplicationInfo.Team && P!=Instigator)
			return;
	}
	else if (P.IsA('ScriptedPawn') && Level.Game.IsA('MonsterHunt'))
			return;
	else if (P != Instigator && TeamGamePlus(Level.Game) == None)
			return;

	For ( Inv=P.Inventory; Inv!=None; Inv=Inv.Inventory )
    	{
		if (Ammo(Inv)!=None && !Ammo(Inv).IsA('WarHeadAmmo') && !Ammo(Inv).IsA('StrangeAmmo') && NaliAmmo(Inv)==None)
		{
			if (Ammo(Inv).AmmoAmount < Ammo(Inv).MaxAmmo)
			{
            			Ammo(Inv).AmmoAmount = Min(Ammo(Inv).AmmoAmount + Int(FMax(1, Ammo(Inv).MaxAmmo / 10)), Ammo(Inv).MaxAmmo);
				GaveAmmo = True;
			}
		}
		else if (NaliAmmo(Inv)!=None)
		{
			if (!NaliAmmo(Inv).bMegaAmmo && Ammo(Inv).AmmoAmount < Ammo(Inv).MaxAmmo)
			{
				Ammo(Inv).AmmoAmount = Min(Ammo(Inv).AmmoAmount + Int(FMax(1, Ammo(Inv).MaxAmmo / 10)), Ammo(Inv).MaxAmmo);
				GaveAmmo = True;
			}
		}
	}

	if (GaveAmmo)
		MakeSound();
}

defaultproperties
{
	Texture=AXEnergy
	EffectRefreshTime=1.000000
	bTimedEffect=True
	EffectSound=Cybot_AX_PickupS
	EnergyParticlesType=Class'GreenRParticles'
}
