
// *** MODIFIED BY CHEBMASTER
// I mark places modified by me with //***Che 

//***Che made it self-cocking to increase rate of fire dramatically
// Otherwise, this weapon *had no niche*!

ACTOR Revolver : BrutalWeapon //5874 // see ShotolverSpawner in WeaponSpawners.txt
{
	//$category "Weapons"
	Weapon.SelectionOrder 1250
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive1 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "AmmoShell"
	Weapon.AmmoType2 "RevolverAmmo"
	Inventory.PickupMessage "You got the Shotvolver! Say farewell to your wrists."
    Inventory.PickupSound "REVOFIRpump"
	Obituary "$OB_MPSHOTGUN"
    AttackSound "None"
    +WEAPON.NOALERT
    +WEAPON.NOAUTOAIM
	+WEAPON.NOAUTOFIRE
	+WEAPON.CHEATNOTWEAPON
	Scale 0.9
	Tag "Revolver"
	States
	{
			
		Spawn:
			REVP A -1
			Stop
			
		Select:
			REVO A 0 A_Giveinventory("GoSpecial",1)
			REVO A 0 A_Takeinventory("FistsSelected",1)
			REVO A 0 A_Takeinventory("sawSelected",1)
			REVO A 0 A_Giveinventory("ShotgunSelected",1)
			REVO A 0 A_Takeinventory("SSGSelected",1)
			REVO A 0 A_Takeinventory("MinigunSelected",1)
			REVO A 0 A_Takeinventory("PlasmaGunSelected",1)
			REVO A 0 A_Takeinventory("RocketLauncherSelected",1)
			REVO A 0 A_Takeinventory("GrenadeLauncherSelected",1)
			REVO A 0 A_Takeinventory("BFGSelected",1)
			REVO A 0 A_Takeinventory("BFG10kSelected",1)
			REVO A 0 A_Takeinventory("RailGunSelected",1)
			REVO A 0 A_Takeinventory("SubMachineGunSelected",1)
			REVO A 0 A_Takeinventory("RevenantLauncherSelected",1)
		
		//***Che
			"----" A 0 A_Takeinventory("UnmakerSelected",1)
			"----" A 0 A_Takeinventory("MG42Selected",1) //***Che
			"----" A 0 A_Takeinventory("AxeSelected",1) //***Che
			"----" A 0 A_Takeinventory("DragonslayerSelected",1) //***Che
		
			REVO A 0 A_Takeinventory("LostSoulSelected",1)
			REVO A 0 A_Takeinventory("FlameCannonSelected",1)
			REVO A 0 A_Takeinventory("HasBarrel",1)
			REVO A 0 A_TakeInventory("TossGrenade", 1)
			REVO A 0 A_TakeInventory("Revolver2", 1)
			REVO AAAAAA 1 A_Raise

		SelectAnimation:
			TNT1 AAAA 0 A_JumpIfInventory("GoFatality", 1, "Steady")
			REVO LMN 1
			TNT1 A 0 A_PlaySound("REVOHAM", 4)
			REVO OPQR 1
			REVO A 0 A_GunFlash
			Goto Ready

		//***Che disabling player weapons for cutscenes and for the evacuation center
		HoldFire: 
			REVR A 0 offset(-6,36) A_JumpIfInventory("Reloading",1,"Reload")
			REVR A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			REVR A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			REVR A 0 A_JumpIfInventory("Unloading",1,"Unload")
			REVR A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			REVR A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")	
			REVR A 1 offset(-6,36) A_WeaponReady(WRF_NOBOB | WRF_NOFIRE | WRF_ALLOWRELOAD)
			REVR A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			Goto Ready		

		Ready3:	
		Ready:	
			REVO A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			REVO A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			REVO A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			REVO A 0 A_JumpIfInventory("Reloading",1,"Reload")
			REVO A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			REVO A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			REVO A 0 A_JumpIfInventory("Unloading",1,"Unload")
			REVO A 0 A_JumpIfInventory("FiredPrimary",1,"Fire")
			
			//***Che: moved the ammo change to this
			// ------ The "revolver alt fire is confusing" bug -----------------------------------------------------
			REVO A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")

			REVO A 0 A_JumpIfInventory("RevolverAmmo",1,1)
			Goto NoAmmo2
			REVO A 0
			
		OkToFire:
			REVO A 0 A_TakeInventory("Reloading", 1)
			REVO A 1 A_WeaponReady(WRF_ALLOWRELOAD)
			REVO A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			REVO A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			Goto Ready
			

		
		Deselect:
			REVO A 0
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_TakeInventory("TossGrenade", 1)
			REVO A 0 A_Takeinventory("ADSmode",1)
			REVO A 0 A_Takeinventory("UseShotgunStrap",1)
			REVO A 0 A_ZoomFactor(1.0)
			REVO A 1 A_Lower
			Wait


		Fire:
			REVO A 0 A_Takeinventory("Reloading",1)
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			REVO A 0 A_JumpIfInventory("RevolverAmmo",1,1)
			Goto NoAmmo
			//***Che
			//REVO B 1
			REVO B 1
			"----" A 0 A_GiveInventory ("PlayerIsFighting", 150) //***Che encourages the follower NPCs to get da fug out of your line of fire
			REVO A 0 A_ZoomFactor(0.9)
			REVO A 0 A_AlertMonsters
			REVO A 0 A_PlaySound("REVOFIR", 1)
			RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
			REVO A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
			TNT1 AAAAAAAAAAAAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-12,12), 0, -1, 0, 0, random(-9,9))
			TNT1 AAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles2", random(-12,12), 0, -1, 0, 0, random(-9,9))
			TNT1 AAAAA 0 A_FireCustomMissile("DecorativeTracer", random(-3,3), 0, 0, -12, 0, random(-3,3))
			
			REVO A 0 A_Takeinventory("RevolverAmmo",1)
			SHO9 A 0 A_firebullets (0,0,1,10,"shotpuff",FBF_NORANDOM,240) // inflicts "SSG", super shotgun's
			SHO9 A 0 A_firebullets (0,0,1,10,"shotpuff",FBF_NORANDOM,120)
			
			//***Che: fixing this DOING ZERO HEADSHOT DAMAGE
			// (because headboxes are *immune* to "ExplosiveImpact" damage)
			//REVO A 0 A_FireBullets (20, 7, 7, 12, "revopuff", FBF_NORANDOM) // inflicts "ExplosiveImpact", the same as explosion splash
			//REVO A 0 A_FireBullets (3, 3, 2, 12, "revopuff", FBF_NORANDOM)
			REVO A 0 A_FireBullets (20, 14, 5, 12, "revopuff", FBF_NORANDOM) // inflicts "ExplosiveImpact", the same as explosion splash
			REVO A 0 A_FireBullets (7, 7, 5, 12, "Shotgunpuff2", FBF_NORANDOM)
			
			REVO A 0 A_JumpIfInventory("IsNOTTacticalClass", 1, 3)//Tactical Mode deals extra damage
			REVO A 0 A_FireBullets (12, 3, 5, 12, "ShotgunPuff2", FBF_NORANDOM)
			REVO A 0 A_SetPitch(pitch-10)
			REVO CD 1 BRIGHT
			REVO A 0 A_SetPitch(-6.0 + pitch)
			REVO A 0 A_ZoomFactor(1.00)
			REVO E 1 A_SetPitch(+1.0 + pitch)
			REVO FG 1 A_SetPitch(+1.0 + pitch)
			REVO H 1 A_SetPitch(+0.5 + pitch)
			REVO IJK 1 A_SetPitch(pitch+0.5)
			
			//***Che making it auto-cocking to increase ROF dramatically (20 tics = 1.75 => 11 tics = 3.18
			"----" A 0 A_JumpIfInventory("RevolverAmmo",1,1)
			Goto NoAmmo
			
			//REVO K 4
			//REVO LMN 1
			//TNT1 A 0 A_PlaySound("REVOHAM", 4)
			//REVO OPQR 1
			//Goto Ready3
			
			REVO B 1 A_PlaySound("REVOHAM", 4)
			REVO A 1
			
			"----" A 0 A_JumpIfInventory("PressedPrimary", 1, "Fire")
			Goto Ready3
			
	  
		CheckSprint:
			REVO A 1 A_WeaponReady(WRF_NOFIRE)
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_ZoomFactor(1.0)
			REVO A 0 A_Takeinventory("ADSmode",1)
			REVO A 0 A_Giveinventory("GoSpecial",1)
			REVO A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			REVO A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
			Goto Ready
			
		StartSprint:
			REVO A 1 A_WeaponReady(WRF_NOFIRE)
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_Takeinventory("ADSmode",1)
			REVO A 0 A_ZoomFactor(1.0)
			REVO A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
			
		Sprinting:	
			REVP B 0 offset(-9,32) 
			REVO A 0 offset(-9,32) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			REVO A 0 offset(-9,32) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
			PLAY A 0 offset(-9,32) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
			REVO A 0 offset(-9,32) A_JumpIfInventory("PowerStrength", 1, 2)
			REVO A 0 offset(-9,32) A_GiveInventory("UsedStamina", 3)
			REVO A 0 offset(-9,32)
			REVP B 1 offset(-9,34) A_SetPitch(pitch -0.5)
			REVP B 1 offset(-6,36) A_SetPitch(pitch -0.5)
			REVP B 1 offset(-3,38) A_SetPitch(pitch -0.5)
			REVP B 1 offset(0,38) A_SetPitch(pitch -0.5)
			REVP B 1 offset(3,36) A_SetPitch(pitch -0.5)
			REVP B 1 offset(6,34) A_SetPitch(pitch -0.5)
			REVP B 1 offset(9,32) A_SetPitch(pitch -0.5)
			REVO A 0 offset(9,32) A_WeaponReady(WRF_NOBOB)
			REVO A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			REVO A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			REVO A 0 A_JumpIfInventory("Reloading",1,"Reload")
			REVO A 0 offset(-9,32) A_GiveInventory("UsedStamina", 3)
			REVO A 0 offset(9,33) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
			REVP B 1 offset(9,34) A_SetPitch(pitch +0.5)
			REVP B 1 offset(6,36) A_SetPitch(pitch +0.5)
			REVP B 1 offset(3,38) A_SetPitch(pitch +0.5)
			REVP B 1 offset(0,38) A_SetPitch(pitch +0.5)
			REVP B 1 offset(-3,36) A_SetPitch(pitch +0.5)
			REVP B 1 offset(-6,34) A_SetPitch(pitch +0.5)
			REVP B 1 offset(-9,32) A_SetPitch(pitch +0.5)
			REVO A 0 offset(-9,32) A_WeaponReady(WRF_NOBOB)
			REVO A 0 offset(-9,32) A_JumpIfInventory("IsRunning", 1, "Sprinting")
			
			Goto StopSprint
		StopSprintTired:
			REVO A 1
			PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			REVO A 0 A_PlaySound("Tired", 2)
			REVO A 0 A_TakeInventory("UsedStamina", 2)
			REVO A 5 A_WeaponReady
			REVO A 0 A_TakeInventory("UsedStamina", 2)
			REVO A 5 A_WeaponReady
			REVO A 0 A_TakeInventory("UsedStamina", 2)
			REVO A 5 A_WeaponReady
			REVO A 0 A_TakeInventory("UsedStamina", 2)
			REVO A 5 A_WeaponReady
			REVO A 0 A_TakeInventory("UsedStamina", 2)
			REVO A 5 A_WeaponReady
			Goto Ready
		StopSprint:
			REVP B 1
			REVO A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
			PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			Goto Ready

		Reload:
			REVO A 0 A_JumpIfInventory("RevolverAmmo", 1, 1)
			Goto ReloadWithNoAmmoLeft
			REVO A 1 A_WeaponReady
			REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"OkToFire")
			REVO RQPON 1 
			Goto ReloadNormally
		
		ReloadWithNoAmmoLeft:
			REVO A 0
			REVO A 0 A_TakeInventory("Reloading", 1)
			REVO A 0 A_JumpIfInventory("AmmoShell", 1, 1)
			Goto NoAmmo2
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_ZoomFactor(1.0)
			//***Che
			//REVO A 1 A_WeaponReady
			REVO K 1 A_WeaponReady
			REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"OkToFire")
			REVO A 0 A_JumpIfInventory("RevolverAmmo", 1, "ReloadNormally")//Check if there is a shell in the chamber
		
		ReloadNormally:	
			REVO A 0 A_JumpIfInventory("AmmoShell",1,1)//If there is no reserve ammo, don't reload, go back to Ready
			Goto Ready
			REVO A 0 A_JumpIfInventory("TurboReload", 1, "TurboReload")//Check if reloads are disabled.
			REVR B 0 A_GiveInventory ("Pumping", 1)
			REVR ABCDEEDCBA 1
			TNT1 A 0 A_PLaySound("RELO1", 4)
			REVR FGHIJJJ 1
			REVR KLM 1
			REVR M 4
		InsertingShells:
			REVO A 0
			REVO A 0 A_JumpIfInventory("AmmoShell",1,2)//if there are no more reserve shells, finish reload.
			Goto FinishedInsertingShells
			REVO A 0
			REVO A 0 A_GiveInventory ("Pumping", 1)
			SSHR A 0 A_TakeInventory("Reloading", 1)
			TNT1 A 0 A_FireCustomMissile("SSGCaseSpawner",0,0,-10, -20)
			REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishedInsertingShells")
			REVO A 0 A_Giveinventory("RevolverAmmo",1)
			REVO A 0 A_Takeinventory("AmmoShell",1)
			
		InsertShellAnimation:	
			REVO A 0
			TNT1 A 0 A_PlaySound("insertshell")
			REVR M 1 Offset(0, 30)
			REVR M 1 Offset(0, 28)
			REVR M 1 Offset(0, 30)
			REVR M 1 Offset(0, 32)
			REVR M 4 A_WeaponReady(WRF_NOBOB)
			SSHR A 0 A_JumpIfInventory("Reloading", 1, "FinishedInsertingShells")
			REVO A 0 A_JumpIfInventory("Kicking",1,"DoKickReloading")
			REVO A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishedInsertingShells")//If there are 8+1 shells, stop it immediately
			Goto InsertingShells
		
			
		FinishedInsertingShells:
			REVO A 0 A_Takeinventory("Reloading",1)
			TNT1 A 0 A_PLaySound("RELO2", 4)
			REVR JIHGFAEDCBA 1
			REVO K 4
			REVO LMN 1
			TNT1 A 0 A_PlaySound("REVOHAM", 4)
			REVO OPQR 1
			REVO A 0 A_Takeinventory("Reloading",1)
			Goto Ready
			
		
		TurboReload:
			SHSS BC 0
		TurboBullets:	
			REVO A 0
			REVO A 0 A_JumpIfInventory("RevolverAmmo",6,"FinishTurboReload")
			REVO A 0 A_JumpIfInventory("AmmoShell",1,3)
			Goto FinishTurboReload
			TNT1 AAAA 0
			REVO A 0 A_Giveinventory("RevolverAmmo",1)
			REVO A 0 A_Takeinventory("AmmoShell",1)
			Goto TurboBullets
		FinishTurboReload:
			REVO A 1 A_Refire
			Goto Ready3

		PuristGun:
			TNT1 A 1
			REVO A 0 A_GiveInventory("ClassicShotgun", 1)
			REVO A 0 A_TakeInventory("Shot_Gun", 1)
			TNT1 A 10
			Goto Ready3
			
		AltFire:
			TNT1 A 0
			//***Che: NO GOOD. Player used to iron sights now. Moving this function to DualWield.
			//TNT1 A 0 A_GiveInventory("RevolverChangeAmmo", 1)
			goto Reload
			
		DualWield:
			TNT1 A 0
			//***Che: temporarily disabling it because it is not working (you just unload, then reload it back)
			// and i cannot figure out why.
			//goto Reload
			REVO A 1
			REVO A 0 A_Takeinventory("StartDualWield",1)
			TNT1 A 0 A_GiveInventory("RevolverChangeAmmo", 1)
			Goto Unload
		
			
		Unload:
			REVO A 1
			REVO A 0 A_ZoomFactor(1.0)
			REVO A 0 A_Takeinventory("Unloading",1)
			REVO A 0 A_Takeinventory("ADSmode",1)
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_JumpIfInventory("RevolverAmmo",1,1)
			Goto OkToFire
			REVO A 0 A_Takeinventory("Zoomed",1)
			REVO A 0 A_GiveInventory ("Pumping", 1)
			REVO A 0 A_Takeinventory("Unloading",1)
			REVR ABCDEEDCBA 1
			TNT1 A 0 A_PLaySound("RELO1", 4)
			REVR FGHIJJJ 1
			REVR KLM 1
			REVR M 4
			
		RemoveBullets:
			TNT1 AAAA 0
			REVO A 0 A_JumpIfInventory("RevolverAmmo",1,1)
			Goto FinishUnload
			REVO A 0 A_Takeinventory("RevolverAmmo",1)
			REVO A 0 A_Giveinventory("AmmoShell",1)
			
			REVR M 1 Offset(0, 30)
			REVR M 1 Offset(0, 28)
			REVR M 1 Offset(0, 30)
			REVR M 1 Offset(0, 32)
			Goto RemoveBullets
		
		FInishUnload:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("RevolverChangeAmmo", 1, "ChangeAmmo")
			REVO A 0 A_Takeinventory("Unloading",1)
			Goto OkToFire	
			
		ChangeAmmo:
			TNT1 A 0
			TNT1 A 0 A_TakeInventory("RevolverChangeAmmo", 1)
			TNT1 A 0 A_GiveInventory("Reloading", 1)
			TNT1 A 0 A_GiveInventory("Revolver2", 1)
			TNT1 A 0 A_SelectWeapon("Revolver2")
			Goto Ready
			
			
		DoKickReloading:
			"----" A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire") //***Che
			NULL A 0 A_JumpIf (momZ > 0, "AirKick")
			NULL A 0 A_JumpIf (momZ < 0, "AirKick")
			REVO A 0 A_PlaySound("KICK")
			REVO A 0 SetPlayerProperty(0,1,0)
			KICK BCD 1
			RIFF A 0 A_FireCustomMissile("KickAttack", 0, 0, 0, -7)
			KICK H 3
			KICK A 0 A_Takeinventory("Kicking",1)
			KICK I 1
			KICK GFEDCBA 1 
			RIBA A 0 A_Takeinventory("Kicking",1)
			REVO A 0 SetPlayerProperty(0,0,0)
			Goto InsertingShells
			
		Steady:
			TNT1 A 1
			Goto Ready
			
			

		NoAmmo:
			RIFG A 0
			RIFG A 0 A_ZoomFactor(1.0)
			RIFG A 0 A_Takeinventory("Zoomed",1)
			RIFG A 0 A_Takeinventory("ADSmode",1)
			RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
			TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
			RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
			RIFG A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			RIFG A 0 A_JumpIfInventory("ExecuteDownedEnemy", 1, "DoExecution")
			RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			
			//***Che
			//REVO A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
			REVO K 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
			
			RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
			RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
			TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
			RIFG A 0 A_JumpIfInventory("AmmoShell",1,"Reload")
			RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
			Goto Ready3
			
	}
}

ACTOR RevolverAmmo : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 6
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 6
   Inventory.Icon "REVPA0"
}



