//=============================================================================
// Introducing... Wildcards Metal Suit
// Counters: 1337 Snipers
// 
// Because I really hate 1337 snipers who hide in your base and or camp somewhere and not even 
// let you leave your own base or kill you at your supplier and keep doing there annoying 
// magical head shot antics! everybodys such a fucking good sniper i doubt they even try!!!
// yet they can nail a headshot and you will not even see them do it. Usually most players
// in unreal get labled a n00b because there not a 1337 Sniper who never misses or
// a Combo Whore with the asmd bitch rifle. 
// 
// Well time to change weapons! if you try to headshot anyone whearing this awesome Metal Suit 
// it won't do any dameage at all! :) yea you heard me! nothing. also makes you to invulnerable 
// to the minigun and enforcer. This suit is not cheap. it means the person whereing it is tired 
// of you and your 1337 headshots! any other weapon can blow this off like normal armor.
// 
// And this can be combined with the rubber suit for aditional protection!
// Any problems or questions? email: wildcardisnotanoob@email.com
//=============================================================================

class WildcardsMetalSuit expands TournamentPickup;

function MakePlayerShiney(bool shiney)
{
	local Inventory OtherSuits;

	OtherSuits = Pawn(Owner).FindInventoryType(class'WildcardsRubberSuit');

	if (shiney == true)
		{
			if ( Pawn(Owner).Weapon != None )
				
					{
						Owner.SetDisplayProperties(ERenderStyle.STY_Normal,Texture,true,true);
						Pawn(Owner).Weapon.SetDisplayProperties
						(ERenderStyle.STY_Normal,Texture,true,true);
					}
				else
					{
						Owner.SetDisplayProperties(ERenderStyle.STY_Normal,Texture'RubberMetalSuitHybrid',true,true);
						Pawn(Owner).Weapon.SetDisplayProperties
						(ERenderStyle.STY_Normal,Texture'RubberMetalSuitHybrid',true,true);
					}
		}
	else
		{
			if ( OtherSuits == none )
				{
					Pawn(Owner).SetDefaultDisplayProperties();
					Pawn(Owner).Weapon.SetDefaultDisplayProperties();
				}
			else
				{
					Owner.SetDisplayProperties(ERenderStyle.STY_Normal,OtherSuits.Texture,true,true);
					Pawn(Owner).Weapon.SetDisplayProperties(ERenderStyle.STY_Normal,OtherSuits.Texture,true,true);
				}
		}
}

function EndState()
{
	MakePlayerShiney(false);
}

function BeginState()
{
	local Inventory OtherSuits;

	// Well everyone bitched and whined enough so I will make it so you can no longer have both suits
	OtherSuits = Pawn(Owner).FindInventoryType(class'WildcardsRubberSuit');
	if ( OtherSuits != none )
		{
			OtherSuits.destroy();
			OtherSuits = None;
		}

	// Fine... no jetpacks either....
	OtherSuits = Pawn(Owner).FindInventoryType(class'Jetpack');
	if ( OtherSuits != none )
		{
			OtherSuits.destroy();
			OtherSuits = None;
		}

	MakePlayerShiney(true);
}

function ChangedWeapon()
{
	if( Inventory != None )
		MakePlayerShiney(true);
}

function bool HandlePickupQuery( inventory Item )
{
	local inventory S;

	if ( item.class == class ) 
	{
		S = Pawn(Owner).FindInventoryType(class'UT_Shieldbelt');	
		if (  S==None )
		{
			if ( Charge<Item.Charge )	
				Charge = Item.Charge;
		}
		else
			Charge = Clamp(S.Default.Charge - S.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, S;

	Copy = Super.SpawnCopy(Other);
	S = Other.FindInventoryType(class'UT_Shieldbelt');	
	if ( S != None )
	{
		Copy.Charge = Min(Copy.Charge, S.Default.Charge - S.Charge);
		if ( Copy.Charge <= 0 )
		{ 
			S.Charge -= 1;
			Copy.Charge = 1;
		}
	}
	return Copy;
}

function int ArmorAbsorbDamage(int Damage, name DamageType, vector HitLocation)
{
	local int ArmorDamage;

	if ( DamageType != 'Drowned' )
		ArmorImpactEffect(HitLocation);

	if( (DamageType!='None') && ((ProtectionType1==DamageType) || (ProtectionType2==DamageType)) )
		{
			Spawn(class'MetalSuitDeflectFx',,,HitLocation);
        	Owner.PlaySound(Sound'MetalSuitDeflect', SLOT_None,
          	Pawn(Owner).SoundDampening*1.2,,, 1 + (FRand()*0.2 - 0.4));
			return 0;
		}
	
	if (DamageType=='Drowned') Return Damage;
	
	ArmorDamage = (Damage * ArmorAbsorption) / 100;
	if( ArmorDamage >= Charge )
	{
		ArmorDamage = Charge;
		Destroy();
	}
	else 
		Charge -= ArmorDamage;
	return (Damage - ArmorDamage);
}

defaultproperties
{
    PickupMessage="You have found the Metal Suit"
    ItemName="Metal Suit"
    RespawnTime=120.00
    PickupViewMesh=LodMesh'UnrealI.AsbSuit'
    ProtectionType1=shot
    ProtectionType2=Decapitated
    Charge=100
    ArmorAbsorption=80
    bIsAnArmor=True
    AbsorptionPriority=7
    MaxDesireability=2.25
    PickupSound=Sound'UnrealShare.Pickups.ArmorSnd'
    RespawnSound=Sound'SiegeUltimateRC7UB01Media.U.PickUpRespawn'
    Texture=Texture'SiegeUltimateRC7UB01Media.U.MetalSuitSkin'
    Mesh=LodMesh'UnrealI.AsbSuit'
    bUnlit=True
    bMeshEnviroMap=True
}
