ACTOR "Legendary Minigun" : Weapon 1473
{
   Tag "Legendary Minigun"
   Weapon.KickBack 23
   Weapon.PreferredSkin "LegendaryCannon-Marine"
   Weapon.AmmoType "LegendaryBulletMag"
   Weapon.AmmoType2 "LegendaryBulletMag"
   Weapon.AmmoGive 200
   Weapon.AmmoUse 1
   Weapon.UpSound "LegMinigun/up"
   AttackSound "LegMinigun/fire"
   Inventory.PickupSound "LegMinigun/up"
   Inventory.PickupMessage "Legendary Minigun"
   Obituary "%o thought that only the spiders could have fun. %k had shown him wrong with his Legendary Minigun."
   +WEAPON.NOAUTOAIM
   States 
   {
   Spawn:
      LECH X -1
      Stop
   Ready:
      LECH A 1 A_WeaponReady
      Loop
   ReadySpin:
      TNT1 A 0 A_PlaySound("LegMinigun/loop", 4)
      LECH ABABABABABABAB 1 A_WeaponReady
      Loop
   Deselect:
      TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	  TNT1 A 0 A_TakeInventory("MineAction",1)
	  TNT1 A 0 A_TakeInventory("RailgunAction",1)
	  TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive2",1)
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive",1)
      TNT1 A 0 A_PlaySound("weapons/weapondown", 5)
   Deselecting:
      LECH A 1 A_Lower
      TNT1 A 0 A_Lower
      Loop
   Select:
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive2",1)
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive",1)
   Selecting:
      LECH A 1 A_Raise
	  LECH A 1 A_Raise
	  LECH A 1 Offset(-90,69)
	  LECH A 1 Offset(-70,60)
	  LECH A 1 Offset(-55,52)
	  LECH A 1 Offset(-35,45)
	  LECH A 1 Offset(-15,39)
	  LECH A 1 Offset(-1,35)
      Loop
   Fire:
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      TNT1 A 0 A_JumpIfInventory("LegendaryMinigunActive2",1,"Firing")
      TNT1 A 0 A_JumpIfInventory("LegendaryMinigunActive",1,"Firing")
      TNT1 A 0 A_PlaySound("LegMinigun/start", 5)
      LECH BABABA 2
      LECH CDCD 1
   Firing:
      TNT1 A 0 A_GiveInventory("LegendaryMinigunActive",1)
      TNT1 A 0 A_PlaySound("LegMinigun/loop", 5)
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("YellowShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("LegMinigun/fire", CHAN_WEAPON)
	  TNT1 A 0 A_FireCustomMissile("LegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      LECH I 1 Bright A_FireBullets(2.4,1.0,1,Random(14,22),"LegendaryASGBulletPuff")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      LECH F 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("YellowShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("LegMinigun/fire", CHAN_WEAPON)
	  TNT1 A 0 A_FireCustomMissile("LegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      LECH E 1 Bright A_FireBullets(2.4,1.4,1,Random(14,22),"LegendaryASGBulletPuff")
      LECH F 1 Bright
   Hold:
      TNT1 A 0 A_GiveInventory("LegendaryMinigunActive",1)
      TNT1 A 0 A_PlaySound("LegMinigun/loop", 5)
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("YellowShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("LegMinigun/fire", CHAN_WEAPON)
	  TNT1 A 0 A_FireCustomMissile("LegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      LECH E 1 Bright A_FireBullets(2.4,2.0,1,Random(14,22),"LegendaryASGBulletPuff")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")
      LECH F 1 Bright
      LECH E 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("YellowShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("LegMinigun/fire", CHAN_WEAPON)
	  TNT1 A 0 A_FireCustomMissile("LegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      LECH F 1 Bright A_FireBullets(2.4,2.0,1,Random(13,22),"LegendaryASGBulletPuff")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      LECH E 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("YellowShellCasing",25,-8,25,Random(2,3),Random(-3,-5),Random(3,5),0)
      TNT1 A 0 A_PlaySound("LegMinigun/fire", CHAN_WEAPON)   
      LECH F 1 Bright A_FireBullets(2.4,2.0,1,Random(14,22),"LegendaryASGBulletPuff")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      TNT1 A 0 A_ReFire
      TNT1 A 0 A_JumpIfInventory("LegendaryMinigunActive2",1,"ReadySpin")
      TNT1 A 0 A_PlaySound("LegMinigun/astop", 5)
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive",1)
      LECH C 1
      LECH B 2
      LECH A 3
      Goto Ready
   AltFire:
      TNT1 A 0
      TNT1 A 0 A_JumpIfInventory("LegendaryMinigunActive2",1,"EmptySpinDown")
      TNT1 A 0 A_PlaySound("LegMinigun/start", 5)
      LECH BABABA 2
      LECH BABABAB 1
      TNT1 A 0 A_GiveInventory("LegendaryMinigunActive2",1)
      Goto ReadySpin
   EmptySpinDown:
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive",1)
      TNT1 A 0 A_TakeInventory("LegendaryMinigunActive2",1)
      TNT1 A 0 A_PlaySound("LegMinigun/stop", 5)
      LECH BABABA 1
      LECH ABAB 1
      LECH ABAB 3
      Goto Ready
   }
}

ACTOR LegendaryMinigunActive : Ammo
{
   Inventory.MaxAmount 1
}
ACTOR LegendaryMinigunActive2 : Ammo
{
   Inventory.MaxAmount 1
}

ACTOR LegendaryMinigunExplosiveTracer : FastProjectile
{
Height 1
Radius 1
Speed 255
Scale 0.8
Damage 0
Species "Player"
RenderStyle Add
Alpha 0.85
DeathSound "sentient/chaingunex"
DamageType "LegendaryPlayer"
Decal DoomImpScorch
+FORCERADIUSDMG
+RANDOMIZE
+FORCEXYBILLBOARD
+NOTIMEFREEZE
+NOTIMEFREEZE
+THRUSPECIES
+DONTHURTSPECIES
+MTHRUSPECIES
States
{
Spawn:
    LRAC A 1 Bright
	Loop
Death:
	TNT1 A 0
	TNT1 A 0 A_SetTranslucent(0.75,1)
	TNT1 A 0 A_SpawnItem("LegendaryMinigunExplosiveEffect")
    LISL B 4 Bright A_Explode(Random(8,12)*5,72)
    LISL CD 3 Bright
    Stop
    }
}

ACTOR LegendaryMinigunExplosiveEffect
{
+CLIENTSIDEONLY
+NOGRAVITY
+NOBLOCKMAP
+NOTIMEFREEZE
States
{
Spawn:
    TNT1 A 0
    TNT1 A 0 A_JumpIf(ACS_ExecuteWithResult(304) == 1, "Toaster")
	TNT1 A 0 A_SpawnItemEx("LegendaryGoldParticleSpawner", 0, 0, 0, 0, 0, 0, 0, 128) 
    TNT1 AAA 0 A_CustomMissile("KaboomLS", 0, 0, random(0,360), 2, random(0,360))
	TNT1 AAA 0 A_CustomMissile("SmokeFX6", 0, 0, random(0,360), 2, random(0,360))
	TNT1 A 1
	Stop
Toaster:
    TNT1 A 0
	Stop
	}
}