ACTOR "Enraged Legendary Plasmatic Rifle" : Weapon
{
   Height 14
   Weapon.PreferredSkin "LegendaryRifle-Marine"
   Weapon.SelectionOrder 7120
   Weapon.KickBack 60
   Weapon.AmmoUse 2
   Weapon.AmmoGive 200
   Scale 0.95
   Weapon.AmmoType "ILDemonMagazine"   
   Weapon.AmmoType2 "ILDemonAmmo"
   Inventory.PickupMessage "Enraged Legendary Plasmatic Rifle Obtained, MAD POWER!"
   Inventory.PickupSound "weapons/legup"
   Obituary "%o was obliterated by a soldier trained by Legendary."
   +WEAPON.AMMO_OPTIONAL
   +WEAPON.NOALERT
   +INVENTORY.UNDROPPABLE
   States
   {
   Ready:
     TNT1 A 0 A_PlaySound("weapons/legup")
	 ITRS ABCDE 1
   ReadyLoop:
     TNT1 A 0 A_JumpIfInventory("LDemonMagazine",1,2)
	 TNT1 A 0
	 Goto NoBuzzing
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady	 
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK AAA 1 A_WeaponReady
	 TNT1 A 0 A_PlaySound("weapons/legrifidle")
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK BB 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK BB 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK CC 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK CC 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK DD 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK DD 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK EE 1 A_WeaponReady
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
	 ITEK EE 1 A_WeaponReady
     Goto ReadyLoop
   NoBuzzing:
     TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
	 TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
     ITEK A 1 A_WeaponReady
	 Loop
   Deselect:
     TNT1 A 0 A_PlaySound ("D_LEGND",5,5.0,1,ATTN_NONE)
     TNT1 A 0 ACS_NamedExecuteAlways("StopWeaponMusic",0)
	 ITEK A 1 A_Lower
     Goto Deselect+2
   Select:
     TNT1 A 0
	 TNT1 A 0 A_Raise
	 Wait
   Fire:
	 TNT1 A 0 Bright A_JumpIfNoAmmo("Empty")
     TNT1 A 0 ACS_NamedExecuteAlways("StartWeaponMusic",0,50)
	 TNT1 A 0 Bright A_AlertMonsters
     TNT1 A 0 Bright A_GunFlash
	 TNT1 A 0 Bright Radius_Quake(4,2,0,1,0)
     TNT1 A 0 Bright A_Light1
	 TNT1 A 0 Bright A_PlayWeaponSound("BlueDTRFire")
     ITKF A 1 Bright A_FireCustomMissile("RPlayerLegendaryProjectile",Random(100,-100)/100.00,1,0,0,0,Random(100,-100)/100.00)
	 ITKF B 1 Bright A_Light2
     ITKF C 2 A_Light0
     TNT1 A 0 A_ReFire
     Goto ReadyLoop
   Empty:
     ITEK A 10 A_PlaySound("weapons/click2")
	 Goto ReadyLoop 
   AltFire:
  	 TNT1 A 0 A_JumpIfInventory("ILDemonMagazine",100,2)
     TNT1 A 0 A_JumpIfInventory("ILDemonAmmo",1,2)
	 TNT1 A 0
	 Goto ReadyLoop
     ITKR AB 2
	 ITKR C 3
	 ITKR D 4 A_PlaySound("weapons/demontecheject")
	 TNT1 A 0 Radius_Quake(2,2,0,1,0)
	 ITKR E 2 A_PlaySound("weapons/demontechsteam")
	 ITKR F 2 Radius_Quake(2,2,0,1,0)
	 ITKR GHI 2 Radius_Quake(2,2,0,1,0)
	 ITKR J 3 A_FireCustomMissile("LDemonTechEmptyMag", 0, 0, 0, 1)
	 ITKR K 15 
	 ITKR LMN 2
	 TNT1 A 0 A_JumpIfInventory("LDemonAmmo",1,"Reload")	 
     ITKR O 6 A_PlayWeaponSound("weapons/demontechload")
     ITKR O 4 A_PlayWeaponSound("weapons/demontechclick")
     ITKR CB 3
	 ITKR A 2
	 Goto ReadyLoop
   Reload:
	 TNT1 A 0 A_TakeInventory("ILDemonAmmo",1)
	 TNT1 A 0 A_GiveInventory("ILDemonMagazine",1)
	 TNT1 A 0 A_JumpIfInventory("ILDemonMagazine",100,"Full")
	 TNT1 A 0 A_JumpIfInventory("ILDemonAmmo",1,"Reload")
	 Goto AltFire+19
   Full:
     TNT1 A 0
	 Goto AltFire+19
   GrenadeCheck:
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
	 TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	 Goto Ready+6
   GrenadeToss:
  	 TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	 ITRS EDCBA 1
	 TNT1 A 6
	 HGRN ABC 1
	 HGRN D 3
	 HGRN EFGHI 2
	 TNT1 A 14 A_PlayWeaponSound("weapons/hgrenadepin")
	 TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	 TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
	 HGRN J 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
	 HGRN K 1
	 HGRN LMNO 2
	 TNT1 A 6
	 TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,2)
     TNT1 A 0 A_TakeInventory("Hand Grenade",1)
	 TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	 TNT1 A 0
	 Goto Ready+1
   MineCheck:
	 TNT1 A 0 A_JumpIfInventory("MineAmmo",1,"MineToss")
	 TNT1 A 0 A_TakeInventory("MineAction",1)
	 Goto Ready+6
   MineToss:
  	 TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	 ITRS EDCBA 1
	 TNT1 A 10
	 TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
	 MINE ABCDEF 1		
	 TNT1 A 0 A_TakeInventory("MineAmmo",1)	  
	 MINE G 1 A_FireCustomMissile("ThrownMine",0,0,0,0)
	 MINE HI 1
	 MINE JK 2
	 TNT1 A 0 A_JumpIfInventory("MineAmmo",1,2)
     TNT1 A 0 A_TakeInventory("Land Mine",1)
	 TNT1 A 0 A_TakeInventory("MineAction",1)
	 TNT1 A 0
	 TNT1 A 5
	 Goto Ready+1 
  Spawn:
     ITEP A -1
     Stop
     }
}

ACTOR ILDemonMagazine : Ammo 
{
Inventory.Amount 0
Inventory.MaxAmount 100
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 100
Inventory.Icon "ITEPA0"
+IGNORESKILL
}

ACTOR ILDemonAmmo : Ammo
{
Scale 0.65
Inventory.PickupMessage "Enraged Cells Obtained."
Inventory.PickupSound "items/LDemonAmmo"
Inventory.Amount 50
Inventory.MaxAmount 250
Ammo.BackpackAmount 50
Ammo.BackpackMaxAmount 500
Inventory.Icon "IAMGA0"
States
{
Spawn:
	IAMG A -1
    Stop
    }
}

ACTOR ILDemonAmmoBox : ILDemonAmmo
{
Scale 0.65
Inventory.Amount 200
Inventory.PickupMessage "Enraged Cell Box Found."
Inventory.PickupSound "items/LDemonAmmopack"
States
{
Spawn:
	IAMO A -1
	Stop
	}
}

ACTOR ILDemonTechEmptyMag : BulletCasing
{
	Scale 0.4
    SeeSound "weapons/emptydrum"
    States
    {
	Spawn:
	  IDTM ABCD 3  
	  Loop
    Death:
	  TNT1 A 0
      TNT1 A 0 A_Jump(128,3)
      IDTM A 100
      IDTM A 5 A_FadeOut(0.10)
      Goto Death+3
      IDTM C 100
	  IDTM C 5 A_FadeOut(0.10)
	  Goto Death+5		  
      }
}
