//=============================================================================
// Ammo556Famas.
//=============================================================================
class Ammo556Famas extends DeusExAmmo;


//
// SimUseAmmo - Spawns shell casings client side
//
simulated function bool SimUseAmmo()
{
	local vector offset, tempvec, X, Y, Z;
	local ShellCasing shell;
	local DeusExWeapon W;

	if ( AmmoAmount > 0 )
	{
		GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
		offset = Owner.CollisionRadius * X + 0.3 * Owner.CollisionRadius * Y;
		tempvec = 0.8 * Owner.CollisionHeight * Z;
		offset.Z += tempvec.Z;

		W = DeusExWeapon(Pawn(Owner).Weapon);

      if ((W != None) && ((W.NoiseLevel < 0.1) || W.bHasSilencer))
         shell = spawn(class'ShellCasingSilent',,, Owner.Location + offset);
      else
         shell = spawn(class'ShellCasing',,, Owner.Location + offset);

		shell.RemoteRole = ROLE_None;

		if (shell != None)
		{
			shell.Velocity = (FRand()*20+90) * Y + (10-FRand()*20) * X;
			shell.Velocity.Z = 0;
		}
		return True;
	}
	return False;
}

function bool UseAmmo(int AmountNeeded)
{
	local vector offset, tempvec, X, Y, Z;
	local ShellCasing shell;
	local DeusExWeapon W;

	if (Super.UseAmmo(AmountNeeded))
	{
		GetAxes(Pawn(Owner).ViewRotation, X, Y, Z);
		offset = Owner.CollisionRadius * X + 0.3 * Owner.CollisionRadius * Y;
		tempvec = 0.8 * Owner.CollisionHeight * Z;
		offset.Z += tempvec.Z;

		// use silent shells if the weapon has been silenced
		W = DeusExWeapon(Pawn(Owner).Weapon);
      if ( DeusExMPGame(Level.Game) != None )
      {
			if ( Level.NetMode == NM_ListenServer )
			{
				if ((W != None) && ((W.NoiseLevel < 0.1) || W.bHasSilencer))
					shell = spawn(class'ShellCasingSilent',,, Owner.Location + offset);
				else
					shell = spawn(class'ShellCasing',,, Owner.Location + offset);

				shell.RemoteRole = ROLE_None;
			}
			else
	         shell = None;
      }
      else
      {
         if ((W != None) && ((W.NoiseLevel < 0.1) || W.bHasSilencer))
            shell = spawn(class'ShellCasingSilent',,, Owner.Location + offset);
         else
            shell = spawn(class'ShellCasing',,, Owner.Location + offset);
      }

		if (shell != None)
		{
			shell.Velocity = (FRand()*20+90) * Y + (10-FRand()*20) * X;
			shell.Velocity.Z = 0;
		}
		return True;
	}

	return False;
}

defaultproperties
{
     bShowInfo=True
     AmmoAmount=25
     MaxAmmo=200
     ItemName="5.56mm NATO Magazine"
     ItemArticle="a"
     PickupViewMesh=LodMesh'ContenderStuff.AmmoFamas'
     LandSound=Sound'DeusExSounds.Generic.MetalHit1'
     Icon=Texture'DeusExUI.Icons.BeltIconAmmo762'
     largeIconWidth=46
     largeIconHeight=34
     Description="5.56 x 12 millimeter (NATO) rounds are used in powerful assault rifles, and unlike it's counterpart of which is used in rifles such as the M4A1 carbine, this type of custom made ammuntion delivers more stopping power at the sacrifice of accuracy."
     beltDescription="5.56 x 12MM"
     Mesh=LodMesh'ContenderStuff.AmmoFamas'
     CollisionRadius=6.000000
     CollisionHeight=0.750000
     bCollideActors=True
}
