// Same as ACTION_IfMonsterSeesEnemy, but can be used with any Pawn (e.g. NPC)
// added MaxDistance
class ACTION_IfSeesEnemy extends ScriptedAction;

var(Action) float MaxDistance;
 
function ProceedToNextAction( ScriptedController C )
{
	C.ActionNum += 1;
	
	if ( C.Enemy != none && (C.Enemy.bDeleteMe || C.Enemy.Health <= 0) )
		C.Enemy = none;
	
	if ( C.Enemy == none || !C.CanSee(C.Enemy) 
		|| (MaxDistance > 0 && vsize(C.Pawn.Location - C.Enemy.Location) > MaxDistance + C.Enemy.CollisionRadius) )
	{
		ProceedToSectionEnd( C );
	}
}
 
function bool StartsSection()
{
        return true;
}

defaultproperties
{
}
