//=============================================================================
// UBersInvisibility.
//=============================================================================
class UBersInvisibility expands UT_invisibility;

//Model Import
#exec mesh import mesh=UTInvisibility2M anivfile=Models\UTInvisibility2M_a.3d datafile=Models\UTInvisibility2M_d.3d x=0 y=0 MLOD=1 LODSTYLE=0
#exec MESH LODPARAMS MESH=UTInvisibility2M STRENGTH=0.25
#exec mesh origin mesh=UTInvisibility2M x=0 y=0 z=0
#exec mesh sequence mesh=UTInvisibility2M seq=All startframe=0 numframes=1

#exec meshmap new meshmap=UTInvisibility2M mesh=UTInvisibility2M
#exec meshmap scale meshmap=UTInvisibility2M x=0.09 y=0.09 z=0.18

//Audio import
#exec AUDIO IMPORT NAME="InvisibilityEnd" FILE=SOUNDS\InvisibilityEnd.wav GROUP="Invisibility"
#exec AUDIO IMPORT NAME="InvisibilityWarning" FILE=SOUNDS\InvisibilityWarning.wav GROUP="Invisibility"
#exec AUDIO IMPORT NAME="InvisibilityPickup" FILE=SOUNDS\InvisibilityPickup.wav GROUP="Invisibility"
#exec AUDIO IMPORT NAME="InvisibiltyRespawn" FILE=SOUNDS\InvisibiltyRespawn.wav GROUP="Invisibility"

//Skins import
#exec TEXTURE IMPORT NAME=InvSkin00 FILE=SKINS\New18AStL.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin00 FILE=SKINS\New18AStL.pcx GROUP=Skins PALETTE=InvSkin00
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=0 TEXTURE=InvSkin00

#exec TEXTURE IMPORT NAME=InvSkin01 FILE=SKINS\CBotT3.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin01 FILE=SKINS\CBotT3.pcx GROUP=Skins PALETTE=InvSkin01
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=1 TEXTURE=InvSkin01

#exec TEXTURE IMPORT NAME=InvSkin02 FILE=SKINS\PBflr06b_InvisCS.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin02 FILE=SKINS\PBflr06b_InvisCS.pcx GROUP=Skins PALETTE=InvSkin02
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=2 TEXTURE=InvSkin02

#exec TEXTURE IMPORT NAME=InvSkin03 FILE=SKINS\light01Tex.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin03 FILE=SKINS\light01Tex.pcx GROUP=Skins PALETTE=InvSkin03
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=3 TEXTURE=InvSkin03

#exec TEXTURE IMPORT NAME=InvSkin04 FILE=SKINS\PBbas18AL.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin04 FILE=SKINS\PBbas18AL.pcx GROUP=Skins PALETTE=InvSkin04
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=4 TEXTURE=InvSkin04

#exec TEXTURE IMPORT NAME=InvSkin05 FILE=SKINS\PBbas03HA.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvSkin05 FILE=SKINS\PBbas03HA.pcx GROUP=Skins PALETTE=InvSkin05
#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=5 TEXTURE=InvSkin05

#exec MESHMAP SETTEXTURE MESHMAP=UTInvisibility2M NUM=6 TEXTURE=UnrealShare.Belt_fx.Invis.Invis

//-----------------------------------------------------------------------

var() sound InvWarnSound;

var int FinalCount;
var int i;
var Weapon InvisibleWeapon;

var() name WearedOffEvent;
var() name DroppedEvent;
var() name ReActivateEvent;
var float BugFixC;
var bool AlreadyDone;

var bool bDroppedNWaiting;

var() sound GroundSound, UseSound;
var AmbientSTrail ast;

var InvisEffect Effect1[3];
var InvisCoronaV Effect2;
var InvisCoronaH Effect3A, Effect3B, Effect3C, Effect3D;

var float EffectTimeCountA, EffectTimeCountB;
var bool bEffectSpawnedA, bEffectSpawnedB;

var name WOEvent[32];
var name DEvent[32];
var name RAEvent[32];

var() byte UseSoundRadius, UseSoundVol;

replication
{
    reliable if( Role==ROLE_Authority)
	bDroppedNWaiting;
}


simulated function PostBeginPlay()
{
	Effect1[0] = Spawn(Class'InvisEffect', Self);
	Effect2 = Spawn(Class'InvisCoronaV', Self);
	Effect3A = Spawn(Class'InvisCoronaH', Self);
	Effect3A.PrePivotDelta = vect(18,1,15.5);
	Effect3B = Spawn(Class'InvisCoronaH', Self);
	Effect3B.PrePivotDelta = vect(-18,1,15.5);
	Effect3C = Spawn(Class'InvisCoronaHMini', Self);
	Effect3C.PrePivotDelta = vect(-7.2,2,-19.5);
	Effect3D = Spawn(Class'InvisCoronaHMini', Self);
	Effect3D.PrePivotDelta = vect(7.2,2,-19.5);

	Super.PostBeginPlay();
}

simulated function Destroyed()
{
local Actor A;
local int i;
local byte bj;

	if (WearedOffEvent != '' && (Charge <= 0 || bDroppedNWaiting))
	{
	ForEach AllActors( class 'Actor', A, WearedOffEvent)
                		A.Trigger( Self, Instigator );

		For (bj=0; bj<32; bj++)
		{
			if (WOEvent[bj] != '')
			{
				ForEach AllActors( class 'Actor', A, WOEvent[bj])
                			A.Trigger( Self, Instigator );
			}
		}
	}

	if (DroppedEvent != '' && Charge > 0 && Pawn(Owner)!=None)
	{
	ForEach AllActors( class 'Actor', A, DroppedEvent)
                		A.Trigger( Self, Instigator );
		
		For (bj=0; bj<32; bj++)
		{
			if (DEvent[bj] != '')
			{
				ForEach AllActors( class 'Actor', A, DEvent[bj])
                			A.Trigger( Self, Instigator );
			}
		}
	}

	for (i=0; i<3; i++)
	{
		if (Effect1[i] != None)
			Effect1[i].Destroy();
	}

	if (Effect2 != None)
		Effect2.Destroy();

	if (Effect3A != None)
		Effect3A.Destroy();
	if (Effect3B != None)
		Effect3B.Destroy();
	if (Effect3C != None)
		Effect3C.Destroy();
	if (Effect3D != None)
		Effect3D.Destroy();

	if (ast != None)
		ast.Destroy();

	if (Charge > 0 && !bDroppedNWaiting)
		DropACopy();

	if (Pawn(Owner) == None && !bHidden)
		Level.Game.PlaySpawnEffect(Self);

	Super.Destroyed();
}


function DropACopy()
{
local UBersInvisibility BS;
local vector PossibleLoc, HitLocation, HitNormal;
local actor AT;
local byte bj;

	PossibleLoc = Pawn(Owner).Location + (Rand(128) - 64)*vect(1,0,0) + (Rand(128) - 64)*vect(0,1,0);
	AT = Trace (HitLocation, HitNormal, PossibleLoc, Pawn(Owner).Location, False);

	if (AT == None)
		BS = Spawn(Class'UBersInvisibility', None,, PossibleLoc, Rand(32768) * rot(0,1,0));
	else
		BS = Spawn(Class'UBersInvisibility', None,, Pawn(Owner).Location, Rand(32768) * rot(0,1,0));

	BS.bDroppedNWaiting = True;
	BS.Charge = Charge;
	BS.Event = Event;
	BS.WearedOffEvent = WearedOffEvent;
	BS.SetPhysics(PHYS_Falling);
	BS.bRotatingPickup = False;
	BS.RotationRate = rot(0,0,0);
	BS.Tag = Tag;
	BS.bFixedRotationDir = False;
	BS.ReActivateEvent = ReActivateEvent;
	BS.DroppedEvent = DroppedEvent;
	BS.LifeSpan = 20.0;

	For (bj=0; bj<32; bj++)
	{
		BS.WOEvent[bj] = WOEvent[bj];
		BS.DEvent[bj] = DEvent[bj];
		BS.RAEvent[bj] = RAEvent[bj];
	}
}

function inventory SpawnCopy( pawn Other )
{
    local inventory Copy;

    if( Level.Game.ShouldRespawn(self) && !bDroppedNWaiting)
    {
        Copy = spawn(Class,Other,,,rot(0,0,0));
        Copy.Tag           = Tag;
        Copy.Event         = Event;
        GotoState('Sleeping');
    }
    else
        Copy = self;

    Copy.RespawnTime = 0.0;
    Copy.bHeldItem = true;
	UBersInvisibility(Copy).WearedOffEvent = WearedOffEvent;
	UBersInvisibility(Copy).DroppedEvent = DroppedEvent;
	UBersInvisibility(Copy).ReActivateEvent = ReActivateEvent;
    Copy.Charge = Charge;
    Copy.GiveTo( Other );
    return Copy;
}


function bool HandlePickupQuery( inventory Item )
{
local byte bj, bi;
local bool bHaveThisEventReg;

    if (item.class == class) 
    {
        if ( Charge < 999 )  
	{
                Charge += Item.Charge;
		if (Charge > 999)
			Charge = 999;

		//Events management
		///////////////////////////////////////////////////////////

		if (WearedOffEvent == '')
			WearedOffEvent = UbersInvisibility(Item).WearedOffEvent;
		if (DroppedEvent == '')
			DroppedEvent = UbersInvisibility(Item).DroppedEvent;

		if (WearedOffEvent != UbersInvisibility(Item).WearedOffEvent)
		{
			bHaveThisEventReg = False;
			For (bj=0; bj<32; bj++)
			{
				if (WOEvent[bj] == UbersInvisibility(Item).WearedOffEvent)
				{
					bHaveThisEventReg = True;
					break;
				}
			}

			if (!bHaveThisEventReg)
			{
				For (bj=0; bj<32; bj++)
				{
					if (WOEvent[bj] == '')
					{
						WOEvent[bj] = UbersInvisibility(Item).WearedOffEvent;
						break;
					}
				}
			}
		}

		if (DroppedEvent != UbersInvisibility(Item).DroppedEvent)
		{
			bHaveThisEventReg = False;
			For (bj=0; bj<32; bj++)
			{
				if (DEvent[bj] == UbersInvisibility(Item).DroppedEvent)
				{
					bHaveThisEventReg = True;
					break;
				}
			}

			if (!bHaveThisEventReg)
			{
				For (bj=0; bj<32; bj++)
				{
					if (DEvent[bj] == '')
					{
						DEvent[bj] = UbersInvisibility(Item).DroppedEvent;
						break;
					}
				}
			}
		}

		if (ReActivateEvent != UbersInvisibility(Item).ReActivateEvent)
		{
			bHaveThisEventReg = False;
			For (bj=0; bj<32; bj++)
			{
				if (RAEvent[bj] == UbersInvisibility(Item).ReActivateEvent)
				{
					bHaveThisEventReg = True;
					break;
				}
			}

			if (!bHaveThisEventReg)
			{
				For (bj=0; bj<32; bj++)
				{
					if (RAEvent[bj] == '')
					{
						RAEvent[bj] = UbersInvisibility(Item).ReActivateEvent;
						break;
					}
				}
			}
		}

		For (bj=0; bj<32; bj++)
		{
			if (UbersInvisibility(Item).WOEvent[bj] != '')
			{
				bHaveThisEventReg = False;
				For (bi=0; bi<32; bi++)
				{
					if (UbersInvisibility(Item).WOEvent[bj] == WOEvent[bi])
					{
						bHaveThisEventReg = True;
						break;
					}
				}

				
				if (!bHaveThisEventReg)
				{
					For (bi=0; bi<32; bi++)
					{
						if (WOEvent[bi] == '')
						{
							WOEvent[bi] = UbersInvisibility(Item).WOEvent[bj];
							break;
						}
					}
				}
				
			}
			else
				break;
		}


		For (bj=0; bj<32; bj++)
		{
			if (UbersInvisibility(Item).DEvent[bj] != '')
			{
				bHaveThisEventReg = False;
				For (bi=0; bi<32; bi++)
				{
					if (UbersInvisibility(Item).DEvent[bj] == DEvent[bi])
					{
						bHaveThisEventReg = True;
						break;
					}
				}

				
				if (!bHaveThisEventReg)
				{
					For (bi=0; bi<32; bi++)
					{
						if (DEvent[bi] == '')
						{
							DEvent[bi] = UbersInvisibility(Item).DEvent[bj];
							break;
						}
					}
				}
				
			}
			else
				break;
		}

		For (bj=0; bj<32; bj++)
		{
			if (UbersInvisibility(Item).RAEvent[bj] != '')
			{
				bHaveThisEventReg = False;
				For (bi=0; bi<32; bi++)
				{
					if (UbersInvisibility(Item).RAEvent[bj] == RAEvent[bi])
					{
						bHaveThisEventReg = True;
						break;
					}
				}

				
				if (!bHaveThisEventReg)
				{
					For (bi=0; bi<32; bi++)
					{
						if (RAEvent[bi] == '')
						{
							RAEvent[bi] = UbersInvisibility(Item).RAEvent[bj];
							break;
						}
					}
				}
				
			}
			else
				break;
		}
			

		if (Event == '')
			Event = UbersInvisibility(Item).Event;
		////////////////////////////////////////////////////////////////////////////////////
	}
            if (Level.Game.LocalLog != None)
                Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
            if (Level.Game.WorldLog != None)
                Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
            if ( Item.PickupMessageClass == None )
                Pawn(Owner).ClientMessage(item.PickupMessage, 'Pickup');
            else
                Pawn(Owner).ReceiveLocalizedMessage( item.PickupMessageClass, 0, None, None, item.Class );
            Item.PlaySound (item.PickupSound,,2.0);
            Item.SetReSpawn();

        return true;        
    }

    if ( Inventory == None )
        return false;

    return Inventory.HandlePickupQuery(Item);
}


singular function UsedUp()
{

	if ( InvisibleWeapon != None )
	{
		InvisibleWeapon.SetDefaultDisplayProperties();
	}

	if ( Owner != None )
	{
		if ( Owner.bIsPawn )
		{
			if ( !Pawn(Owner).bIsPlayer || (Pawn(Owner).PlayerReplicationInfo.HasFlag == None) )
			{
				Owner.AmbientGlow = Owner.Default.AmbientGlow;
				Owner.LightType = LT_None;
			}
		}

		bActive = false;

		if ( Owner.Inventory != None )
		{
			Owner.Inventory.SetOwnerDisplay();
			Owner.Inventory.ChangedWeapon();
		}

		if (Level.Game.LocalLog != None)
			Level.Game.LocalLog.LogItemDeactivate(Self, Pawn(Owner));
		if (Level.Game.WorldLog != None)
			Level.Game.WorldLog.LogItemDeactivate(Self, Pawn(Owner));
	}
	Destroy();
}



function SetInvisibleGuy()
{
	if ( !bActive )
		return;

	Owner.SetDisplayProperties(ERenderStyle.STY_Translucent, 
							 FireTexture'unrealshare.Belt_fx.Invis',
							 true,
							 true);
}


function SetInvisibleWeapon()
{
	if ( !bActive )
		return;

	SetOwnerLighting();

	// Make old weapon normal again.
	if ( InvisibleWeapon != None )
	{
		InvisibleWeapon.SetDefaultDisplayProperties();
	}
	
	InvisibleWeapon = Pawn(Owner).Weapon;

	// Make new weapon invisible.
	if ( InvisibleWeapon != None)
	{
	if (!InvisibleWeapon.IsA('BersChainSaw') && !InvisibleWeapon.IsA('UbersImpactHammer') && !InvisibleWeapon.IsA('UBersEnforcer') && !InvisibleWeapon.IsA('UbersUT_Biorifle')
 && !InvisibleWeapon.IsA('UBersShockRifle') && !InvisibleWeapon.IsA('UBersSuperShockRifle') && !InvisibleWeapon.IsA('UBersPulseGun') && !InvisibleWeapon.IsA('UBersRipper')
 && !InvisibleWeapon.IsA('UBersMinigun2') && !InvisibleWeapon.IsA('UBersUT_FlakCannon') && !InvisibleWeapon.IsA('UBersUT_Eightball') && !InvisibleWeapon.IsA('UBersSniperRifle')
 && !InvisibleWeapon.IsA('UBersWarheadLauncher') && !InvisibleWeapon.IsA('UBersTranslocator'))
	{

		if ( Pawn(Owner).Weapon != None )
			Pawn(Owner).Weapon.SetDisplayProperties(ERenderStyle.STY_Translucent, 
									 FireTexture'Unrealshare.Belt_fx.Invis',
									 true,
									 true);

	}

		if (InvisibleWeapon.IsA('BersChainSaw'))
			BersChainSaw(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UbersImpactHammer'))
			UbersImpactHammer(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersEnforcer'))
			UBersEnforcer(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UbersUT_Biorifle'))
			UbersUT_Biorifle(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersShockRifle'))
			UBersShockRifle(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersSuperShockRifle'))
			UBersSuperShockRifle(InvisibleWeapon).SetPickupSkins();
		else if (InvisibleWeapon.IsA('UBersPulseGun'))
			UBersPulseGun(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersRipper'))
			UBersRipper(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersMinigun2'))
			UBersMinigun2(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersUT_FlakCannon'))
			UBersUT_FlakCannon(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersUT_Eightball'))
			UBersUT_Eightball(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersSniperRifle'))
			UBersSniperRifle(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersWarheadLauncher'))
			UBersWarheadLauncher(InvisibleWeapon).SetTranslucentWeapon();
		else if (InvisibleWeapon.IsA('UBersTranslocator'))
			UBersTranslocator(InvisibleWeapon).SetTranslucentWeapon();

	}
}




function SetOwnerLighting()
{

	if ( Owner != None )
	{
		if ( Owner.bIsPawn )
		{
			if ( !Pawn(Owner).bIsPlayer || 

(Pawn(Owner).PlayerReplicationInfo.HasFlag == None) )
			{
				Owner.AmbientGlow = Owner.Default.AmbientGlow;
				Owner.LightType = LT_None;
			}
		}
	}
}

simulated function Tick(float DeltaTime)
{
	if (!bHidden && Pawn(Owner) == None && AmbientSound != GroundSound)
		AmbientSound = GroundSound;
	else if (bHidden && AmbientSound == GroundSound)
		AmbientSound = None;


	if (!bEffectSpawnedA)
		EffectTimeCountA += DeltaTime;

	if (!bEffectSpawnedA && EffectTimeCountA > 1.67)
	{
		bEffectSpawnedA = True;
		Effect1[1] = Spawn(Class'InvisEffect', Self);
	}


	if (!bEffectSpawnedB)
		EffectTimeCountB += DeltaTime;

	if (!bEffectSpawnedB && EffectTimeCountB > 3.34)
	{
		bEffectSpawnedB = True;
		Effect1[2] = Spawn(Class'InvisEffect', Self);
	}

	if ((Region.Zone.bDestructive || Region.Zone.bKillZone || Region.Zone.DamagePerSec > 0) && Pawn(Owner) == None)
	{
		Charge = 0;
		Destroy();
	}
}

simulated function SpawnAS()
{
	ast = Spawn(Class'AmbientSTrail', Pawn(Owner));
	ast.AmbientSound = UseSound;
	ast.SoundRadius = UseSoundRadius;
	ast.SoundVolume = UseSoundVol;
}


state Activated
{


function EndState()
{
local Inventory S;

		Owner.SetDefaultDisplayProperties();
		S = Pawn(Owner).FindInventoryType(class'Ubers_ShieldBelt');
		if ( (S != None) && (Ubers_ShieldBelt(S).MyEffect != None) )
			Ubers_ShieldBelt(S).MyEffect.bHidden = false;

		S = Pawn(Owner).FindInventoryType(class'BattleSuit');
		if ( (S != None) && (BattleSuit(S).MyEffect != None) )
			BattleSuit(S).MyEffect.bHidden = false;

		UsedUp();
}


function SetOwnerDisplay()
	{

		if( Inventory != None )
			Inventory.SetOwnerDisplay();

		SetInvisibleGuy();
		SetInvisibleWeapon();

	}

//Little quick bug fix, until I realize why exacly it happens :)
	//--------------------------------
	simulated function Tick( float DeltaTime)
	{
		BugFixC += DeltaTime;

		if (BugFixC >= 0.04)
		{
			BugFixC = 0;
			if (Pawn(Owner).FindInventoryType(Class'BattleSuit')==None && !AlreadyDone)
			{
				SetInvisibleWeapon();
				AlreadyDone = True;
			}
			else if (Pawn(Owner).FindInventoryType(Class'BattleSuit')!=None)
			{
				AlreadyDone = False;
			}
		}

		if ((Pawn(Owner).FindInventoryType(Class'UBerseker') != None || Pawn(Owner).FindInventoryType(Class'UbersUDamage') != None) && ast!=None)
		{
			ast.Destroy();
			ast = None;
		}
		else if (ast==None && (Pawn(Owner).FindInventoryType(Class'UBerseker') == None && Pawn(Owner).FindInventoryType(Class'UbersUDamage') == None))
		{
			ast = Spawn(Class'AmbientSTrail', Pawn(Owner));
			ast.AmbientSound = UseSound;
			ast.SoundRadius = UseSoundRadius;
			ast.SoundVolume = UseSoundVol;
		}
	}
	//--------------------------------


function ChangedWeapon()
	{

		if( Inventory != None )
			Inventory.ChangedWeapon();

		SetInvisibleWeapon();
	}


	function Timer()
	{

		Charge--;

		if (Charge <= FinalCount && Charge>0)
		{
			SetTimer(0.7, False);
			Owner.PlaySound(InvWarnSound,, 8);
		}
		else if (Charge <= 0)
		{
			Owner.PlaySound(DeactivateSound,, 8);
			UsedUp();
		}
		else
			SetTimer(1.0, False);
	}



function BeginState()
{
local Inventory S;
local Actor A;
local byte bj;

bActive = true;
LifeSpan = 0.0;
AmbientSound = None;

Pawn(Owner).Visibility = 10;

FinalCount = Min(FinalCount, Charge - 1);
		SetTimer(1.0,false);

		PlaySound(ActivateSound,,4.0);

		SetInvisibleGuy();
		SetInvisibleWeapon();

		S = Pawn(Owner).FindInventoryType(class'Ubers_ShieldBelt');
		if ( (S != None) && (Ubers_ShieldBelt(S).MyEffect != None) )
			Ubers_ShieldBelt(S).MyEffect.bHidden = True;

		S = Pawn(Owner).FindInventoryType(class'BattleSuit');
		if ( (S != None) && (BattleSuit(S).MyEffect != None) )
			BattleSuit(S).MyEffect.bHidden = True;

		if (ReActivateEvent != '' && bDroppedNWaiting)
		{
			ForEach AllActors( class 'Actor', A, ReActivateEvent)
                		A.Trigger( Self, Instigator );

		For (bj=0; bj<32; bj++)
		{
			if (RAEvent[bj] != '')
			{
				ForEach AllActors( class 'Actor', A, RAEvent[bj])
                			A.Trigger( Self, Instigator );
			}
		}

		}

		bDroppedNWaiting = False;

		SpawnAS();

}

}


State Sleeping
{
    ignores Touch;

    function BeginState()
    {
        BecomePickup();
        bHidden = true;
    }
    function EndState()
    {
        local int i;

        bSleepTouch = false;
        for ( i=0; i<4; i++ )
            if ( (Touching[i] != None) && Touching[i].IsA('Pawn') )
                bSleepTouch = true;
    }           
Begin:
    Sleep( ReSpawnTime );
    Sleep( XPlaySpawnEffect(self) );
    GoToState( 'Pickup' );
}


function float XPlaySpawnEffect(inventory Inv)
{
    spawn(class 'EnhancedReSpawnX',Inv,, Inv.Location );
    return 0.3;
}


defaultproperties
{
	LODBias=0.750000
	RespawnSound=InvisibiltyRespawn
	FinalCount=4
	InvWarnSound=Sound'XPickups.Invisibility.InvisibilityWarning'
	DeactivateSound=Sound'XPickups.Invisibility.InvisibilityEnd'
	PickupSound=Sound'XPickups.Invisibility.InvisibilityPickup'
	Charge=30
	RespawnTime=82.000000
	Mesh=Mesh'XPickups.UTInvisibility2M'
	PickupviewMesh=Mesh'XPickups.UTInvisibility2M'
	bRotatingPickup=True
	RotationRate=(Yaw=30000)
	ActivateSound=None
	SoundVolume=125
	SoundRadius=45
	GroundSound=Invis_GroundLoop
	UseSound=Invis_PowerLoop
	MaxDesireability=4.000000
	PickupMessage="INVISIBILITY"
	UseSoundRadius=20
	UseSoundVol=255
}