class WreckedPiece expands Projectile;

#exec TEXTURE IMPORT NAME=Wrecked FILE=Skins\Wrecked.bmp GROUP=Skins FLAGS=2

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;
		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 )
{
	HitWall(-Normal(Velocity), Other );
}

simulated function HitWall( vector HitNormal, actor Wall )
{
	Velocity = 0.75*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
	RandSpin(100000);
	speed = VSize(Velocity);
	if ( Level.NetMode != NM_DedicatedServer )
		PlaySound(ImpactSound, SLOT_Misc, 8.0);
	if ( Velocity.Z > 400 )
		Velocity.Z = 0.5 * (400 + Velocity.Z);	
	else if ( speed < 20 ) 
	{
		bBounce = False;
		SetPhysics(PHYS_None);
	}
}



defaultproperties
{
	DrawType=DT_Mesh
	bBounce=True
	bFixedRotationDir=True
	Physics=PHYS_Falling
	RemoteRole=ROLE_SimulatedProxy
	ExplosionDecal=None
	ImpactSound=MetalHit
	MaxSpeed=700.000000
	speed=400.000000
	Multiskins(0)=Wrecked
	Multiskins(1)=Wrecked
	Multiskins(2)=Wrecked
	Multiskins(3)=Wrecked
	Multiskins(4)=Wrecked
	Multiskins(5)=Wrecked
	Multiskins(6)=Wrecked
	Multiskins(7)=Wrecked
	Texture=Wrecked
	LifeSpan=10.000000
	AnimSequence=Openned
}
