actor "Barrett M82" : RGUWeapon
{
  obituary "%k gives %o a .50 cal bullet."
  inventory.pickupmessage "You got the Barrett M82 anti-materiel rifle. You're going to blow them apart!"
  //attacksound "barrett/fire"
  weapon.selectionorder 16
  weapon.ammotype "BarrettClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "BarrettAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    B50A A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    B50A BCDEFGH 2 A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWZOOM)
	B50A IJKLMNOP 2 A_WeaponReady(WRF_ALLOWZOOM)
	M4CD A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50A P 0 A_JumpIfNoAmmo("Reload")
	M4CC F 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    B50A P 0 A_JumpIfInventory("Aiming",1,5)
    B50A P 0 A_JumpIfInventory("Reloading",1,"Reload")
    B50A P 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    B50A P 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50A P 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+20
    INTF G 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    INTF G 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    INTF G 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    INTF G 0 A_JumpIfInventory("GZCheck",1,4)
    INTF G 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    INTF G 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    INTF G 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    SCOP B 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
  Deselect:
    B50A P 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    B50A P 0 A_TakeInventory("Aiming",1)
    B50A P 0 A_TakeInventory("Reloading",1)
    B50A P 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50A P 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50A P 0 A_Lower
    B50A P 1 A_Lower
    Goto Deselect+5
  Select:
    B50A A 0 A_Raise
    Loop
  Fire:
    "####" "#" 0 A_JumpIfInventory("Aiming",1,"FireAim")
    B50A P 1 A_JumpIfNoAmmo("ReloadStart")
    B50B A 0 A_JumpIfInventory("CoopCheck",1,2)
    B50B A 0 A_TakeInventory("PowerInvisibility",500)
    B50B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    B50B A 0 A_PlayWeaponSound("barrett/fire")
    B50B AA 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,6,3)
    B50B A 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,6,3)
    B50B A 1 BRIGHT A_FireCustomMissile("HHCBBARRETTA", frandom(-15.00,15.00), 1, 0, 4, 0, frandom(-15.00,15.00))
	B50B A 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    B50B B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    B50B A 0 A_JumpIfNoAmmo("FireEmpty")
    B50B B 1 BRIGHT A_GunFlash
    B50B CDEF 1
    B50A PPPPPPPPPP 1 
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  FireEmpty:
    B50B B 1 BRIGHT A_GunFlash
    B50B C 1 A_GiveInventory("BarrettBolt",1)
    B50B DEF 1
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  FireAim:
    "####" "#" 1 A_JumpIfNoAmmo("ReloadStart")
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    "####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
  FireAimCont:
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    "####" "#" 0 A_JumpIfNoAmmo("FireAimEmpty")
    "####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "#" 2
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+26
    "####" "#" 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+26
  FireAimSteady:
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "#" 2
    "####" "##" 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWZOOM)
	Goto FireAimCont+7
  FireAimMoving:
    "####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,3)
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTC", frandom(-6.00,6.00), 1, 0, 4, 0, frandom(-6.00,6.00))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    Goto FireAimCont
    "####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 0, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-1.00,1.00), 1, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    Goto FireAimCont
  FireAimEmpty:
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "#" 1 A_GiveInventory("BarrettBolt",1)
    "####" "###" 1
    "####" "#" 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+26
    "####" "#" 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+26
  Reload: //AltFire:
    B50C A 0 A_JumpIfInventory("BarrettClip",10,2)
    B50C A 0 A_JumpIfInventory("BarrettAmmo",1,"ReloadStart")
    B50C A 0 A_TakeInventory("Reloading",1)
    B50C A 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+23
  ReloadStart:
    B50C A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    B50C A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    B50C A 3 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
	B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload2")
    B50C BCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50C GHIJK 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    B50C L 3 A_PlaySoundEx("barrett/clipout","SoundSlot5")
    B50C MNOPQR 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C R 0 A_FireCustomMissile("BarrettEmptyMagSpawner",0,0,0,-4)
	B50C R 0 A_GiveInventory("BarrettToken",1)
	goto Reload2
  Reload2:
    B50C STUVWXYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D ABC 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C A 0 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo
  ReloadAmmo:
    B50D C 0 A_JumpIfInventory("BarrettClip",10,"ReloadEnd")
	B50D C 0 A_TakeInventory("BarrettToken",1)
    B50D C 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto ReloadEnd
    B50D C 0 A_GiveInventory("BarrettClip",1)
    B50D C 0 A_TakeInventory("BarrettAmmo",1)
    Goto ReloadAmmo
  ReloadEnd:
    B50D D 3 A_PlaySoundEx("barrett/clipin","SoundSlot5")
    B50D EFGHIJKLM 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D N 3 A_JumpIfInventory("BarrettBolt",1,"ReloadEndBolt")
    B50A MNOP 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt") 
    Goto Ready+20
  ReloadEndBolt:
    B50D NO 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D P 3 A_PlaySoundEx("barrett/bolt","SoundSlot5")
    B50D Q 3 A_TakeInventory("BarrettBolt",1)
    B50D R 3
    B50D STUV 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+20
  Zoom:
  PostReloadAlt:
    B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50F D 0 A_GiveInventory("Aiming",1)
	B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50F ABCDE 1
	B50F E 0 A_ZoomFactor(3.0,ZOOM_INSTANT)
	"####" "#" 0 ACS_NamedExecuteAlways("RefKick",0,0,0,2)
    Goto AltHold
  ReloadBreak:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	TNT1 A 0 A_ClearReFire
    Goto Reload
  ClearRefire: 
    SCOP B 1 A_ClearReFire
	Goto AltHold
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
	"####" "#" 0 A_TakeInventory("BarrettClip",1)
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    //"####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    //"####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
	TNT1 A 0
    Goto AltHold
  AltHold:
    "####" "#" 0 A_JumpIfInventory("FireHeld",1,"ClearRefire")
    SCOP B 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
	"####" "#" 0 A_JumpIfInventory("FireHeld",1,"FireAimAltHold")
	"####" "#" 0 A_JumpIfInventory("Reloading",1,"ReloadBreak")
	"####" "#" 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    "####" "#" 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	//"####" "#" 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
	"####" "#" 0 A_Refire("AltHold")
	"####" "#" 0 A_JumpIfInventory("Aiming",1,"AltFire2")
	Goto Ready+26
  AltFire:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    M4CD A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
	"####" "#" 0 A_JumpIfInventory("AltFireHeld",1,"AltHold")
    B50F A 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    B50F AB 1
    B50F B 0 A_GiveInventory("Aiming",1)
    B50F CDE 1
    B50F E 0 A_ZoomFactor(3.0,ZOOM_INSTANT)
    B50F E 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50F E 0 ACS_NamedExecuteAlways("RefKick",0,0,0,2)
	"####" "##" 0 A_Refire("AltHold")
    Goto Ready+26
  AltFire2:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto Ready+20
  ReloadStartAim:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F 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 E 0
    WEAP E 0 A_SpawnItem("BarrettDrop")
    stop
  Fire_SteadyAim:
    B50B A 0 A_PlayWeaponSound("barrett/fire")
    B50B AA 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,6,3)
    B50B A 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,6,3)
    B50B A 1 BRIGHT A_FireCustomMissile("HHCBBARRETTA", frandom(-10.00,10.00), 1, 0, 4, 0, frandom(-10.00,10.00))
	B50B A 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    B50B B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    B50B A 0 A_JumpIfNoAmmo("FireEmpty")
    B50B B 1 BRIGHT A_GunFlash
    B50B CDEF 1
    B50A PPPPPPPPPP 1 
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  ReloadStart_SOH:
    B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload3")
    B50C A 2
    B50C BCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50C GHIJK 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    B50C L 2 A_PlaySoundEx("barrett/clipout","SoundSlot5")
    B50C MNOPQR 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C R 0 A_FireCustomMissile("BarrettEmptyMagSpawner",0,0,0,-4)
	B50C R 0 A_GiveInventory("BarrettToken",1)
	goto Reload3
  Reload3:
    B50C STUVWXYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D AB 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C A 0 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    B50D C 0 A_JumpIfInventory("BarrettClip",10,"ReloadEnd_SOH")
	B50D C 0 A_TakeInventory("BarrettToken",1)
    B50D C 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto ReloadEnd_SOH
    B50D C 0 A_GiveInventory("BarrettClip",1)
    B50D C 0 A_TakeInventory("BarrettAmmo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    B50D C 2 A_PlaySoundEx("barrett/clipin","SoundSlot5")
    B50D DEFGHIJKLM 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D N 2 A_JumpIfInventory("BarrettBolt",1,"ReloadEndBolt_SOH")
    B50A MNOP 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+20
  ReloadEndBolt_SOH:
    B50D N 2 A_PlaySoundEx("barrett/bolt","SoundSlot5")
    B50D O 2 A_TakeInventory("BarrettBolt",1)
    B50D P 2
    B50D QRSTUV 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+20
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,1,0,0)
    U45F A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    U45F A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    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("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  DropWeapon:
    B50A ONMLKJIHGFEDCB 2 A_WeaponReady(WRF_NOPRIMARY)
	B50A 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("BarrettDropped",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("BarrettThrown",0,0,7,2)
	stop
  }
}

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

actor BarrettBolt : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor "Barrett M82 Thermal" : "Barrett M82"
{
  obituary "%k gives %o a .50 cal bullet."
  inventory.pickupmessage "You got the Barrett M82 anti-materiel rifle. Let's pop some skulls!"
  //attacksound "barrett/fire"
  weapon.selectionorder 28
  weapon.ammotype "BarrettClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "BarrettAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    B50A A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    B50A BCDEFGH 2 A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWZOOM)
	B50A IJKLMNOP 2 A_WeaponReady(WRF_ALLOWZOOM)
	M4CD A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50A P 0 A_JumpIfNoAmmo("Reload")
	M4CC F 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    B50A P 0 A_JumpIfInventory("Aiming",1,5)
    B50A P 0 A_JumpIfInventory("Reloading",1,"Reload")
    B50A P 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    B50A P 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50A P 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+20
    INTF G 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    INTF G 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    INTF G 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    INTF G 0 A_GiveInventory("SniperInfrared",1)
    INTF G 0 A_JumpIfInventory("GZCheck",1,4)
    INTF G 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    INTF G 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    INTF G 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    SCOP B 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
  Deselect:
    B50A P 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    B50A P 0 A_TakeInventory("PowerLightAmp",500)
    B50A P 0 A_TakeInventory("Aiming",1)
    B50A P 0 A_TakeInventory("AimingFar",1)
    B50A P 0 A_TakeInventory("Reloading",1)
    B50A P 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50A P 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50A P 0 A_Lower
    B50A P 1 A_Lower
    Goto Deselect+7
  Zoom:
  PostReloadAlt:
    B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50F D 0 A_GiveInventory("Aiming",1)
	B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50F ABCDE 1
	B50F E 0 A_ZoomFactor(3.0,ZOOM_INSTANT)
	B50F E 0 ACS_NamedExecuteAlways("RefKick",0,0,0,2)
	"####" "#" 0 A_GiveInventory("SniperInfrared",1)
	"####" "#" 0 A_GiveInventory("AimingFar",1)
    Goto AltHold
  ReloadBreak:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
	M14C F 0 A_TakeInventory("PowerLightAmp",500)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	TNT1 A 0 A_ClearReFire
    Goto Reload
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
	"####" "#" 0 A_TakeInventory("BarrettClip",1)
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    //"####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    //"####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
	TNT1 A 0
    Goto AltHold
  AltHold:
    "####" "#" 0 A_GiveInventory("SniperInfrared",1)
	"####" "#" 0 A_GiveInventory("AimingFar",1)
    "####" "#" 0 A_JumpIfInventory("FireHeld",1,"ClearRefire")
    SCOP B 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
	"####" "#" 0 A_JumpIfInventory("FireHeld",1,"FireAimAltHold")
	"####" "#" 0 A_JumpIfInventory("Reloading",1,"ReloadBreak")
	"####" "#" 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    "####" "#" 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
	//"####" "#" 0 A_JumpIfInventory("weapondropper",1,"AltFire3")
	"####" "#" 0 A_Refire("AltHold")
	"####" "#" 0 A_JumpIfInventory("Aiming",1,"AltFire2")
	Goto Ready+26
  AltFire:
    "####" "#" 0 A_TakeInventory("weapondropper",2)
    "####" "#" 0 A_JumpIfInventory("BarrettToken",1,"Reload")
	"####" "#" 0 A_JumpIfInventory("AltFireHeld",1,"AltHold")
    "####" "#" 0 A_JumpIfInventory("Aiming",1,"AltFire2")
    B50F AB 1
    B50F B 0 A_GiveInventory("Aiming",1)
    B50F B 0 A_TakeInventory("AimingFar",1)
    B50F CDE 1
    B50F E 0 A_ZoomFactor(3.0,ZOOM_INSTANT)
    B50F E 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50F E 0 ACS_NamedExecuteAlways("RefKick",0,0,0,2)
	"####" "##" 0 A_Refire("AltHold")
    Goto Ready+26
  AltFire2:
    "####" "#" 0 A_JumpIfInventory("AimingFar",1,"AltFire3")
    "####" "#" 0 A_PlaySoundEx("weapon/down","SoundSlot5")
    "####" "#" 0 A_GiveInventory("AimingFar",1)
    "####" "#" 5 A_ZoomFactor(7.5)
    Goto Ready+26
  AltFire3:
    B50F E 0 A_TakeInventory("PowerLightAmp",500)
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F D 0 A_TakeInventory("AimingFar",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto Ready+20
  ReloadStartAim:
    B50F E 0 A_TakeInventory("PowerLightAmp",500)
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F D 0 A_TakeInventory("AimingFar",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  FragGrenade:
    U45F A 0 ACS_NamedExecuteAlways("RefSpeak",0,1,0,0)
    U45F A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    U45F A 0 A_TakeInventory("PowerLightAmp",500)
    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
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  KnifeAttack:
    GRNA L 0 A_TakeInventory("weapondropper",2)
    U45F A 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    U45F A 0 A_TakeInventory("PowerLightAmp",500)
    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("ThrowingGrenade",1)
    GRNA L 0 A_TakeInventory("KnifeAttack",1)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+3
  }
}
ACTOR SniperInfrared : PowerupGiver
{
  Game Doom
  SpawnID 138
  +COUNTITEM
  +INVENTORY.AUTOACTIVATE
  +INVENTORY.ALWAYSPICKUP
  Inventory.MaxAmount 0
  Powerup.Type "LightAmp"
  Powerup.Duration -350
  Inventory.PickupMessage "$GOTVISOR" // "Light Amplification Visor"
  States
  {
    Spawn:
    PVIS A 6 Bright
    PVIS B 6
    Loop
  }
}

actor BarrettThermal : Inventory
{
    inventory.amount 0
    inventory.maxamount 1
}
actor "Barrett M82 Ex Mags" : "Barrett M82"
{
  obituary "%k gives %o a .50 cal bullet."
  inventory.pickupmessage "You got the Barrett M82 anti-materiel rifle. Let's pop some skulls!"
  //attacksound "barrett/fire"
  weapon.selectionorder 16
  weapon.ammotype "BarrettClip2"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "BarrettAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Ready:
    M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    GRNA L 0 A_TakeInventory("weapondropper",2)
    B50A A 0 A_PlaySoundEx("weapon/draw","SoundSlot5")
    B50A BCDEFGH 2 A_WeaponReady(WRF_NOPRIMARY|WRF_ALLOWZOOM)
	B50A IJKLMNOP 2 A_WeaponReady(WRF_ALLOWZOOM)
	M4CD A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50A P 0 A_JumpIfNoAmmo("Reload")
	M4CC F 0 A_JumpIfInventory("weapondropper",1,"DropWeapon")
    B50A P 0 A_JumpIfInventory("Aiming",1,5)
    B50A P 0 A_JumpIfInventory("Reloading",1,"Reload")
    B50A P 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    B50A P 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50A P 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+20
    INTF G 0 A_JumpIfInventory("Reloading",1,"Reload")
  ReadyAim:
    INTF G 0 A_JumpIfInventory("ThrowingGrenade",1,"FragGrenade")
    INTF G 0 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    INTF G 0 A_JumpIfInventory("GZCheck",1,4)
    INTF G 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    INTF G 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    INTF G 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,2)
    SCOP B 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
    SCOP B 1 A_WeaponReady(WRF_NOBOB|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Goto Ready+26
  Reload: //AltFire:
    B50C A 0 A_JumpIfInventory("BarrettClip2",15,2)
    B50C A 0 A_JumpIfInventory("BarrettAmmo",1,"ReloadStart")
    B50C A 0 A_TakeInventory("Reloading",1)
    B50C A 0 A_JumpIfInventory("Aiming",1,"ReadyAim")
    Goto Ready+23
  ReloadStart:
    B50C A 0 ACS_NamedExecuteAlways("RefSpeak",0,0,0,0)
    B50C A 0 A_JumpIfInventory("Aiming",1,"ReloadStartAim")
    B50C A 3 A_JumpIfInventory("Perk1_SOH",1,"ReloadStart_SOH")
	B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload2")
    B50C BCDEF 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50C GHIJK 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    B50C L 3 A_PlaySoundEx("barrett/clipout","SoundSlot5")
    B50C MNOPQR 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C R 0 A_FireCustomMissile("BarrettEmptyMagSpawner",0,0,0,-4)
	B50C R 0 A_GiveInventory("BarrettToken",1)
	goto Reload2
  Reload2:
    B50C STUVWXYZ 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D ABC 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C A 0 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo
  ReloadAmmo:
    B50D C 0 A_JumpIfInventory("BarrettClip2",15,"ReloadEnd")
	B50D C 0 A_TakeInventory("BarrettToken",1)
    B50D C 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto ReloadEnd
    B50D C 0 A_GiveInventory("BarrettClip2",1)
    B50D C 0 A_TakeInventory("BarrettAmmo",1)
    Goto ReloadAmmo
  ReloadEnd:
    B50D D 3 A_PlaySoundEx("barrett/clipin","SoundSlot5")
    B50D EFGHIJKLM 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D N 3 A_JumpIfInventory("BarrettBolt",1,"ReloadEndBolt")
    B50A MNOP 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+20
  ReloadEndBolt:
    B50D NO 3 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D P 3 A_PlaySoundEx("barrett/bolt","SoundSlot5")
    B50D Q 3 A_TakeInventory("BarrettBolt",1)
    B50D R 3
    B50D STUV 3 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+20
  ReloadStart_SOH:
    B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload3")
    B50C A 2
    B50C BCDEF 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50C GHIJK 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    B50C L 2 A_PlaySoundEx("barrett/clipout","SoundSlot5")
    B50C MNOPQR 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C R 0 A_FireCustomMissile("BarrettEmptyMagSpawner",0,0,0,-4)
	B50C R 0 A_GiveInventory("BarrettToken",1)
	goto Reload3
  Reload3:
    B50C STUVWXYZ 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D AB 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	B50C A 0 A_TakeInventory("Reloading",1)
    Goto ReloadAmmo_SOH
  ReloadAmmo_SOH:
    B50D C 0 A_JumpIfInventory("BarrettClip2",15,"ReloadEnd_SOH")
	B50D C 0 A_TakeInventory("BarrettToken",1)
    B50D C 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto ReloadEnd_SOH
    B50D C 0 A_GiveInventory("BarrettClip2",1)
    B50D C 0 A_TakeInventory("BarrettAmmo",1)
    Goto ReloadAmmo_SOH
  ReloadEnd_SOH:
    B50D C 2 A_PlaySoundEx("barrett/clipin","SoundSlot5")
    B50D DEFGHIJKLM 2 A_JumpIfInventory("KnifeAttack",1,"KnifeAttack")
    B50D N 2 A_JumpIfInventory("BarrettBolt",1,"ReloadEndBolt_SOH")
    B50A MNOP 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
	M4CA C 0 A_JumpIfInventory("AltFireHeld",1,"PostReloadAlt")
    Goto Ready+20
  ReloadEndBolt_SOH:
    B50D N 2 A_PlaySoundEx("barrett/bolt","SoundSlot5")
    B50D O 2 A_TakeInventory("BarrettBolt",1)
    B50D P 2
    B50D QRSTUV 2 A_WeaponReady(WRF_NOBOB|WRF_NOFIRE)
    Goto Ready+20
  ReloadStartAim:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    Goto ReloadStart+2
  PostReloadAlt:
    B50C A 0 A_JumpIfInventory("BarrettToken",1,"Reload")
    B50F D 0 A_GiveInventory("Aiming",1)
	B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
    B50F ABCDE 1
	B50F E 0 A_ZoomFactor(3.0,ZOOM_INSTANT)
	"####" "#" 0 ACS_NamedExecuteAlways("RefKick",0,0,0,2)
    Goto AltHold
  ReloadBreak:
    B50F E 0 A_ZoomFactor(1.0,ZOOM_INSTANT)
    B50F ED 1
    B50F D 0 A_TakeInventory("Aiming",1)
    B50F CBA 1
    B50F A 0 ACS_NamedExecuteAlways("RefSpeed",0,0,0,0)
	TNT1 A 0 A_ClearReFire
    Goto Reload
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("BarrettClip2",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
	"####" "#" 0 A_TakeInventory("BarrettClip2",1)
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    //"####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 0, 0, 4, 0, frandom(-0.10,0.10))
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTD", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50Cal",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    //"####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettClip2",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
	TNT1 A 0
    Goto AltHold
  }
}

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

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

actor "Barrett M82 Explosive" : "Barrett M82"
{
  obituary "%k's Barrett M82 showed %o what 'Anti Materiel' means."
  inventory.pickupmessage "You got the Barrett M82 anti-materiel rifle. Let's pop some skulls!"
  //attacksound "barrett/fire"
  +WEAPON.EXPLOSIVE
  weapon.selectionorder 16
  weapon.ammotype "BarrettClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "BarrettAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0
  states
  {
  Fire:
    "####" "#" 0 A_JumpIfInventory("Aiming",1,"FireAim")
    B50A P 1 A_JumpIfNoAmmo("ReloadStart")
    B50B A 0 A_JumpIfInventory("CoopCheck",1,2)
    B50B A 0 A_TakeInventory("PowerInvisibility",500)
    B50B A 0 A_JumpIfInventory("Perk3_SteadyAim",1,"Fire_SteadyAim")
    B50B A 0 A_PlayWeaponSound("barrett/fire")
    B50B AA 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,6,3)
    B50B A 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,6,3)
    B50B A 1 BRIGHT A_FireCustomMissile("HHCBBARRETTAE", frandom(-15.00,15.00), 1, 0, 4, 0, frandom(-15.00,15.00))
	B50B A 0 A_SpawnItemEx("RifleCasing50CalEXP",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    B50B B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    B50B A 0 A_JumpIfNoAmmo("FireEmpty")
    B50B B 1 BRIGHT A_GunFlash
    B50B CDEF 1
    B50A PPPPPPPPPP 1 
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  FireEmpty:
    B50B B 1 BRIGHT A_GunFlash
    B50B C 1 A_GiveInventory("BarrettBolt",1)
    B50B DEF 1
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  FireAim:
    "####" "#" 1 A_JumpIfNoAmmo("ReloadStart")
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    "####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTBE", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50CalEXP",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
  FireAimCont:
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    "####" "#" 0 A_JumpIfNoAmmo("FireAimEmpty")
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "#" 2
    "####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+26
    "####" "#" 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+26
  FireAimMoving:
    "####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,3)
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTCE", frandom(-6.00,6.00), 1, 0, 4, 0, frandom(-6.00,6.00))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50CalEXP",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    Goto FireAimCont
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTBE", frandom(-1.00,1.00), 1, 0, 4, 0, frandom(-1.00,1.00))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50CalEXP",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    Goto FireAimCont
  FireAimEmpty:
    "####" "#" 1 BRIGHT A_GunFlash
    "####" "#" 1 A_GiveInventory("BarrettBolt",1)
    "####" "###" 1
    "####" "#" 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+26
    INTF G 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+26
  Fire_SteadyAim:
    B50B A 0 A_PlayWeaponSound("barrett/fire")
    B50B AA 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,6,3)
    B50B A 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,6,3)
    B50B A 1 BRIGHT A_FireCustomMissile("HHCBBARRETTDE", frandom(-10.00,10.00), 1, 0, 4, 0, frandom(-10.00,10.00))
    B50B B 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    B50B A 0 A_JumpIfNoAmmo("FireEmpty")
    B50B B 1 BRIGHT A_GunFlash
    B50B CDEF 1
    B50A PPPPPPPPPP 1 
    B50B A 0 A_JumpIfInventory("BarrettAmmo",1,1)
    Goto Ready+20
    B50B A 0 A_JumpIfNoAmmo("ReloadStart")
    Goto Ready+20
  FireAimAltHold:
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
    "####" "#" 0 A_JumpIfInventory("CoopCheck",1,2)
    "####" "#" 0 A_TakeInventory("PowerInvisibility",500)
    "####" "#" 0 A_PlayWeaponSound("barrett/fire")
	"####" "#" 0 A_TakeInventory("BarrettClip",1)
    "####" "##" 0 A_FireCustomMissile("WeaponSmokePuffShotgun",0,0,0,2)
    "####" "#" 0 A_FireCustomMissile("WeaponSmokePuff_ShotMuzzle",0,0,0,2)
    //"####" "#" 0 A_JumpIf((MomX*MomX)+(MomY*MomY) > 15,"FireAimMoving")
    "####" "#" 1 BRIGHT A_FireCustomMissile("HHCBBARRETTBE", frandom(-0.10,0.10), 1, 0, 4, 0, frandom(-0.10,0.10))
	"####" "#" 0 A_SpawnItemEx("RifleCasing50CalEXP",Cos(Pitch)*30,3,34-(Sin(Pitch)*25),Cos(Pitch)*FRandom(2,4),FRandom(3,6),-Sin(Pitch)*FRandom(3,6),0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
    "####" "#" 0 BRIGHT ACS_NamedExecuteAlways("RefKick",0,0,0,0)
    "####" "#" 1 BRIGHT A_GunFlash
    //"####" "#" 0 A_JumpIfInventory("Perk3_SteadyAim_Pro",1,"FireAimSteady")
    "####" "##" 1 A_WeaponReady(WRF_ALLOWZOOM)
    "####" "#" 0 A_JumpIfInventory("BarrettClip",1,2)
	TNT1 A 0 A_GiveInventory("BarrettBolt",1)
	Goto ReloadBreak
	TNT1 A 0
    Goto AltHold
  }
}

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

actor BarrettPickup : CustomInventory
{
  inventory.pickupmessage "You got the Barrett M82 anti-materiel rifle. Let's pop some skulls!"
  inventory.pickupsound "barrett/bolt"
  +INVENTORY.AUTOACTIVATE
  //inventory.respawntics 70
  scale 0.16
  States
  {
  Spawn:
    WEAP E -1
    stop
  Pickup:
    WEAP E 0
    WEAP E 0 A_JumpIf((ACS_NamedExecuteWithResult("RefCheckVar",0,0,0)) == 1, "PickupStay")
    WEAP E 0 A_JumpIfInventory("Barrett M82",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP E 0 A_JumpIfInventory("Barrett M82 Ex Mags",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Thermal",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Explosive",1,"AmmoPickup")
	WEAP E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP E 0 A_JumpIfInventory("MaxWeaponsFilled",61,"FailPickup2")
	WEAP E 0 A_GiveInventory("MaxWeaponsFilled",40)
    WEAP E 0 ACS_NamedExecuteWithResult("RefPickU",2,0,0)
    stop
  PickupStay:
    WEAP E 0
    WEAP E 0 A_JumpIfInventory("Barrett M82",1,"FailPickup") // If the player already has this weapon, they get more ammo for it
    WEAP E 0 A_JumpIfInventory("Barrett M82 Ex Mags",1,"FailPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Thermal",1,"FailPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Explosive",1,"FailPickup")
	WEAP E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP E 0 A_JumpIfInventory("MaxWeaponsFilled",61,"FailPickup2")
	WEAP E 0 A_GiveInventory("MaxWeaponsFilled",40)
    WEAP E 0 ACS_NamedExecuteWithResult("RefPickU",2,0,0)
    WEAP E 0 ACS_NamedExecuteWithResult("RefPickC",2,0,0)
    WEAP E 0 A_PlaySound("barrett/bolt")
    fail
  AmmoPickup:
    WEAP E 0
    WEAP E 0 A_JumpIfInventory("BarrettAmmo",0,"FailPickup")
    WEAP E 0 A_GiveInventory("BarrettAmmo",10)
    stop
  OneManArmy:
    WEAP E 0
	WEAP E 0 A_JumpIfInventory("MaxWeaponsFilled",98,"FailPickup2")
	WEAP E 0 A_GiveInventory("MaxWeaponsFilled",40)
	WEAP E 0 ACS_NamedExecuteWithResult("RefPickU",2,0,0)
	stop
  FailPickup:
    WEAP E 1
    fail
  FailPickup2:
    WEAP E 1
    WEAP E 0 ACS_NamedExecuteAlways("RefSlots",0,29,0,0)
    fail
  }
}

actor BarrettDrop : BarrettPickup
{
  States
  {
  Spawn:
    WEAP E -1
    stop
  Pickup:
    WEAP E 0
    WEAP E 0 A_JumpIfInventory("Barrett M82",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP E 0 A_JumpIfInventory("Barrett M82 Ex Mags",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Thermal",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Explosive",1,"AmmoPickup")
	WEAP E 0 A_JumpIfInventory("Perk1_OneManArmy",1,"OneManArmy")
    WEAP E 0 A_JumpIfInventory("MaxWeaponsFilled",61,"FailPickup2")
	WEAP E 0 A_GiveInventory("MaxWeaponsFilled",40)
    WEAP E 0 ACS_NamedExecuteWithResult("RefPickU",2,0,0)
    stop
  }
}

actor BarrettDrop2 : BarrettDrop
{
  States
  {
  Spawn:
    WEAP E 5880
    WEAP EEEEEEEEEEEEEEEEEE 140 A_FadeOut(0.05)
    stop
  Pickup:
    WEAP E 0
    WEAP E 0 A_JumpIfInventory("Barrett M82",1,"AmmoPickup") // If the player already has this weapon, they get more ammo for it
    WEAP E 0 A_JumpIfInventory("Barrett M82 Ex Mags",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Thermal",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("Barrett M82 Explosive",1,"AmmoPickup")
    WEAP E 0 A_JumpIfInventory("MaxWeaponsFilled",0,"FailPickup2")
	WEAP E 0 A_GiveInventory("MaxWeaponsFilled",1)
    WEAP E 0 ACS_NamedExecuteWithResult("RefPickU",2,0,0)
    stop
  AmmoPickup:
    WEAP E 0
    stop
  }
}

actor HHCBBARRETTA : HHBullet
{
  damage (254)
  //damagetype "Explosion"
  +EXTREMEDEATH
  obituary "%k gives %o a .50 cal bullet."
  States
  {
  Spawn:
    TNT1 A 2
    Loop
  Death:
    TNT1 A 0 A_SpawnItemEx("ImpactSmokePuff", 0, 0, 0, 0, 0, 0, 0, 128, 0)
    TNT1 A 5 A_PlaySound("generic/ricochet")
	TNT1 A 10 A_AlertMonsters(136)
    stop
  XDeath:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
    TNT1 A 5 A_PlaySound("generic/ricochets")
	TNT1 A 10 A_AlertMonsters(136)
    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")
	TNT1 A 10 A_AlertMonsters(136)
    stop
  }
}
actor HHCBBARRETTB : HHCBBARRETTA
{
  +EXTREMEDEATH
  damage (36)
}
actor HHCBBARRETTC : HHCBBARRETTA
{
  +EXTREMEDEATH
  damage (246)
}
actor HHCBBARRETTD : HHCBBARRETTA
{
  +EXTREMEDEATH
  damage (38)
}

actor HHCBBARRETTAE : HHBullet
{
  damage (230)
  +FORCERADIUSDMG
  -BLOODSPLATTER
  +EXTREMEDEATH
  decal RevenantScorch
  damagetype "Explosion"
  SeeSound "generic/explosionsmall"
  AttackSound "generic/explosionsmall"
  States
  {
  Spawn:
    TNT1 A 2
	Loop
  XDeath:
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
  Death:
    TNT1 A 0 Radius_Quake(2,5,0,6,0)
    TNT1 A 0 A_SetDamageType("Explosion")
    TNT1 A 0 A_Explode(33,75)
	TNT1 A 0 A_PlaySoundEx("distant/explosionsmaller","SoundSlot6")
    TNT1 AAAAAAA 0 A_SpawnItemEx("ImpactSpark2", 0, 0, 0, random(-3,-1), random(-2,2), random(-2,2), 0, 128, 64)
    TNT1 AA 0 A_SpawnItemEx("ExplosionSmall2", random(-2,0), random(-1,1), random(-1,1), 0, 0, 0, 0, 128, 0)
    TNT1 A 5
    TNT1 A 15 A_AlertMonsters(300)
    stop
  }
}
actor HHCBBARRETTBE : HHCBBARRETTAE
{
  damage (200)
    +EXTREMEDEATH
  States
  {
  XDeath:
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
  Death:
    TNT1 A 0 Radius_Quake(2,5,0,6,0)
    TNT1 A 0 A_SetDamageType("Explosion")
    TNT1 A 0 A_Explode(75,75)
	TNT1 A 0 A_PlaySoundEx("distant/explosionsmaller","SoundSlot6")
    TNT1 AAAAAAA 0 A_SpawnItemEx("ImpactSpark2", 0, 0, 0, random(-3,-1), random(-2,2), random(-2,2), 0, 128, 64)
    TNT1 AA 0 A_SpawnItemEx("ExplosionSmall2", random(-2,0), random(-1,1), random(-1,1), 0, 0, 0, 0, 128, 0)
    TNT1 A 5
    TNT1 A 15 A_AlertMonsters(300)
    stop
  }
}
actor HHCBBARRETTCE : HHCBBARRETTAE
{
  damage (190)
    +EXTREMEDEATH
  States
  {
  XDeath:
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
  Death:
    TNT1 A 0 Radius_Quake(2,5,0,6,0)
    TNT1 A 0 A_SetDamageType("Explosion")
    TNT1 A 0 A_Explode(65,75)
	TNT1 A 0 A_PlaySoundEx("distant/explosionsmaller","SoundSlot6")
    TNT1 AAAAAAA 0 A_SpawnItemEx("ImpactSpark2", 0, 0, 0, random(-3,-1), random(-2,2), random(-2,2), 0, 128, 64)
    TNT1 AA 0 A_SpawnItemEx("ExplosionSmall2", random(-2,0), random(-1,1), random(-1,1), 0, 0, 0, 0, 128, 0)
    TNT1 A 5
    TNT1 A 15 A_AlertMonsters(300)
    stop
  }
}
actor HHCBBARRETTDE : HHCBBARRETTAE
{
  damage (189)
    +EXTREMEDEATH
  States
  {
  XDeath:
  Crash:
    TNT1 A 0 A_GiveToTarget("HitIndicator",1)
  Death:
    TNT1 A 0 Radius_Quake(2,5,0,6,0)
    TNT1 A 0 A_SetDamageType("Explosion")
    TNT1 A 0 A_Explode(38,75)
	TNT1 A 0 A_PlaySoundEx("distant/explosionsmaller","SoundSlot6")
    TNT1 AAAAAAA 0 A_SpawnItemEx("ImpactSpark2", 0, 0, 0, random(-3,-1), random(-2,2), random(-2,2), 0, 128, 64)
    TNT1 AA 0 A_SpawnItemEx("ExplosionSmall2", random(-2,0), random(-1,1), random(-1,1), 0, 0, 0, 0, 128, 0)
    TNT1 A 5
    TNT1 A 15 A_AlertMonsters(300)
    stop
  }
}