
ACTOR RLHighPowerPistol : RLPistolWeapon
{
  Obituary "%o was killed by %k's pistol."
  Decal BulletChip
  Tag "High Power Pistol"
  Weapon.SelectionOrder 1900
  Weapon.SlotNumber 2
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLHighPowerPistolClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "QPISICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolNanoMod",1,2)
    QPIS A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
  NanoRegenCheck:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip",1,2)
    QPIS A 70 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	Goto NanoRegenCheckBegin
  NanoRegenCheckBegin:
    QPIS A 70 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 4, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 5, "Ready")
	Goto NanoRegen
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 6, "Ready")
	Goto NanoRegen
  NanoRegen:
	TNT1 A 0 A_GiveInventory("RLHighPowerPistolClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolNanoMod",2,2)
    QPIS A 17 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin+1
    QPIS A 9 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Goto NanoRegenCheckBegin+1
	
  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_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLHighPowerPistolPickup", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLHighPowerPistolPickupModded", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLHighPowerPistol",1)
	Stop
  AfterModDrop:
    QPIS A 8 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    QPIS A 1 A_WeaponReady (WRF_NOFIRE | WRF_NOBOB)
    TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLHighPowerPistolSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 AA 0 A_Lower
    QPIS 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("RLBasicAssemblyTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLHighPowerPistolSelected", 1)
	TNT1 A 0 A_JumpIfInventory("RLScavengerPerk",1, 1)
    Goto SelectLoop
	TNT1 A 0 A_GiveInventory("PowerRLTechnicianBasicDamage", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 AA 0 A_Raise
    QPIS A 1 A_Raise
    Loop
// 10x damage with Scout, half spread
  Fire:
	QPIS A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	QPIS A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	QPIS A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	QPIS A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	QPIS 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("RLHighPowerPistolSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (4, 0, -1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 0, -1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolPowerMod",2,"FirePP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolAgilityMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (4, 0, -1, (random(1,6)*7), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 0, -1, (70), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolPowerMod",1,"FirePA")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolAgilityMod",2,"FireAA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 0, -1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.75, 0, -1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FirePP:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (4, 0, -1, (random(1,6)*8), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (2, 0, -1, (80), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FirePA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 0, -1, (random(1,6)*7), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.75, 0, -1, (70), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireAA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (3, 0, -1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.5, 0, -1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolSniperMod",2,"FireSS")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolPowerMod",1,"FireSP")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolAgilityMod",1,"FireSA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2, 0, 1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1, 0, 1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireSS:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (0, 0, 1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0, 0, 1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireSP:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2, 0, 1, (random(1,6)*7), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1, 0, 1, (70), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireSA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (1.5, 0, 1, (random(1,6)*6), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0.75, 0, 1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLPistolRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/highpowerpistol", CHAN_WEAPON, 1, 0, 0.6)
    TNT1 A 0 A_PlaySound("weapons/highpowerpistol", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolFirestormMod",2,"FireFinishF2")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolFirestormMod",1,"FireFinishF1")
    QPIS B 2 Bright A_GunFlash
    QPIS C 2 Bright
    QPIS DEFFEG 1
    QPIS A 4
    QPIS A 5 A_ReFire
    Goto Ready
  FireFinishF1:
    QPIS B 1 Bright A_GunFlash
    QPIS C 1 Bright
    QPIS DEFFEG 1
    QPIS A 4
    QPIS A 5 A_ReFire
    Goto Ready
  FireFinishF2:
    QPIS B 1 Bright A_GunFlash
    QPIS C 1 Bright
    QPIS DEFFEG 1
    QPIS A 2
    QPIS A 5 A_ReFire
    Goto Ready
  Reload:
	QPIS A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 4, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 5, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip", 6, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolTechnicalMod",2,"Reload2")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolTechnicalMod",1,"Reload1")
    QPIS H 2
    QPIS I 2
    TNT1 A 0 A_PlaySound("weapons/hppistolunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QPIS J 2
    QPIS K 2
    QPIS L 2
    QPIS M 2
    QPIS N 2
    QPIS O 2
    QPIS P 2
    TNT1 A 2
	Goto ReloadWorking
  Reload1:
    QPIS H 1
    QPIS I 1
    TNT1 A 0 A_PlaySound("weapons/hpistolunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QPIS J 1
    QPIS K 2
    QPIS L 2
    QPIS M 2
    QPIS N 2
    QPIS O 2
    QPIS P 2
    TNT1 A 2
	Goto ReloadWorking
  Reload2:
    QPIS H 1
    QPIS I 1
    TNT1 A 0 A_PlaySound("weapons/hppistolunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QPIS J 1
    QPIS K 1
    QPIS L 1
    QPIS M 1
    QPIS N 2
    QPIS O 2
    QPIS P 2
    TNT1 A 2
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLHighPowerPistolClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip",4,5)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolBulkMod",2,2)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip",5,3)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolClip",6,2)
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip",1,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadFinish:
	TNT1 A 0 A_PlaySound("weapons/hppistolload", 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("RLHighPowerPistolTechnicalMod",2,"ReloadFinish2")
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolTechnicalMod",1,"ReloadFinish1")
	QPIS P 1
	QPIS O 1
	QPIS N 1
	QPIS M 1
	QPIS L 1
	QPIS K 1
	QPIS J 1
	QPIS I 1
	QPIS H 1
	TNT1 A 0 A_PlaySound("weapons/hppistolcock", CHAN_ITEM)
	Goto Ready
  ReloadFinish1:
	QPIS P 1
	QPIS N 1
	QPIS L 1
	QPIS J 1
	QPIS I 1
	QPIS H 1
	TNT1 A 0 A_PlaySound("weapons/hppistolcock", CHAN_ITEM)
	Goto Ready
  ReloadFinish2:
	QPIS N 1
	QPIS L 1
	QPIS K 1
	TNT1 A 0 A_PlaySound("weapons/hppistolcock", CHAN_ITEM)
	Goto Ready
  Flash:
    TNT1 A 2 A_Light1
    TNT1 A 2 A_Light2
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLHighPowerPistolPickup",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("RLHighPowerPistolModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
    TNT1 A 0 A_GiveInventory("RLHighPowerWeaponAssemblyLearntToken", 1) // Assembly is now listed in the HUD menus
	TNT1 A 0 A_JumpIfInventory("RLHighPowerPistolModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolModLimit", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolPowerMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolBulkMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolAgilityMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolTechnicalMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolSniperMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolFirestormMod", 2)
    TNT1 A 0 A_TakeInventory("RLHighPowerPistolNanoMod", 2)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerPistolSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_Jump(256,1,2)
	TNT1 A 0 A_FireCustomMissile("DroppedRLBulkMod",0,0,0)
	Goto ScavengerTimeEnd
	TNT1 A 0 A_FireCustomMissile("DroppedRLPowerMod",0,0,0)
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLHighPowerPistol",1)
	Stop
  }
}

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

Actor RLHighPowerPistolSelected : RLPermanentInventory {}
Actor RLHighPowerPistolModLimit : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolPowerMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolBulkMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolAgilityMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolTechnicalMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolNanoMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolFirestormMod : RLBasicAssemblyModAmount {}
Actor RLHighPowerPistolSniperMod : RLBasicAssemblyModAmount {}

ACTOR RLHighPowerPistolClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 6
   Inventory.Icon ""
}

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

ACTOR RLHighPowerPistolPickup : RLBasicAssembledWeaponPickup 17408
{
	//$Sprite QPISX0
	Tag "High Power Pistol [Pickup]"
	States
	{
	SpawnFrame:
		QPIS 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("RLHighPowerPistol",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("RLHighPowerPistol",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvHigh Power Pistol.")
		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= High Power Pistol =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/hpPistolpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonPistolClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}

ACTOR RLHighPowerPistolPickupModded : RLHighPowerPistolPickup
{
	+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:
		QPIS 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("RLHighPowerPistol",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cvHigh Power Pistol.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= High Power Pistol =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLHighPowerPistolModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cv= High Power Pistol =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Shell",9)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cv= High Power Pistol =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
