actor "H&K MG4" : RGUWeapon
{
  obituary "%k mutilated %o with lead from the MG4."
  inventory.pickupmessage "You got the H&K MG4 light machinegun. Mutilate them to pieces!!"
  //attacksound "mg4/fire1"
  weapon.selectionorder 1
  weapon.ammotype "MG4Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "MG4Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Ready:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    MG4A A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    MG4A BCDEFGH 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4A IJKLMNO 2 A_WeaponReady(WRF_ALLOWZOOM)
	M4CD A 0 A_JumpIfInventory("MG4Token",1,"Reload")
    MG4A P 0 A_JumpIfNoAmmo("Reload")
	M4CC F 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    MG4A P 0 A_JumpIfInventory("Aiming",1,5)
    MG4A P 0 A_JumpIfInventory("Reloading",1,"Reload")
    MG4A P 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    MG4A P 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4A P 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+19
    MG4C F 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    MG4C F 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    MG4C F 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
    MG4C F 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+25
  Deselect:
    MG4A P 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    MG4A P 0 A_TakeInventory("Aiming",1)
    MG4A P 0 A_TakeInventory("Reloading",1)
    MG4A P 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    MG4A P 0 A_ZoomFactor(1.0)
    MG4A P 0 A_Lower
    MG4A P 1 A_Lower
    Goto Deselect+5
  Select:
    MG4A A 0 A_Raise
    Loop
  Fire:
    MG4B A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    MG4B A 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  Hold:
    MG4B A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    MG4B A 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-9.00,9.00), 1, 0, 4, 0, frandom(-9.00,9.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  FireAim:
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-1.75,1.75), 1, 0, 4, 0, frandom(-1.75,1.75))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C J 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4C J 1 A_ReFire
    Goto Ready+25
    MG4C J 0 A_JumpIfNoAmmo("ReloadStart")
    MG4C J 1 A_ReFire
    Goto Ready+25
  HoldAim:
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-2.70,2.70), 1, 0, 4, 0, frandom(-2.70,2.70))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C J 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4C J 1 A_ReFire
    Goto Ready+25
    MG4C J 0 A_JumpIfNoAmmo("ReloadStart")
    MG4C J 1 A_ReFire
    Goto Ready+25
  Reload: //AltFire:
    MG4D A 0 A_JumpIfInventory("MG4Clip",100,2)
    MG4D A 0 A_JumpIfInventory("MG4Ammo",1,"ReloadStart")
    MG4D A 0 A_TakeInventory("Reloading",1)
    MG4D A 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+22
  ReloadStart:
    MG4D A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    MG4D A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    MG4D A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
	MG4D A 0 A_JumpIfInventory("MG4Token",1,"Reload2")
    MG4D A 3 A_PlaySoundEx("mg4/reload1","SoundSlot5")
    MG4D BCDEFGHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D JKLMNOPQ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4D RSTUVWXY 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D Z 3 A_PlaySoundEx("mg4/reload2","SoundSlot5")
    MG4E ABCDEFGHI 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4E J 3 A_PlaySoundEx("mg4/reload3","SoundSlot5")
	MG4E J 0 A_FireCustomMissile("EmptyLMGMagSpawner",0,0,0,-4)
	MG4E J 0 A_GiveInventory("MG4Token",1)
    MG4E KLMNOPQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	goto Reload2
  Reload2:
    MG4E TUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4F ABCD 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F E 3 A_PlaySoundEx("mg4/reload5","SoundSlot5")
    MG4F FGI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F J 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo
  ReloadAmmo:
    U46C P 0 A_JumpIfInventory("MG4Clip",100,"ReloadEnd")
	U46C P 0 A_TakeInventory("MG4Token",1)
    U46C P 0 A_JumpIfInventory("MG4Ammo",1,1)
    Goto ReloadEnd
    U46C P 0 A_GiveInventory("MG4Clip",1)
    U46C P 0 A_TakeInventory("MG4Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    MG4F PRTUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4G A 3 A_PlaySoundEx("mg4/reload6","SoundSlot5")
    MG4G BHIJKLM 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4G NOPQRSTUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4H ABF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    U46D B 0 A_ReFire
    Goto Ready+19
  Zoom:
  PostReloadAlt:
    MG4D A 0 A_JumpIfInventory("MG4Token",1,"Reload")
    MG4C F 0 A_ZoomFactor(1.2)
    MG4C E 0 A_GiveInventory("Aiming",1)
	MG4C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    MG4C ABCDEF 2
    Goto AltHold
  AltFireHoldAim:
    "####" "#" 0 A_JumpIfInventory("MG4Clip",1,1)
	Goto Reload
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
	GRNA L 0 A_TakeInventory("MG4Clip",1)
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-2.70,2.70), 1, 0, 4, 0, frandom(-2.70,2.70))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 A_JumpIfInventory("MG4Clip",1,1)
	Goto Reload
    MG4C J 1 A_ReFire
    Goto Ready+25
  AltHold:
    MG4C F 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
	M4CA C 0 A_JumpIfInventory("FireHeld",1,"AltFireHoldAim")
	M4CA C 0 A_JumpIfInventory("Reloading",1,"Reload")
	U45A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    U45A L 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
	M4CA F 0 A_Refire("AltHold")
	M4CA C 0 A_JumpIfInventory("Aiming",1,"AltFire2")
	Goto Ready+25
  AltFire:
    GRNA L 0 A_TakeInventory("weapondropper",2)
	M4CD A 0 A_JumpIfInventory("MG4Token",1,"Reload")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"AltHold")
    MG4C A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    MG4C A 0 A_ZoomFactor(1.2)
    MG4C AB 2
    MG4C B 0 A_GiveInventory("Aiming",1)
    MG4C CDEF 2
    MG4C F 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    MG4C F 0 A_Refire
    Goto Ready+25
  AltFire2:
    MG4C F 0 A_ZoomFactor(1.0)
    MG4C FE 2
    MG4C E 0 A_TakeInventory("Aiming",1)
    MG4C DCBA 2
    MG4C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	MG4A PPPP 1
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+19
  AltFire3:
    MG4C F 0 A_ZoomFactor(1.0)
    MG4C FE 2
    MG4C E 0 A_TakeInventory("Aiming",1)
    MG4C DCBA 2
    MG4C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    MG4C A 0 A_Refire
	goto DropWeapon
  ReloadStartAim:
    MG4C F 0 A_ZoomFactor(1.0)
    MG4C FE 2
    MG4C E 0 A_TakeInventory("Aiming",1)
    MG4C DCBA 2
    MG4C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  Flash:
    TNT1 A 2 bright A_Light1
    TNT1 A 0 bright A_Light0
    stop
  Spawn:
    WEAP J 0
    WEAP J 0 A_SpawnItem("MG4Drop")
    stop
  Fire_SteadyAim:
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-5.00,5.00), 1, 0, 4, 0, frandom(-5.00,5.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  Hold_SteadyAim:
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  ReloadStart_SOH:
    MG4D A 0 A_JumpIfInventory("MG4Token",1,"Reload3")
    MG4D A 2 A_PlaySoundEx("mg4/reload1soh","SoundSlot5")
    MG4D BCDEFGHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D JKLMNOPQ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4D RSTUVWXY 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D Z 2 A_PlaySoundEx("mg4/reload2","SoundSlot5")
    MG4E ABCDEFGHI 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4E J 2 A_PlaySoundEx("mg4/reload3","SoundSlot5")
	MG4E J 0 A_FireCustomMissile("EmptyLMGMagSpawner",0,0,0,-4)
	MG4E J 0 A_GiveInventory("MG4Token",1)
    MG4E KLMNOPQ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	goto Reload3
  Reload3:
    MG4E TUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4F ABCD 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F E 2 A_PlaySoundEx("mg4/reload5","SoundSlot5")
    MG4F FGI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F J 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    U46C P 0 A_JumpIfInventory("MG4Clip",100,"ReloadEnd_SOH")
	U46C P 0 A_TakeInventory("MG4Token",1)
    U46C P 0 A_JumpIfInventory("MG4Ammo",1,1)
    Goto ReloadEnd_SOH
    U46C P 0 A_GiveInventory("MG4Clip",1)
    U46C P 0 A_TakeInventory("MG4Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    MG4F PRTUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4G A 2 A_PlaySoundEx("mg4/reload6","SoundSlot5")
    MG4G BHIJKLM 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4G NOPQRSTUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4H ABF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    U46D B 0 A_ReFire
    Goto Ready+19
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,1,0,0)
    U45F A 0 A_ZoomFactor(1.0)
    U45A L 0 A_TakeInventory("Aiming",1)
    U45A L 0 A_TakeInventory("Reloading",1)
    U45F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	M4CA J 0 A_JumpIfInventory("ThrowingStun",1,"StunGrenade")
	M4CA J 0 A_JumpIfInventory("ThrowingIncd",1,"IncGrenade")
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"FragGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 2
    TNT1 A 15
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 2
    GRNA L 0 A_TakeInventory("GrenadeAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("FragGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  FragGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 1
    TNT1 A 10
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 1
    GRNA L 0 A_TakeInventory("GrenadeAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("FragGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    U45F A 0 A_ZoomFactor(1.0)
    U45A L 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    U45A L 0 A_TakeInventory("Aiming",1)
    U45A L 0 A_TakeInventory("Reloading",1)
    U45F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"KnifeAttack_SOH")
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_Commando")
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    Goto Ready+2
  KnifeAttack_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 20
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    Goto Ready+2
  KnifeAttack_SOH:
    U45C A 0 A_JumpIfInventory("Perk3_Commando",1,"KnifeAttack_SOH_Commando")
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",104)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    Goto Ready+2
  KnifeAttack_SOH_Commando:
    KNFA A 0 ACS_NamedExecuteAlways("RefSlash",0,0,0,0)
    KNFA AB 1
    KNFA B 0 A_PlaySound("knife/swing")
    KNFA C 1 A_CustomPunch(102,1,0,"KnifePuff",160)
    KNFA DEFGHIJKL 1
    TNT1 A 10
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
    Goto Ready+2
  StunGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"StunGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 2
    TNT1 A 15
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 2
    GRNA L 0 A_TakeInventory("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  IncGrenade:
    U45A L 0 A_JumpIfInventory("Perk1_SOH_Pro",1,"IncGrenade_SOH")
    GRNA ABC 2
    GRNA D 2 A_PlaySound("grenade/pinpull")
    GRNA EFGH 2
    TNT1 A 15
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 2
    GRNA L 0 A_TakeInventory("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 2 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 2
    Goto Ready+2
  StunGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 1
    TNT1 A 10
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 1
    GRNA L 0 A_TakeInventory("StunAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("StunGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  IncGrenade_SOH:
    GRNA ABC 1
    GRNA D 1 A_PlaySound("grenade/pinpull")
    GRNA EFGH 1
    TNT1 A 10
    TNT1 A 0 A_PlaySound("grenade/throw")
    GRNA A 0 A_PlaySoundEx("us/grenades","Voice")
    GRNA IJK 1
    GRNA L 0 A_TakeInventory("IncdAmmo",1)
    GRNA L 0 A_TakeInventory("ThrowingGrenade",1)
	GRNA L 0 A_TakeInventory("ThrowingStun",1)
	GRNA L 0 A_TakeInventory("ThrowingIncd",1)
    U45A L 0 A_TakeInventory("Aiming",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
    GRNA L 1 A_FireCustomMissile("IncGrenade",frandom(-2.00,2.00),0,0,16,0,frandom(-1.50,1.50))
    GRNA MN 1
    Goto Ready+2
  DropWeapon:
    MG4A PONMLKJIHGFEDCB 2 A_WeaponReady(WRF_NOPRIMARY)
	MG4A A 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CC F 0 A_JumpIfInventory("weapondropper",2,"ThrowWeapon")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",1)
	M4CB A 0 A_FireCustomMissile("MG4Dropped",0,0,7,2)
	stop
  ThrowWeapon:
    GRNA IKMN 1
	KNFA B 0 A_PlaySound("knife/swing")
    KNFA A 0 ACS_NamedExecuteAlways("RefDropW",0,0,0,0)
	GRNA L 0 A_TakeInventory("weapondropper",2)
	M4CB A 0 A_FireCustomMissile("MG4Thrown",0,0,7,2)
	stop
  }
}

actor MG4Clip : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 100
    ammo.backpackamount 0
    ammo.backpackmaxamount 100
    +IGNORESKILL
}
actor "H&K MG4 Ex Mags" : "H&K MG4"
{
  obituary "%k fed %o with lead from the MG4."
  inventory.pickupmessage "You got the H&K MG4 light machinegun."
  //attacksound "mg4/fire1"
  weapon.selectionorder 1
  weapon.ammotype "MG4Clip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "MG4Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Ready:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    MG4A A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    MG4A BCDEFGH 2
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4A IJKLMNO 2 A_WeaponReady(WRF_ALLOWZOOM)
	M4CD A 0 A_JumpIfInventory("MG4Token",1,"Reload")
    MG4A P 0 A_JumpIfNoAmmo("Reload")
	M4CC F 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    MG4A P 0 A_JumpIfInventory("Aiming",1,5)
    MG4A P 0 A_JumpIfInventory("Reloading",1,"Reload")
    MG4A P 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    MG4A P 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4A P 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+19
    MG4C F 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    MG4C F 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    MG4C F 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	G18A I 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
    MG4C F 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+25
  Reload: //AltFire:
    MG4D A 0 A_JumpIfInventory("MG4Clip2",150,2)
    MG4D A 0 A_JumpIfInventory("MG4Ammo",1,"ReloadStart")
    MG4D A 0 A_TakeInventory("Reloading",1)
    MG4D A 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+22
  ReloadStart:
    MG4D A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    MG4D A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    MG4D A 0 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
	MG4D A 0 A_JumpIfInventory("MG4Token",1,"Reload2")
    MG4D A 3 A_PlaySoundEx("mg4/reload1","SoundSlot5")
    MG4D BCDEFGHI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D JKLMNOPQ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4D RSTUVWXY 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D Z 3 A_PlaySoundEx("mg4/reload2","SoundSlot5")
    MG4E ABCDEFGHI 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4E J 3 A_PlaySoundEx("mg4/reload3","SoundSlot5")
	MG4E J 0 A_FireCustomMissile("EmptyLMGMagExtSpawner",0,0,0,-4)
	MG4E J 0 A_GiveInventory("MG4Token",1)
    MG4E KLMNOPQ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	goto Reload2
  Reload2:
    MG4E TUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4F ABCD 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F E 3 A_PlaySoundEx("mg4/reload5","SoundSlot5")
    MG4F FGI 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F J 3 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo
  ReloadAmmo:
    U46C P 0 A_JumpIfInventory("MG4Clip2",150,"ReloadEnd")
	U46C P 0 A_TakeInventory("MG4Token",1)
    U46C P 0 A_JumpIfInventory("MG4Ammo",1,1)
    Goto ReloadEnd
    U46C P 0 A_GiveInventory("MG4Clip2",1)
    U46C P 0 A_TakeInventory("MG4Ammo",1)
    Goto ReloadAmmo
  ReloadEnd:
    MG4F PRTUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4G A 3 A_PlaySoundEx("mg4/reload6","SoundSlot5")
    MG4G BHIJKLM 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4G NOPQRSTUVWXYZ 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4H ABF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    U46D B 0 A_ReFire
    Goto Ready+19
  ReloadStartAim:
    MG4C F 0 A_ZoomFactor(1.0)
    MG4C FE 2
    MG4C E 0 A_TakeInventory("Aiming",1)
    MG4C DCBA 2
    MG4C A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  ReloadStart_SOH:
    MG4D A 0 A_JumpIfInventory("MG4Token",1,"Reload3")
    MG4D A 2 A_PlaySoundEx("mg4/reload1soh","SoundSlot5")
    MG4D BCDEFGHI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D JKLMNOPQ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4D RSTUVWXY 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4D Z 2 A_PlaySoundEx("mg4/reload2","SoundSlot5")
    MG4E ABCDEFGHI 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4E J 2 A_PlaySoundEx("mg4/reload3","SoundSlot5")
	MG4E J 0 A_FireCustomMissile("EmptyLMGMagExtSpawner",0,0,0,-4)
	MG4E J 0 A_GiveInventory("MG4Token",1)
    MG4E KLMNOPQ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	goto Reload3
  Reload3:
    MG4E TUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4F ABCD 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F E 2 A_PlaySoundEx("mg4/reload5","SoundSlot5")
    MG4F FGI 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4F J 2 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    U46C P 0 A_JumpIfInventory("MG4Clip2",150,"ReloadEnd_SOH")
	U46C P 0 A_TakeInventory("MG4Token",1)
    U46C P 0 A_JumpIfInventory("MG4Ammo",1,1)
    Goto ReloadEnd_SOH
    U46C P 0 A_GiveInventory("MG4Clip2",1)
    U46C P 0 A_TakeInventory("MG4Ammo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    MG4F PRTUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4G A 2 A_PlaySoundEx("mg4/reload6","SoundSlot5")
    MG4G BHIJKLM 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    MG4G NOPQRSTUVWXYZ 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    MG4H ABF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    U46D B 0 A_ReFire
    Goto Ready+19
  AltFireHoldAim:
    "####" "#" 0 A_JumpIfInventory("MG4Clip2",1,1)
	Goto Reload
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
	GRNA L 0 A_TakeInventory("MG4Clip2",1)
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4", frandom(-2.70,2.70), 1, 0, 4, 0, frandom(-2.70,2.70))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 A_JumpIfInventory("MG4Clip2",1,1)
	Goto Reload
    MG4C J 1 A_ReFire
    Goto Ready+25
  }
}

actor MG4Clip2 : Ammo
{
    inventory.icon "CLIPA0"
    inventory.amount 0
    inventory.maxamount 150
    ammo.backpackamount 0
    ammo.backpackmaxamount 150
    +IGNORESKILL
}

actor MG4ExMags : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}

actor "H&K MG4 Grip" : "H&K MG4"
{
  obituary "%k fed %o with lead from the MG4."
  inventory.pickupmessage "You got the H&K MG4 light machinegun."
  //attacksound "mg4/fire1"
  weapon.selectionorder 1
  weapon.ammotype "MG4Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "MG4Ammo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  -NOAUTOFIRE
  states
  {
  Fire:
    MG4B A 0 A_JumpIfInventory("Aiming",1,"FireAim")
    MG4B A 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-5.00,5.00), 1, 0, 4, 0, frandom(-5.00,5.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BCC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  Hold:
    MG4B A 0 A_JumpIfInventory("Aiming",1,"HoldAim")
    MG4B A 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Hold_SteadyAim")
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-7.00,7.00), 1, 0, 4, 0, frandom(-7.00,7.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BCC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  FireAim:
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-1.25,1.25), 1, 0, 4, 0, frandom(-1.25,1.25))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C J 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4C J 1 A_ReFire
    Goto Ready+25
    MG4C J 0 A_JumpIfNoAmmo("ReloadStart")
    MG4C J 1 A_ReFire
    Goto Ready+25
  HoldAim:
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-1.80,1.80), 1, 0, 4, 0, frandom(-1.80,1.80))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C J 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4C J 1 A_ReFire
    Goto Ready+25
    MG4C J 0 A_JumpIfNoAmmo("ReloadStart")
    MG4C J 1 A_ReFire
    Goto Ready+25
  Fire_SteadyAim:
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-4.00,4.00), 1, 0, 4, 0, frandom(-4.00,4.00))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  Hold_SteadyAim:
    MG4B A 0 A_PlayWeaponSound("mg4/fire")
    MG4B A 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,7,3)
    MG4B A 0 BRIGHT A_GunFlash
    MG4B A 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-5.50,5.50), 1, 0, 4, 0, frandom(-5.50,5.50))
	MG4B A 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4B A 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4B BC 1
	MG4B C 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,8,31-(Sin(Pitch)*25),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    MG4B D 0 A_JumpIfInventory("MG4Ammo",1,2)
    MG4B D 1 A_ReFire
    Goto Ready+19
    MG4B D 0 A_JumpIfNoAmmo("ReloadStart")
    MG4B D 1 A_ReFire
    Goto Ready+19
  AltFireHoldAim:
    "####" "#" 0 A_JumpIfInventory("MG4Clip",1,1)
	Goto Reload
    MG4C G 0 A_PlayWeaponSound("mg4/fire")
	GRNA L 0 A_TakeInventory("MG4Clip",1)
    MG4C G 0 A_FireCustomMissile("WeaponSmokePuff_LMGMuzzle",0,0,0,2)
    MG4C G 0 BRIGHT A_GunFlash
    MG4C G 1 BRIGHT A_FireCustomMissile("HHCBMG4G", frandom(-1.80,1.80), 1, 0, 4, 0, frandom(-1.80,1.80))
	MG4C G 0 A_SpawnItemEx("RifleCasingSCAR",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    MG4C G 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    MG4C HI 1
	MG4C I 0 A_SpawnItemEx("RifleLink",Cos(Pitch)*30,-4,34-(Sin(Pitch)*43),Cos(Pitch)*FRandom(1,2),FRandom(1,3),-Sin(Pitch)*FRandom(1,3),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 A_JumpIfInventory("MG4Clip",1,1)
	Goto Reload
    MG4C J 1 A_ReFire
    Goto Ready+25
  }
}

actor MG4Grip : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}

actor MG4Pickup : CustomInventory
{
  inventory.pickupmessage "You got the H&K MG4 light machinegun."
  inventory.pickupsound "hbar/bolt"
  +INVENTORY.AUTOACTIVATE
  //inventory.respawntics 70
  scale 0.17
  States
  {
  Spawn:
    WEAP J -1
    stop
  Pickup:
    WEAP J 0
    WEAP J 0 A_JumpIf((ACS_NamedExecuteWithResult("RefCheckVar",0,0,0)) == 1, "PickupStay")
    WEAP J 0 A_JumpIfInventory("H&K MG4",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP J 0 A_JumpIfInventory("H&K MG4 Ex Mags",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("H&K MG4 Grip",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP J 0 A_JumpIfInventory("MaxWeaponsFilled",51,"FailPickup2")
	WEAP J 0 A_GiveInventory("MaxWeaponsFilled",50)
	WEAP J 0 A_GiveInventory("BIGGRINSound",1)
    WEAP J 0 ACS_NamedExecuteWithResult("RefPickU",14,0,0)
    stop
  PickupStay:
    WEAP J 0
    WEAP J 0 A_JumpIfInventory("H&K MG4",1,"FailPickup") // If the player already has this weapon, they get more ammo for it
    WEAP J 0 A_JumpIfInventory("H&K MG4 Ex Mags",1,"FailPickup")
    WEAP J 0 A_JumpIfInventory("H&K MG4 Grip",1,"FailPickup")
    WEAP J 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP J 0 A_JumpIfInventory("MaxWeaponsFilled",51,"FailPickup2")
	WEAP J 0 A_GiveInventory("MaxWeaponsFilled",50)
	WEAP J 0 A_GiveInventory("BIGGRINSound",1)
    WEAP J 0 ACS_NamedExecuteWithResult("RefPickU",14,0,0)
    WEAP J 0 ACS_NamedExecuteWithResult("RefPickC",14,0,0)
    WEAP J 0 A_PlaySound("hbar/bolt")
    fail
  AmmoPickup:
    WEAP J 0
    WEAP J 0 A_JumpIfInventory("MG4Ammo",0,"FailPickup")
    WEAP J 0 A_GiveInventory("MG4Ammo",100)
    stop
  OneManArmy:
    WEAP J 0
	WEAP J 0 A_JumpIfInventory("MaxWeaponsFilled",88,"FailPickup2")
	WEAP J 0 A_GiveInventory("MaxWeaponsFilled",50)
	WEAP J 0 A_GiveInventory("BIGGRINSound",1)
	WEAP J 0 ACS_NamedExecuteWithResult("RefPickU",14,0,0)
	stop
  FailPickup:
    WEAP J 1
    fail
  FailPickup2:
    WEAP J 1
    WEAP J 0 ACS_NamedExecuteAlways("RefSlots",0,32,0,0)
    fail
  }
}

actor MG4Drop : MG4Pickup
{
  States
  {
  Spawn:
    WEAP J -1
    stop
  Pickup:
    WEAP J 0
    WEAP J 0 A_JumpIfInventory("H&K MG4",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP J 0 A_JumpIfInventory("H&K MG4 Ex Mags",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("H&K MG4 Grip",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP J 0 A_JumpIfInventory("MaxWeaponsFilled",51,"FailPickup2")
	WEAP J 0 A_GiveInventory("MaxWeaponsFilled",50)
	WEAP J 0 A_GiveInventory("BIGGRINSound",1)
    WEAP J 0 ACS_NamedExecuteWithResult("RefPickU",14,0,0)
    stop
  }
}

actor MG4Drop2 : MG4Drop
{
  States
  {
  Spawn:
    WEAP J -1
    stop
  Pickup:
    WEAP J 0
    WEAP J 0 A_JumpIfInventory("H&K MG4",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP J 0 A_JumpIfInventory("H&K MG4 Ex Mags",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("H&K MG4 Grip",1,"AmmoPickup")
    WEAP J 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP J 0 A_JumpIfInventory("MaxWeaponsFilled",51,"FailPickup2")
	WEAP J 0 A_GiveInventory("MaxWeaponsFilled",50)
	WEAP J 0 A_GiveInventory("BIGGRINSound",1)
    WEAP J 0 ACS_NamedExecuteWithResult("RefPickU",14,0,0)
    stop
  AmmoPickup:
    WEAP J 0
    stop
  }
}

actor HHCBMG4 : HHBullet
{
  damage (random(28,38))
  Speed 400
  damagetype "LMG"
  States
  {
  Spawn:
    TNT1 A 15
    stop
  Death:
    TNT1 A 0 A_SpawnItemEx("ImpactSmokePuff", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    TNT1 A 5 A_PlaySound("generic/ricochet")
    stop
  XDeath:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
    TNT1 A 5 A_PlaySound("generic/ricochets")
    stop
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
    TNT1 A 0 A_SpawnItemEx("ImpactSmokePuff_2", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    TNT1 A 5 A_PlaySound("generic/ricochet")
    stop
  }
}

actor HHCBMG4G : HHCBMG4
{
  damage (random(30,40))
}