
ACTOR RLLaserMinigun : RLWeapon
{
  Obituary "%o was ezzaporzated by %k's laser minigun."
  Decal BulletChip
  Tag "Laser Minigun"
  Weapon.SelectionOrder 25
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLLaserMinigunClip"
  Weapon.AmmoType2 "Cell"
  Inventory.Icon "LMINICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"Ready3")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"Ready2")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"Ready1")
    LMIN A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
  Ready1:
    LMIN Q 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
  Ready2:
    LMIN R 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
  Ready3:
    LMIN S 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
	
  ScavengerDrop:
	"####" "#" 0 A_JumpIfInventory("RLScavengerDrop",1,"WeaponDropConfirm")
	"####" "#" 0 A_GiveInventory("RLScavengerDrop",1)
	"####" "#" 0 A_Print("Press again to drop current weapon,\nor press \crAlt Fire\c- to scrap it to retrieve a Mod Pack.")
	Goto AfterModDrop
  WeaponDropConfirm:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
	TNT1 A 0 A_SpawnItemEx("RLLaserMinigunPickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	TNT1 A 0 A_TakeInventory("RLLaserMinigunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLLaserMinigun",1)
	Stop
  AfterModDrop:
    "####" "#" 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    "####" "#" 1 A_WeaponReady (WRF_NOFIRE | WRF_NOBOB)
    "####" "#" 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"DeselectFrame3")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"DeselectFrame2")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"DeselectFrame1")
    LMIN A 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto DeselectContinue
  DeselectFrame1:
    LMIN Q 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto DeselectContinue
  DeselectFrame2:
    LMIN R 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto DeselectContinue
  DeselectFrame3:
    LMIN S 1 A_WeaponReady (WRF_ALLOWRELOAD | WRF_ALLOWZOOM)
    Goto DeselectContinue
  DeselectContinue:
    "####" "#" 0 A_ClearReFire
	"####" "#" 0 A_StopSound(6)
	"####" "#" 0 A_GiveInventory("RLDeselectionFunction",1)
	"####" "#" 0 A_TakeInventory("RLLaserMinigunSelected", 1)
	"####" "#" 0 A_GiveInventory("RLRarityTokenRemover", 1)
	"####" "#" 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
  DeselectLoop:
    "####" "#" 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    "####" "#" 1 A_Lower
    Loop
  DeselectRenegade:
    "####" "#" 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLMasterAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLLaserMinigunSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianMasterDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"SelectLoop3")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"SelectLoop2")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"SelectLoop1")
  SelectLoop0:
    LMIN A 1 A_Raise
    Loop
  SelectLoop1:
    LMIN Q 1 A_Raise
    Loop
  SelectLoop2:
    LMIN R 1 A_Raise
    Loop
  SelectLoop3:
    LMIN S 1 A_Raise
    Loop
	
  Fire:
	LMIN A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	LMIN A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	LMIN A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	LMIN A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	LMIN A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireStartPowerupCheck") // Check for powerups.
  FireStartPowerupCheckDone: // No valid powerups detected.
  FireWindUp:
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_PlaySound("weapons/laserminigunstart", 6)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"FireWindUpB")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"FireWindUpE")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"FireWindUpD")
  FireWindUpC:
	LMIN C 6
	LMIN DE 5
	LMIN BC 4
	LMIN DE 3
	LMIN BCDE 2
	LMIN BCDE 1
	LMIN B 1
    Goto FireStart
  FireWindUpD:
	LMIN D 6
	LMIN EB 5
	LMIN CD 4
	LMIN EB 3
	LMIN CDEB 2
	LMIN CDEB 1
	LMIN C 1
    Goto FireStart
  FireWindUpE:
	LMIN E 6
	LMIN BC 5
	LMIN DE 4
	LMIN BC 3
	LMIN DEBC 2
	LMIN DEBC 1
	LMIN D 1
    Goto FireStart
  FireWindUpB:
	LMIN B 6
	LMIN CD 5
	LMIN EB 4
	LMIN CD 3
	LMIN EBCD 2
	LMIN EBCD 1
	LMIN E 1
    Goto FireStart
	
  FireWindUp1:
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_PlaySound("weapons/laserminigunstart", 6)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"FireWindUp1B")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"FireWindUp1E")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"FireWindUp1D")
  FireWindUp1C:
	LMIN C 5
	LMIN DE 4
	LMIN BC 3
	LMIN DE 2
	LMIN BCDE 1
	LMIN B 1
    Goto FireStart
  FireWindUp1D:
	LMIN D 5
	LMIN EB 4
	LMIN CD 3
	LMIN EB 2
	LMIN CDEB 1
	LMIN C 1
    Goto FireStart
  FireWindUp1E:
	LMIN E 5
	LMIN BC 4
	LMIN DE 3
	LMIN BC 2
	LMIN DEBC 1
	LMIN D 1
    Goto FireStart
  FireWindUp1B:
	LMIN B 5
	LMIN CD 4
	LMIN EB 3
	LMIN CD 2
	LMIN EBCD 1
	LMIN E 1
    Goto FireStart
	
  Hold:
	TNT1 A 0 A_JumpIfNoAmmo("WindDown")
	TNT1 A 0 A_AlertMonsters
  FireStart:
	TNT1 A 0 A_PlaySound("weapons/laserminigunloop", 6, 1, 1)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunAmmochain",3,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (1.5, 1.5, -1, (random(1,7)*5), "RLLaserPuff", FBF_USEAMMO | FBF_NORANDOM)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.5, 1.5, -1, (random(1,7)*5), "RLLaserPuff", FBF_NORANDOM)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_PlaySound("weapons/laserminigun", CHAN_WEAPON, 1, 0, 0.7)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"FireState1")
    LMIN F 1 Bright A_GunFlash ("Flash")
	TNT1 A 0 A_GiveInventory("RLLaserMinigunState",1)
    Goto FireFinishContinue
  FireState1:
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"FireState2")
    LMIN G 1 Bright A_GunFlash ("Flash2")
	TNT1 A 0 A_GiveInventory("RLLaserMinigunState",1)
    Goto FireFinishContinue
  FireState2:
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"FireState3")
    LMIN H 1 Bright A_GunFlash ("Flash")
	TNT1 A 0 A_GiveInventory("RLLaserMinigunState",1)
    Goto FireFinishContinue
  FireState3:
    LMIN I 1 Bright A_GunFlash ("Flash2")
	TNT1 A 0 A_TakeInventory("RLLaserMinigunState",3)
    Goto FireFinishContinue
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunAmmochain",3,2)
	TNT1 A 0 A_Jump(256,3)
	TNT1 A 0 A_TakeInventory("RLLaserMinigunAmmochain",3)
    TNT1 A 0 A_ReFire ("Hold")
    Goto WindDown
	TNT1 A 0 A_GiveInventory("RLLaserMinigunAmmochain",1)
    TNT1 A 0 A_ReFire ("Hold")
    Goto WindDown
	
//-------------------------------------------------------------------------------------------------
  FireStartPowerupCheck: // Marine fires one Firestorm's worth faster while affected by powerups.
	TNT1 A 0 A_JumpIfInventory("PowerInvulnerable",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInvisibility",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerIronFeet",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerLightAmp",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerDrain",1,"FireStartPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerRLBerserkResistance",1,"FireStartPowerupCheckConfirmed")
	Goto FireStartPowerupCheckDone
  FireStartPowerupCheckConfirmed:
	TNT1 A 0
	Goto FireWindUp1
	
  FireFinishPowerupCheck: // Marine fires one Firestorm's worth faster while affected by powerups.
	TNT1 A 0 A_JumpIfInventory("PowerInvulnerable",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInvisibility",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerIronFeet",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerLightAmp",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerDrain",1,"FireFinishPowerupCheckConfirmed")
	TNT1 A 0 A_JumpIfInventory("PowerRLBerserkResistance",1,"FireFinishPowerupCheckConfirmed")
	Goto FireFinishPowerupCheckDone
  FireFinishPowerupCheckConfirmed:
	TNT1 A 0
	Goto WindDown1
//-------------------------------------------------------------------------------------------------

  WindDown:
    TNT1 A 0 A_ClearReFire
	TNT1 A 0 A_PlaySound("weapons/laserminigunstop", 6)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"WindDownB")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"WindDownE")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"WindDownD")
  WindDownC:
	LMIN CDEB 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN CDEB 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN CD 3
	LMIN EB 4
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN CD 5
	LMIN EB 6
	Goto Ready
  WindDownD:
	LMIN DEBC 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN DEBC 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN DEBC 3
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN DE 5
	LMIN BC 6
	Goto Ready
  WindDownE:
	LMIN EBCD 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN EBCD 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN EBCD 3
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN EB 5
	LMIN CD 6
	Goto Ready
  WindDownB:
	LMIN BCDE 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN BCDE 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN BCDE 3
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN BC 5
	LMIN DE 6
	Goto Ready
  WindDown1: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"WindDown1B")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"WindDown1E")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"WindDown1D")
  WindDown1C:
	LMIN CDEB 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN CDEB 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN CD 3
	LMIN EB 4
	Goto Ready
  WindDown1D:
	LMIN DEBC 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN DEBC 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN DE 3
	LMIN BC 4
	Goto Ready
  WindDown1E:
	LMIN EBCD 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN EBCD 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN EB 3
	LMIN CD 4
	Goto Ready
  WindDown1B:
	LMIN BCDE 1
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN BCDE 2
	TNT1 A 0 A_JumpIfNoAmmo(2)
	TNT1 A 0 A_Refire ("Hold")
	LMIN BC 3
	LMIN DE 4
	Goto Ready
	
  Reload:
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"ReloadStart3")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"ReloadStart2")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"ReloadStart1")
    LMIN A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReloadStart
  ReloadStart1:
    LMIN Q 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReloadStart
  ReloadStart2:
    LMIN R 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReloadStart
  ReloadStart3:
    LMIN S 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
    Goto ReloadStart
  ReloadStart:
    TNT1 A 0 A_ClearReFire
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunClip", 500, "Ready")
	Goto ReloadStartCheck
  ReloadStartCheck:
	TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",3,"ReloadSpinFrame3")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",2,"ReloadSpinFrame2")
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunState",1,"ReloadSpinFrame1")
    LMIN AAA 1
    Goto ReloadSpinComplete
  ReloadSpinFrame1:
    LMIN QRS 1
    Goto ReloadSpinComplete
  ReloadSpinFrame2:
    LMIN RSA 1
    Goto ReloadSpinComplete
  ReloadSpinFrame3:
    LMIN SAA 1
    Goto ReloadSpinComplete
  ReloadSpinComplete:
	TNT1 A 0 A_TakeInventory("RLLaserMinigunState",3)
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_StopSound(6)
    LMIN J 2
    LMIN K 2
    LMIN L 2
    LMIN K 2
    LMIN A 2
    LMIN M 2
    LMIN N 2
    LMIN O 2
    LMIN P 2
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 10 A_PlaySound("weapons/laserminigunload", CHAN_ITEM)
    TNT1 A 0 A_PlaySound("weapons/laserminigunpowerup", 7)
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLLaserMinigunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunClip", 500, "ReloadFinish")
	TNT1 A 0 A_JumpIfInventory("Cell",1,1)
	Goto ReloadFinish
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLLaserMinigunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunClip", 500, "ReloadFinish")
	TNT1 A 0 A_JumpIfInventory("Cell",1,1)
	Goto ReloadFinish
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLLaserMinigunClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLLaserMinigunClip", 500, "ReloadFinish")
	TNT1 A 1
	TNT1 A 0 A_JumpIfInventory("Cell",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
    TNT1 A 0 A_PlaySound("weapons/laserminigunloadfinish", CHAN_WEAPON)
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 10
    LMIN P 2
    LMIN O 2
    LMIN N 2
    LMIN M 2
    LMIN A 2
    LMIN K 2
    LMIN L 2
    LMIN K 2
    LMIN J 2
	Goto Ready
	
  Flash:
    TNT1 A 1 A_Light2
    TNT1 A 1 A_Light1
    TNT1 A 0 A_Light0
    Goto LightDone
  Flash2:
    TNT1 A 1 A_Light1
    TNT1 A 0 A_Light0
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLLaserMinigunPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION, 0, tid)
    Stop
	
  Altfire:
	"####" "#" 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ArmorModConversion")
	"####" "#" 0 A_JumpIfInventory("RLScavengerDrop",1,"ScavengerTime")
	Goto Ready
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLPlasmaInfusionAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_StopSound (6)
	TNT1 A 0 A_TakeInventory("RLLaserMinigunSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianMasterDamage", 1)
	TNT1 A 0 A_Jump(256,1,2,3,4)
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLAgilityMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLTechnicalMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLTechnicalMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLLaserMinigun",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		MECHANICS

Actor RLLaserMinigunSelected : RLPermanentInventory {}
Actor RLLaserMinigunState : RLPermanentInventory
{
inventory.maxamount 3
}

Actor RLLaserMinigunAmmochain : RLAmmochainDefault {}

ACTOR RLLaserMinigunClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 500
   Inventory.Icon ""
}

//-------------------------------------------------------------------
//		PICKUPS

ACTOR RLLaserMinigunPickup : RLMasterAssembledWeaponPickup
{
	//$Sprite LMINX0
	Tag "Laser Minigun [Pickup]"
	States
	{
	SpawnFrame:
		LMIN X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(Abs(VelZ) <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 1
		Loop
	FloorHit:
		"####" "#" 0 A_PlaySound("weapons/gundropbig")
		"####" "#" 0 A_ScaleVelocity (0.25)
		"####" "#" 0 A_ChangeFlag("SPECIAL", true)
		"####" "#" 0 A_ChangeFlag("THRUACTORS", false)
		"####" "#" 0 A_SetUserVar("user_floorhit", 1)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Stop
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLLaserMinigun",1,"NotPickup") // If the player already has this weapon, they are not given the weapon
		"####" "#" 0 A_JumpIfInventory("RLWeaponLimit",0,"NotPickupLimit") // The absolute max limit check for weapons
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLLaserMinigun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvLaser Minigun.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_Jump(256, "NotPickup")
		Goto NotPickup
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Laser Minigun =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/LaserMinigunpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	SuperweaponStuff:
		"####" "#" 0 A_Jump(256, "NoSpecialStartsStuff")
		Goto NoSpecialStartsStuff
	}
}

ACTOR RLLaserMinigunWorldSpawnPickup : RLLaserMinigunPickup 17803
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_JumpIf(CallACS("DRLA_opengl"), 3) // If enabled, rarity beam will be cyan, rather than blue
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorld", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_Jump(256,2)
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamAssembledWorldDRPG", 0, 0, 0, 0, 0, 0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
	SpawnFrame:
		LMIN X 4
		"####" "#" 0 A_GiveInventory("RLMasterItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/masterspawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLLaserMinigun",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvLaser Minigun.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelMasterGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}
