class TankMLProj expands xTreadVehProjectile;

#exec MESH IMPORT MESH=TankMLProj ANIVFILE=MODELS\TankMLProj_a.3d DATAFILE=MODELS\TankMLProj_d.3d X=0 Y=0 Z=0 UNMIRROR=1
#exec MESH LODPARAMS MESH=TankMLProj STRENGTH=0.75
#exec MESH ORIGIN MESH=TankMLProj X=0 Y=0 Z=0

#exec MESH SEQUENCE MESH=TankMLProj SEQ=All STARTFRAME=0 NUMFRAMES=8
#exec MESH SEQUENCE MESH=TankMLProj SEQ=Still STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=TankMLProj SEQ=Revolve STARTFRAME=0 NUMFRAMES=8 RATE=8.0
#exec MESH SEQUENCE MESH=TankMLProj SEQ=RevolveLoop STARTFRAME=0 NUMFRAMES=7 RATE=7.0

#exec MESHMAP NEW MESHMAP=TankMLProj MESH=TankMLProj
#exec MESHMAP SCALE MESHMAP=TankMLProj X=2.5 Y=0.35 Z=0.7

#exec obj load file=..\Textures\UExplosionsSet01.utx package=UExplosionsSet01

#exec AUDIO IMPORT NAME="TankMLProjAmb" FILE=SOUNDS\TankMLProjAmb.wav GROUP="TankMLLoop"

var texture RandTexFX[8];
var TankMLProjFX TProjTrail;
var() const float ProjLength;
var TankMLProjCor TMLTrail;
var() vector TMLTrailOffset;

simulated function PostBeginPlay()
{
	Super.PostBeginPlay();
	
	TProjTrail = Spawn(Class'TankMLProjFX', Self);
	TProjTrail.DrawScale = DrawScale;
	TProjTrail.ScaleGlow = ScaleGlow;
	
	ApplyRandomParticles(Self);
	ApplyRandomParticles(TProjTrail);
	
	Velocity = Speed * vector(Rotation);
	LoopAnim('RevolveLoop', Speed/ProjLength/10);
	
	TMLTrail = Spawn(Class'TankMLProjCor', Self,, Location + (TMLTrailOffset >> Rotation));
	TMLTrail.PrePivot = TMLTrailOffset >> Rotation;
	
	SetTimer(0.1,True);
}

simulated function Timer()
{
	if (TMLTrail != None)
		TMLTrail.PrePivot = TMLTrailOffset >> Rotation;
}

simulated function ApplyRandomParticles(Actor A)
{
local byte i;

	if (A != None)
	{
		for (i = 0; i < ArrayCount(RandTexFX); i++)
			A.MultiSkins[i] = RandTexFX[Rand(ArrayCount(RandTexFX))];
	}
}

simulated function Destroyed()
{
	if (TProjTrail != None)
		TProjTrail.Destroy();
	if (TMLTrail != None)
		TMLTrail.Destroy();
		
	Super.Destroyed();
}

simulated function ProcessTouch (Actor Other, Vector HitLocation)
{
	if (Other != Owner && (!Other.IsA('Projectile') || Other.CollisionRadius > 0))
		Explode(HitLocation, vect(0,0,1));
}

    function BlowTheHellUp(vector HitLocation, vector HitNormal)
    {
	local byte i;

		HurtRadiusOwned(Damage , 1400.0, MyDamageType, MomentumTransfer, HitLocation);
	   
		Spawn(Class'TankMLProjExplController',,, HitLocation, rotator(HitNormal));
		Spawn(Class'TankMLSmkRing',,, HitLocation, rotator(HitNormal));
		Spawn(Class'TankMLSmkRing',,, HitLocation, rotator(HitNormal) + rot(0,0,2731));
		Spawn(Class'TankMLShockRing',,, HitLocation + HitNormal, rotator(HitNormal));

		ClientShakes(1500);
	
        MakeNoise(3.75);
    }

simulated function Explode(vector HitLocation, vector HitNormal)
{
	BlowTheHellUp(HitLocation, HitNormal);
	Destroy();
}

defaultproperties
{
	DrawType=DT_Mesh
	Mesh=TankMLProj
	bParticles=True
	bRandomFrame=True
	DrawScale=0.750000
	ScaleGlow=1.500000
	bUnlit=True
	Style=STY_Translucent
	Texture=Texture'TransInvis'
	MultiSkins(0)=Texture'UExplosionsSet01.ExplF01'
	MultiSkins(1)=Texture'UExplosionsSet01.ExplF02'
	MultiSkins(2)=Texture'UExplosionsSet01.ExplF03'
	MultiSkins(3)=Texture'UExplosionsSet01.ExplF04'
	MultiSkins(4)=Texture'UExplosionsSet01.ExplF05'
	MultiSkins(5)=Texture'UExplosionsSet01.ExplF06'
	MultiSkins(6)=Texture'UExplosionsSet01.ExplF07'
	MultiSkins(7)=Texture'UExplosionsSet01.ExplF08'
	RandTexFX(0)=Texture'UExplosionsSet01.ExplF04'
	RandTexFX(1)=Texture'UExplosionsSet01.ExplF05'
	RandTexFX(2)=Texture'UExplosionsSet01.ExplF06'
	RandTexFX(3)=Texture'UExplosionsSet01.ExplF07'
	RandTexFX(4)=Texture'UExplosionsSet01.ExplF08'
	RandTexFX(5)=Texture'UExplosionsSet01.ExplF09'
	RandTexFX(6)=Texture'UExplosionsSet01.ExplF10'
	RandTexFX(7)=Texture'UExplosionsSet01.ExplF11'
	bBounce=False
	RemoteRole=ROLE_SimulatedProxy
	Damage=1500
	MaxSpeed=12000.000000
	MomentumTransfer=100000
	MyDamageType=MegaBurned
	speed=6000.000000
	CollisionHeight=0.000000
	CollisionRadius=0.000000
	SoundVolume=200
	SoundRadius=128
	AmbientSound=TankMLProjAmb
	ExplosionDecal=Class'TankMLMark'
	bNetTemporary=True
	Mass=500.000000
	ProjLength=320.000000
	LightBrightness=80
	LightHue=0
	LightSaturation=0
	LightEffect=LE_NonIncidence
	LightRadius=8
	LightType=LT_Steady
	TMLTrailOffset=(X=96.000000)
}
