class NuclearExplosionI expands NuclearExplSets;

#exec AUDIO IMPORT NAME="MegaTon_Explosion" FILE=SOUNDS\MegaTon_Explosion.wav GROUP="MegaTon"

var byte EffectsTiming;
var float Timing;

simulated function PostBeginPlay()
{
	Spawn(Class'CoronaNukeB',,, Location + vect(0,0,280));
	//Spawn(Class'X_NukeCoronaB',,, Location + vect(0,0,280));
	SpawnFirstEffects();
	ClientFlashes();
	SetTimer(0.8, True);
	SpawnShock();
	SpawnNukeHead();
	MakeSound();
}

simulated function SpawnFirstEffects()
{
local NukeColumn NukeC;

	//Mushroom Base
	if (!Region.Zone.bWaterZone)
	{
		Spawn(Class'NukeColumn',,, Location - vect(0,0,14));
		Spawn(Class'NukeColumnThin',,, Location - vect(0,0,14));
		NukeC = Spawn(Class'NukeColumnThin',,, Location - vect(0,0,14));
		NukeC.DrawScale = 0.8;
		NukeC = Spawn(Class'NukeColumnThin',,, Location - vect(0,0,14));
		NukeC.DrawScale = 0.7;
	}

	if (Role == ROLE_Authority)
	{
		Spawn(Class'NukeDustRotA');
		Spawn(Class'NukeDustRotB');
		Spawn(Class'NukeDustRotC');
	}
}

simulated function SpawnNukeHead()
{
local NukeMush NukeM;

	//Mushroom Head
	NukeM = Spawn(Class'NukeMush',,,, rot(0,0,0));
	Spawn(Class'NukeRisingCorona', NukeM);

	Spawn(Class'NukeMush',,,, rot(0,4096,0));
	Spawn(Class'NukeMush',,,, rot(0,8192,0));
	Spawn(Class'NukeMush',,,, rot(0,12288,0));
}

simulated function Tick( float DeltaTime)
{

	if (LifeSpan < 10 && EffectsTiming == 0)
	{
		if (Role == ROLE_Authority)
			Spawn(Class'NuclearRingUp',,, Location + vect(0,0,3000), rot(-16384,0,0));
		EffectsTiming++;
	}
	else if (LifeSpan < 7 && EffectsTiming == 1)
	{
		if (Role == ROLE_Authority)
			Spawn(Class'NuclearRingUp',,, Location + vect(0,0,3800), rot(-16384,0,0));
		EffectsTiming++;
	}

	Timing += DeltaTime;

	if (Timing >= 0.3)
	{
		Timing = 0;
		DoSomeDamage();
	}
}


function DoSomeDamage()
{
	HurtRadius(10000, 2500.0, 'MushroomNuke', 120000, Location);
}


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

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

simulated function Timer()
{
	if (Role == ROLE_Authority)
		Spawn(Class'NukeDust');
}

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

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

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



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