class NuclearUTIIIExpl expands NuclearExplSets;

#exec AUDIO IMPORT NAME="UT3ExplRemix" FILE=SOUNDS\UT3ExplRemix.wav GROUP="Nuke"

var float TimeCount, IntervalCount;
var NukeBoulder NkB[30];
var byte BCount;

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

simulated function PostBeginPlay()
{
	Spawn(Class'CoronaNukeE');
	SpawnAkira();
	MakeSound();
	SetTimer(1.0, False);
}

function SpawnShock()
{
	Spawn(Class'NuclearMiniShockI');
}

function SpawnAkira()
{
	Spawn(Class'BigShockwaveIII');
}

function MakeSound()
{
	PlaySound (Sound'UT3ExplRemix', SLOT_Interface, 255.0, True, 20000.0);
	PlaySound (Sound'UT3ExplRemix', SLOT_None, 255.0, True, 20000.0);
	PlaySound (Sound'UT3ExplRemix', SLOT_Misc, 255.0, True, 20000.0);
	PlaySound (Sound'UT3ExplRemix', SLOT_Talk, 255.0, True, 20000.0);
}

simulated function Timer()
{
local byte i;

	For (i=0; i<30; i++)
	{
		if (NkB[i] != None)
			NkB[i].Velocity = Normal(NkB[i].Location - Location)*300000;
	}

	ClientFlashes();
	SpawnShock();
}


simulated function ClientFlashes()
{
local Vector EndFlashFog;
local float f;
local PlayerPawn p;

	//EndFlashFog.X=1;	EndFlashFog.Y=3;	EndFlashFog.Z=0;
	EndFlashFog.X=3;	EndFlashFog.Y=1;	EndFlashFog.Z=0;

	ForEach VisibleActors( class'PlayerPawn', p)
		p.ClientFlash( 2, 1000*EndFlashFog );
}

function SpawnNukeBoulder(byte b, float BSize)
{
local float XRel, YRel, SizeRel, RelRot;
local vector X, Y, Z, AngLoc;
local rotator AngRot;

	SizeRel = BSize * 1200;
	RelRot = Rand(360) * pi / 180;
	XRel = SizeRel * sin(RelRot);
	YRel = SizeRel * cos(RelRot);

	GetAxes(Rotation, X, Y, Z);
	AngLoc = Location + 8*X + YRel*Y + XRel*Z;
	AngRot = rotator(AngLoc - Location);
	
	NkB[b] = Spawn(Class'NukeBoulder',,, AngLoc, AngRot);

	if (NkB[b] != None)
		NkB[b].Velocity = vector(Rotation) * (1 - BSize) * 1200;
}

simulated function Tick(float DeltaTime)
{
	TimeCount += DeltaTime;

	if (IntervalCount == 0 && BCount<30)
	{
		SpawnNukeBoulder(BCount, TimeCount);
		BCount++;
	}
	
	IntervalCount += DeltaTime;

	if (IntervalCount >= 0.0375)
		IntervalCount = 0;
}



defaultproperties
{
	Texture=GravityLight
	DrawScale=0.200000
	LifeSpan=1.500000
	RemoteRole=ROLE_SimulatedProxy
	bHidden=True
	bNetTemporary=False
	NetPriority=2.000000
	bAlwaysRelevant=True
}