#library "SwatScripts.acs"
#include "zcommon.acs"
#import "CustomFunctions.acs"
#import "PickupScripts.acs"

Script "Swatclass_AmmoPickupSystem" (void)
{  
   int plr = PlayerNumber();

  SetInventory("PickedUp", 0);
 
  int multiplyammo;
  multiplyammo = 1;
  if((GameSkill() == 4) || (GetCVAR("sv_doubleammo") == 1))
  multiplyammo = 2;

  
     switch(ammonumbersave[plr])
  {
  
   case 1: //Clip
   if((CheckInventory("FlashbangGrenadeAmmo")) == (GetAmmoCapacity("FlashbangGrenadeAmmo"))&& (CheckInventory("SWATAssaultRifleRounds")) == (GetAmmoCapacity("SWATAssaultRifleRounds"))) { terminate; }
	   GiveInventory("FlashbangGrenadeAmmo", 1*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("SWATAssaultRifleRounds", 12*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Flashbangs +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Rifle Rounds  +", i:((12*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 2: //Shell
   if((CheckInventory("Shell")) == (GetAmmoCapacity("Shell")) && (CheckInventory("RemingtonSlugs")) == (GetAmmoCapacity("RemingtonSlugs"))) { terminate; }
   GiveInventory("Shell", 4*ammomultiplysave[plr]/ammodividesave[plr]);
     GiveInventory("RemingtonSlugs", 2*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"AA12 Shells +", i:((4*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Remington Slugs  +", i:((2*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 3: //Rocket
   if((CheckInventory("SWATRPG7Rockets")) == (GetAmmoCapacity("SWATRPG7Rockets")) && (CheckInventory("SwatGrenadeAmmo")) == (GetAmmoCapacity("SwatGrenadeAmmo"))) { terminate; }
	   GiveInventory("SWATRPG7Rockets", 1*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("SwatGrenadeAmmo", 2*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"RPG-7 Rockets +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Frag Grenades +", i:((2*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 4: //Cell 
   if((CheckInventory("SwatSniperRifleAmmo")) == (GetAmmoCapacity("SwatSniperRifleAmmo")) && (CheckInventory("SwatMinigunAmmo")) == (GetAmmoCapacity("SwatMinigunAmmo"))) { terminate; }
   GiveInventory("SwatSniperRifleAmmo", 5*ammomultiplysave[plr]/ammodividesave[plr]);
   GiveInventory("SwatMinigunAmmo", 20*ammomultiplysave[plr]/ammodividesave[plr]);
 message[plr] = strparam(s:"Sniper Rounds +", i:((5*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Heavy Minigun Ammo +", i:((20*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   }
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "AMMO", 4);
   ACS_NamedExecuteWithResult("PostLog", 0, 0, 0, 0);
}

Script "SwatClass_PistolStart" (void)
{ 
	TakeInventory("SwatFlashbangs", 1);
	GiveInventory("SwatGlock",1);
	GiveInventory("SwatPistol",1);
	TakeInventory("FlashbangGrenadeAmmo", 0);
	TakeInventory("SwatShotgun", 1);
	TakeInventory("SwatAA12",1);
	TakeInventory("HasSwatGrenades", 1);
	TakeInventory("SwatGrenadeAmmo", 0);
	TakeInventory("SwatRPG7",1);
	TakeInventory("SWATRPG7Rockets",0);
	TakeInventory("UpgradedSwatGlock", 1);
	TakeInventory("UpgradedSwatRifle", 1);
	SetInventory("SWATAssaultRifleRounds", 150);
	TakeInventory("SwatSniperRifle", 1);
	TakeInventory("SniperRifleAmmo", 0);
	TakeInventory("SwatMinigun", 1);
	TakeInventory("MinigunAmmo", 0);
}

Script "SwatClass_PickupSystem" (void)
{ 
   
   int plr = PlayerNumber();
   
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "DSWPNUP", 4);
   
     switch(weaponnumbersave[plr])
  {
   case 1: GiveInventory("SwatFlashbangs", 1);  print(s:"\cfGot your Flashbangs! Stun those demons!"); ; SetInventory("HasChainsaw", 1); break;
   case 2: GiveInventory("SwatShotgun", 1);  print(s:"\cfGot the Remington Model 870!"); SetInventory("HasShotgun", 1); break;
   case 3: GiveInventory("SwatAA12",1); print(s:"\cfGot your AA-12!");  SetInventory("HasSuperShotgun", 1); break;
   case 4: GiveInventory("UpgradedSwatRifle",1); GiveInventory("UpgradedSwatGlock",1); Takeinventory("SwatGlock",1); Takeinventory("SwatRifle",1);  print(s:"\cfGot an upgrade kit for your pistol and rifle!"); SetInventory("HasChaingun", 1); break;
   case 5: GiveInventory("SwatRPG7", 1); GiveInventory("HasSwatGrenades", 1);  print(s:"\cfGot your explosive ordinance! Some Hand Grenades and the RPG-7! Press Zoom to throw a Frag Grenade!"); SetInventory("HasRocketLauncher", 1); break;
   case 6: GiveInventory("SwatSniperRifle", 1); print(s:"\cfGot your Sniper Rifle!"); SetInventory("HasPlasmaRifle", 1); break;
   case 7: GiveInventory("SwatMinigun", 1); print(s:"\cfGot your Minigun! This will take 'em down!"); SetInventory("HasBFG9000", 1); break;
   }
   
}

script "SwatStaminaRecharge" ENTER // Allows the SatchelAmmo to recharge whlie the Satchel is holstered.
{
    str CurrentClass = GetActorClass(0);

    if (StrCmp(CurrentClass, "SwatClass") == 0)
    {
        while (true)
        {
            str CurrentWeapon = GetWeapon();
            if (StrCmp(CurrentWeapon, "SwatFists") != 0)
            {
                GiveInventory("Stamina", 1);
            }

            delay(2);
        }
    }
}
