
ACTOR RLHighPowerHuntingRevolver : RLPistolWeapon
{
  Obituary "%o was dedified by %k's revolver."
  Decal BulletChip
  Tag "High Power Hunting Revolver"
  Weapon.SelectionOrder 1900
  Weapon.SlotNumber 2
  Weapon.AmmoUse1 1
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLHighPowerHuntingRevolverClip"
  Weapon.AmmoType2 "Clip"
  Inventory.Icon "QREVICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    QREV 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_TakeInventory("PowerRLTechnicianBasicDamage", 1)
	TNT1 A 0 A_SpawnItemEx("RLHighPowerHuntingRevolverPickup", 0, 0, 40, 16, 0, 0, 0, SXF_SETMASTER)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerHuntingRevolverSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLHighPowerHuntingRevolver",1)
	Stop
  AfterModDrop:
    QREV A 8 A_WeaponReady (WRF_ALLOWRELOAD)
    Goto Ready
  MisfirePrevention:
    QREV 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("RLHighPowerHuntingRevolverSelected", 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
    QREV 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("RLSuperiorAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLPistolTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLAssembledWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLHighPowerHuntingRevolverSelected", 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
    QREV A 1 A_Raise
    Loop
// 10x damage with Scout, half spread
  Fire:
	QREV A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	QREV A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	QREV A 0 A_JumpIfInventory("RLRestrictionBoomOnly",1,"BoomRestricted") // Cannot fire in levels that restrict it
	QREV A 0 A_JumpIfInventory("RLRestrictionHighTechOnly",1,"HighTechRestricted") // Cannot fire in levels that restrict it
	QREV 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("RLWildWeaselPeacekeeperArmorBonus",1,4)
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (2, 2, -1, (random(1,5)*35), "RLPiercingPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (1, 1, -1, (350), "RLPiercingPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
	TNT1 A 0 A_JumpIfInventory("RLSharpshooterPerk",1,2)
	TNT1 A 0 A_FireBullets (0, 0, -1, (random(1,5)*53), "RLPiercingPuff")
    Goto FireFinish
	TNT1 A 0 A_FireBullets (0, 0, -1, (530), "RLPiercingPuff", FBF_NORANDOM | FBF_USEAMMO)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLRocketLauncherRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    TNT1 A 0 A_PlaySound("weapons/highpowerhuntingrevolver", CHAN_WEAPON, 1, 0, 0.5)
    TNT1 A 0 A_PlaySound("weapons/highpowerhuntingrevolver", 7, 0.05, 0, 0.10)
    QREV B 2 Bright A_GunFlash
    QREV C 2
    QREV D 2
    QREV E 2
    QREV F 1
    QREV A 4
    QREV A 5 A_ReFire
    Goto Ready
  Reload:
	QREV A 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerHuntingRevolverClip", 4, "Ready")
	TNT1 A 0 A_JumpIfInventory("Clip", 1, 1)
	Goto Ready
	TNT1 A 0 // Play the reload animation.
    QREV G 2
    QREV H 2
    QREV I 2
	TNT1 A 0 A_PlaySound("weapons/highpowerhuntingrevolveropen", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QREV J 2
    QREV K 2
    QREV L 12
	TNT1 A 0 A_PlaySound("weapons/highpowerhuntingrevolverout", 7)
    QREV L 12
	Goto ReloadWorking
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Clip", 1)
	TNT1 A 0 A_GiveInventory("RLHighPowerHuntingRevolverClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLHighPowerHuntingRevolverClip",4,"ReloadFinish")
	TNT1 A 0 A_JumpIfInventory("Clip",1,"ReloadWorking")
	Goto ReloadFinish
  ReloadFinish:
	TNT1 A 0 A_PlaySound("weapons/highpowerhuntingrevolverin", CHAN_ITEM)
    TNT1 A 0 A_SpawnItemEx ("RLStandardReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QREV J 2
    QREV K 2
    QREV L 24
    QREV K 2
    QREV J 2
	QREV I 2
	QREV H 2
	QREV G 3
	Goto Ready
  Flash:
    TNT1 A 2 A_Light2
    TNT1 A 2 A_Light1
    TNT1 A 2 A_Light0
    Goto LightDone
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLHighPowerHuntingRevolverPickup",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
  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_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLHighPowerHuntingRevolverSelected", 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("RLHighPowerHuntingRevolver",1)
	Stop
  }
}

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

Actor RLHighPowerHuntingRevolverSelected : RLPermanentInventory {}

ACTOR RLHighPowerHuntingRevolverClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 4
   Inventory.Icon ""
}

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

ACTOR RLHighPowerHuntingRevolverPickup : RLBasicAssembledWeaponPickup 17426
{
	//$Sprite QREVX0
	Tag "High Power Hunting Revolver [Pickup]"
	States
	{
	SpawnFrame:
		QREV 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("RLHighPowerHuntingRevolver",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("RLHighPowerHuntingRevolver",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cvHigh Power Hunting Revolver.")
		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 Hunting Revolver =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/hpHuntingRevolverpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonPistolClip",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	}
}
