// --------------------------------------------------------------------------
//
// Karabiner 98K Scoped Rifle
//
// --------------------------------------------------------------------------

ACTOR Karabiner98 : LowWeapon replaces Supershotgun
{
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.NOAUTOFIRE
	Weapon.SlotNumber 3
	Weapon.AmmoType1 "KARreload"
	Weapon.AmmoUse1 1
	Weapon.AmmoType2 "792ammo"
	Weapon.AmmoGive2 5
	Weapon.UpSound "weapons/upwp5"
	Inventory.Pickupmessage "You got the Karabiner 98K Rifle."
	Tag "Karabiner 98K"
	Scale 0.55
	States
	{
	Spawn:
		KARP A -1
		Stop
	Ready:
		TNT1 A 0 A_StopSound (7)
		TNT1 A 0 A_JumpIfInventory("SniperZoomed",1,"ReadyZoomed")
		KARG A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		TNT1 A 0 A_JumpifInventory("IsKicking",1,"Kick")
		TNT1 A 0 A_JumpifInventory("ThrowTNT",1,"TNT")
		Loop
	ReadyZoomed:
		TNT1 A 0 A_JumpifInventory("IsKicking",1,"Kick")
		KARZ A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Goto Ready
	Deselect:
		TNT1 A 0 A_StopSound (7)
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		TNT1 A 0 A_PlaySound("weapons/swap",6)
		KARG D 1 Offset (8, 0) A_Lower
		TNT1 A 0 A_Lower
		KARG D 1 Offset (16, 0) A_Lower
		TNT1 A 0 A_Lower
		KARG D 1 Offset (24, 0) A_Lower
		TNT1 A 0 A_Lower
		KARG D 1 Offset (32, 0) A_Lower
		TNT1 A 0 A_Lower
		KARR A 1 Offset (40, 0) A_Lower
		TNT1 A 0 A_Lower
		KARR A 1 Offset (48, 0) A_Lower
		TNT1 A 0 A_Lower
		KARR A 1 Offset (56, 0) A_Lower
		TNT1 A 0 A_Lower
		KARR A 1 Offset (64, 0) A_Lower
		TNT1 A 1 A_Lower
		Wait
	Select:
		KARR A 1 Offset (64, 0) A_Raise
		TNT1 A 0 A_Raise
		KARR A 1 Offset (56, 0) A_Raise
		TNT1 A 0 A_Raise
		KARR A 1 Offset (48, 0) A_Raise
		TNT1 A 0 A_Raise
		KARR A 1 Offset (40, 0) A_Raise
		TNT1 A 0 A_Raise
		KARG D 1 Offset (32, 0) A_Raise
		TNT1 A 0 A_Raise
		KARG D 1 Offset (24, 0) A_Raise
		TNT1 A 0 A_Raise
		KARG D 1 Offset (16, 0) A_Raise
		TNT1 A 0 A_Raise
		KARG D 1 Offset (8, 0) A_Raise
		TNT1 A 0 A_Raise
		Wait
	Fire:
		TNT1 A 0 A_StopSound (7)
		TNT1 A 0 A_JumpIfInventory("KARreload",1,1)
		Goto Dryfire
		TNT1 A 0 A_JumpIfInventory("SniperZoomed",1,"FireZoomed")
		TNT1 A 0 A_Playsound("weapons/KARFR", 6)
		KARF A 1 BRIGHT A_FireBullets(1.9,2.1,1,60,"Bullet_Puff2",1)
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0)
		TNT1 A 0 Radius_Quake (2, 2, 0, 1, 0)
		TNT1 A 0 A_SetPitch(pitch -2.5)
		TNT1 A 0 A_AlertMonsters 
		KARG BCD 3
		KARG EEFF 2
		KARG G 3 A_PlaySound("weapons/KARrd1")
		KARG H 3
		KARG I 2 A_FireCustomMissile("RifleCaseSpawn",345+random(-8,8),0,-4,-5,0)
		KARG IHHHGGF 2
		KARG D 3
		KARG C 2
		KARG A 1
		KARF A 0 A_Refire
		Goto Ready
	FireZoomed:
		TNT1 A 0 A_JumpIfInventory("KARreload",1,1)
		Goto SniperDryfire
		TNT1 A 0 A_Playsound("weapons/KARFR", 6)
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0)
		KARZ B 1 A_FireBullets(0,0,1,60,"Bullet_Puff2",1)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(pitch -5.5)
		KARZ A 2 Offset(0,35) A_ZoomFactor(4.2)
		KARZ A 2 Offset(0,33) A_ZoomFactor(4.15)
		KARZ A 2 Offset(0,33) A_ZoomFactor(4.1)
		KARZ A 2 Offset(0,33) A_ZoomFactor(4.05)
		KARZ A 4 Offset(0,32) A_ZoomFactor(4.0)
		KARZ A 13
		KARG A 1 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1.0)
		KARG BC 3
		KARG D 3
		KARG EEFF 2
		KARG G 3 A_PlaySound("weapons/KARrd1")
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",345+random(-8,8),0,-4,-5,0)
		KARG HI 3
		KARG IHHHGGF 2
		KARG D 3
		KARG C 2
		KARG A 1
		KARF A 0 A_Refire
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("ScopeToggle")==1,"AltFire")
		//TNT1 A 0 A_JumpIfInventory("KARreload",1,"Altfire")
		Goto Ready
	Altfire:
		TNT1 A 0 A_JumpIfInventory("SniperZoomed",1,"UnZoom")
		TNT1 A 0 A_GiveInventory("SniperZoomed",1)
		TNT1 A 0 A_PlaySound("weapons/KARzm")
		TNT1 A 0 A_ZoomFactor(4)
		Goto Ready
	UnZoom:
		KARZ A 1 A_ZoomFactor(3)
		KARZ A 1 A_ZoomFactor(2.5)
		KARZ A 1 A_ZoomFactor(2)
		KARZ A 1 A_ZoomFactor(1.5)
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_PlaySound("weapons/KARzm")
		TNT1 A 0 A_ZoomFactor(1)
		TNT1 A 0 A_StopSound (7)
		Goto Ready
	Flash:
		TNT1 A 2 Bright A_Light1
		TNT1 A 1 Bright A_Light2
		Goto LightDone
	SniperDryfire:
		TNT1 A 0 A_StopSound (7)
		KARZ A 1 A_ZoomFactor(1.0)
		KARZ A 1 A_TakeInventory("SniperZoomed",1)
		goto ReadyZoomed
	DryFire:
		TNT1 A 0 A_StopSound (7)
		TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		KARG B 3 A_PlaySound("weapons/MGDryfire")
		KARG A 10
	Reload:
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		TNT1 A 0 A_JumpIfInventory("KARreload", 5, 2)
		TNT1 A 0 A_JumpIfInventory("792ammo", 1, "ReloadWork")
		KARG A 1 A_WeaponReady
		Goto Ready
	ReloadWork:
		TNT1 A 0 A_Jumpifinventory("SniperZoomed",1,"Unzoom")
		KARG DE 2
		KARR E 3
	ReloadLoop:
		NULL A 0 A_JumpifInventory("IsKicking",1,"Kick")
		NULL A 0 A_JumpifInventory("ThrowTNT",1,"TNT")
		KARR A 3
		KARR B 3 A_WeaponReady(WRF_NOSWITCH|WRF_NOSECONDARY)
		KARR C 4 A_PlaySound("weapons/Karrd2")
		KARR D 3 A_WeaponReady(WRF_NOSWITCH|WRF_NOSECONDARY)
		TNT1 A 0 A_TakeInventory("792ammo", 1)
		TNT1 A 0 A_GiveInventory("KARreload", 1)
		TNT1 A 0 A_JumpIfInventory("KARreload", 5, "ReloadFinish")
		TNT1 A 0 A_JumpIfInventory("792ammo", 1, "ReloadLoop")
		Goto ReloadFinish
	ReloadFinish:
		KARR E 4
		KARG IIHHGG 1
		KARG G 1 A_PlaySound("weapons/Karrd3")
		KARG FFEEDD 1
		KARG EEDDCCBBAA 1
		Goto Ready
//  Kick Actions
	Kick:
		TNT1 A 0 A_JumpIf (momZ > 0, "AirKick")
		TNT1 A 0 A_JumpIf (momZ < 0, "AirKick")
		TNT1 A 0 A_JumpIfInventory("SuperBlow",1,"BerserkKick")
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		KKGR A 1 Offset(0,32)
		KKGR BCDE 1
		KKGR FG 1 A_Recoil(-1)
		KKGR H 2 A_CustomPunch (5,0,0,"FightPuff3") 
		KKGR IHGFEDC 1 
		KKGR BA 1 A_Recoil(+1)
		Goto Ready
	AirKick:
		TNT1 A 0 A_JumpIfInventory("SuperBlow",1,"AirBerserkKick")
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		FISG B 1
		FISG B 1 Offset(0,36)
		TNT1 A 0 Offset(-1,32)
		KI3K ABCDE 1
		KI3K F 3 A_CustomPunch (9,0,0,"FightPuff3") 
		KI3K GHIJK 2 
		Goto Ready
	BerserkKick:
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		KKGR A 1 Offset(0,32)
		KKGR BCDE 1
		KKGR FG 1 A_Recoil(-1)
		KKGR H 2 A_CustomPunch (9,0,0,"FightPuff3") 
		KKGR IHGFEDC 1 
		KKGR BA 1 A_Recoil(+1)
		Goto Ready
	AirBerserkKick:
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		FISG B 1
		FISG B 1 Offset(0,36)
		TNT1 A 0 Offset(-1,32)
		KI3K ABCDE 1 A_Recoil(-2)
		KI3K F 3 A_CustomPunch (12,0,0,"FightPuff3") 
		KI3K GHIJK 2 
		Goto Ready
// TNT Actions
	TNT:
		TNT1 A 0 A_TakeInventory("SniperZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		TNT1 A 0 A_JumpIfInventory("TNTammo",1,1)
		Goto NoTNT
		TNT1 A 0 A_JumpIf(waterlevel>2,"YouCannot")
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 Offset(-20,32)
		TAND ABC 2
		TAND D 2 A_PlaySound ("weapons/tnttr")
		TNT1 A 0 A_FireCustomMissile("STNT",0,0,0,0)
		TNT1 A 0 A_TakeInventory("TNTammo",1)
		TAND EDCBA 2
		TNT1 A 0 A_JumpIfInventory("TNTammo",0,"NoTNT")
		KARG A 1 Offset(67, 100)
		KARG A 1 Offset(54, 81)
		KARG A 1 Offset(32, 69)
		KARG A 1 Offset(22, 58)
		KARG A 1 Offset(10, 47)
		KARG A 1 Offset(7, 39)
		KARG A 1 Offset(2, 34)
		Goto Ready
	YouCannot:
		TNT1 A 0 A_Print("You Are Underwater!",8)
		Goto Ready
	NoTNT:
		TNT1 A 0 A_Print("No dynamites left.")
		Goto Ready
	}
}

ACTOR SniperZoomed : Inventory
{
Inventory.MaxAmount 1
}

ACTOR KARreload : Ammo
{
	Inventory.MaxAmount 5
	+IGNORESKILL
}