actor FMG : Weapon
{
  Game Doom
  Weapon.AmmoUse 1
  Weapon.AmmoGive 0
  Weapon.AmmoGive2 70
  Weapon.AmmoType "FMGClip"
  Weapon.AmmoType2 "BulletAmmo"
  Weapon.SlotNumber 4
  Weapon.SelectionOrder 3
  Weapon.UpSound "FMG/Up"
  Weapon.Kickback 50
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "Nabbed a rather shiny FMG! A Fucking MachineGun! (4)"
  Obituary "%o was sworn to death by %k's FMG."
  Weapon.BobStyle InverseSmooth
  Weapon.BobSpeed 2.0
  Weapon.BobRangeY 0.4
  Weapon.BobRangeX 0.7
  +AMMO_CHECKBOTH
  +NOALERT
  +NOAUTOFIRE
  //+NOAUTOAIM
  States
  {
  Ready:
    FMGU ABCDEF 1
  ReadyMain:
	FMGG A 0 A_JumpIfInventory("FMGZoomed",1,"ZoomedReady")
	FMGG A 0 A_JumpIfInventory("MacheteGoesFast",1,"CaberToss")
	FMGG A 0 A_SetCrosshair(0)
    FMGG A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
    Loop
  AltFire:
    FMIU A 0 A_PlaySound("Sights/Weapon",5,0.8)
    FMIU A 0 A_JumpIfInventory("FMGZoomed",1,"UnZoom")
	FMIU A 0 A_ZoomFactor(2.5)
	FMIU A 0 A_SetCrosshair(77)
    FMIU ABCDEF 1
    FMIG A 1 A_GiveInventory("FMGZoomed",1)
	Goto ZoomedReady
  UnZoom:
	FMIU A 0 A_ZoomFactor(1)
    FMIU FEDCBA 1
    FMGG A 1 A_TakeInventory("FMGZoomed",1)
	Goto ReadyMain
  ZoomedReady:
    FMIG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
	Goto ReadyMain
  DryFire:
	FMGF A 0 A_JumpIfInventory("FMGFireToken",1,"Gundown")
	FMGD A 0 A_PlaySound("FMG/Dry",4,0.7)
	FMGD ABCBA 1
	Goto ReadyMain
  ZoomedDryFire:
	FMGF A 0 A_JumpIfInventory("FMGFireToken",1,"GundownZoom")
	FMGD A 0 A_PlaySound("FMG/Dry",4,0.9) //Louder in ironsights. DETAILS!
	FMID ABCBA 1
	Goto ReadyMain
  Gundown: //to make it not jump into ready state all of a sudden, as it looks ugly as fuck. :3
    FMGF A 0 A_TakeInventory("FMGFireToken",1)
	FMGF DE 1
	Goto ReadyMain
  GundownZoom:
    FMGF A 0 A_TakeInventory("FMGFireToken",1)
	FMIG A 2
	Goto ReadyMain
  Deselect:
    FMGU A 0 A_JumpIfInventory("FMGZoomed",1,"ZoomedDeselect")
	FMGU A 0 A_TakeInventory("FMGFireToken",1)
	FMIU A 0 A_ZoomFactor(1)
	FMIU A 0 A_SetCrosshair(0)
    FMGU FEDCBA 1
    TNT1 A 0 SetPlayerProperty(0, 0, PROP_INSTANTWEAPONSWITCH)
    TNT1 AAAAAAAAAAAAAAA 0 A_Lower
    TNT1 A 1 A_Lower
    Wait
  ZoomedDeselect:
    FMIU A 0 A_PlaySound("Sights/Weapon",5,0.8)
	FMIU A 0 A_ZoomFactor(1)
	FMIU A 0 A_SetCrosshair(0)
    FMIU FEDCBA 1
    FMGG A 4 A_TakeInventory("FMGZoomed",1)
    Goto Deselect
  Select:
    TNT1 A 0 SetPlayerProperty(0, 1, PROP_INSTANTWEAPONSWITCH)
    TNT1 A 0 A_Raise
    TNT1 A 1 A_Raise
    Loop
  Fire:
    FMGF A 0 A_JumpIfInventory("FMGZoomed",1,"ZoomedFire")
    FMGF A 0 A_JumpIfInventory("FMGClip",1,1)
	Goto DryFire
	FMGF A 0 A_GiveInventory("FMGFireToken",1) //This thing here is something totally not worth bothering, but my OCD doesn't feel right, when you empty the BulletAmmo, and the weapon goes into ready state like some brick. Sooo I had to smooth it out. Also, it helps with the kaczink state. What the hell is kaczink? Well, I guess one can figure that one out for himself. :P
    FMGF A 0 A_PlaySound("FMG/Fire",1,0.8)
	FMGF A 0 A_FireCustomMissile("GunsmokeSpawner_Small_MG",0,0,7,0)
	FMGF A 0 A_FireBullets(1.5, 0.5, 1, 8, "BulletPuff")
	FMGF A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGF C 0 A_JumpIf(Health<25,2)
	FMGF A 0 A_Jump(256,2)
	FMGF A 0 A_FireBullets(1.5, 0.5, 1, 8, "BulletPuff")
	FMGF A 0 A_AlertMonsters
	FMFG A 0 A_GunFlash
    FMGF A 1 Bright A_SetPitch(pitch-0.25)
	FMGF B 1 Bright A_SetPitch(pitch-0.15)
	FMGF C 0 A_FireCustomMissile("BuellerCasingSpawner",0,0,4,0)
	FMGF A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGF C 0 A_JumpIf(Health<25,2)
	FMGF A 0 A_Jump(256,2)
	FMGF C 0 A_FireCustomMissile("BuellerCasingSpawner",0,0,4,0)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,4)
	FMGF C 0 A_JumpIf(Health<50,3)
	FMGF C 0 A_Jump(128,2)
	FMGF C 1
	FMGF A 0 A_ReFire
	FMGF A 0 A_TakeInventory("FMGFireToken",1)
	FMGF DE 1
	Goto ReadyMain
  ZoomedFire:
    FMGF A 0 A_JumpIfInventory("FMGClip",1,1)
	Goto ZoomedDryFire
	FMGF A 0 A_GiveInventory("FMGFireToken",1)
	FMIF A 0 A_PlaySound("FMG/Fire",1,0.9)
	FMGF A 0 A_FireCustomMissile("GunsmokeSpawner_Small_MG",0,0,0,3)
	FMIF A 0 A_FireBullets(0.375, 0.125, 1, 8, "BulletPuff") //Precision!
	FMGF A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGF C 0 A_JumpIf(Health<25,2)
	FMGF A 0 A_Jump(256,2)
	FMGF A 0 A_FireBullets(0.375, 0.125, 1, 8, "BulletPuff")
	FMIF A 0 A_AlertMonsters
	FMIF A 0 A_GunFlash
    FMIF A 1 Bright A_SetPitch(pitch-0.075)
	FMIF A 0 A_ZoomFactor(2.48)
	FMIF B 1 Bright A_SetPitch(pitch-0.075)
	FMIF A 0 A_ZoomFactor(2.49)
	FMGF C 0 A_FireCustomMissile("BuellerCasingSpawner",0,0,4,0)
	FMGF A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGF C 0 A_JumpIf(Health<25,2)
	FMGF A 0 A_Jump(256,2)
	FMGF C 0 A_FireCustomMissile("BuellerCasingSpawner",0,0,4,0)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,4)
	FMGF C 0 A_JumpIf(Health<50,4)
	FMIG A 0 A_Jump(128,3)
	FMIG A 1 A_SetPitch(pitch+0.15)
	FMIG A 0 A_ZoomFactor(2.5)
	FMIG A 0 A_ReFire
	FMIG A 2 A_TakeInventory("FMGFireToken",1)
	Goto ReadyMain
  ZoomedReload:
    FMIU A 0 A_PlaySound("Sights/Weapon",5,0.8)
	FMIU A 0 A_ZoomFactor(1)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
    FMIU F 1 A_JumpIf(Health<75,2)
	FMIU ED 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMIU C 1 A_JumpIf(Health<50,2)
	FMIU BA 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGG A 1 A_JumpIf(Health<25,2)
	FMGG AA 1
    FMGG A 1 A_TakeInventory("FMGZoomed",1)
    FMGF A 0 A_GiveInventory("FMGZoomReload",1)
  Reload:
    FMGG A 0 A_JumpIfInventory("FMGZoomed",1,"ZoomedReload")
	TNT1 A 0 A_JumpIfInventory("FMGClip",0,"ReadyMain")
	TNT1 A 0 A_JumpIfInventory("BulletAmmo",1,1)
	Goto ReadyMain
  ReloadCheckForDry:
    FMGG A 0 A_JumpIfInventory("FMGClip",1,2)
	FMGG A 0 A_GiveInventory("FMGEmptiedToken",1)
  ReloadMain:
	FMGH A 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGH C 1 A_JumpIf(Health<75,2)
	FMGH EFG 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGH H 1 A_JumpIf(Health<50,2)
	FMGH IJ 1

	FMGC A 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC B 1 A_JumpIf(Health<25,2)
	FMGC CDE 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC F 1 A_JumpIf(Health<75,2)
	FMGC H 1
	FMGC H 0 A_PlaySound("FMG/Out",5)

	FMGC IJ 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC K 1 A_JumpIf(Health<50,2)
	FMGC LNO 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC P 1 A_JumpIf(Health<25,2)
	FMGC QR 1
	FMGC T 0 A_SpawnItemEx("FMGClipDrop",0,0,20)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC T 0 A_JumpIf(Health<75,2)
	FMGC T 2
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC T 0 A_JumpIf(Health<50,2)
	FMGC T 2
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGC T 0 A_JumpIf(Health<25,2)
	FMGC T 2
	FMGC T 2
	FMGI BCDFGHI 1 A_SetAngle(angle-0.2)
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("BulletAmmo",1,TIF_NOTAKEINFINITE)
	TNT1 A 0 A_GiveInventory("FMGClip", 1)
	TNT1 A 0 A_JumpIfInventory("FMGClip",0,2)
	TNT1 A 0 A_JumpIfInventory("BulletAmmo",1,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadFinish:
	FMGI J 0 A_PlaySound("FMG/In",5,0.7)
	FMGI J 0 A_SetAngle(angle-1)
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGI J 1 A_JumpIf(Health<75,2)
	FMGI KL 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGI M 1 A_JumpIf(Health<50,2)
	FMGI NO 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGI P 1 A_JumpIf(Health<25,2)
	FMGI QRR 1
	FMGH I 1 A_JumpIfInventory("PowerBlazing",1,3)
	FMGH H 1 A_JumpIf(Health<75,2)
	FMGH GFE 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGH D 1 A_JumpIf(Health<50,2)
	FMGH CBA 1
	FMGG A 0 A_JumpIfInventory("FMGEmptiedToken",1,"Kaczink")
	FMGG A 2
    FMGF A 0 A_JumpifInventory("FMGZoomReload",1,"Derp")
	Goto ReadyMain
  Kaczink:
    FMGG A 0 A_TakeInventory("FMGEmptiedToken",1)
	FMGP AB 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP C 1 A_JumpIf(Health<75,2)
	FMGP DE 1
	FMGP FG 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP I 1 A_JumpIf(Health<50,2)
	FMGP KL 1
	FMGP L 0 A_PlaySound("FMG/Cock",5,0.7)
	FMGP M 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP N 1 A_JumpIf(Health<25,2)
	FMGP OPQ 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP R 1 A_JumpIf(Health<75,2)
	FMGP QPO 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP N 1 A_JumpIf(Health<50,2)
	FMGP MLK 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP J 1 A_JumpIf(Health<25,2)
	FMGP HFD 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	FMGP B 1 A_JumpIf(Health<75,1)
	FMGP A 1
    FMGF A 0 A_JumpifInventory("FMGZoomReload",1,"Derp")
	Goto ReadyMain
  Derp:
    FMGG A 0 A_TakeInventory("FMGZoomReload",1)
	Goto AltFire
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 3 A_Light1
    TNT1 A 0 A_Light0
    Stop
  Zoom:
    PCFN A 0 A_JumpIfInventory("ZoomReFire",1,"PunchFuck")
	FMGH ABCDEFGHJ 1
	SDKU A 0 A_GiveInventory("ZoomReFire",1)
  PunchFuck:
	QML1 A 0 A_Gunflash("PunchFlash", GFF_NOEXTCHANGE)
	QML1 A 0 A_JumpIfInventory("PowerStrength2",1,2)
    QML1 A 0 A_Jump(256,3)
  	FML1 A 0 A_SetBlend("Orange",0.05,10)
	FML1 A 0 A_PlaySound("Melee/Firepunch",0)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" A 1 A_SetPitch(pitch-0.3)
	"####" B 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" C 1 A_SetPitch(pitch-0.3)
	"####" D 1 A_SetPitch(pitch-0.3)
	"####" A 0 A_JumpIfInventory("PowerStrength2",1,3)
	"####" A 0 A_CustomPunch(30, 1, 0, "PunchCracker", 100)
	"####" A 0 A_Jump(256,2)
	"####" A 0 A_CustomPunch(90, 1, 0, "FlamePunchCracker", 150)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" E 1 A_SetPitch(pitch+0.3)
	"####" F 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<75,2)
	"####" G 1 A_SetPitch(pitch+0.3)
	"####" H 1 A_SetPitch(pitch+0.3)
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<50,2)
	"####" I 1
	"####" J 1
	"####" A 0 A_JumpIfInventory("PowerBlazing",1,3)
	"####" A 0 A_JumpIf(Health<25,2)
	"####" K 1
	TNT1 A 5
	TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWZOOM)
	FMGH JHGFEDCBA 1
	FMGU A 0 A_TakeInventory("ZoomReFire",1)
	Goto ReadyMain
  PunchFlash:
	FMGM A 1 A_PlaySound("Punch/Swing",6,1.0)
	FMGM BCD 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<75,2)
	FMGM EF 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<50,2)
	FMGM GH 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<25,2)
	FMGM IA 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<75,2)
	FMGM AA 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<50,2)
	FMGM AA 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,3)
	TNT1 A 0 A_JumpIf(Health<25,1)
	FMGM AA 1
	Stop
  CaberToss:
  	FMGG A 1 A_JumpIfInventory("MacheteAmmo",1,1)
	Goto ReadyMain
	MCHT A 0 A_TakeInventory("MacheteAmmo",1)
	FMGU ECA 1
	
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<75,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<50,1)
	TNT1 A 1
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	TNT1 A 1 A_JumpIf(Health<25,1)
	TNT1 A 1
    MC4S A 0 A_PlaySound("Machete1/Slash",1,0.9)
    MC4S A 0 A_PlaySound("Machete2/Slash",5,0.2)
	MCHT ABC 1
	TNT1 A 0 A_JumpIfInventory("PowerStrength2",1,3)
	MCHT A 0 A_SpawnItemEX("MacheterangProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*35,0,sin(-pitch)*35,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	TNT1 A 0 A_Jump(256,2)
	MCHT A 0 A_SpawnItemEX("MacheterangBerserkProjectile",cos(-pitch)*48,0,32+(sin(-pitch)*48),cos(-pitch)*25,0,sin(-pitch)*25,0,SXF_NOCHECKPOSITION|SXF_TRANSFERPITCH)
	// This solution is ten times better. Just let it bouncecount out.
    TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT D 1 A_JumpIf(Health<75,1)
	MCHT E 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT F 1 A_JumpIf(Health<50,1)
	MCHT G 1
	TNT1 A 0 A_JumpIfInventory("PowerBlazing",1,2)
	MCHT H 1 A_JumpIf(Health<25,1)
	MCHT I 1
	TNT1 A 3

	FMGU BDF 1
	Goto ReadyMain
  Spawn:
    FMGG X -1
    Stop
  }
}

ACTOR FMGClip : Ammo
{
   Inventory.MaxAmount 70
   Inventory.Icon FMGGX0
   +IGNORESKILL
}

ACTOR FMGFireToken : Inventory { Inventory.MaxAmount 1 }
ACTOR FMGEmptiedToken : Inventory { Inventory.MaxAmount 1 }
ACTOR FMGZoomed : Inventory { Inventory.MaxAmount 1 }
ACTOR FMGZoomReload : Inventory { Inventory.MaxAmount 1 }