class VXEnergy expands XEnergy;

#exec TEXTURE IMPORT NAME=VXEnergy FILE=CORONAS\VXEnergy.bmp GROUP=Coronas FLAGS=2
#exec AUDIO IMPORT NAME="Cybot_VX_PullAmb" FILE=SOUNDS\Cybot_VX_PullAmb.wav GROUP="Cybot"

var bool bFirst;
var float CountB;
var byte ParticleNB;
var MegaPurpleRParticles mpp[3];

simulated function Timer()
{
local Actor A;
local GravityTrace gt;
local byte i;

	Super.Timer();

	if (!bFirst)
	{
		bFirst = True;
		AmbientSound=Sound'Cybot_VX_PullAmb';
		SoundRadius = 255;
		SoundVolume = 255;
	}

	For (i=0; i<3; i++)
	{
		gt = Spawn(Class'GravityTrace',,,, RotRand());
		gt.RemoteRole = ROLE_None;
	}

	ForEach VisibleCollidingActors(Class'Actor', A, 1000.0)
	{
		if (A.IsA('Pawn'))
			CheckPawn(Pawn(A));
		else
			CheckActor(A);
	}
}

simulated function Tick( float DeltaTime)
{
	Super.Tick(DeltaTime);

	if (bFirst)
	{
		if (ParticleNB < 3)
		{
		CountB += DeltaTime;

			if (CountB >= 0.33)
			{
				CountB = 0;
				mpp[ParticleNB] = Spawn(Class'MegaPurpleRParticles', Self);
				ParticleNB++;
			}
		}
	}
}

simulated function Destroyed()
{
local byte i;
	
	For (i=0; i<3; i++)
	{
		if (mpp[i] != None)
			mpp[i].Destroy();
	}

	Super.Destroyed();
}

function CheckActor( actor A)
{
	if ((A.IsA('Projectile') || A.IsA('Decoration')) && !A.bStatic)
	{
		if (VSize(Location - A.Location) < 128)
			A.TakeDamage(10000, Instigator, A.Location, vect(0,0,1) * (A.Mass/25) * 10000, 'Gravity');
		else
			A.TakeDamage(0, Instigator, A.Location, Normal(Location - A.Location) * (A.Mass/25) * 10000, 'Gravity');
	}
}

function CheckPawn( pawn P)
{

	if (Level.Game.IsA('DeathMatchPlus'))
	{
		If (TeamGamePlus(Level.Game)!= None && !Level.Game.IsA('MonsterHunt'))
		{
			If (P.PlayerReplicationInfo.Team == Instigator.PlayerReplicationInfo.Team || P==Instigator)
				return;
		}
		else if (!P.IsA('ScriptedPawn') && Level.Game.IsA('MonsterHunt'))
			return;
		else if (P == Instigator && TeamGamePlus(Level.Game) == None)
			return;
	}
	else
	{
		if (P == Instigator)
			return;
		else if (P.IsA('ScriptedPawn') && Instigator.IsA('ScriptedPawn'))
		{
			if (ScriptedPawn(P).TeamTag == ScriptedPawn(Instigator).TeamTag && ScriptedPawn(P).TeamTag != '')
				return;
		}
		else if (Instigator.IsA('PlayerPawn') && (P.AttitudeToPlayer == ATTITUDE_Friendly || P.AttitudeToPlayer == ATTITUDE_Follow))
			return;
	}


	if (VSize(Location - P.Location) < 128)
		P.TakeDamage(10000, Instigator, P.Location, vect(0,0,1) * (P.Mass/25) * 10000, 'Gravity');
	else
		P.TakeDamage(0, Instigator, P.Location, Normal(Location - P.Location) * (P.Mass/25) * 10000, 'Gravity');
		
	MakeSound();
}


defaultproperties
{
	Texture=VXEnergy
	EffectRefreshTime=0.100000
	bTimedEffect=True
	EnergyParticlesType=Class'PurpleRParticles'
}
