actor CamRifle : Weapon
{
  Weapon.AmmoUse 1 
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 24
  Weapon.AmmoType1 "CamRifleMagazine" 
  Weapon.AmmoType2 "CamRifleAmmo"
  Obituary "%o was perforated by %k's Rifle."
  Inventory.RestrictedTo "CameronClass"
  +AMMO_OPTIONAL
  +WEAPON.NOALERT //Made so the alt fire doesn't alert monsters
  Inventory.Pickupmessage "You got the rifle!"
  Tag "Rifle"
  States
  {    
  Spawn:
    CRFW A -1
    Stop
  Ready:
    CRFL A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    loop
  Deselect:
    CRFL A 1 A_Lower
	TNT1 A 0 A_Lower
	TNT1 A 0 A_Lower
    loop
  Select:
    CRFL A 1 A_Raise
	TNT1 A 0 A_Raise
	TNT1 A 0 A_Raise
    loop
  Fire:    
	TNT1 A 0 A_JumpIfNoAmmo("Empty")
	CRFL A 1
    CRFL B 0 A_AlertMonsters 
    CRFL B 0 A_GunFlash
    CRFL B 2 A_FireBullets (2, 2, 1, 6, "CameronAcidicBulletPuff")
    CRFL B 0 A_PlaySound("weapons/camrflfire")
    CRFL C 1
    CRFL B 0 A_GunFlash
    CRFL B 2 A_FireBullets (2, 2, 1, 6, "CameronAcidicBulletPuff")
    CRFL B 0 A_PlaySound("weapons/camrflfire")
    CRFL C 1
    CRFL A 0 A_ReFire
    goto Ready
  Empty:
    CRFL A 0
	Goto Reload
  Reload:
	CRFL A 0 A_JumpIfInventory("CamRifleMagazine", 30, "Ready") //Have full ammo? Go to ready!
	CRFL A 0 A_JumpIfInventory("CamRifleAmmo", 1, "ReloadStart")
	CRFL A 1 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  ReloadStart:
    CRFL A 6 A_PlayWeaponSound("Weapons/wpnout")
    CRFL DEF 6
    CRFL GH 3
	Goto ReloadWork
  ReloadWork:
	CRFL I 0 A_TakeInventory("CamRifleAmmo",1)
    CRFL I 0 A_GiveInventory("CamRifleMagazine",1)
	CRFL I 0 A_JumpIfInventory("CamRifleMagazine",30,"ReloadFinish")
    CRFL I 0 A_JumpifInventory("CamRifleAmmo",1,"ReloadWork") 
  ReloadFinish:
    CRFL I 0 A_PlayWeaponSound("Weapons/loadclip")
    CRFL I 8
    CRFL J 3
    CRFL D 6
	Goto Ready
  Flash:
    TNT1 A 0 A_Jump (128, "Flash1", "Flash2")
  Flash1:
    CRFF A 1 bright A_Light1
    TNT1 A 0 bright A_Light0
  Flash2:
    CRFF B 1 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  }
}

actor CamRifleMagazine : Ammo
{
	+IGNORESKILL // Make sure you add this so you don't get double ammo on lower difficulties
     Inventory.MaxAmount 30
}

ACTOR CamChaingun : Weapon
{
   Weapon.SelectionOrder 700
   Weapon.AmmoUse 1
   Weapon.AmmoGive1 0
   Weapon.AmmoGive2 20
   Weapon.AmmoType1 "CamChaingunBelt"
   Weapon.AmmoType2 "CamChaingunAmmo"
  +AMMO_OPTIONAL
  Inventory.RestrictedTo "CameronClass"
  +WEAPON.NOALERT //Made so the alt fire doesn't alert monsters
   Inventory.PickupMessage "$GOTCHAINGUN" // "You got the chaingun"
   Obituary "%o became swiss cheese by %k's chaingun."
   Tag "Chaingun"
   States
   {
   Ready:
     CCHG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
     Loop
   Deselect:
     CCHG A 1 A_Lower
	 TNT1 A 0 A_Lower
	 TNT1 A 0 A_Lower
     Loop
   Select:
     CCHG A 1 A_Raise
	 TNT1 A 0 A_Raise
	 TNT1 A 0 A_Raise
     Loop
   Fire:    
	TNT1 A 0 A_JumpIfNoAmmo("Empty")
    CCHG D 2
    CCHG C 0 A_AlertMonsters 
    CCHG C 0 A_GunFlash
    CCHG C 2 A_FireBullets (5.6, 0, 1, 7, "CameronAcidicBulletPuff")
    CCHG C 0 A_PlaySound("weapons/camchaingunfire")
    CCHG D 2
    CCHG C 0 A_GunFlash
    CCHG C 2 A_FireBullets (5.6, 0, 1, 7, "CameronAcidicBulletPuff")
    CCHG C 0 A_PlaySound("weapons/camchaingunfire")
    CCHG A 0 A_ReFire
    goto Ready
  Empty:
    CCHG A 0
	Goto Reload
  Reload:
	CCHG A 0 A_JumpIfInventory("CamChaingunBelt", 100, "Ready") //Have full ammo? Go to ready!
	CCHG A 0 A_JumpIfInventory("CamPistolAmmo", 1, "ReloadStart")
	CCHG A 1 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  ReloadStart:
    CCHG A 0 A_PlayWeaponSound("Weapons/camchaingunrld")
    CCHG ABE 6
	CCHG F 12
	CCHG G 6
	Goto ReloadWork
  ReloadWork:
	CCHG E 0 A_TakeInventory("CamChaingunAmmo",1)
    CCHG E 0 A_GiveInventory("CamChaingunBelt",1)
	CCHG E 0 A_JumpIfInventory("CamChaingunBelt",100,"ReloadFinish")
    CCHG E 0 A_JumpifInventory("CamChaingunAmmo",1,"ReloadWork") 
  ReloadFinish:
    CCHG E 6
	Goto Ready
   Flash:
    TNT1 A 0 A_Jump (128, "Flash1", "Flash2")
  Flash1:
    CCHF A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
  Flash2:
    CCHF B 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
   Spawn:
     CCHW A -1
     Stop
   }
}

actor CamRifleAmmo : Ammo
{
  Inventory.Amount 30
  Inventory.MaxAmount 300
  Ammo.BackpackAmount 30
  Ammo.BackpackMaxAmount 600
}

actor CamChaingunAmmo : Ammo
{
  Inventory.Amount 20
  Inventory.MaxAmount 400
  Ammo.BackpackAmount 20
  Ammo.BackpackMaxAmount 800
}

actor CamChaingunBelt : Ammo
{
	+IGNORESKILL 
     Inventory.MaxAmount 100
}