ACTOR "CorruptedMachineGun" : Weapon
{
	Weapon.PreferredSkin "LegLMG-Marine"
	Weapon.AmmoType "CLMGMagazine"
	Weapon.AmmoType2 "CorruptedLMGBulletMag"
	Tag "Corrupted Machine Gun"
	Weapon.SelectionOrder 380
	Weapon.KickBack 200
	Weapon.AmmoGive 76
	Weapon.AmmoGive2 20
	Weapon.AmmoUse 0
	Scale 0.95
	Inventory.PickupSound "weapons/LMGReload3"
    Inventory.PickupMessage "%o was turned into a raw cheese by %k's Corrupted Machine Gun."
    Inventory.PickupMessage "You got the Corrupted Machine Gun!"
	+WEAPON.AMMO_OPTIONAL
    +WEAPON.NOALERT
	+INVENTORY.UNDROPPABLE
	+NOTIMEFREEZE
  States
	{
  Deselect:
	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0 A_TakeInventory("RailgunAction",1)
  DeselectLoop:
    TNT1 A 0 A_Lower
	CMGG A 1 A_Lower
	Loop
  Select:
	TNT1 A 0 A_Raise
	Wait
  Ready:
	TNT1 A 0 A_PlayWeaponSound("weapons/LMGReload3")
	CMGG BCDEFA 1
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	CMGG A 1 A_WeaponReady
	Goto Ready+7
   ReadyLoop:
     TNT1 A 0 A_JumpIfInventory("CLMGMagazine",1,2)
	 TNT1 A 0
	 Goto NoBuzzing
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 CMGG AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 CMGG AAA 1 A_WeaponReady
	 Goto ReadyLoop
  NoBuzzing:
     TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
     CMGG A 1 A_WeaponReady
	 Loop
  Fire:
	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",1,1)
	Goto Empty
	TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	TNT1 A 0 A_AlertMonsters	
	TNT1 A 0 A_GunFlash
	TNT1 A 0 Radius_Quake(4,3,0,1,0)
	TNT1 A 0 A_SpawnItemEx("LegRifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
	TNT1 A 0 A_Light1
	CMGF A 3 Bright A_FireCustomMissile("CorruptedLMGBallPlayer",frandom(-1,1),1,0,0,0,frandom(-1,1))
	TNT1 A 0 A_Light0
	TNT1 A 0 A_TakeInventory("CLMGMagazine",1)
	CMGF B 1
	CMGF C 1
	CMGG A 1
	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",1,1)
	Goto ReadyLoop
	TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	TNT1 A 0 A_AlertMonsters	
	TNT1 A 0 A_GunFlash
	TNT1 A 0 Radius_Quake(4,3,0,1,0)
	TNT1 A 0 A_SpawnItemEx("LegRifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
	TNT1 A 0 A_Light2
	CMGF D 3 Bright A_FireCustomMissile("CorruptedLMGBallPlayer",frandom(-1,1),1,0,0,0,frandom(-1,1))
	TNT1 A 0 A_Light0
	TNT1 A 0 A_TakeInventory("CLMGMagazine",1)
	CMGF B 1
	CMGF C 1
	CMGG A 1
	TNT1 A 0 A_ReFire
	Goto ReadyLoop
  Flash:
	TNT1 A 0
	Goto LightDone
  Empty:
    CMGG A 10 A_PlayWeaponSound("weapons/click")
  AltFire:
  	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",60,2)
    TNT1 A 0 A_JumpIfInventory("CorruptedLMGBulletMag",1,2)
	TNT1 A 0
	Goto Ready+7
	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",1,"MaxReload")
	CMGR A 1 A_PlayWeaponSound("weapons/LMGReload2")
 	CMGR BCD 1
	CMGR E 1 A_FireCustomMissile("LegendaryEmptyDrumSpawner", 0, 0, 0, 1)
	CMGR F 1
	CMGR GG 25
	CMGR HIJK 1 A_PlayWeaponSound("weapons/LMGReload1")
	CMGR L 8	
	CMGR MN 2
	CMGR OP 1
	CMGR QRSTU 1
	CMGR V 2
	CMGR W 3 A_PlayWeaponSound("weapons/LMGReload3")
	CMGR X 4
	CMGR Y 3
	CMGR Z 2
	TNT1 A 0 A_JumpIfInventory("CorruptedLMGBulletMag",1,"Reload")
  Reload:
	TNT1 A 0 A_TakeInventory("CorruptedLMGBulletMag",1)
	TNT1 A 0 A_GiveInventory("CLMGMagazine",1)
	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",60,2)
	TNT1 A 0 A_JumpIfInventory("CorruptedLMGBulletMag",1,"Reload")
    TNT1 A 0
	Goto Ready+7
  MaxReload:
	CMGR A 1 A_PlayWeaponSound("weapons/LMGReload2")
 	CMGR BCD 1
	CMGR E 1 A_FireCustomMissile("LegendaryEmptyDrumSpawner", 0, 0, 0, 1)
	CMGR F 1
	CMGR GG 25
	CMGR HIJK 1 A_PlayWeaponSound("weapons/LMGReload1")
	TNT1 A 0 A_JumpIfInventory("CorruptedLMGBulletMag",1,"Reload2")
  Reload2:
	TNT1 A 0 A_TakeInventory("CorruptedLMGBulletMag",1)
	TNT1 A 0 A_GiveInventory("CLMGMagazine",1)
	TNT1 A 0 A_JumpIfInventory("CLMGMagazine",60,"Full")
	TNT1 A 0 A_JumpIfInventory("CorruptedLMGBulletMag",1,"Reload2")
  Full:
	CMGR L 8	
	CMGR MN 2
	CMGR OPQRS 1
	CMGG A 2
	Goto Ready+7
  GrenadeCheck:
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	Goto Ready+7
  GrenadeToss:
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	CMGR ABCDEFG 1
	TNT1 A 4
	HGRN ABC 1
	HGRN D 2
	HGRN EFG 1
	HGRN HI 2
	TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	HGRN J 1
	HGRN KLM 2
	HGRN NO 1
	TNT1 A 6
	TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	TNT1 A 0
	Goto Ready+1
  MineCheck:
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	TNT1 A 0 A_TakeInventory("MineAction",1)
	Goto Ready+7
  MineToss:
  	TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	CMGR ABCDEFG 1
	TNT1 A 8
	TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	MINE ABCDEF 1		
	TNT1 A 0 A_TakeInventory("MineAmmo",1)	  
	MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	MINE HI 1
	MINE JK 2
	TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
	TNT1 A 0 A_TakeInventory("Land Mine",1)
	TNT1 A 0 A_TakeInventory("MineAction",1)
	TNT1 A 0
	TNT1 A 5
	Goto Ready+1
  Spawn:
	CMGL Z -1
	Stop
	}
}

ACTOR CorruptedLMGBall : PulsePlasmaBall 
{ 
    Speed 200 
	Damage 50 
	DamageType "DBFG2" 
}

ACTOR CorruptedLMGBallPlayer : PulsePlasmaBall 
{ 
    Speed 200 
	Damage 40 // 50
	Species "Player" 
	DamageType "DBFG2" 
}

ACTOR CLMGMagazine : Ammo
{
	Inventory.Amount 0
	Inventory.MaxAmount 76
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 76
	Inventory.Icon "CMGLZ0"
	+IGNORESKILL
}

ACTOR CorruptedBulletBox : CorruptedLMGBulletMag
{
	Scale 0.75
	Inventory.Amount 40
	Inventory.PickupMessage "Corrupted Clip Box"
	Inventory.PickupSound "items/clipbox"
	Inventory.Icon "CCBXA0"
	+NOTIMEFREEZE
	States 
	{
	Spawn:
		CCBX A -1
		Stop
    }
}
