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

Script "CameronClass_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("CamPistolAmmo")) == (GetAmmoCapacity("CamPistolAmmo")) && (CheckInventory("CamChaingunAmmo")) == (GetAmmoCapacity("CamChaingunAmmo"))) { terminate; }
	   GiveInventory("CamPistolAmmo", 10*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("CamChaingunAmmo", 20*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Light Corrosive Rounds +", i:((10*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Corrosive Heavy Rounds  +", i:((20*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 2: //Shell
   if((CheckInventory("CamShell")) == (GetAmmoCapacity("CamShell")) && (CheckInventory("CamRifleAmmo")) == (GetAmmoCapacity("CamRifleAmmo"))) { terminate; }
	   GiveInventory("CamShell", 4*ammomultiplysave[plr]/ammodividesave[plr]);
	   GiveInventory("CamRifleAmmo", 10*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Corrosive Shells +", i:((4*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo), s:" & Corrosive Medium Rounds  +", i:((10*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   case 3: //Rocket
   if((CheckInventory("CamRocketAmmo")) == (GetAmmoCapacity("CamRocketAmmo"))) { terminate; }
	   GiveInventory("CamRocketAmmo", 1*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Rockets +", i:((1*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
  case 4: //Cell 
   if((CheckInventory("CamPlasmaAmmo")) == (GetAmmoCapacity("CamPlasmaAmmo"))) { terminate; }
   GiveInventory("CamPlasmaAmmo", 20*ammomultiplysave[plr]/ammodividesave[plr]);
   message[plr] = strparam(s:"Energy Cells +", i:((20*ammomultiplysave[plr]/ammodividesave[plr])*multiplyammo));
   break;
   }
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "AMMO", 4);
   ACS_NamedExecuteWithResult("PostLog", 0, 0, 0, 0);
}

Script "CameronClass_PistolStart" (void)
{ 
	TakeInventory("CamShotgun", 1);
	SetInventory("CamShotgunMagazine",8);
	TakeInventory("CamSuperShotgun", 0);
	TakeInventory("CamShell", 0);
	TakeInventory("CamChaingunAmmo", 0);
	TakeInventory("CamChaingun", 1);
	SetInventory("CamPistolAmmo",36);
	SetInventory("CamRifleAmmo",90);
	SetInventory("CamPistolMagazine",12);
	SetInventory("CamChaingunBelt",100);
	SetInventory("CamRifleMagazine",60);
	SetInventory("CamRocketPack",5);
	SetInventory("CamLaserCell",50);
	TakeInventory("CamRL", 1);
	TakeInventory("CamRocketAmmo", 0);
	TakeInventory("CamLaserCannon", 1);
	TakeInventory("CamPlasmaAmmo", 0);
}

Script "CameronClass_PickupSystem" (void)
{ 
   
   int plr = PlayerNumber();
   
   GiveInventory("PickupBlend", 1);
   PlaySound(0, "DSWPNUP", 4);
   
     switch(weaponnumbersave[plr])
  {
   case 1: print(s:"\cfYou got... nothing?"); ; SetInventory("HasChainsaw", 1); break;
   case 2: GiveInventory("CamShotgun", 1);  print(s:"\cfYou got the Spas-12!"); SetInventory("HasShotgun", 1); break;
   case 3: GiveInventory("CamSuperShotgun",1); print(s:"\cfGot the Double Shotgun!");  SetInventory("HasSuperShotgun", 1); break;
   case 4:GiveInventory("CamChaingun",1);  print(s:"\cfYou got the Chaingun!"); SetInventory("HasChaingun", 1); break;
   case 5: GiveInventory("CamRL", 1);  print(s:"\cfYou got the Rocket Launcher!"); SetInventory("HasRocketLauncher", 1); break;
   case 6: GiveInventory("CamLaserCannon", 1); print(s:"\cfYou got the Laser Cannon!"); SetInventory("HasPlasmaRifle", 1); break;
   case 7: GiveInventory("CamDecimator", 1); print(s:"\cfYou got the Decimator!"); SetInventory("HasBFG9000", 1); break;
   }
   
}

Script "CameronClass_MiscPickupSystem" (void)
{  
  int plr = PlayerNumber();
  SetInventory("PickedUp", 0);
  switch(miscnumbersave[plr])
  {
  case 1: 
  if(GetActorProperty(0, APROP_HEALTH) >= (GetActorProperty(0, APROP_SpawnHealth)+100)) { terminate; }
  HealThing(2, GetActorProperty(0, APROP_SpawnHealth)+100); PlaySound(0, "HELTH1", 4);
  message[plr] = strparam(s:"Health +2");
  break;
  case 2: 
  if(GetActorProperty(0, APROP_HEALTH) >= GetActorProperty(0, APROP_SpawnHealth)) { terminate; }
  HealThing(20, GetActorProperty(0, APROP_SpawnHealth)); PlaySound(0, "HELTH2", 4);
  message[plr] = strparam(s:"Health +20");
  break;
  case 3: 
  if(GetActorProperty(0, APROP_HEALTH) >= GetActorProperty(0, APROP_SpawnHealth)) { terminate; }
  HealThing(50, GetActorProperty(0, APROP_SpawnHealth)); PlaySound(0, "HELTH3", 4);
  message[plr] = strparam(s:"Health +50");
  break;
  case 4: 
  if(GetActorProperty(0, APROP_HEALTH) >= (GetActorProperty(0, APROP_SpawnHealth)+100)) { terminate; }
  HealThing(100, GetActorProperty(0, APROP_SpawnHealth)+100); 
//   PlaySound(0, "SPHERE", 4);
  PlaySound(0, "misc/gwonamsphere/squadala", 4);
  message[plr] = strparam(s:"Soulsphere!");
  break;
  case 5: 
  if(CheckInventory("BasicArmor") >= 200) { terminate; }
  GiveInventory("ArmorBonus", 1); PlaySound(0, "ARMR1", 4);
  message[plr] = strparam(s:"Green Armor +1 (33% damage reduction)");
  break;
  case 6: 
  if(CheckInventory("BasicArmor") >= 100) { terminate; }
  GiveInventory("GreenArmor", 1); PlaySound(0, "ARMR2", 4);
  message[plr] = strparam(s:"Green Armor +100 (33% damage reduction)");
  break;
  case 7: 
  if(CheckInventory("BasicArmor") >= 200) { terminate; }
  GiveInventory("BlueArmor", 1); PlaySound(0, "ARMR2", 4);
  message[plr] = strparam(s:"Blue Armor +200 (50% damage reduction)");
  break;
  case 8: 
  HealThing(GetActorProperty(0, APROP_SpawnHealth)+100, GetActorProperty(0, APROP_SpawnHealth)+100);
  GiveInventory("BlueArmor", 1); 
  PlaySound(0, "misc/harksphere/dinnerHD", 4);
//   PlaySound(0, "SPHERE", 4);
  message[plr] = strparam(s:"Megasphere!");
  break;
  case 9: 
  GiveInventory("Allmap", 1); PlaySound(0, "POWERUP", 4);
  message[plr] = strparam(s:"The Entire Map!");
  break;
  case 10: 
  GiveInventory("QuadDamagePowerup", 1); PlaySound(0, "QUADDAMG", 4);
  message[plr] = strparam(s:"Damage boost!");
  break;
  case 11: 
  GiveInventory("BlurSphere", 1); PlaySound(0, "POWERUP", 4);
  message[plr] = strparam(s:"Partial Invisibility!");
  break;
  case 12: 
  GiveInventory("Infrared", 1); PlaySound(0, "POWERUP", 4);
  message[plr] = strparam(s:"Light Amplification Visor!");
  break;
  case 13: 
  GiveInventory("NewInvulnerabilitySphere", 1); 
  PlaySound(0, "POWERUP", 4);
  message[plr] = strparam(s:"INVULNERABILITY!");
  break;
  case 14: 
  GiveInventory("RadSuit", 1); PlaySound(0, "POWERUP", 4);
  message[plr] = strparam(s:"Radiation Shielding Suit!");
  break;
  }
  GiveInventory("PickupBlend", 1);
  ACS_NamedExecuteWithResult("PostLog", 0, 0, 0, 0);
}

script "CameronFriendlyMonsterFilter" (void)
{
    if (GetActorProperty(0, APROP_Friendly))
    {
        GiveInventory("Health", 10);
    }
}