//=============================================================================
// WarShell.
//=============================================================================
class WarShell expands Projectile;

#exec MESH IMPORT MESH=WarShellm ANIVFILE=MODELS\wars_a.3D DATAFILE=MODELS\wars_d.3D X=0 Y=0 Z=0
#exec MESH ORIGIN MESH=WarShellm X=0 Y=0 Z=0 YAW=64 PITCH=0  ROLL=-64
#exec MESH SEQUENCE MESH=WarShellm SEQ=All STARTFRAME=0  NUMFRAMES=1
#exec TEXTURE IMPORT NAME=Jwars1 FILE=MODELS\wars.PCX
#exec OBJ LOAD FILE=Textures\whlvapor.utx PACKAGE=BotPack.whlvapor
#exec MESHMAP SCALE MESHMAP=WarShellm X=0.1 Y=0.1 Z=0.2
#exec MESHMAP SETTEXTURE MESHMAP=WarShellm NUM=1 TEXTURE=Jwars1
#exec MESHMAP SETTEXTURE MESHMAP=WarShellm NUM=0 TEXTURE=BotPack.whlvapor.whlvapor

var Actor Seeking;
var float MagnitudeVel,Count,SmokeRate;
var vector InitialDir;
var bool bRing,bHitWater,bWaterStart;

simulated function PostBeginPlay()
{
	Count = -0.1;
	if (Level.bHighDetailMode) SmokeRate = 0.02;
	else SmokeRate = 0.15;
}

simulated function Tick(float DeltaTime)
{
	local SpriteSmokePuff b;

	if (bHitWater)
	{
		Disable('Tick');
		Return;
	}
	Count += DeltaTime;
	if ( (Count>(SmokeRate+FRand()*SmokeRate)) && (Level.NetMode!=NM_DedicatedServer) ) 
	{
		b = Spawn(class'SpriteSmokePuff');
		b.RemoteRole = ROLE_None;					
		Count=0.0;
	}
}

singular function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation, 
						vector momentum, name damageType )
{
	if ( NDamage > 5 )
		Explode(HitLocation,Normal(HitLocation-instigatedBy.Location));
}

auto state Flying
{

	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;	
	}

	function ProcessTouch (Actor Other, Vector HitLocation)
	{
		if ((Other != instigator) && (WarShell(Other) == none)) 
			Explode(HitLocation,Normal(HitLocation-Other.Location));
	}

	function Explode(vector HitLocation, vector HitNormal)
	{
		HurtRadius(Damage,200.0, 'exploded', MomentumTransfer, HitLocation );	 		 		
 		spawn(class'ShockWave',,,HitLocation+ HitNormal*16);	
 		Destroy();
	}

	function BeginState()
	{
		initialDir = vector(Rotation);	
		Velocity = speed*initialDir;
		Acceleration = initialDir*50;
		PlaySound(SpawnSound, SLOT_None, 2.3);	
		if (Region.Zone.bWaterZone)
		{
			bHitWater = True;
			Velocity=0.6*Velocity;
		}
	}
}

defaultproperties
{
     RemoteRole=ROLE_SimulatedProxy
     speed=500.000000
     Damage=100.000000
     Mesh=Mesh'BotPack.WarShellm'
     bMeshCurvy=False
     bProjTarget=True
     CollisionRadius=+00008.000000
     CollisionHeight=+00002.000000
	 bNetTemporary=false
}