// causes touching Pawns' damage or death on trigger

class TriggerDamageVolume extends Volume;

var() class<Pawn> PawnClass;
var() name PawnTag;
var() int Damage;
var() class<DamageType> DamageType;
var() bool bInstantKill; // instant kill pawns instead of damaging them


function Trigger( actor Other, pawn EventInstigator )
{
	local Pawn P;
	local vector VoidVector;
	local Controller Killer;
	local int i;
	
	// log("TriggerDamageVolume triggered: " $ name $ " by " $ EventInstigator);
	// PlayerController(EventInstigator.Controller).ClientMessage("TriggerDamageVolume"@name@"triggered");
	
	if ( EventInstigator != none )
		Killer = EventInstigator.Controller;

	// TouchingActors doesn't work correctly, because after killing the pawn, 
	// it gets removed from the array, breaking the iterator
	for ( i = Touching.length-1 ; i >= 0 ; --i ) {
		P = Pawn(Touching[i]);
		if ( P != none && (P.Tag == PawnTag || PawnTag == '') ) {
			if ( bInstantKill )
				P.Died(Killer, DamageType , P.Location);
			else 
				P.TakeDamage(Damage, EventInstigator, P.Location, VoidVector, DamageType);
		}
	}
}

defaultproperties
{
     PawnClass=Class'KFMod.KFMonster'
     DamageType=Class'Engine.Suicided'
     bInstantKill=True
}
