//=============================================================================
// EMPGrenade.
//=============================================================================
class NapProj extends ThrownProjectile;

#exec OBJ LOAD FILE=Effects

var ParticleGenerator smokeGen;

function PostBeginPlay()
{
	Super.PostBeginPlay();

   if (Level.NetMode == NM_DedicatedServer)
      return;
   
   SpawnFuseEffects();
}

simulated function PostNetBeginPlay()
{
   Super.PostNetBeginPlay();
   
   if (Role != ROLE_Authority)
      SpawnFuseEffects();
}


simulated function SpawnFuseEffects()
{
	smokeGen = Spawn(class'ParticleGenerator', Self);
	if (smokeGen != None)
	{
      smokeGen.RemoteRole = ROLE_None;
		smokeGen.particleTexture = Texture'Effects.Smoke.SmokePuff1';
		smokeGen.particleDrawScale = 0.1;
		smokeGen.checkTime = 0.02;
		smokeGen.riseRate = 8.0;
		smokeGen.ejectSpeed = 0.0;
		smokeGen.particleLifeSpan = 1.0;
		smokeGen.bRandomEject = True;
		smokeGen.SetBase(Self);
	}
}

simulated function Destroyed()
{
	if (smokeGen != None)
		smokeGen.DelayedDestroy();

	Super.Destroyed();
}

auto simulated state Flying
{
	simulated function Explode(vector HitLocation, vector HitNormal)
	{
		SpawnFire(HitLocation);
		Super.Explode(HitLocation, HitNormal);
	}
}

function SpawnFire(vector HitLocation)
{
	local NapFire fire;
	local int i;
	local Vector loc;
	
	if(Role == ROLE_Authority)
	{
		//Code used from ThrownProjectile
		for (i=0; i<blastRadius/36; i++)
		{
			if (FRand() < 0.9)
			{
				loc = HitLocation;
				loc.X += FRand() * blastRadius - blastRadius * 0.5;
				loc.Y += FRand() * blastRadius - blastRadius * 0.5;
				loc.Z += 30;

				fire = Spawn(class'NapFire',,,loc);
				if (fire != None)
				{
					fire.PawnOwner = Pawn(Owner);
				}
			}
		}
	}
}

function PlayBeepSound( float Range, float Pitch, float volume )
{

}
defaultproperties
{
     blastradius=512.000000
     fuseLength=5.000000
     proxRadius=128.000000
     AISoundLevel=0.000000
     bBlood=False
     bDebris=False
     DamageType=Flamed
     spawnWeaponClass=Class'Contender.NapWeap'
     ItemName="Napalm Grenade"
     speed=1000.000000
     MaxSpeed=1000.000000
     Damage=0.000000
     MomentumTransfer=50000
     ImpactSound=Sound'ContenderStuff.Weapons.NapExp'
     MiscSound=Sound'ContenderStuff.Weapons.GasBounce'
     LifeSpan=0.000000
     Mesh=LodMesh'DeusExItems.GasGrenadePickup'
    MultiSkins=Texture'ContenderStuff.Skins.Nap3rd'
     CollisionRadius=4.300000
     CollisionHeight=1.400000
     Mass=5.000000
     Buoyancy=2.000000
}
