
ACTOR RLPlasmaUzi : RLPistolWeapon
{
  Obituary "%o was burnt a lot by %k's plasma uzi."
  Decal BulletChip
  Tag "Plasma Uzi"
  Weapon.SelectionOrder 25
  Weapon.SlotNumber 6
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLPlasmaUziClip"
  Weapon.AmmoType2 "Cell"
  Inventory.Icon "PUZIICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    TNT1 A 0 A_PlaySound("weapons/plasmauziidle", 6, 1, 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziNanoMod",1,"NanoRegenCheck")
    PUZI BCD 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto Ready
  NanoRegenCheck:
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip",1,"ReadyNanoNormal")
    PUZI BCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCD 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto ReadyNanoNormal
  ReadyNanoNormal:
    PUZI BCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCDBCD 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
  ReadyNano2:
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip", 32, "Ready")
	TNT1 A 0 A_GiveInventory("RLPlasmaUziClip", 1)
    PUZI BCDBCDBCDBCDBCD 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto ReadyNano2
	
  ScavengerDrop:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"WeaponDropConfirm")
	TNT1 A 0 A_GiveInventory("RLScavengerDrop",1)
	TNT1 A 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("PowerRLTechnicianAdvancedDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLPlasmaUziPickup", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLPlasmaUziPickupModded", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLPlasmaUziModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaUziSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLPlasmaUzi",1)
	Stop
	
  AfterModDrop:
    TNT1 A 0 A_PlaySound("weapons/plasmauziidle", 6, 1, 1)
    PUZI BCDBCDBCD 1 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    TNT1 A 0 A_PlaySound("weapons/plasmauziidle", 6, 1, 1)
    PUZI BCD 1 A_WeaponReady (WRF_NOPRIMARY | WRF_NOBOB)
    TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLPlasmaUziSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 AA 0 A_Lower
    PUZI A 1 A_Lower
    Loop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLAdvancedAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaUziSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianAdvancedDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 AA 0 A_Raise
    PUZI A 1 A_Raise
    Loop
	
// 4x damage with Scout
  Fire:
	PUZI A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	PUZI A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	PUZI A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	PUZI A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	PUZI A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfNoAmmo("Reload")
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBall", frandom(5,-5), 1, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBall", frandom(5,-5), 0, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallSharpshooter", frandom(5,-5), 1, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallP", frandom(5,-5), 1, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallP", frandom(5,-5), 0, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallPSharpshooter", frandom(5,-5), 1, 0, 0, 0, frandom(2,-2))
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallA", frandom(4,-4), 1, 0, 0, 0, frandom(1,-1))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallA", frandom(4,-4), 0, 0, 0, 0, frandom(1,-1))
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallASharpshooter", frandom(4,-4), 1, 0, 0, 0, frandom(1,-1))
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallS", 0, 1)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallS", 0, 0)
    Goto FireFinish
	TNT1 A 0 A_FireCustomMissile ("RLPlasmaUziBallSSharpshooter", 0, 1)
    Goto FireFinish
	
  FireFinish:
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziFirestormMod",1,"FireFinishF")
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PUZI E 1 Bright A_GunFlash
    PUZI F 1 Bright
    PUZI G 1
    Goto FireFinishContinue
  FireFinishF:
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle2Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PUZI E 1 Bright A_GunFlash
    PUZI F 1 Bright
    Goto FireFinishContinue
	
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziAmmochain",0,2)
	TNT1 A 0 A_Jump(256,5)
	TNT1 A 0 A_TakeInventory("RLPlasmaUziAmmochain",0)
    TNT1 A 0 A_ReFire
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziFirestormMod",1,1)
    Goto Ready
    PUZI G 1
    Goto Ready
	TNT1 A 0 A_GiveInventory("RLPlasmaUziAmmochain",1)
    TNT1 A 0 A_ReFire
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziFirestormMod",1,1)
    Goto Ready
    PUZI G 1
    Goto Ready


//-------------------------------------------------------------------------------------------------
  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 A_JumpIfInventory("RLPlasmaUziFirestormMod",1,1)
	Goto FireFinishF
    TNT1 A 0 A_SpawnItemEx ("RLPlasmaRifle3Recoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziState",1,3)
	TNT1 A 0 A_GiveInventory("RLPlasmaUziState",1)
    PUZI E 1 Bright A_GunFlash ("FlashFF")
    Goto FireFinishContinue
	TNT1 A 0 A_TakeInventory("RLPlasmaUziState",1)
    PUZI F 1 Bright A_GunFlash ("FlashFF")
    Goto FireFinishContinue
//-------------------------------------------------------------------------------------------------
  
  Reload:
	PUZI BCD 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip", 32, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip", 42, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,2)
	TNT1 A 0 A_JumpIfInventory("Cell", 2, 2)
	Goto Ready
	TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziTechnicalMod",1,"Reload1")
    PUZR A 2
    PUZR B 2
    TNT1 A 0 A_PlaySound("weapons/plasmauziunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PUZR C 2
    PUZR D 2
    PUZR E 2
    PUZR F 2
    PUZR G 2
    PUZR H 2
    PUZR I 2
    PUZR J 2
    PUZR K 2
    PUZR L 2
    PUZR M 2
    PUZR N 2
    PUZR O 2
    PUZR P 2
	Goto ReloadWorking
  Reload1:
    PUZR A 1
    PUZR B 1
    TNT1 A 0 A_PlaySound("weapons/plasmauziunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    PUZR C 1
    PUZR D 2
    PUZR E 2
    PUZR F 2
    PUZR G 2
    PUZR H 2
    PUZR I 2
    PUZR J 2
    PUZR K 2
    PUZR L 2
    PUZR M 2
    PUZR N 2
    PUZR O 2
    PUZR P 2
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"ReloadWorkingDemo")
	TNT1 A 0 A_TakeInventory("Cell", 2)
	TNT1 A 0 A_GiveInventory("RLPlasmaUziClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip",32,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip",42,"ReloadFinish")
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Cell",2,"ReloadWorking")
	Goto ReloadFinish
  ReloadWorkingDemo:
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLPlasmaUziClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip",32,"ReloadFinish")
	Goto ReloadWorkingDemoAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziClip",42,"ReloadFinish")
  ReloadWorkingDemoAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Cell",1,"ReloadWorkingDemo")
	Goto ReloadFinish
  ReloadFinish:
    TNT1 A 0 A_PlaySound("weapons/plasmauziload", 7)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziTechnicalMod",1,"ReloadFinish1")
    PUZR Q 2
    PUZR R 2
    PUZR S 2
    PUZR T 2
    PUZR U 2
	Goto Ready
  ReloadFinish1:
    PUZR Q 2
    PUZR R 2
    PUZR S 1
    PUZR T 1
    PUZR U 1
	Goto Ready
	
  Flash:
    TNT1 A 1 A_Light2
    TNT1 A 1 A_Light1
    Goto LightDone
  FlashFF:
    TNT1 A 1 A_Light (random(1,2))
    TNT1 A 0 A_Light0
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLPlasmaUziPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION, 0, tid)
    Stop
  Altfire:
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ArmorModConversion")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ScavengerTime")
	Goto Ready
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaUziSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLPlasmaPistolAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLPlasmaUziModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLPlasmaUziNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLPlasmaUziSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianAdvancedDamage", 1)
    TNT1 A 0 A_StopSound(6)
	TNT1 A 0 A_Jump(256,1,2,3)
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLTechnicalMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLPlasmaUzi",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		PROJECTILES

ACTOR RLPlasmaUziBall : RLPlasmaBall
{
	Radius 7
	Height 4
	Speed 45
	Scale 0.5
	Alpha 0.85
	Damage 10
	Species "Player"
	+THRUSPECIES
	+THRUGHOST
	Decal "PlasmaScorch"
	Damagetype "Plasma"
	SeeSound "weapons/plasmauzi"
	DeathSound "weapons/plasmauziimpact"
}

ACTOR RLPlasmaUziBallP : RLPlasmaUziBall
{
  Damage 12
}

ACTOR RLPlasmaUziBallA : RLPlasmaUziBall
{
  Speed 55
}

ACTOR RLPlasmaUziBallS : RLPlasmaUziBall
{
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_JumpIf(CallACS("DRLA_FancyProjectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PLSS AB 6 Bright A_ScaleVelocity(1.10)
			Loop
		Spawn.Fancy:
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			
			Loop
	}
}

//-------------------------------------------------------------------
//		SHARPSHOOTER PROJECTILES

ACTOR RLPlasmaUziBallSharpshooter : RLPlasmaUziBall
{
  Damage (40)
}

ACTOR RLPlasmaUziBallPSharpshooter : RLPlasmaUziBallSharpshooter
{
  Damage (48)
}

ACTOR RLPlasmaUziBallASharpshooter : RLPlasmaUziBallSharpshooter
{
  Speed 55
}

ACTOR RLPlasmaUziBallSSharpshooter : RLPlasmaUziBallSharpshooter
{
	States
	{
		Spawn:
			TNT1 A 0 NoDelay A_JumpIf(CallACS("DRLA_FancyProjectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			PLSS AB 6 Bright A_ScaleVelocity(1.10)
			Loop
		Spawn.Fancy:
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS A 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			PLSS B 1 Bright A_ScaleVelocity(1.10)
			"####" "#" 0 A_CustomMissile("RLPlasmaFancyTrail", frandom(-1.0,1.0), frandom(-1.0,1.0))
			
			Loop
	}
}

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

Actor RLPlasmaUziSelected : RLPermanentInventory {}
Actor RLPlasmaUziAmmochain : RLAmmochainDefault {}
Actor RLPlasmaUziState : RLPermanentInventory {}
Actor RLPlasmaUziModLimit : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziPowerMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziBulkMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziAgilityMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziTechnicalMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziFirestormMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziNanoMod : RLAdvancedAssemblyModAmount {}
Actor RLPlasmaUziSniperMod : RLAdvancedAssemblyModAmount {}

ACTOR RLPlasmaUziClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 42
   Inventory.Icon ""
}

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

ACTOR RLPlasmaUziPickup : RLAdvancedAssembledWeaponPickup 17631
{
	//$Sprite PUZIX0
	Scale 0.6
	Tag "Plasma Uzi [Pickup]"
	States
	{
	SpawnFrame:
		PUZI 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/gundropsmall")
		"####" "#" 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("RLPlasmaUzi",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("RLPlasmaUzi",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvPlasma Uzi.")
		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= Plasma Uzi =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/PlasmaUzipickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLPlasmaUziPickupModded : RLPlasmaUziPickup
{
	+INVENTORY.TRANSFER
	+DONTGIB
	States
	{
	Spawn:
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("GetWeaponMods", 0)
		TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 0, "NoSpecialStartsStuff")
		"####" "#" 0 A_Jump(256, "SpecialStartsStuff")
		Goto SpecialStartsStuff
		
	SpawnFrame:
		PUZI X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(VelZ <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 0 ACS_NamedExecuteAlways("RLWeaponModDisplay", 0)
		"####" "#" 1
		Loop
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLPlasmaUzi",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvPlasma Uzi.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Plasma Uzi =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLPlasmaUziModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= Plasma Uzi =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Cell",32)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= Plasma Uzi =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
