//=============================================================================
// UBersJumpBoots.
//=============================================================================
class UBersJumpBoots expands UT_JumpBoots;

#exec TEXTURE IMPORT NAME=UBersJBootsNL FILE=SKINS\UBersJBootsNL.bmp GROUP=Skins FLAGS=2

#exec AUDIO IMPORT NAME="JB_GroundLoop" FILE=SOUNDS\JB_GroundLoop.wav GROUP="JumpBoots"
#exec AUDIO IMPORT NAME="JumpBootsPickedUp" FILE=SOUNDS\JumpBootsPickedUp.wav GROUP="JumpBoots"
#exec AUDIO IMPORT NAME="JumpBootsRespawn" FILE=SOUNDS\JumpBootsRespawn.wav GROUP="JumpBoots"

var() sound GroundSound;
var JumpBootsSOver OverFX;

var GoldenDarkOver OvShader;

simulated function PostBeginPlay()
{

	OvShader = Spawn(Class'GoldenDarkOver', Self);
	OvShader.Mesh = Mesh;
	
	OverFX = Spawn(Class'JumpBootsSOver', Self);

	Super.PostBeginPlay();
}


simulated function Destroyed()
{

	if (OvShader != None)
		OvShader.Destroy();
	if (OverFX != None)
		OverFX.Destroy();

	Super.Destroyed();
}


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

	Super.Tick(DeltaTime);
}

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

    if (item.class == class) 
    {
        if ( Charge < 15 )  
	{
                Charge += Item.Charge;
		if (Charge > 15)
			Charge = 15;
	}
            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);
}


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
{
	ActivateSound=None
	RespawnSound=JumpBootsRespawn
	PickupSound=JumpBootsPickedUp
	RotationRate=(Yaw=30000)
	RespawnTime=27.000000
	GroundSound=JB_GroundLoop
	SoundVolume=125
	SoundRadius=45
	MultiSkins(1)=UBersJBootsNL
}