ACTOR ELegLMGSight : Inventory{Inventory.MaxAmount 1 }

ACTOR "Enraged Legendary Light Machine Gun" : Weapon 
{
//$Category Weapons/ILCA
//$Sprite EMGLZ0
//$Title "Enraged Legendary Light Machine Gun"
	Weapon.PreferredSkin "LegLMG-Marine"
	Weapon.AmmoType "ELLMGMagazine"
	Weapon.AmmoType2 "ELegendaryLMGBulletMag"
	Tag "Enraged Legendary Light Machine Gun"
	Weapon.SelectionOrder 381
	Weapon.KickBack 220
	Weapon.AmmoGive 92
	Weapon.AmmoGive2 20
	Weapon.AmmoUse 1
	Scale 0.95
	Inventory.PickupSound "weapons/LMGReload3"
	Obituary "%o was turned into swiss cheese by %k's Enraged Legendary Light Machine Gun."
    Inventory.PickupMessage "Enraged Legendary Light Machine Gun, comes with accuracy enhancements from a Railgun."
	+WEAPON.AMMO_OPTIONAL
    +WEAPON.NOALERT
	+INVENTORY.UNDROPPABLE
	var int user_laser;
	States
	{
    Deselect:
		TNT1 A 0 A_PlayWeaponSound("weapons/weapondown")
		EMGG A 1 A_Lower
		Goto Deselect+1
	Select:
		TNT1 A 0 A_Raise
		Wait
	Zoom:
		TNT1 A 0 A_TakeInventory("RailgunAction",1)
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Off")
		EMGG A 1 A_Print("Laser Sight Engaged",1)
		Goto Ready.Laser
	Off:
		TNT1 A 0 A_TakeInventory("ELegLMGSight",1)
		EMGG A 1 A_Print("Laser Sight Disengaged",2)
		Goto Ready+8
	Ready:
		TNT1 A 0 A_PlayWeaponSound("weapons/LMGReload3")
		EMGG BCDEFA 1
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Ready.Laser")
		TNT1 A 0 A_JumpIfInventory("RailgunAction",1,"Zoom")
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		EMGG A 1 A_WeaponReady
		Goto Ready+8
	Ready.Laser:
		TNT1 A 0 A_GiveInventory("ELegLMGSight",1)
		TNT1 A 0 A_JumpIfInventory("RailgunAction",1,"Zoom")
		TNT1 A 0 A_JumpIfInventory("HandGrenadeAction",1,"GrenadeCheck")
		TNT1 A 0 A_JumpIfInventory("MineAction",1,"MineCheck")
		EMGG A 0 A_RailAttack(-1,0,False,NONE,NONE,RGF_SILENT|RGF_NOPIERCING|WRF_NOBOB,0,"RailTargetPuff",0,0,0,0,0,0,"EnragedLaserSight")
		EMGG A 1 A_WeaponReady(WRF_NOBOB)
		Loop
	Fire:
	    TNT1 A 0 A_JumpIfNoAmmo("Empty")	
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Fire.Laser")
	    TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(4,3,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("ELegRifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light1

		// Ark patch: START
		TNT1 A      0 A_FireCustomMissile("PlayerEnragedLegLMGPellet", random(-240, 240)/100.00, 1, 0, 1, 0) // Use 1 ammo.
		EMGF A 2 Bright // A_FireBullets(8.0,4.8,1,Random(98,100),"ELLMGPuff")
		// Ark patch: END

		TNT1 A 0 A_Light0
		EMGF B 1 
		EMGF C 1
	    TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",1,1)
		Goto Ready+7
	    TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
		TNT1 A 0 Radius_Quake(4,3,0,1,0)
	    TNT1 A 0 A_SpawnItemEx("ELegRifleCasing",30,3,25,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light2

		// Ark patch: START
		TNT1 A      0 A_FireCustomMissile("PlayerEnragedLegLMGPellet", random(-240, 240)/100.00, 1, 0, 1, 0) // Use 1 ammo.
		EMGF D 2 Bright // A_FireBullets(8.0,4.8,1,Random(98,100),"ELLMGPuff")
		// Ark patch: END

		TNT1 A 0 A_Light0
		EMGF B 1
		EMGF C 1
		TNT1 A 0 A_ReFire
		Goto Ready+7
	Fire.Laser:
	    TNT1 A 0 A_JumpIfNoAmmo("Empty")	
	    TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
	    TNT1 A 0 A_SpawnItemEx("ELegRifleCasing",30,3,28,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light1

		// Ark patch: START
		TNT1 A      0 A_FireCustomMissile("PlayerEnragedLegLaserLMGPellet", random(-60, 60)/100.00, 1, 0, 1, 0) // Use 1 ammo.
		// TNT1 A 0 Bright A_FireBullets(3,2,1,Random(98,100),"ELLMGPuff")
		// Ark patch: END

		EMGF A 1 A_RailAttack(-1,0,False,NONE,NONE,RGF_SILENT|RGF_NOPIERCING,0,"RailTargetPuff",0,0,0,0,0,0,"EnragedLaserSight")
		EMGF BBBCCC 1 A_RailAttack(-1,0,False,NONE,NONE,RGF_SILENT|RGF_NOPIERCING,0,"RailTargetPuff",0,0,0,0,0,0,"EnragedLaserSight")
	    TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",1,1)
		TNT1 A 0 A_Light0
		TNT1 A 0 A_ReFire
		Goto Ready.Laser
	    TNT1 A 0 A_PlaySound("weapons/LMGFire",5)
	    TNT1 A 0 A_AlertMonsters	
		TNT1 A 0 A_GunFlash
	    TNT1 A 0 A_SpawnItemEx("ELegRifleCasing",30,3,28,Random(2,4),Random(3,6),Random(3,6),0)
		TNT1 A 0 A_Light2

		// Ark patch: START
		TNT1 A      0 A_FireCustomMissile("PlayerEnragedLegLaserLMGPellet", random(-60, 60)/100.00, 1, 0, 1, 0) // Use 1 ammo.
		EMGF D 2 Bright // A_FireBullets(3,2,1,Random(98,100),"ELLMGPuff")
		// Ark patch: END

		TNT1 A 0 A_Light0
		EMGF BBBCCC 1 A_RailAttack(-1,0,False,NONE,NONE,RGF_SILENT|RGF_NOPIERCING,0,"RailTargetPuff",0,0,0,0,0,0,"EnragedLaserSight")
		TNT1 A 0 A_ReFire
		Goto Ready.Laser
    Empty:
        EMGG A 10 A_PlayWeaponSound("weapons/click")
    AltFire:
  	    TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",92,2)
        TNT1 A 0 A_JumpIfInventory("ELegendaryLMGBulletMag",1,3)
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Ready.Laser")
		Goto Ready+8
		TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",1,"MaxReload")
	    EMGR A 1 A_PlayWeaponSound("weapons/LMGReload2")
 	    EMGR BCD 1
	    EMGR E 1 A_FireCustomMissile("LegendaryEmptyDrumSpawner", 0, 0, 0, 1)
	    EMGR F 1
		EMGR GG 25
		EMGR HIJK 1 A_PlayWeaponSound("weapons/LMGReload1")
	    EMGR L 8	
		EMGR MN 2
		EMGR OP 1
		EMGR QRSTU 1
		EMGR V 2
		EMGR W 3 A_PlayWeaponSound("weapons/LMGReload3")
		EMGR X 4
		EMGR Y 3
		EMGR Z 2
		TNT1 A 0 A_JumpIfInventory("ELegendaryLMGBulletMag",1,"Reload")
    Reload:
	    TNT1 A 0 A_TakeInventory("ELegendaryLMGBulletMag",1)
	    TNT1 A 0 A_GiveInventory("ELLMGMagazine",1)
	    TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",92,2)
	    TNT1 A 0 A_JumpIfInventory("ELegendaryLMGBulletMag",1,"Reload")
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Ready.Laser")
		Goto Ready+8
	MaxReload:
	    EMGR A 1 A_PlayWeaponSound("weapons/LMGReload2")
 	    EMGR BCD 1
	    EMGR E 1 A_FireCustomMissile("LegendaryEmptyDrumSpawner", 0, 0, 0, 1)
	    EMGR F 1
		EMGR G 25
		EMGR HIJK 1 A_PlayWeaponSound("weapons/LMGReload1")
	    TNT1 A 0 A_JumpIfInventory("ELegendaryLMGBulletMag",1,"Reload2")
    Reload2:
	    TNT1 A 0 A_TakeInventory("ELegendaryLMGBulletMag",1)
	    TNT1 A 0 A_GiveInventory("ELLMGMagazine",1)
	    TNT1 A 0 A_JumpIfInventory("ELLMGMagazine",92,"Full")
	    TNT1 A 0 A_JumpIfInventory("ELegendaryLMGBulletMag",1,"Reload2")
    Full:
	    EMGR L 8	
		EMGR MN 2
		EMGR OPQRS 1
	    EMGG A 2
		TNT1 A 0 A_JumpIfInventory("ELegLMGSight",1,"Ready.Laser")
	    Goto Ready+8
    GrenadeCheck:
	    TNT1 A 0 A_JumpIfInventory("HandGrenadeAmmo",1,"GrenadeToss")
		TNT1 A 0 A_TakeInventory("HandGrenadeAction",1)
	    Goto Ready+8
    GrenadeToss:
  	    TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	    EMGG GFEDCB 1
	    TNT1 A 4
		HGRN ABC 1
		HGRN D 2
		HGRN EFG 1
		HGRN HI 2
		TNT1 A 15 A_PlayWeaponSound("weapons/hgrenadepin")
		TNT1 A 0 A_PlayWeaponSound("weapons/hgrenadethrow")
		TNT1 A 0 A_TakeInventory("HandGrenadeAmmo",1)
		HGNE A 1 A_FireCustomMissile("ThrownGrenade",0,0,0,0)
		HGRN J 1
		HGRN KLM 2
		HGRN NO 1
		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+8
    MineToss:
  	    TNT1 A 0 A_PlayWeaponSound("weapons/weapondown") 
	    EMGG GFEDCB 1
		TNT1 A 8
		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:
		EMGL Z 30
		TNT1 A 0 A_SpawnItemEx("RHellionSmoke",Random(-12,12),Random(-12,12),Random(0,12),Random(-2,2),Random(-2,2),Random(-2,2),Random(-20,20),SXF_CLIENTSIDE,64)
		Loop		
		}
}

ACTOR ELLMGMagazine : Ammo 
{
	Inventory.Amount 0
	Inventory.MaxAmount 92
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 92
	Inventory.Icon "EMGLZ0"
	+IGNORESKILL
}

ACTOR EnragedLaserSight
{
RenderStyle Add
Scale 0.01 
Alpha 0.3
+CLIENTSIDEONLY
+NOBLOCKMAP
+DONTSPLASH
+NOCLIP
+NOINTERACTION
+THRUACTORS
+NOTIMEFREEZE
DECAL ""
States
{
Spawn:
DRTR A 2 A_FadeOut(0.5)
	Stop
	}
}

ACTOR ELegendaryLMGBulletMag : Ammo
{
//$Category Ammunition/LCA
//$Sprite EBLPA0
//$Title "Enraged Legendary LMG Bullet Magazine"
	Scale 0.3
	Inventory.PickupMessage "Enraged Legendary Bullets"
	Inventory.PickupSound "items/clipbox"
	Inventory.Amount 10
	Inventory.MaxAmount 150
	Ammo.BackpackAmount 13
	Ammo.BackpackMaxAmount 300
	Inventory.Icon "IBLPA0"
	+NOTIMEFREEZE
	States 
	{
	Spawn:
		IBLP A -1
		Stop
    }
}

ACTOR ELegendaryBulletBox : ELegendaryLMGBulletMag
{
//$Category Ammunition/ILCA
//$Sprite ECBXA0
//$Title "Enraged Legendary Box of Bullets"
	Scale 0.75
	Inventory.Amount 40
	Inventory.PickupMessage "Enraged Legendary Bullet Crate"
	Inventory.PickupSound "items/clipbox"
	Inventory.Icon "ICBXA0"
	+NOTIMEFREEZE
	States 
	{
	Spawn:
		ICBX A -1
		Stop
    }
}