//----------------------------------------------------------------------------

datablock AudioProfile(TurretPackActivateSound)
{
	filename = "fx/packs/turret_place.wav";
	description = AudioClose3D;
   preload = true;
};


//----------------------------------------------------------------------------

function Pack::onUse(%data,%obj)
{
   if (%obj.getMountedImage($BackpackSlot) != %data.image.getId())
      %obj.mountImage(%data.image,$BackpackSlot);
   else
   {
      // Toggle the image trigger.
      %obj.setImageTrigger($BackpackSlot,
         !%obj.getImageTrigger($BackpackSlot));
   }
}

function Pack::onInventory(%data,%obj,%amount)
{
	//only do this for players
	if(%obj.getClassName() !$= "Player")
		return;

   // Auto-mount the packs on players
   if((%oldPack = %obj.getMountedImage($BackpackSlot)) != 0)
      %obj.setInventory(%oldPack.item, 0);
   if (%amount && %obj.getDatablock().className $= Armor)
   {
		// if you picked up another pack after you placed a satchel charge but
		// before you detonated it, delete the charge
		if(%obj.thrownChargeId > 0)
		{
			%obj.thrownChargeId.delete();
			%obj.thrownChargeId = 0;
		}
      %obj.mountImage(%data.image,$BackpackSlot);
	   %obj.client.setBackpackHudItem(%data.getName(), 1);   
	}
	if(%amount == 0)
	   %obj.client.setBackpackHudItem(%data.getName(), 0);
   ItemData::onInventory(%data,%obj,%amount);
}   

//----------------------------------------------------------------------------

// --- packs
exec("scripts/packs/AmmoPack.cs");
exec("scripts/packs/AutoRocketPack.cs");
exec("scripts/packs/CloakingPack.cs");
exec("scripts/packs/EnergyPack.cs");
exec("scripts/packs/JetPack.cs");
exec("scripts/packs/SatchelCharge.cs");
exec("scripts/packs/RepairPack.cs");
exec("scripts/packs/ShieldPack.cs");
exec("scripts/packs/SensorJammerpack.cs");
