//=============================================================================
// UBersArmor. 50 points of armor, 75% absorption
//=============================================================================
class UBersArmor expands Armor2;

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

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

var GoldenDarkOver OvShader;
var ShieldCoronaV Effect1;

simulated function PostBeginPlay()
{

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

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

	Super.PostBeginPlay();
}

simulated function Destroyed()
{

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

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

	Super.Destroyed();
}

function bool HandlePickupQuery( inventory Item )
{

    if ( item.class == class ) 
    {
            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 ( PickupMessageClass == None )
            Pawn(Owner).ClientMessage(PickupMessage, 'Pickup');
        else
            Pawn(Owner).ReceiveLocalizedMessage( PickupMessageClass, 0, None, None, Self.Class );
        Item.PlaySound (PickupSound,,2.0);
        Item.SetReSpawn();
        return true;                
    }
    if ( Inventory == None )
        return false;

    return Inventory.HandlePickupQuery(Item);
}

function inventory SpawnCopy( pawn Other )
{
    local inventory Copy;
    if( Level.Game.ShouldRespawn(self) )
    {
        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;
    Copy.GiveTo( Other );
    return Copy;
}



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=50
     PickupSound=Sound'XPickups.Armor.ArmorSnd'
     RotationRate=(Yaw=30000)
     RespawnTime=27.000000
     CollisionHeight=25.000000
     CollisionRadius=30.000000
     MultiSkins(1)=UBersJarmor2
}
