class NuclearShockI expands Effects;

#exec MESH IMPORT MESH=NuclearShockI ANIVFILE=MODELS\NuclearShockI_a.3d DATAFILE=MODELS\NuclearShockI_d.3d X=0 Y=0 Z=0
#exec MESH LODPARAMS MESH=NuclearShockI STRENGTH=0
#exec MESH ORIGIN MESH=NuclearShockI X=0 Y=0 Z=0

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

#exec MESHMAP NEW MESHMAP=NuclearShockI MESH=NuclearShockI
#exec MESHMAP SCALE MESHMAP=NuclearShockI X=0.1 Y=0.1 Z=0.1

#exec TEXTURE IMPORT NAME=ShockTranslucent FILE=SKINS\ShockTranslucent.bmp GROUP=Skins FLAGS=2 LODSET=2
#exec MESHMAP SETTEXTURE MESHMAP=NuclearShockI NUM=1 TEXTURE=ShockTranslucent

const ScaleCoef = 80.000000;


simulated function PostBeginPlay()
{
	SetTimer(0.1, True);
}


simulated function Timer()
{
local PlayerPawn PP;
local Actor A;
local vector dir;

	ForEach AllActors(Class'PlayerPawn', PP)
	{
		if ((DrawScale * 80) - VSize(Location - PP.Location) < 720 && PP.ViewTarget == None && VSize(Location - PP.Location) < (DrawScale * 80))
		{
			PP.ShakeView( 0.5, 800.0, 80.0);

			if ((DrawScale * 80) > 18000)
				Spawn(Class'ShockHitExtended',,, PP.Location);
			else
				Spawn(Class'ShockHit',,, PP.Location);
		}
		else if (PP.ViewTarget != None)
		{
			if ((DrawScale * 80) - VSize(Location - PP.ViewTarget.Location) < 720 && VSize(Location - PP.ViewTarget.Location) < (DrawScale * 80))
			{
				PP.ShakeView( 0.5, 800.0, 80.0);
	
				if ((DrawScale * 80) > 18000)
					Spawn(Class'ShockHitExtended',,, PP.ViewTarget.Location);
				else
					Spawn(Class'ShockHit',,, PP.ViewTarget.Location);
			}
		}
	}

	if (DrawScale < Default.DrawScale / 3)
	{
	ForEach VisibleCollidingActors(Class'Actor', A, DrawScale * 80)
	{
		if ((DrawScale * 80) - VSize(Location - A.Location) < 720 && Role == ROLE_Authority)
		{
			dir = Normal(A.Location - Location);
			A.TakeDamage(Max((Default.DrawScale * 27) - DrawScale, 0),  Instigator, A.Location - 0.5 * (A.CollisionHeight + A.CollisionRadius) * dir, dir * 600000 * (ScaleGlow/Default.ScaleGlow), 'MushroomNuke');
		}
	}
	}
}


simulated function Tick( float DeltaTime)
{
	DrawScale = (Default.LifeSpan - LifeSpan) * Default.DrawScale / Default.LifeSpan;
	ScaleGlow = LifeSpan * Default.ScaleGlow / Default.LifeSpan;
}

defaultproperties
{
	DrawType=DT_Mesh
	Mesh=NuclearShockI
	LifeSpan=3.000000
	DrawScale=270.000000
	bNetTemporary=True
	RemoteRole=ROLE_SimulatedProxy
	ScaleGlow=0.750000
	Style=STY_Translucent
	bUnlit=True
}
