
ACTOR RLGrammatonClericBeretta : RLPistolWeapon
{
  Inventory.Pickupsound "weapons/unique"
  Obituary "%o fell to %k's impressive gun kata."
  Decal BulletChip
  Tag "Grammaton Cleric Beretta"
  Weapon.SelectionOrder 11
  Weapon.SlotNumber 2
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLGrammatonClericBerettaClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "GCBPICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBurst",3)
    GCBP A 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
	
  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_JumpIfInventory("RLGrammatonClericBerettaModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLGrammatonClericBerettaPickup", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLGrammatonClericBerettaPickupModded", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLGrammatonClericBeretta",1)
	Stop
	
  AfterModDrop:
    GCBP A 8 A_WeaponReady (WRF_NOSECONDARY | WRF_ALLOWRELOAD)
    Goto Ready
  MisfirePrevention:
    GCBP 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("RLGrammatonClericBerettaSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    TNT1 AA 0 A_Lower
    GCBP A 1 A_Lower
    Goto DeselectLoop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLRapidfireTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLShotgunTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLUniqueWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLGrammatonClericBerettaSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 AA 0 A_Raise
    GCBP A 1 A_Raise
    Loop
	
// 8x damage with Scout, half spread normal mode
// 6x damage with Scout burst mode
// 4x damage with Scout fullauto mode
  Fire:
	
	GCBP A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	GCBP A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	GCBP A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	GCBP A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	GCBP 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("RLGrammatonClericBerettaNanoMod",1,"FireN")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAgilityMod",1,"FireA")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAuto")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurst")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 7, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.25, 0.75, -1, (56), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurst:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLBulletPuff")
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLBulletPuff", 0)
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, (42), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishBurst
  FireAuto:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLBulletPuff")
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLBulletPuff", 0)
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, (28), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
	
  FireP:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAutoP")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurstP")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 10, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.25, 0.75, -1, (80), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurstP:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 10, "RLBulletPuff")
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 10, "RLBulletPuff", 0)
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, (60), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishBurst
  FireAutoP:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 10, "RLBulletPuff")
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 10, "RLBulletPuff", 0)
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, (40), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
	
  FireA:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAutoA")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurstA")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (1, 0, -1, 7, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0.5, 0, -1, (56), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurstA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (2, 0.5, -1, 7, "RLBulletPuff")
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (2, 0.5, -1, 7, "RLBulletPuff", 0)
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (2, 0.5, -1, (49), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishBurst
  FireAutoA:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (5, 0.5, -1, 7, "RLBulletPuff")
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5, 0.5, -1, 7, "RLBulletPuff", 0)
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5, 0.5, -1, (28), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
	
  FireS:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAutoS")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurstS")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 7, "RLBulletPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.25, 0.75, -1, (56), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurstS:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaClip", 3, 1)
    Goto Reload
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeBurst")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,3)
	TNT1 A 0 A_FireBullets (3.5, 2, 3, 7, "RLBulletPuff")
	TNT1 A 0 A_TakeInventory ("RLGrammatonClericBerettaClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
	TNT1 A 0 A_FireBullets (3.5, 2, 3, (49), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
	TNT1 A 0 A_TakeInventory ("RLGrammatonClericBerettaClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireRenegadeBurst:
	TNT1 A 0 A_FireBullets (3.5, 2, 4, 7, "RLBulletPuff")
	TNT1 A 0 A_TakeInventory ("RLGrammatonClericBerettaClip", 2, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireAutoS:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "FireRenegadeAuto")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,"FireAutoSLoopSharpshooter")
  FireAutoSLoop:
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireAutoSLoopDRPG")
	TNT1 A 0 A_JumpIfInventory("DRPGDarkBlueAuraInfiniteAmmo",1,"FireAutoSLoopDRPG")
	TNT1 A 0 A_JumpIfInventory("DRPGPowerStimInfinity",1,"FireAutoSLoopDRPG")
	TNT1 A 0 A_JumpIfInventory("PowerShieldInfiniteAmmo", 1, "FireAutoSLoopDRPG")
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLBulletPuff")
	TNT1 A 0 A_JumpIfNoAmmo("FireFinishAuto")
    Goto FireAutoSLoop
  FireAutoSLoopSharpshooter:
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireAutoSLoopDRPGSharpshooter")
	TNT1 A 0 A_JumpIfInventory("DRPGDarkBlueAuraInfiniteAmmo",1,"FireAutoSLoopDRPGSharpshooter")
	TNT1 A 0 A_JumpIfInventory("PowerShieldInfiniteAmmo", 1, "FireAutoSLoopDRPGSharpshooter")
	TNT1 A 0 A_FireBullets (5.5, 2, -1, (28), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
	TNT1 A 0 A_JumpIfNoAmmo("FireFinishAuto")
    Goto FireAutoSLoopSharpshooter
  FireRenegadeAuto:
	TNT1 A 0 A_JumpIfInventory("PowerInfiniteAmmo",1,"FireAutoSLoopDRPGRenegade")
	TNT1 A 0 A_JumpIfInventory("DRPGDarkBlueAuraInfiniteAmmo",1,"FireAutoSLoopDRPGRenegade")
	TNT1 A 0 A_JumpIfInventory("PowerShieldInfiniteAmmo", 1, "FireAutoSLoopDRPGRenegade")
	TNT1 A 0 A_FireBullets (5.5, 2, 2, 7, "RLBulletPuff")
	TNT1 A 0 A_JumpIfNoAmmo("FireFinishAuto")
    Goto FireRenegadeAuto
  FireAutoSLoopDRPG:
	TNT1 A 0 A_FireBullets (5.5, 2, 18, 7, "RLBulletPuff")
    Goto FireFinishAuto
  FireAutoSLoopDRPGSharpshooter:
	TNT1 A 0 A_FireBullets (5.5, 2, 18, (28), "RLBulletPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
  FireAutoSLoopDRPGRenegade:
	TNT1 A 0 A_FireBullets (5.5, 2, 27, 7, "RLBulletPuff")
    Goto FireFinishAuto
	
  FireF:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAutoF")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurstF")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 7, "RLGCBFirestormPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.25, 0.75, -1, (56), "RLGCBFirestormPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurstF:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLGCBFirestormPuff")
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLGCBFirestormPuff", 0)
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, (42), "RLGCBFirestormPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishBurst
  FireAutoF:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLGCBFirestormPuff")
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLGCBFirestormPuff", 0)
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, (28), "RLGCBFirestormPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
	
  FireN:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,"FireAutoN")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,"FireBurstN")
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2.5, 1.5, -1, 7, "RLGCBNanoPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1.25, 0.75, -1, (56), "RLGCBNanoPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireBurstN:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLGCBNanoPuff")
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, 7, "RLGCBNanoPuff", 0)
    Goto FireFinishBurst
	TNT1 A 0 A_FireBullets (3.5, 2, -1, (42), "RLGCBNanoPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishBurst
  FireAutoN:
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,5)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,2)
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLGCBNanoPuff")
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, 7, "RLGCBNanoPuff", 0)
    Goto FireFinishAuto
	TNT1 A 0 A_FireBullets (5.5, 2, -1, (28), "RLGCBNanoPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinishAuto
	
  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/gcb", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/gcb", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_AlertMonsters
    GCBP C 1 Bright A_GunFlash
    GCBP D 2 Bright
    GCBP E 3 Bright
    GCBP F 1
    GCBP G 2
    GCBP H 3
    GCBP G 2
    GCBP F 2
    GCBP A 2
    GCBP AAAAAAAAAA 1 A_WeaponReady (WRF_NOBOB | WRF_NOSECONDARY | WRF_ALLOWRELOAD)
    Goto Ready
	
  FireFinishBurst:
    TNT1 A 0 A_SpawnItemEx ("RLChaingunRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/gcb", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/gcb", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",2,"FireFinishBurst3")
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBurst",1,"FireFinishBurst2")
    GCBP C 1 Bright A_GunFlash ("FlashBurst")
    GCBP D 1 Bright
    GCBP E 1 Bright
	TNT1 A 0 A_GiveInventory("RLGrammatonClericBerettaBurst",1)
    Goto Fire
  FireFinishBurst2:
    GCBP D 1 Bright A_GunFlash ("FlashBurst2")
    GCBP E 1 Bright
	TNT1 A 0 A_GiveInventory("RLGrammatonClericBerettaBurst",1)
    Goto Fire
  FireFinishBurst3:
    GCBP D 1 Bright A_GunFlash ("FlashBurst2")
    GCBP E 1 Bright
    GCBP F 1
    GCBP G 2
    GCBP H 3
    GCBP G 2
    GCBP F 2
    GCBP A 2
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBurst",3)
    GCBP AAAAAAAAAA 1 A_WeaponReady (WRF_NOBOB | WRF_NOSECONDARY | WRF_ALLOWRELOAD)
    Goto Ready
	
  FireFinishAuto:
    TNT1 A 0 A_SpawnItemEx ("RLBattleRifleRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/gcb", CHAN_WEAPON, 1, 0, 0.7)
    TNT1 A 0 A_PlaySound("weapons/gcb", 7, 0.05, 0, 0.20)
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLAmmochainPerk",1,"FireFinishPowerupCheck") // Check for powerups.
  FireFinishPowerupCheckDone: // No valid powerups detected.
    GCBP C 1 Bright A_GunFlash
    GCBP D 1 Bright
    GCBP E 1 Bright
    GCBP G 1
    GCBP A 1
    Goto FireFinishContinue
	
  FireFinishContinue:
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaAmmochain",0,2)
	TNT1 A 0 A_Jump(256,3)
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaAmmochain",0)
    GCBP F 1 A_ReFire
    Goto FireFinishAutoEnd
	TNT1 A 0 A_GiveInventory("RLGrammatonClericBerettaAmmochain",1)
    GCBP F 1 A_ReFire
    Goto FireFinishAutoEnd
  FireFinishAutoEnd:
    GCBP G 2
    GCBP H 3
    GCBP G 2
    GCBP F 2
    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:
    GCBP C 1 Bright A_GunFlash
    GCBP D 1 Bright
    GCBP E 1 Bright
    GCBP G 1
    Goto FireFinishContinue
//-------------------------------------------------------------------------------------------------
  
	
  Reload:
	GCBP A 2 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBurst",3)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaClip", 18, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaClip", 32, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
    TNT1 A 0 A_PlaySound("weapons/gcbunload", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaTechnicalMod",1,"Reload1")
    GCBP I 2
    GCBP J 2
    GCBP K 2
    GCBP L 2
    GCBP M 2
    GCBP N 2
    GCBP O 2
    GCBP P 2
    GCBP Q 2
    GCBP R 2
	Goto ReloadWorking
  Reload1:
    GCBP I 1
    GCBP J 1
    GCBP K 1
    GCBP L 2
    GCBP M 2
    GCBP N 2
    GCBP O 2
    GCBP P 2
    GCBP Q 2
    GCBP R 2
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLGrammatonClericBerettaClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaClip",18,"ReloadFinish")
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaClip",32,"ReloadFinish")
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Clip",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
    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("RLGrammatonClericBerettaTechnicalMod",1,"ReloadFinish1")
    TNT1 A 0 A_PlaySound("weapons/gcbload", 7)
	GCBP S 2
	GCBP T 2
	GCBP U 2
	TNT1 A 0 A_PlaySound("weapons/gcbcock", CHAN_ITEM)
	GCBP V 2
	GCBP W 2
	GCBP Y 2
	Goto Ready
  ReloadFinish1:
    TNT1 A 0 A_PlaySound("weapons/gcbload", 7)
	GCBP S 2
	GCBP T 2
	GCBP U 2
	TNT1 A 0 A_PlaySound("weapons/gcbcock", CHAN_ITEM)
	GCBP V 1
	GCBP W 1
	GCBP Y 1
	Goto Ready
	
  Flash:
    TNT1 A 3 A_Light1
    TNT1 A 3 A_Light2
    Goto LightDone
  FlashBurst:
    TNT1 A 1 A_Light1
    TNT1 A 2 A_Light2
    Goto LightDone
  FlashBurst2:
    TNT1 A 1 A_Light1
    TNT1 A 1 A_Light2
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLGrammatonClericBerettaPickup",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")
	TNT1 A 0 A_PlaySound("weapons/gcbmode", CHAN_WEAPON)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",2,6)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaMode",1,3)
	TNT1 A 0 A_Print("Burst-fire Mode.", 2)
	GCBP F 20 A_GiveInventory("RLGrammatonClericBerettaMode",1)
	Goto Ready
	TNT1 A 0 A_Print("Full-auto Mode.", 2)
	GCBP F 20 A_GiveInventory("RLGrammatonClericBerettaMode",1)
	Goto Ready
	TNT1 A 0 A_Print("Semi-auto Mode.", 2)
	GCBP F 20 A_TakeInventory("RLGrammatonClericBerettaMode",2)
	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("RLGrammatonClericBerettaModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLGrammatonClericBerettaModLimit",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("RLGrammatonClericBerettaModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLGrammatonClericBerettaSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_GiveInventory("RLEmitScavengedModUnique", 1) // Determines what mods this can generate when scavenged.
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLGrammatonClericBeretta",1)
	Stop
  }
}

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

actor RLGCBNanoPuff : BulletPuff
{
	DamageType "Bullet"
    +NOEXTREMEDEATH
	+PUFFONACTORS
	+PUFFGETSOWNER
    States
    {
      Spawn:
        TNT1 A 0
        PUFF AB 4 Bright
        Goto Melee
      Melee:
        TNT1 A 0
        PUFF CD 4 Bright
        stop
      XDeath:
        TNT1 A 0
        stop
      Crash:
        TNT1 A 0
        TNT1 A 0 A_GiveToTarget ("Clip", 1)
        Goto Melee
    }
}

actor RLGCBFirestormPuff : RLBulletPuff
{
	+PUFFONACTORS
	+PUFFGETSOWNER
	+HITTRACER
    States
    {
      XDeath:
        TNT1 A 0
        TNT1 A 0 A_GiveInventory ("PowerRLGCBFirestormDebuff", 1, AAPTR_TRACER)
        stop
    }
}

actor PowerRLGCBFirestormDebuff : PowerProtection
{
   inventory.icon ""
   Powerup.Duration -10
   +INVENTORY.PERSISTENTPOWER
   +INVENTORY.UNTOSSABLE
   DamageFactor "Normal", 1.5
   DamageFactor "Melee", 1.5
   DamageFactor "Bullet", 1.5
   DamageFactor "Fire", 1.5
   DamageFactor "Plasma", 1.5
   DamageFactor "Holy", 1.5
   DamageFactor "Unholy", 1.5
}

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

Actor RLGrammatonClericBerettaSelected : RLPermanentInventory {}
Actor RLGrammatonClericBerettaMode : RLPermanentInventory
{
inventory.maxamount 2
}

Actor RLGrammatonClericBerettaBurst : RLPermanentInventory
{
inventory.maxamount 2
}

Actor RLGrammatonClericBerettaAmmochain : RLAmmochainDefault {}
Actor RLGrammatonClericBerettaModLimit : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaPowerMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaBulkMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaAgilityMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaTechnicalMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaNanoMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaFirestormMod : RLUniqueModAmount {}
Actor RLGrammatonClericBerettaSniperMod : RLUniqueModAmount {}

ACTOR RLGrammatonClericBerettaClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 32
   Inventory.Icon ""
}

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

ACTOR RLGrammatonClericBerettaPickup : RLUniqueWeaponPickup
{
	//$Sprite GCBPX0
	Tag "Grammaton Cleric Beretta [Pickup]"
	States
	{
	SpawnFrame:
		GCBP 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("RLGrammatonClericBeretta",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("RLGrammatonClericBeretta",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdGrammaton Cleric Beretta.")
		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("\cd= Grammaton Cleric Beretta =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/gcbpickup")
		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 RLGrammatonClericBerettaWorldSpawnPickup : RLGrammatonClericBerettaPickup 17109
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamUniqueWorld", 0,0,0, 0,0,0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
		"####" "#" 0 A_Jump(256, "SpawnFrame")
		Goto SpawnFrame
		
	SpawnFrame:
		GCBP X 4
		"####" "#" 0 A_GiveInventory("RLUniqueItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/uniquespawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLGrammatonClericBeretta",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdGrammaton Cleric Beretta.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelUniqueGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}

ACTOR RLGrammatonClericBerettaPickupModded : RLGrammatonClericBerettaPickup
{
	+INVENTORY.TRANSFER
	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:
		GCBP 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("RLGrammatonClericBeretta",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cdGrammaton Cleric Beretta.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Grammaton Cleric Beretta =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLGrammatonClericBerettaModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Grammaton Cleric Beretta =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Clip",18)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cd= GrammatonClericBeretta =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
