class BigShockwave expands Effects;

//Model import
#exec MESH IMPORT MESH=BigShockwave ANIVFILE=MODELS\BigShockwave_a.3d DATAFILE=MODELS\BigShockwave_d.3d X=0 Y=0 Z=0
#exec MESH LODPARAMS MESH=BigShockwave STRENGTH=0
#exec MESH ORIGIN MESH=BigShockwave X=0 Y=0 Z=0 PITCH=64

#exec MESH SEQUENCE MESH=BigShockwave SEQ=All STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=BigShockwave SEQ=Still STARTFRAME=0 NUMFRAMES=1

#exec MESHMAP NEW MESHMAP=BigShockwave MESH=BigShockwave
#exec MESHMAP SCALE MESHMAP=BigShockwave X=0.1 Y=0.1 Z=0.2


//Pan fire texture import (a lot! O.O' I need lots of detail for my own reasons :])
#exec TEXTURE IMPORT NAME=FirePan_01 FILE=PANFIRE\FirePan_01.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_02 FILE=PANFIRE\FirePan_02.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_03 FILE=PANFIRE\FirePan_03.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_04 FILE=PANFIRE\FirePan_04.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_05 FILE=PANFIRE\FirePan_05.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_06 FILE=PANFIRE\FirePan_06.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_07 FILE=PANFIRE\FirePan_07.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_08 FILE=PANFIRE\FirePan_08.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_09 FILE=PANFIRE\FirePan_09.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_10 FILE=PANFIRE\FirePan_10.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_11 FILE=PANFIRE\FirePan_11.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_12 FILE=PANFIRE\FirePan_12.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_13 FILE=PANFIRE\FirePan_13.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_14 FILE=PANFIRE\FirePan_14.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_15 FILE=PANFIRE\FirePan_15.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_16 FILE=PANFIRE\FirePan_16.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_17 FILE=PANFIRE\FirePan_17.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_18 FILE=PANFIRE\FirePan_18.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_19 FILE=PANFIRE\FirePan_19.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_20 FILE=PANFIRE\FirePan_20.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_21 FILE=PANFIRE\FirePan_21.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_22 FILE=PANFIRE\FirePan_22.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_23 FILE=PANFIRE\FirePan_23.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_24 FILE=PANFIRE\FirePan_24.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_25 FILE=PANFIRE\FirePan_25.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_26 FILE=PANFIRE\FirePan_26.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_27 FILE=PANFIRE\FirePan_27.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_28 FILE=PANFIRE\FirePan_28.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_29 FILE=PANFIRE\FirePan_29.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_30 FILE=PANFIRE\FirePan_30.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_31 FILE=PANFIRE\FirePan_31.bmp GROUP=Pan FLAGS=2
#exec TEXTURE IMPORT NAME=FirePan_32 FILE=PANFIRE\FirePan_32.bmp GROUP=Pan FLAGS=2

//Basic skinning
#exec MESHMAP SETTEXTURE MESHMAP=BigShockwave NUM=1 TEXTURE=FirePan_01

//Some sound
#exec AUDIO IMPORT NAME="XM_Expl" FILE=SOUNDS\XM_Expl.wav GROUP="MultiML"


var() texture PanningTextures[32];	//Panning textures
var() float PanSpeed;			//Pan speed or rate
var() float MaxScaleInc;		//Final scale is (DrawScale + MaxScaleInc)
var(Damage) bool bDamage;		//Should this shock do any damage
var() bool bGrowing;			//Growing shock?
var() bool bFadeOut;			//Should fade out?
var(Damage) int Damage;			//Damage instigated
var(Damage) bool bRangedDamage;		//Be damage taken relative to distance, but it only works if bFadeOut is True
var(Damage) name MyDamageType;
var(Damage) int Momentum;
var(SoundEffect) sound ShockSound;
var(SoundEffect) int ShockSVolume;
var(SoundEffect) int ShockSRange;
var bool ExecuteSpecialEndCode;		//Only used by coders, used to call the function SpecialCode to spawn other effects at the life end

var byte PanC;
var float Count;
var float MinDrawScale;

var int Kickback;
var float Splasher, MoreDamage;

replication
{
	// Things the server should send to the client.
	reliable if(Role==ROLE_Authority)
		Kickback, MoreDamage, Splasher;
}

function MakeSound()
{
	PlaySound(ShockSound,,ShockSVolume,,ShockSRange);
}

simulated function PostBeginPlay()
{
	if (PanSpeed != 0)
		SetTimer(1/Abs(PanSpeed), True);

	if (ShockSound!=None)
		MakeSound();

	MinDrawScale = DrawScale;
}


simulated function Destroyed()
{
	SpecialCode();
	Super.Destroyed();
}


function SpecialCode()
{
	//Spawn or execute other things
}


simulated function Tick( float DeltaTime)
{

	if (bGrowing)
		DrawScale = MinDrawScale + (MaxScaleInc * (Default.LifeSpan - LifeSpan) / Default.LifeSpan);
	else
		DrawScale = MinDrawScale + (MaxScaleInc * LifeSpan / Default.LifeSpan);


	if (bFadeOut)
		ScaleGlow = LifeSpan * Default.ScaleGlow / Default.LifeSpan;

	
	Count += DeltaTime;

	if (Count >= 0.2)
	{
		Count = 0;
	if (bDamage)
	{
		GiveDamage();
	}
	}
}


function GiveDamage()
{
local Pawn P;
local Actor A;
local vector dir;

	ForEach VisibleCollidingActors(Class'Actor', A, DrawScale * 64 * FMax(1.0, Splasher))
	{
		if (!A.IsA('NukeBoulder'))
		{
		dir = Normal(A.Location - Location);

		if (bRangedDamage)
			A.TakeDamage(Damage * FMax(1.0,MoreDamage) * (ScaleGlow/Default.ScaleGlow),  Instigator, A.Location - 0.5 * (A.CollisionHeight + A.CollisionRadius) * dir, dir * Momentum * FMax(1.0, Kickback) * (ScaleGlow/Default.ScaleGlow), MyDamageType);
		else
			A.TakeDamage(Damage * FMax(1.0,MoreDamage),  Instigator, A.Location - 0.5 * (A.CollisionHeight + A.CollisionRadius) * dir, dir * Momentum * FMax(1.0, Kickback), MyDamageType);
		}
	}
}


simulated function Timer()
{
	if (PanSpeed > 0)
	{
		PanC++;
		if (PanC > 31)
			PanC = 0;
	}
	else
	{
		if (PanC == 0)
			PanC = 32;
		PanC--;
	}

	MultiSkins[1] = PanningTextures[PanC];
}


defaultproperties
{
	DrawType=DT_Mesh
	Mesh=BigShockwave
	DrawScale=1.000000
	ScaleGlow=5.000000
	LifeSpan=2.000000
	PanSpeed=128.000000
	MaxScaleInc=10.000000
	bDamage=True
	bGrowing=True
	bFadeOut=True
	Damage=1000
	bRangedDamage=True
	MyDamageType=NuclearExplosion
	Momentum=300000
	ShockSound=XM_Expl
	ShockSVolume=250
	ShockSRange=8000
	RemoteRole=ROLE_SimulatedProxy
	bUnlit=True
	Style=STY_Translucent
	PanningTextures(0)=FirePan_01
	PanningTextures(1)=FirePan_02
	PanningTextures(2)=FirePan_03
	PanningTextures(3)=FirePan_04
	PanningTextures(4)=FirePan_05
	PanningTextures(5)=FirePan_06
	PanningTextures(6)=FirePan_07
	PanningTextures(7)=FirePan_08
	PanningTextures(8)=FirePan_09
	PanningTextures(9)=FirePan_10
	PanningTextures(10)=FirePan_11
	PanningTextures(11)=FirePan_12
	PanningTextures(12)=FirePan_13
	PanningTextures(13)=FirePan_14
	PanningTextures(14)=FirePan_15
	PanningTextures(15)=FirePan_16
	PanningTextures(16)=FirePan_17
	PanningTextures(17)=FirePan_18
	PanningTextures(18)=FirePan_19
	PanningTextures(19)=FirePan_20
	PanningTextures(20)=FirePan_21
	PanningTextures(21)=FirePan_22
	PanningTextures(22)=FirePan_23
	PanningTextures(23)=FirePan_24
	PanningTextures(24)=FirePan_25
	PanningTextures(25)=FirePan_26
	PanningTextures(26)=FirePan_27
	PanningTextures(27)=FirePan_28
	PanningTextures(28)=FirePan_29
	PanningTextures(29)=FirePan_30
	PanningTextures(30)=FirePan_31
	PanningTextures(31)=FirePan_32
}
