//=============================================================================
// ExplosionChain.
//=============================================================================
class ExplosionChain expands Effects;


#exec Texture Import File=models\exp001.pcx Name=s_Exp001 Mips=Off Mask=On Flags=2

var() float MomentumTransfer;
var() float Damage;
var() float Size;
var() float Delaytime;

var bool bExploding;

function PreBeginPlay()
{
	Texture=None;
}

singular function Damage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
						Vector momentum, name damageType)
{
	if (!bOnlyTriggerable || DamageType=='Detonated') {
		Instigator = InstigatedBy;
		GoToState('Exploding');
	}
}

function Trigger( actor Other, pawn EventInstigator )
{
	Damage(10, EventInstigator, Location, Vector(Rotation), 'Detonated');
}

//////////////////////////////////////////////////////////////
state Exploding
{
	ignores Damage;

	function Timer()
	{
		local SpriteBallExplosion f;
		
		bExploding = true;
 		HurtRadius(damage, Damage+100, 'Detonated', MomentumTransfer, Location);
 		f = spawn(class'SpriteBallExplosion',,,Location + vect(0,0,1)*16,rotation(vect(0,0,1))); 
 		f.DrawScale = (Damage/100+0.4+FRand()*0.5)*Size;
		Destroy();
	}
	
	function BeginState()
	{
		bExploding = True;
		SetTimer(DelayTime+FRand()*DelayTime*2, False);
	}
}

