class CyBotProj expands Projectile;

var bool bHitWater;

simulated function PostBeginPlay()
{
	local vector X,Y,Z;
	local rotator RandRot;

	Super.PostBeginPlay();

	if ( Role == ROLE_Authority )
	{
		GetAxes(Instigator.ViewRotation,X,Y,Z);	
		Velocity = X * (Instigator.Velocity Dot X)*0.4 + Vector(Rotation) * (Speed +
			FRand() * 100);
		Velocity.z += 210;
		MaxSpeed = 1000;
		RandSpin(50000);
		if (Instigator.HeadRegion.Zone.bWaterZone)
		{
			bHitWater = True;
			Disable('Tick');
			Velocity=0.6*Velocity;			
		}
	}	
}

simulated function ZoneChange( Zoneinfo NewZone )
{
	local waterring w;
	
	if (!NewZone.bWaterZone || bHitWater) Return;

	bHitWater = True;
	w = Spawn(class'WaterRing',,,,rot(16384,0,0));
	w.DrawScale = 0.2;
	w.RemoteRole = ROLE_None;
	Velocity=0.6*Velocity;
}

simulated function Landed( vector HitNormal )
{
	HitWall( HitNormal, None);
}

simulated function ProcessTouch( actor Other, vector HitLocation )
{
	if (Other!=instigator)
		HitWall( Normal(-Velocity), Other );
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	if (HitNormal.Z > 0.7 && !Wall.IsA('Mover') && !Wall.IsA('Vehicle') && !Wall.IsA('Projectile') && !Wall.IsA('Pawn'))
	{
		SpawnCybot();
		Destroy();
	}
	else
	{
	Velocity = (( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
	RandSpin(10000);
	speed = VSize(Velocity);
	if ( Level.NetMode != NM_DedicatedServer )
		PlaySound(ImpactSound, SLOT_Misc, 8.0);
	}
}

function SpawnCybot();

///////////////////////////////////////////////////////


simulated function Explosion(vector HitLocation)
{
 	Destroy();
}



defaultproperties
{
	DrawType=DT_Mesh
	Mesh=None
	bBounce=True
	bFixedRotationDir=True
	Physics=PHYS_Falling
	RemoteRole=ROLE_SimulatedProxy
	Damage=0.000000
	ExplosionDecal=None
	ImpactSound=MetalHit
	MaxSpeed=500.000000
	CollisionRadius=6.000000
	CollisionHeight=11.000000
	MomentumTransfer=0
	MyDamageType="NoDamage"
	speed=300.000000
}
