// --------------------------------------------------------------------------
//
// Glock (Weapon)
//
// --------------------------------------------------------------------------


//Weapon Auxiliar
Actor GlockwillBurst: Inventory
{
Inventory.MaxAmount 1
}

ACTOR "Glock" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon Glock_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 600
  weapon.ammotype "GlockClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "9mmAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //20
	obituary "%k killed %o with Glock-18."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a Glock-18."
	Tag "Glock-18"
	Weapon.UpSound "Glock/Ready"
	//AttackSound "Glock/Fire" 
	Scale 0.2
	+NOAUTOFIRE

	States
	{
	Ready:
		W15E K 1 A_WeaponReady
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotReady")
	TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")
		Loop




		
		

	ToBurst:
	TNT1 A 0 A_JumpIfInventory("GlockWillBurst", 1, "ToSingle")
        TNT1 A 0 A_Playsound("Function/Alternate")
	  SCOP A 0 A_GiveInventory("GlockwillBurst", 1)
	TNT1 A 0 A_Print("Switched to Burst Fire")
		W15E K 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
		


	ToSingle:
	  TNT1 A 0 A_TakeInventory("GlockWillBurst", 1)
        TNT1 A 0 A_Playsound("Function/Alternate")
	TNT1 A 0 A_Print("Switched to Semi-Auto")
		W15E K 10 A_WeaponReady(WRF_NOFIRE)
		Goto Ready
		
		


	Deselect:
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
    TNT1 A 1 
	Goto DeselectLoop		
		
	Select:
	TNT1 A 1 A_Raise
	TNT1 AA 0 A_Raise
	TNT1 A 0 ACS_ExecuteAlways(798, 0, 240, 0, 0)//Weapon Weight
	TNT1 A 1 A_TakeInventory("CrosshairType",2)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")
	TNT1 A 4 A_WEAPONREADY(WRF_NOFIRE)
		W15A GHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W15B ABCDEFGHIJKLM 1 A_WEAPONREADY(WRF_NOFIRE)//NOPQ
		Goto Ready

	rat_triggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)

	TNT1 A 4 A_WEAPONREADY(WRF_NOFIRE)
		W15A GHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W15B ABCDEFGHIJKLMNOPQ 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:

	W15E K 0 A_JumpIfNoAmmo("AltFire")
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	TNT1 A 0 A_JumpIfInventory("Glockwillburst", 1, "FireBurst")
	
		W15D A 1 A_GunFlash
		W15D B 1 A_WEAPONREADY(WRF_NOFIRE)
		W15D C 1 A_WEAPONREADY(WRF_NOFIRE)
		//W15D D 1

		//TNT1 A 0 A_Refire
		W15D D 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D E 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D F 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D G 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D H 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D I 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D J 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D K 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D L 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D M 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D N 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D O 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D P 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Q 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D R 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D S 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D T 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D U 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D V 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D W 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D X 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Y 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Z 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")
		


		W15E A 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E B 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E C 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E D 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E E 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E F 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E G 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E H 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E I 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E J 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E K 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")
		
		Goto Ready



	FireBurst:

	W15E K 0 A_JumpIfNoAmmo("AltFire")	
		W15D A 1 A_GunFlash("FlashBurst")
		W15D B 1 A_WEAPONREADY(WRF_NOFIRE)
	W15E K 0 A_JumpIfNoAmmo("AltFire")	
		W15D C 1 A_GunFlash("FlashBurst")
		W15D A 1 A_WEAPONREADY(WRF_NOFIRE)
	W15E K 0 A_JumpIfNoAmmo("AltFire")	
		W15D B 1 A_GunFlash("FlashBurst")
		W15D C 1 A_WEAPONREADY(WRF_NOFIRE)
		//TNT1 A 0 A_Refire
		W15D DEFGHIJKLMNO 1 A_WeaponReady(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		
		
				W15D P 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Q 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D R 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D S 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D T 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D U 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D V 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D W 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D X 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Y 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15D Z 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")
		
		
		W15E A 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E B 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E C 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E D 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E E 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E F 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E G 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E H 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E I 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E J 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")

		W15E K 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToBurst")
		Goto Ready







//Bot compatibility

	BotReady:
		
		W15E K 1 A_WeaponReady
		TNT1 A 0 A_REFIRE
		Loop


	BotFire:
		W15D A 1 A_GunFlash
		W15D B 1 A_WEAPONREADY(WRF_NOFIRE)
		W15D CDE 1 A_WEAPONREADY(WRF_NOFIRE)
		W15D DEFGHIJKLMNOPQRSTUVWXYZ 1 A_Refire
		W15E ABCDEFGHIJK 1 A_Refire
		Goto Ready




  Altfire:
    TNT1 A 0 A_JumpIfInventory("GlockClip",20,"Ready")
    TNT1 A 0 A_JumpIfInventory("9mmAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W15F ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("Glock/Reload", 6)
W15F KLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W15G ABCDE 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		Goto ReloadAmmo
	
	
  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("GlockClip",1)
    TNT1 A 0 A_TakeInventory("9mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("GlockClip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("9mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd		

	ReloadEnd:
		
		W15G FGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W15H ABCDE 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W15H FGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W15I ABC 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_JumpIfInventory("Fire_Holdkey",1,"Fire")//A_Refire
		Goto Ready




	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 7)
	    TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,10,5)
TNT1 A 0 A_PlaySound ("Glock/FIRE")
		TNT1 A 0 A_PlaySound("Glock/Distant", 7)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", frandom(-1.5,1.5), 0, 11, 0, 0, frandom(-1.5,1.5))
		TNT1 A 2 A_FireBullets(0.5, 0.5, -1, 23.0, "glockBullet")//6.75
		Goto LightDone
		
	FlashBurst:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 7)
	    TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,10,5)
TNT1 A 0 A_PlaySound ("Glock/FIRE")
		TNT1 A 0 A_PlaySound("Glock/Distant", 7)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", 0, 0, 11, 0, 0, 0)
		TNT1 A 2 A_FireBullets(0.5, 0.5, 1, 23.0, "glockBullet")//6.75
		Goto LightDone
		
 	Spawn:
		W15Z A -1
		Stop
	}
}