//=============================================================================
// SuperMine 
// Written by nOs*Badger
//=============================================================================
class SuperMine extends Mine;

function PostBeginPlay()
{

Super.PostBeginPlay();

Texture = Texture'SKFlare';

}

simulated event Timer()
{
    	local Pawn p;
	Super.Timer();

	if ( SCount > 0 || Role != ROLE_Authority )
        	return;

		foreach RadiusActors(class'Pawn', p, 100)
			if ( p.bIsPlayer && p.Health > 0 &&
        			p.PlayerReplicationInfo != None &&
          			p.PlayerReplicationInfo.Team != Team && !p.PlayerReplicationInfo.bIsSpectator)
				if (p != None && !bDisabledByEMP) 
					Damage();
}

function Damage()
{
	local int i;
    	local Pawn p;
	local Pawn pAward;

    	local vector dir;
	local int x;
	local int y;
	local int z;
	local string sMessage;
	local string sName;

	Self.PlaySound(Sound'SharpExplosion',, 4.0);

	pAward = GetAwardedPlayer();

        for ( i = 0; i <= Grade; i++ )
	{
		dir.x = Rand(80)-40;
		dir.y = Rand(80)-40;
		dir.z = Rand(80)-40;
		spawn(class'MineExplosion',,,Location + dir); 
		foreach RadiusActors(class'Pawn', p, 100+(i*35))
			if (p != None) 
				if (ShouldAttack(p))
				{
        				dir = Location - p.Location;
        				dir = normal(dir); 
					if (p.Health>0)
					{
        					p.TakeDamage((Grade+1) * 15, instigator, 0.5 * (p.CollisionHeight + p.CollisionRadius)*dir, vect(0,0,0), 'supermine');
						sgPRI(pAward.PlayerReplicationInfo).AddRU((Grade+1) * 4);
					}
				}
	}

	sgPRI(pAward.PlayerReplicationInfo).AddRU(50);

	Energy -= 200;
	if ( Energy <= 0 )
        Destruct();
}

defaultproperties
{
    BuildingName="Super Mine"
    BuildCost=750
    UpgradeCost=30
    MaxEnergy=1000.00
    SpriteScale=0.30
    DSofMFX=1.60
}
