class BoltFlareEnd expands BoltFlare;

#exec AUDIO IMPORT NAME="BoltRHitSound" FILE=SOUNDS\BoltRHitSound.wav GROUP="BoltR"
#exec OBJ LOAD FILE=..\Sounds\AmbOutside.uax

var float Splasher, MoreDamage;
var bool HealthGiver;

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


simulated function PostBeginPlay()
{
local X_Electric_CorpseOv XOver;

	Xover = Spawn(class'X_Electric_CorpseOv',,, Location);
	Xover.EffectRadius = 30 * FMax(1.0, Splasher);

	Spawn(class'BotPack.ImpactHole');

	SetTimer(0.1, False);
}


simulated function Timer()
{
local Pawn P;
local int ElecDamage;

	if (Region.Zone.bWaterZone)
	{
		
		if (Role == ROLE_Authority)
		{
		ForEach RadiusActors( Class'Pawn', P, 500, Location)
		{
			ElecDamage = (VSize(P.Location - Location) - 500) / -1;

			if (P.Region.Zone == Region.Zone)
			{
				if (HealthGiver)
				{
				If (((P.PlayerReplicationInfo.Team == Instigator.PlayerReplicationInfo.Team && Level.Game.IsA('TeamGamePlus') && !Level.Game.IsA('MonsterHunt')) ||
				(Level.Game.IsA('MonsterHunt') && !P.IsA('ScriptedPawn')) || P == Instigator)  && P.Health < Class'NWMutator'.default.MaxHealth)
				{
					P.Health += ElecDamage * FMax(1.0, MoreDamage);
					if (P.Health > Class'NWMutator'.default.MaxHealth)
						P.Health = Class'NWMutator'.default.MaxHealth;
				}
				}

				if ((HealthGiver && P != Instigator) || !HealthGiver)
					P.TakeDamage( ElecDamage * FMax(1.0,MoreDamage), Instigator, P.Location, vect(0,0,0), 'Electrified');
			}
		}
		}

		PlaySound (Sound'AmbOutside.OneShot.lightn12', SLOT_Interface, 255.0, True, 50000.0);
		PlaySound (Sound'AmbOutside.OneShot.lightn12', SLOT_None, 255.0, True, 50000.0);
		PlaySound (Sound'AmbOutside.OneShot.lightn12', SLOT_Misc, 255.0, True, 50000.0);
		PlaySound (Sound'AmbOutside.OneShot.lightn12', SLOT_Talk, 255.0, True, 50000.0);

		Spawn(Class'X_ElectricZoned',,, Location);

		ClientFlashes();
	}
	else
		PlaySound(Sound'BoltRHitSound',, 12.0,,100);
}


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

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

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