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

Script "Survivalistclass_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("SurvAmmo30")) == (GetAmmoCapacity("SurvAmmo30")) && (CheckInventory("SurvHMGAmmo")) == (GetAmmoCapacity("SurvHMGAmmo"))) { terminate; }
	   GiveInventory("SurvAmmo30", 8*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("SurvHMGAmmo", 20*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Garand Rounds +", i:((8*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & HMG Rounds +", i:((20*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 2: //Shell
    if((CheckInventory("SurvBuckshotShell")) == (GetAmmoCapacity("SurvBuckshotShell")) && (CheckInventory("SurvAutoShell")) == (GetAmmoCapacity("SurvAutoShell"))) { terminate; }
	   GiveInventory("SurvBuckshotShell", 4*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("SurvAutoShell", 6*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Buckshot Shells +", i:((4*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Auto Shells +", i:((6*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 3: //Rocket
   if((CheckInventory("SurvPipebombAmmo")) == (GetAmmoCapacity("SurvPipebombAmmo")) && (CheckInventory("SurvGrenadeAmmo")) == (GetAmmoCapacity("SurvGrenadeAmmo"))) { terminate; }
	   GiveInventory("SurvPipebombAmmo", 1*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("SurvGrenadeAmmo", 1*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Pipebombs +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Frag Grenades +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 4: //Cell 
   if((CheckInventory("SurvAntiMaterialAmmo")) == (GetAmmoCapacity("SurvAntiMaterialAmmo")) && (CheckInventory("SurvFlamethrowerFuel")) == (GetAmmoCapacity("SurvFlamethrowerFuel"))) { terminate; }
   GiveInventory("SurvAntiMaterialAmmo", 1*ammomultiplysave[plr]/ammodividesave[plr]);
   GiveInventory("SurvFlamethrowerFuel", 50*ammomultiplysave[plr]/ammodividesave[plr]);
 message[plr] = strparam(s:"Anti-Material Rounds +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Flamethrower Fuel +", i:((50*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   }
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "AMMO", 4);
   ACS_NamedExecuteWithResult("PostLog", 0, 0, 0, 0);
}

Script "SurvivalistClass_PistolStart" (void)
{ 
	TakeInventory("SurvivalistImpactorGauntlets", 1);
	TakeInventory("SurvivalistTerminator", 1);
	TakeInventory("SurvBuckshotShell", 0);
	TakeInventory("SurvivalistAutoShotgun",1);
	TakeInventory("SurvAutoShell", 0);
	TakeInventory("SurvivalistFragGrenades", 1);
	TakeInventory("SurvivalistPipebombs", 1);
	TakeInventory("SurvPipebombAmmo",0);
	TakeInventory("SurvFragGrenadeAmmo",0);
	TakeInventory("SurvivalistFlamethrower", 1);
	TakeInventory("SurvFlamethrowerFuel", 0);
	TakeInventory("SurvivalistAMR", 1);
	TakeInventory("SurvAntiMaterialAmmo", 0);
}

Script "SurvivalistClass_PickupSystem" (void)
{ 
   
   int plr = PlayerNumber();
   
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "DSWPNUP", 4);
   
     switch(weaponnumbersave[plr])
  {
   case 1: GiveInventory("SurvivalistImpactorGauntlets", 1);  print(s:"\cfGot the Impactor Gauntlets! Time your swings to deflect projectiles!"); ; SetInventory("HasChainsaw", 1); break;
   case 2: GiveInventory("SurvivalistTerminatorShotgun", 1);  print(s:"\cfGot the Terminator Shotgun! They will be terminated!"); SetInventory("HasShotgun", 1); break;
   case 3: GiveInventory("SurvivalistAutoShotgun",1); print(s:"\cfGot the Autoshotgun! Turn 'em into swiss cheese!");  SetInventory("HasSuperShotgun", 1); break;
   case 4: GiveInventory("SurvivalistHMG",1);  print(s:"\cfGot the Heavy Machine Gun! Bring 'em Hell!"); SetInventory("HasChaingun", 1); break;
   case 5: GiveInventory("SurvivalistPipebombs", 1); GiveInventory("SurvivalistFragGrenades", 1);  print(s:"\cfGot some explosives! Frags and Pipebombs!"); SetInventory("HasRocketLauncher", 1); break;
   case 6: GiveInventory("SurvivalistFlamethrower", 1); print(s:"\cfGot the Flamethrower! Burn them to the ground!"); SetInventory("HasPlasmaRifle", 1); break;
   case 7: GiveInventory("SurvivalistAMR", 1); print(s:"\cfGot the Anti-Material Rifle! Time to take out Hell's biggest demons!"); SetInventory("HasBFG9000", 1); break;
   }
   
}

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

    if (StrCmp(CurrentClass, "SurvivalistClass") == 0)
    {
        while (true)
        {
            str CurrentWeapon = GetWeapon();
            if (StrCmp(CurrentWeapon, "SurvivalistAmmoSatchel") != 0)
            {
                GiveInventory("SatchelAmmo", 1);
            }

            delay(2);
        }
    }
}
