ACTOR NEWWEnragedLegendaryMinigun : Weapon replaces EnragedLegendaryMinigun
{
   Tag "Enraged Legendary Minigun"
   Weapon.KickBack 23
   Weapon.PreferredSkin "LegendaryCannon-Marine"
   Weapon.AmmoType "ELegendaryLMGBulletMag"
   Weapon.AmmoType2 "ELegendaryLMGBulletMag"
   Weapon.AmmoGive 275
   Weapon.AmmoUse 1
   Weapon.UpSound "weapons/explosiveminigunpickup"
   AttackSound "weapons/expmgunspinstart"
   Inventory.PickupSound "weapons/explosiveminigunpickup"
   Inventory.PickupMessage "Enraged Legendary Minigun"
   Obituary "%o saw a monster. That monster was %k"
   +WEAPON.NOAUTOAIM
   States 
   {
   Spawn:
      ENGH X -1
      Stop
   Ready:
      ENGH A 1 A_WeaponReady
      Loop
   ReadySpin:
      TNT1 A 0 A_PlaySound("weapons/expmgunspin", 4)
      ENGH 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("EnragedMinigunActive2",1)
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive",1)
      TNT1 A 0 A_PlaySound("weapons/weapondown", 5)
   Deselecting:
      ENGH A 1 A_Lower
      TNT1 A 0 A_Lower
      Loop
   Select:
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive2",1)
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive",1)
   Selecting:
      ENGH A 1 A_Raise
	  ENGH A 1 A_Raise
	  ENGH A 1 Offset(-90,69)
	  ENGH A 1 Offset(-70,60)
	  ENGH A 1 Offset(-55,52)
	  ENGH A 1 Offset(-35,45)
	  ENGH A 1 Offset(-15,39)
	  ENGH A 1 Offset(-1,35)
      Loop
   Fire:
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      TNT1 A 0 A_JumpIfInventory("EnragedMinigunActive2",1,"Firing")
      TNT1 A 0 A_JumpIfInventory("EnragedMinigunActive",1,"Firing")
      TNT1 A 0 A_PlaySound("EnrLegMinigun/start", 5)
      ENGH BABAB 1
      ENGH CDCD 1
   Firing:
      TNT1 A 0 A_GiveInventory("EnragedMinigunActive",1)
      TNT1 A 0 A_PlaySound("weapons/expmgunspin", 5)
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("RedShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("weapons/expmgunspinstart", CHAN_WEAPON)
	  TNT1 A 0 A_StopSound
	  TNT1 A 0 A_FireCustomMissile("ILegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      ENGH G 1 Bright A_FireBullets(6.7,1.0,2,Random(15,25),"PILMinigunEx")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      ENGH I 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("RedShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("weapons/expmgunspinstart", CHAN_WEAPON)
	  TNT1 A 0 A_StopSound
	  TNT1 A 0 A_FireCustomMissile("ILegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      ENGH H 1 Bright A_FireBullets(6.7,1.4,2,Random(15,25),"PILMinigunEx")
      ENGH I 1 Bright
   Hold:
      TNT1 A 0 A_GiveInventory("EnragedMinigunActive",1)
      TNT1 A 0 A_PlaySound("weapons/expmgunspin", 5)
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("RedShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("weapons/expmgunspinstart", CHAN_WEAPON)
	  TNT1 A 0 A_StopSound
	  TNT1 A 0 A_FireCustomMissile("ILegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      ENGH H 1 Bright A_FireBullets(6.7,2.0,-1,Random(15,25),"PILMinigunEx")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")
      ENGH I 1 Bright
      ENGH H 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("RedShellCasing",25,-8,25,Random(2,4),Random(-3,-6),Random(3,6),0)
      TNT1 A 0 A_PlaySound("weapons/expmgunspinstart", CHAN_WEAPON)
	  TNT1 A 0 A_StopSound
	  TNT1 A 0 A_FireCustomMissile("ILegendaryMinigunExplosiveTracer",Random(4,-4),0,0,Random(4,-4))
      ENGH I 1 Bright A_FireBullets(6.7,2.0,-1,Random(15,25),"PILMinigunEx")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      ENGH H 1 Bright
      TNT1 A 0 Radius_Quake(2,2,0,1,0)
      TNT1 A 0 A_SpawnItemEx("RedShellCasing",25,-8,25,Random(2,3),Random(-3,-5),Random(3,5),0)
      TNT1 A 0 A_PlaySound("weapons/expmgunspinstart", CHAN_WEAPON)
	  TNT1 A 0 A_StopSound
      ENGH I 1 Bright A_FireBullets(6.7,2.0,-1,Random(15,25),"PILMinigunEx")
      TNT1 A 0 A_JumpIfNoAmmo("EmptySpinDown")   
      TNT1 A 0 A_ReFire
      TNT1 A 0 A_JumpIfInventory("EnragedMinigunActive2",1,"ReadySpin")
      TNT1 A 0 A_PlaySound("EnrLegMinigun/stop", 5)
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive",1)
      ENGH A 1
      ENGH B 2
      ENGH A 3
      Goto Ready
   AltFire:
      TNT1 A 0
      TNT1 A 0 A_JumpIfInventory("EnragedMinigunActive2",1,"EmptySpinDown")
      TNT1 A 0 A_PlaySound("EnrLegMinigun/start", 5)
      ENGH BABA 2
      ENGH BABABABA 1
      TNT1 A 0 A_GiveInventory("EnragedMinigunActive2",1)
      Goto ReadySpin
   EmptySpinDown:
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive",1)
      TNT1 A 0 A_TakeInventory("EnragedMinigunActive2",1)
      TNT1 A 0 A_PlaySound("EnrLegMinigun/stopnonfire", 5)
      ENGH BABABA 1
      ENGH ABAB 1
      ENGH ABAB 3
      Goto Ready
   }
}

ACTOR ILMinigunEx : ILDemonTechEx
{
Scale 0.50
Alpha 0.80
DamageType "Legendary"
}

ACTOR PILMinigunEx : ILMinigunEx { species "Player" }

ACTOR ILegendaryMinigunExplosiveTracer : FastProjectile
{
Height 1
Radius 1
Speed 255
Scale 0.85
Damage 0
Species "Player"
RenderStyle Add
Alpha 0.85
DeathSound "sentient/chaingunex"
DamageType "LegendaryPlayer"
Decal DoomImpScorch
+FORCERADIUSDMG
+RANDOMIZE
+FORCEXYBILLBOARD
+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("ILegendaryMinigunExplosiveEffect")
    LISL B 4 Bright A_Explode(Random(12,15)*5,72)
    LISL CD 3 Bright
    Stop
    }
}

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

ACTOR KaboomILDM : Kaboom
{
Speed 2
Alpha 0.80
Scale 0.6
+NOTIMEFREEZE
}



ACTOR EnragedMinigunActive : Ammo
{
   Inventory.MaxAmount 1
}
ACTOR EnragedMinigunActive2 : Ammo
{
   Inventory.MaxAmount 1
}