//=============================================================================
// BotzSpectator.
//
// For testing purposes, do not modify or redistribute
// Have suggestions? Contact me.
// caco_fff@hotmail.com - Higor at UT99.org
//=============================================================================
class BotzSpectator expands Spectator;

var() Pawn Simulator;

event PostBeginPlay()
{
	if (Level.Game.IsA('TournamentGameInfo') )
		Destroy();
	Enable('Tick');;
	Enable('SeePlayer');
	Enable('HearNoise');
	bIsPlayer = true;
}

event HearNoise( float Loudness, Actor NoiseMaker)
{
	if (NoiseMaker == Simulator)
		MakeNoise(LoudNess * 2);
}

event Tick( float DeltaTime)
{
	if (Simulator == none)
		FindSimulator();
	else
		SetConds();
}

function FindSimulator()
{
	local Pawn P;

	P = Level.Pawnlist;
	While ( P != None)
	{
		if ( (P.IsA('Bot') || (P.IsA('Botz') ) && (P.SpecialMesh != "Possessed") ) )
		{
			Simulator = P;
			break;
		}
		P = P.NextPawn;
	}
}

event Destroyed()
{
	if (Simulator != none)
		Simulator.SpecialMesh = Simulator.Default.SpecialMesh;
}

event SeePlayer(actor Seen)
{
	if ( (Simulator != none) && (Seen != simulator) )
		Simulator.SeePlayer(seen);
}

function SetConds()
{
	local pawn P;

//	Visibility = Simulator.Visibility;
	SetLocation(Simulator.Location);
	SetRotation(Simulator.ViewRotation);
	ViewRotation = Simulator.ViewRotation;
	PlayerReplicationInfo.Team = Simulator.PlayerReplicationInfo.Team;
	PlayerReplicationInfo.TeamID = 200;

	For (P=Level.PawnList ; P!=none ; P=P.NextPawn )
	{
		if (P.Enemy == self)
			P.Enemy = Simulator;
	}

	if ( (Simulator.Enemy == self) || (Simulator.Enemy == Simulator) )
		Simulator.Enemy = none;
}

defaultproperties
{
     Visibility=128
     SightRadius=5000.000000
     PeripheralVision=-1.000000
     HearingThreshold=0.000000
     BaseEyeHeight=20.000000
     Intelligence=BRAINS_HUMAN
}
