ACTOR ClassicGewehr98 : ClassicWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	YScale 0.6
	XScale 0.8
	Weapon.SelectionOrder 2500
	Weapon.AmmoType "792UAC"
	Obituary "%o was shot down by %k's Gewehr 98."
    AttackSound "None"
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "$GOTGW98"
    +WEAPON.NOAUTOAIM
    +WEAPON.NOALERT
	+WEAPON.NOAUTOFIRE
	+FORCEXYBILLBOARD
	Tag "Gewehr 98 Sniper"
    Scale 0.8
	VisibleToPlayerClass Purist
	States
	{
		Spawn:
			WNUG Y 1
			WNUG Y -1
			Stop	
			
		//***Che disabling player weapons for cutscenes and for the evacuation center
		HoldFire:
			W98R G 0 offset(-50,62) A_JumpIfInventory("Zoomed",1,"StopAlt")
			W98R G 0 A_JumpIfInventory("Taunting",1,"Taunt")
			W98R G 0 A_JumpIfInventory("Salute1", 1, "Salute")
			W98R G 0 A_JumpIfInventory("Salute2", 1, "Salute")
			W98R G 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			W98R G 1 offset(-50,62) A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
			W98R G 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			Goto Ready				
		
		Ready:
		Ready3:
			W98G A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			W98G A 1 A_WeaponReady(WRF_ALLOWRELOAD)
			W98G A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			W98G A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			//W98G A 0 A_JumpIfInventory("Reloading",1,"Reload")
			W98G A 0 A_JumpIfInventory("Taunting",1,"Taunt")
			W98G A 0 A_JumpIfInventory("Salute1", 1, "Salute")
			W98G A 0 A_JumpIfInventory("Salute2", 1, "Salute")			
			W98G A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			//"----" # 0 A_JumpIfInventory("UsedBandage", 1, "UseBandages")
			Loop
			
		Ready2:
			SNIP Y 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "StopAlt")
			"----" A 0 A_GiveInventory ("PlayerIsFighting", 20) //***Che encourages the follower NPCs to get da fug out of your line of fire
			SNIP Y 1 A_WeaponReady(WRF_ALLOWRELOAD)
			SNIP Y 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			SNIP Y 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			//SNIP Y 0 A_JumpIfInventory("Reloading",1,"Reload")
			SNIP Y 0 A_JumpIfInventory("Taunting",1,"Taunt")
			SNIP Y 0 A_JumpIfInventory("Salute1", 1, "Salute")
			SNIP Y 0 A_JumpIfInventory("Salute2", 1, "Salute")				
			SNIP Y 0 A_JumpIfInventory("Kicking",1,"DoKick")
			Loop	
		
			
		Deselect:
			W98G A 0
			W98G A 0 A_TakeInventory("TossGrenade", 1)
			W98G A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			W98G A 0 A_TakeInventory("Reloading",1)
			W98G A 0 A_TakeInventory("Unloading",1)
			W98G A 0 A_ZoomFactor(1.0)
			W98G AAAAA 1 A_Lower
			TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
			TNT1 A 1 A_Lower
			Wait
			
		Select:
			W98G A 0
			W98G AAAAA 1 A_Raise
			TNT1 A 0 A_GunFlash // start the background tasks layer
			TNT1 AAAAAAAAA 0 A_Raise
			Goto Ready3

		Drop:
			RIFF A 0
			TNT1 A 0 A_TakeInventory("DropWeapon", 1)
			RIFF A 0 A_SpawnItemEx("Gewehr98", 0, 0, 30, 10, 0, 2)
			TNT1 A 0 A_TakeInventory("Gewehr98", 1)
			//TNT1 A 0 A_TakeInventory("Slot2Weapon", 1)
			Goto Ready
		
		Fire:
			W98G A 0 A_JumpIfInventory("792UAC",1,2)
			Goto NoAmmo
			TNT1 AA 0
			W98G A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			
			"----" A 0 A_JumpIfInventory("QPowerQuadDamage", 1, 2)
			"----" A 0 A_JumpIf(true, 2)
			"----" A 0 A_PlaySound("quaddamage/echo", CHAN_7)
			"----" A 0 A_GiveInventory ("PlayerIsFighting", 150) //***Che encourages the follower NPCs to get da fug out of your line of fire
			
			W98G A 0 A_AlertMonsters
			W98G A 0 A_PlaySound("m14FIRE", 1)
			SMGG A 0 A_PlaySound("FARM14", 6)
			TNT1 A 0 A_JumpIFInventory("Zoomed", 1, "Fire2")
			
			W98F A 1 A_FireBullets (1, 1, -1, 70, "m14Puff", FBF_NORANDOM)
			W98F B 1 A_FireCustomMissile("SmokeSpawner", random(-0.3,0.3), 0, 0, 0, 0, random(-0.3,0.3))
			W98G A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
			//W98F A 0 A_FireCustomMissile("m14Tracer", 0, 0, 0, 0, 0, 0)
			W98G A 0 A_ZoomFactor(0.96)
			W98G A 0 A_SetPitch(pitch-2.6)
			W98G A 0 A_SetANgle(angle-1.4)
			W98G A 0 A_Takeinventory("792UAC",1)
			W98F C 1 A_FireCustomMissile("RifleCaseSpawn",5,0,6,-14)
			W98G A 0 A_ZoomFactor(1.0)
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_SetPitch(pitch+0.2)
			W98G A 0 A_SetANgle(angle+0.1)
			W98G A 1
			W98G A 0 A_JumpIfInventory("792UAC",1,2)
			Goto NoAmmo
			TNT1 AA 0
			Goto Bolt
		
		 Bolt:
			W98B ABCDEF 1
			TNT1 A 0 A_PLaySound("RELO1", 4)
			W98B GHIJKKK 1
			W98B JHIGFEDCBA 1
			TNT1 A 0 A_JumpIFInventory("Zoomed", 1, "ZoomBack")
			Goto Ready3

		 Fire2:
			SNIP Y 1 A_FireBullets (0, 0, -1, 70, "M14PuffZoomed", FBF_NORANDOM)
			SNIP Y 1 A_FireCustomMissile("SmokeSpawner", random(-0.3,0.3), 0, 0, 0, 0, random(-0.3,0.3))
			W98G A 0 A_SpawnItemEx("PlayerMuzzle1",30,5,30)
			//W98F A 0 A_FireCustomMissile("m14Tracer", 0, 0, 0, 0, 0, 0)
			W98G A 0 A_ZoomFactor(5.96)
			SNIP Y  0 A_SetPitch(pitch-2.6)
			SNIP Y  0 A_SetANgle(angle-1.4)
			SNIP Y  0 A_Takeinventory("Gewehr98Ammo",1)
			SNIP Y 1 A_FireCustomMissile("RifleCaseSpawn",5,0,6,-14)
			SNIP Y  0 A_ZoomFactor(6.0)
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			SNIP Y  1 A_WeaponReady
			SNIP Y  0 A_SetPitch(pitch+0.2)
			SNIP Y  0 A_SetANgle(angle+0.1)
			TNT1 A 0 A_ZoomFactor(1.0)
			W98Z BA 1
			W98G A 0 A_JumpIfInventory("Gewehr98Ammo",1,2)
			Goto NoAmmo
			TNT1 AA 0
			Goto Bolt
			
		AltFire:
			TNT1 A 0
			TNT1 A 0 A_JumpIFInventory("Zoomed", 1, "StopAlt")
			TNT1 A 0 A_JumpIfInventory("DisablePlayerWeapons", 1, "HoldFire")
			TNT1 A 0 A_GiveInventory("Zoomed", 1)
		ZoomBack:
			TNT1 A 0 A_ZoomFactor(6.0)
			W98Z AB 1
			Goto Ready2
			
		StopAlt:
			TNT1 A 0 A_ZoomFactor(1.0)
			W98Z BA 1
			TNT1 A 0 A_TakeInventory("Zoomed", 1)
			Goto Ready3
				
			
		NoAmmo:
			W98G A 0
			W98G A 0 A_ZoomFactor(1.0)
			W98G A 0 A_Takeinventory("Zoomed",1)
			W98G A 0 A_Takeinventory("ADSmode",1)
			TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
			W98G A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
			W98G A 0 A_JumpIfInventory("IsRunning",1,"CheckSprint")
			//W98G A 0 A_JumpIfInventory("Reloading",1,"Reload")
			W98G A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			W98G A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOPRIMARY)
			//W98G A 0 A_JumpIfInventory("Reloading",1,"Reload")
			TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
			W98G A 0 A_JumpIfInventory("792UAC",1,"Bolt")//"Reload")//"BuzzsawAmmo",1,"Reload")
			Goto Ready3
/*		
		Reload:
			W98G A 1 A_WeaponReady
			W98G A 0 A_ZoomFactor(1.0)
			W98G A 0 A_Takeinventory("Reloading",1)
			W98G A 0 A_Takeinventory("ADSmode",1)
			W98G A 0 A_Takeinventory("Zoomed",1)
			W98G A 0 A_JumpIfInventory("Gewehr98Ammo",21,76)
			W98G A 0 A_JumpIfInventory("792UAC",1,3)//"BuzzsawAmmo",1,3)
			Goto FinishReloading
			TNT1 AAA 0
			W98G A 0 A_Takeinventory("Zoomed",1)
			W98G A 0 A_GiveInventory ("Pumping", 1)
			W98G A 0 A_Takeinventory("Reloading",1)
			
			W98B ABCDEF 1
			TNT1 A 0 A_PLaySound("RELO1", 4)
			W98B GHIJKKK 1
			W98R ABCD 1
			W98R D 10
			Goto InsertBullets
			
			
		InsertBullets:
			TNT1 AAAA 0
			W98G A 0 A_JumpIfInventory("Gewehr98Ammo",5,"FinishReloading")
			W98G A 0 A_JumpIfInventory("792UAC",1,3)//"BuzzsawAmmo"
			Goto FinishReloading
			TNT1 AAAAAA 0
			W98G A 0 A_Giveinventory("Gewehr98Ammo",1)
			W98G A 0 A_Giveinventory("DoubleGewehr98Ammo",1)
			W98G A 0 A_Takeinventory("792UAC",1) //"BuzzsawAmmo",1)
			TNT1 A 0 A_PlaySound("insertshell")
			W98R DEFGFEDDDD 1
			Goto InsertBullets
			
			TNT1 AAAAAAAAAA 0
			W98G A 0 A_Takeinventory("Reloading",1)
			Goto FinishReloading	
			TNT1 AAAA 0
			W98G A 0 A_Takeinventory("Reloading",1)
			Goto FinishReloading	
		
		FinishReloading:

			W98R DCBA 1
			TNT1 A 0 A_PLaySound("RELO4", 4)
			W98B KJHIGFEDCBA 1
			W98G A 0 A_Refire
			Goto Ready3
*/			
			
		CheckSprint:
			W98G A 1 A_WeaponReady(WRF_NOFIRE)
			W98G A 0 A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			W98G A 0 A_JumpIfInventory("IsTacticalClass", 1, "StartSprint")
			Goto Ready
			
		StartSprint:
			W98G A 1 A_WeaponReady(WRF_NOFIRE)
			W98G A 0 A_Takeinventory("Zoomed",1)
			W98G A 0 A_Takeinventory("ADSmode",1)
			W98G A 0 A_ZoomFactor(1.0)
			W98G A 0 A_JumpIfInventory("UsedStamina", 40, "StopSprintTired")
			
		Sprinting:	
			W98B A 0 offset(-9,42) 
			W98B A 0 offset(-9,42) A_JumpIfInventory("IsStandingStill", 1, "Ready3")
			W98B A 0 offset(-9,42) A_JumpIfInventory("UsedStamina", 100, "StopSprintTired")
			W98B A 0 offset(-9,42) ACS_ExecuteAlways(852, 0, 0, 0, 0)//Makes player faster.
			W98B A 0 offset(-9,42) A_JumpIfInventory("PowerStrength", 1, 2)
			W98B A 0 offset(-9,42) A_GiveInventory("UsedStamina", 5)
			W98B A 0 offset(-9,42)
			W98B A 1 offset(-9,44) A_SetPitch(pitch -0.5)
			W98B A 1 offset(-6,46) A_SetPitch(pitch -0.5)
			W98B A 1 offset(-3,48) A_SetPitch(pitch -0.5)
			W98B A 1 offset(0,48) A_SetPitch(pitch -0.5)
			W98B A 1 offset(3,46) A_SetPitch(pitch -0.5)
			W98B A 1 offset(6,44) A_SetPitch(pitch -0.5)
			W98B A 1 offset(9,42) A_SetPitch(pitch -0.5)
			W98B A 0 offset(9,42) A_WeaponReady(WRF_NOBOB)
			W98B A 0 A_JumpIfInventory("Kicking",1,"DoKick")
			W98B A 0 A_JumpIfInventory("Taunting",1,"Taunt")
//			W98B A 0 A_JumpIfInventory("Reloading",1,"Reload")
			W98B A 0 offset(-9,42) A_GiveInventory("UsedStamina", 5)
			W98B A 0 offset(9,43) A_SpawnItemEx("FootStep", 0, 0, 2, 0, 0, -4)
			W98B A 1 offset(9,44) A_SetPitch(pitch +0.5)
			W98B A 1 offset(6,46) A_SetPitch(pitch +0.5)
			W98B A 1 offset(3,48) A_SetPitch(pitch +0.5)
			W98B A 1 offset(0,48) A_SetPitch(pitch +0.5)
			W98B A 1 offset(-3,46) A_SetPitch(pitch +0.5)
			W98B A 1 offset(-6,44) A_SetPitch(pitch +0.5)
			W98B A 1 offset(-9,42) A_SetPitch(pitch +0.5)
			W98B A 0 offset(-9,42) A_WeaponReady(WRF_NOBOB)
			W98B A 0 offset(-9,42) A_JumpIfInventory("IsRunning", 1, "Sprinting")
			Goto StopSprint
			
		StopSprintTired:
			W98G A 1
			PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			W98G A 0 A_PlaySound("Tired", 2)
			W98G A 0 A_TakeInventory("UsedStamina", 2)
			W98G AAAAA 1 A_WeaponReady
			W98G A 0 A_TakeInventory("UsedStamina", 2)
			W98G AAAAA 1 A_WeaponReady
			W98G A 0 A_TakeInventory("UsedStamina", 2)
			W98G AAAAA 1 A_WeaponReady
			W98G A 0 A_TakeInventory("UsedStamina", 2)
			W98G AAAAA 1 A_WeaponReady
			W98G A 0 A_TakeInventory("UsedStamina", 2)
			W98G AAAAA 1 A_WeaponReady
			Goto Ready
		StopSprint:
			W98G A 1
			W98G A 0 A_JumpIfInventory("UsedStamina", 60, "StopSprintTired")
			PLAY A 0 ACS_ExecuteAlways(853, 0, 0, 0, 0)//Makes player slower.
			Goto Ready				
	}
}