//=============================================================================
// DispersionAmmo.
//=============================================================================
class DispersionAmmo expands Projectile;


#exec TEXTURE IMPORT NAME=D0_A00 FILE=MODELS\D0_A00.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D0_A01 FILE=MODELS\D0_A01.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D0_A02 FILE=MODELS\D0_A02.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D0_A03 FILE=MODELS\D0_A03.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D0_A04 FILE=MODELS\D0_A04.pcx GROUP=Effects

#exec TEXTURE IMPORT NAME=D1_A00 FILE=MODELS\D1_A00.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D1_A01 FILE=MODELS\D1_A01.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D1_A02 FILE=MODELS\D1_A02.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D1_A03 FILE=MODELS\D1_A03.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D1_A04 FILE=MODELS\D1_A04.pcx GROUP=Effects

#exec TEXTURE IMPORT NAME=D2_A00 FILE=MODELS\D2_A00.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D2_A01 FILE=MODELS\D2_A01.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D2_A02 FILE=MODELS\D2_A02.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D2_A03 FILE=MODELS\D2_A03.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D2_A04 FILE=MODELS\D2_A04.pcx GROUP=Effects

#exec TEXTURE IMPORT NAME=D3_A00 FILE=MODELS\D3_A00.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D3_A01 FILE=MODELS\D3_A01.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D3_A02 FILE=MODELS\D3_A02.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D3_A03 FILE=MODELS\D3_A03.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D3_A04 FILE=MODELS\D3_A04.pcx GROUP=Effects

#exec TEXTURE IMPORT NAME=D4_A00 FILE=MODELS\D4_A00.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D4_A01 FILE=MODELS\D4_A01.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D4_A02 FILE=MODELS\D4_A02.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D4_A03 FILE=MODELS\D4_A03.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=D4_A04 FILE=MODELS\D4_A04.pcx GROUP=Effects


var() texture VisualEffect[7];
var bool bExploded, bSpashDamage;

function PreBeginPlay()
{
	CallParent.PreBeginPlay();
	Velocity = Speed * vector(Rotation);
	PlaySound(SpawnSound);
	Texture = VisualEffect[min(int(Damage/11.0),6)];
}

function Damage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
					Vector momentum, name damageType)
{
	bExploded = True;
}

function Explode(vector HitLocation, vector HitNormal)
{
	local DispBurst b;
	local SpriteBallExplosion s;
	local DefaultBurst d;
	local int i;

	if (bSpashDamage) {
		HurtRadius(Damage,150.0, 'exploded', MomentumTransfer, HitLocation );	
		if (!bExploded) {
			if (Damage>30) {
				d = Spawn(class'DefaultBurstAlt',, '', HitLocation, Rotation(HitNormal));
				d.DrawScale = Min(Damage/20.0 + 0.8,3.0);						
			}
			else {
				d = Spawn(class'DefaultBurst',, '', HitLocation, Rotation(HitNormal));
				d.DrawScale = Min(Damage/20.0 + 0.8,3.0);			
			}
		}
	}
	else {
		s = Spawn(class'SpriteBallExplosion',, '', HitLocation);		
		s.DrawScale = 1.0;
	}
	Destroy();
}

function ProcessTouch (Actor Other, vector HitLocation)
{
	If (Other!=Instigator  && DispersionAmmo(Other)==None)
	{
		Other.damage( Damage, instigator, HitLocation, MomentumTransfer*Vector(Rotation), 'exploded');	
		Explode(HitLocation, vect(0,0,1));
	}
}

