//=============================================================================
// UBers_ShieldBelt. 100 charge - 100% effective
//=============================================================================
class UBers_ShieldBelt expands ut_ShieldBelt;

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

//Audio import
#exec AUDIO IMPORT NAME="ShieldBeltSnd" FILE=SOUNDS\UT3_Belt.wav GROUP="Armor"
#exec AUDIO IMPORT NAME="ArmourRespawn" FILE=SOUNDS\ArmourRespawn.wav GROUP="Armor"

var ShieldBeltSOver OverFX;
var ShieldCoronaV Effect1;

var GoldShine ShineEffect[3];
var GoldenOver OvShader;


simulated function PostBeginPlay()
{
local byte j;

	For (j=0; j<3; j++)
	{
		ShineEffect[j] = Spawn(Class'GoldShine', Self);
		
		if (j == 0)
		{
			ShineEffect[j].MaxDrawScale = 0.15;
			ShineEffect[j].PrePivotDelta = vect( 15, -6, 8);
		}
		if (j == 1)
		{
			ShineEffect[j].MaxDrawScale = 0.2;
			ShineEffect[j].PrePivotDelta = vect( 1, 19, 1);
		}
		if (j == 2)
		{
			ShineEffect[j].MaxDrawScale = 0.1;
			ShineEffect[j].PrePivotDelta = vect( -12, -16, -1);
		}
	}

	OvShader = Spawn(Class'GoldenOver', Self);
	OvShader.Mesh = Mesh;

	OverFX = Spawn(Class'ShieldBeltSOver', Self);
	Effect1 = Spawn(Class'ShieldCoronaV', Self);

	Super.PostBeginPlay();
}


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

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

	if ( Owner != None )
    {
        Owner.SetDefaultDisplayProperties();
    }
    if ( MyEffect != None )
        MyEffect.Destroy();

    Super(Inventory).Destroyed();
}

function PickupFunction(Pawn Other)
{
    local Inventory I;

    MyEffect = Spawn(class'UT_ShieldBeltEffect', Other,,Other.Location, Other.Rotation); 
    MyEffect.Mesh = Owner.Mesh;
    MyEffect.DrawScale = Owner.Drawscale;

    if ( Level.Game.bTeamGame && (Other.PlayerReplicationInfo != None) )
        TeamNum = Other.PlayerReplicationInfo.Team;
    else
        TeamNum = 3;
    SetEffectTexture();

    I = Pawn(Owner).FindInventoryType(class'UBersInvisibility');
    if ( I != None )
        MyEffect.bHidden = true;
}


function bool HandlePickupQuery( inventory Item )
{
    if (item.class == class) 
    {
        if (bCanHaveMultipleCopies) 
        {   // for items like Artifact
            NumCopies++;
            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();
        }
        else if ( bDisplayableInv ) 
        {       
            if ( Charge<Item.Charge )   
                Charge= Item.Charge;
            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
{
     RespawnSound=ArmourRespawn
     Charge=100
     PickupSound=Sound'XPickups.Armor.ShieldBeltSnd'
     RotationRate=(Yaw=30000)
     RespawnTime=54.000000
     MultiSkins(1)=UBersAUbeltNL
}