//=============================================================================
// 
//=============================================================================
class SecretLocker4 extends DeusExDecoration;

var DeusExPlayer Player;
var int jphail;
var int xphail;
var int antime;

function Frob(Actor Frobber, Inventory frobWith)
{
	if(xphail == 0)
	{
		Player = DeusExPlayer(Frobber);
		jphail = 1;
		xphail = 1;
	}

}

Function Tick(Float DT)
{
	local DeusExPickup hmm;
	local KeyDummy hmm2;
	local DataCubeAdv4 Inv;
	local DataCubeBasic4 Inv2;
	local float rnd;
	local DataCubePro4 Inv3;

	if(jphail == 1)
	{
		JPhail = 0;
		foreach AllActors(class'DataCubeAdv4', Inv)
		{
			if (Inv.Owner == Player)
			{		
				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == False)
					{
						xPhail=0;
						return;
					}
				}

				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == True)
					{
						Inv.Destroy();

					rnd = FRand();
					Player.SkillPointsAdd(750);

					if(rnd < 0.25)
					{
						foreach AllActors(class'DeusExPickup', hmm)
						{
							if(hmm.Owner == Player)
							{
								if(hmm.IsA('FireCone'))
								{
									hmm.NumCopies += 1;
									Player.ClientMessage("You found a "$hmm.Default.ItemName$"");
									xPhail=0;
									return;
								}
							}
						}
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.FireCone');
					}
					else if(rnd < 0.5)
					{
						foreach AllActors(class'DeusExPickup', hmm)
						{
							if(hmm.Owner == Player)
							{
								if(hmm.IsA('SuperTee'))
								{
									hmm.NumCopies += 1;
									Player.ClientMessage("You found a "$hmm.Default.ItemName$"");
									xPhail=0;
									return;
								}
							}
						}
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.SuperTee');
					}
					else if(rnd < 0.75)
					{
						_MMRPGPlayer(Player).CCardz.CreditAmount += 100;
						_MMRPGPlayer(Player).ReceiveMessage("You found 100c.!");
					}
					else
					{
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.WeaponUSP');
					}
						xPhail=0;
						return;
					}
				}
			}
		}


		foreach AllActors(class'DataCubeBasic4', Inv2)
		{
			if (Inv2.Owner == Player)
			{		
				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == False)
					{
						xPhail=0;
						return;
					}
				}

				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == True)
					{
						Inv2.Destroy();

					rnd = FRand();
					Player.SkillPointsAdd(500);

					if(rnd < 0.25)
					{
						foreach AllActors(class'DeusExPickup', hmm)
						{
							if(hmm.Owner == Player)
							{
								if(hmm.IsA('GalaxyChoc2'))
								{
									hmm.NumCopies += 1;
									Player.ClientMessage("You found a "$hmm.Default.ItemName$"");
									xPhail=0;
									return;
								}
							}
						}
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.GalaxyChoc2');
					}
					else if(rnd < 0.5)
					{
						foreach AllActors(class'DeusExPickup', hmm)
						{
							if(hmm.Owner == Player)
							{
								if(hmm.IsA('Coffee'))
								{
									hmm.NumCopies += 1;
									Player.ClientMessage("You found a "$hmm.Default.ItemName$"");
									xPhail=0;
									return;
								}
							}
						}
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.Coffee');
					}
					else if(rnd < 0.75)
					{
						_MMRPGPlayer(Player).CCardz.CreditAmount += 40;
						_MMRPGPlayer(Player).ReceiveMessage("You found 40c.!");
					}
					else
					{
						foreach AllActors(class'DeusExPickup', hmm)
						{
							if(hmm.Owner == Player)
							{
								if(hmm.IsA('MMRPGBarCard'))
								{
									hmm.NumCopies += 1;
									Player.ClientMessage("You found a "$hmm.Default.ItemName$"");
									xPhail=0;
									return;
								}
							}
						}
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.MMRPGBarCard');
					}
						xPhail=0;
						return;
					}
				}
			}
		}

		foreach AllActors(class'DataCubePro4', Inv3)
		{
			if (Inv3.Owner == Player)
			{		
				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == False)
					{
						xPhail=0;
						return;
					}
				}

				foreach AllActors(class'KeyDummy', hmm2)
				{
					if (Player.HandleItemPickup(hmm2, True) == True)
					{
						Inv3.Destroy();

					rnd = FRand();
					Player.SkillPointsAdd(1000);

					if(rnd < 0.25)
					{
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.WeaponWidowMaker');
					}
					else if(rnd < 0.5)
					{
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.NapWeap');
					}
					else if(rnd < 0.75)
					{
						_MMRPGPlayer(Player).CCardz.CreditAmount += 201;
						_MMRPGPlayer(Player).ReceiveMessage("You found 201c.!");
					}
					else
					{
						_MMRPGPlayer(Player).SpawnItemz(Class'Contender.Hax');
					}
						xPhail=0;
						return;
					}
				}
			}
		}

		xPhail=0;
	}
}

//Function Timer()
//{
// Mesh=Mesh'crateShut';
//}


defaultproperties
{
     bInvincible=True
     ItemName="Crate"
     bPushable=False
     Skin=Texture'DeusExDeco.Button1Tex0'
     Physics=PHYS_None
     RemoteRole=ROLE_SimulatedProxy
     Mass=5.000000
     Buoyancy=2.000000
  Mesh=Mesh'crateShut'
  CollisionRadius=24.00000
  CollisionHeight=12.50000
  MultiSkins(0)=Texture'CoreTexWood.Wood.DamgGreyWood01'
  MultiSkins(1)=Texture'NailageEffects.SawDust'
     bCollideWorld=False
     bBlockActors=False
     Mass=5.000000
     Buoyancy=2.000000
     bCanBeBase=True
}
