actor CamLaserCannon : Weapon
{
  Weapon.AmmoUse 1 
  Weapon.AmmoGive1 0
  Weapon.AmmoGive2 20
  Weapon.AmmoType1 "CamLaserCell" 
  Weapon.AmmoType2 "CamPlasmaAmmo"
  Obituary "%o was melted by %k."
  Inventory.RestrictedTo "CameronClass"
  +AMMO_OPTIONAL
  +WEAPON.NOALERT //Made so the alt fire doesn't alert monsters
  Tag "Laser Cannon"
  States
  {    
  Spawn:
    CPLW A -1
    Stop
  Ready:
    CPLS A 1 A_WeaponReady(WRF_ALLOWRELOAD)
    loop
  Deselect:
    CPLS A 1 A_Lower
	TNT1 A 0 A_Lower
	TNT1 A 0 A_Lower
    loop
  Select:
    CPLS A 1 A_Raise
	TNT1 A 0 A_Raise
	TNT1 A 0 A_Raise
    loop
  Fire:    
	TNT1 A 0 A_JumpIfNoAmmo("Empty")
    CPLS B 0 A_AlertMonsters 
    CPLS B 0 A_GunFlash
    CPLS B 0 A_PlaySound("weapons/camplasmafire", CHAN_AUTO)
    CPLS B 2 A_FireCustomMissile ("CamLaserBolt", 0, 1, 6, -1)
    CPLS B 0
    CPLS C 2
    CPLS A 0 A_ReFire
    goto Ready
  Empty:
    CPLS A 0
	Goto Reload
  Reload:
	CPLS A 0 A_JumpIfInventory("CamLaserCell", 50, "Ready") //Have full ammo? Go to ready!
	CPLS A 0 A_JumpIfInventory("CamPlasmaAmmo", 1, "ReloadStart")
	CPLS A 1 A_WeaponReady(WRF_NOFIRE)
	Goto Ready
  ReloadStart:
    TNT1 A 0 A_PlayWeaponSound("weapons/camplasmareload")
    CPLS DEF 6
    CPLS GH 6
	Goto ReloadWork
  ReloadWork:
	CPLS I 0 A_TakeInventory("CamPlasmaAmmo",1)
    CPLS I 0 A_GiveInventory("CamLaserCell",1)
	CPLS I 0 A_JumpIfInventory("CamLaserCell",50,"ReloadFinish")
    CPLS I 0 A_JumpifInventory("CamPlasmaAmmo",1,"ReloadWork") 
  ReloadFinish:
    CPLS I 6
    CPLS J 6
    CPLS K 6
    CPLS L 6
	Goto Ready
  Flash:
    TNT1 A 0 A_Jump (128, "Flash1", "Flash2", "Flash3")
  Flash1:
    CPLF A 1 bright A_Light1
    TNT1 A 0 bright A_Light0
  Flash2:
    CPLF B 1 bright A_Light1
    TNT1 A 0 bright A_Light0
  Flash3:
    CPLF C 1 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  }
}

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

ACTOR CamPlasmaAmmo : Ammo
{
  Inventory.PickupMessage "$GOTCELL" // "Picked up an energy cell."
  Inventory.Amount 25
  Inventory.MaxAmount 300
  Ammo.BackpackAmount 25
  Ammo.BackpackMaxAmount 600
  Inventory.Icon "CELLA0"
  States
  {
  Spawn:
    CELL A -1
    Stop
  }
}

Actor CamLaserBolt : DoomImpBall
{
  Damage (Random(10, 20))
  Height 5
  Radius 5
  Scale 0.8
  Speed 60
  Decal PlasmaScorchLower
  SeeSound NULL
  Species "Player"
  DeathSound "weapons/plasmax"
  Obituary "%o was vaporized by %k."
  States
  {
  Spawn:
    LCHB AAAABBBB 1 Bright A_SpawnItemEx("CamLaserBoltTrail", -(MomX/1.2), -(MomY/1.2), (MomZ/1.2*-1), (MomX/1.2), (MomY/1.2), (MomZ/1.2), -Angle, 138)
    Loop
  Death:
    LCHB C 0 Bright A_Explode(50, 50, 0)
    LCHB CDEFG 3 Bright
    Stop
  }
}

Actor CamLaserBoltTrail
{
  Projectile
  RenderStyle Add
  Scale 0.8
  Alpha 1
  States
  {
  Spawn:
    LCHB AABB 2 Bright A_FadeOut(0.05)
    Loop
  }
}