// --------------------------------------------------------------------------
//
// Deagle (Demo weapon)
//
// --------------------------------------------------------------------------

Actor USP45AltFire : Inventory
{
Inventory.MaxAmount 1
}

ACTOR "USP" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon usp_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 600
  weapon.ammotype "USPClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "45acpAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //7
	obituary "%k killed %o with USP."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a USP."
	Tag "R8 USP"
	Weapon.UpSound "USP/Ready"
	//AttackSound "Deagle/Fire" 
	Scale 0.2
	+NOAUTOFIRE

	States
	{
	Ready:
		44WC M 1 A_WeaponReady
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotReady")
	TNT1 A 0 A_JumpIfInventory("IsAltFire", 1, "Sil")
		Loop

	ReadySilencer:
		W44C M 1 A_WeaponReady
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotReady")
	TNT1 A 0 A_JumpIfInventory("IsAltFire", 1, "UnSil")
		Loop

		

	
		
		

	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 5 A_TakeInventory("CrosshairType",2)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
		TNT1 A 0 A_WEAPONREADY(WRF_NOFIRE)


		TNT1 A 0 A_JumpIfInventory("USP45AltFire", 1, "SelectSilencer")

	
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")

		44WA ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WB AB 1 A_WEAPONREADY(WRF_NOFIRE)
		44WB CDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

	SelectSilencer:
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelectSilencer")
	
		W44A ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W44B AB 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W44B CDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReadySilencer


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


		44WA ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WB AB 1 A_WEAPONREADY(WRF_NOFIRE)
		44WB CDEFGHI 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

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

	
		W44A ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44B AB 1 A_WEAPONREADY(WRF_NOBOB)
		W44B CDEFGH 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto ReadySilencer




	Fire:

	W44F H 0 A_JumpIfNoAmmo("AltFire")
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	
		TNT1 A 0 A_JumpIfInventory("USP45AltFire", 1, "FireSilencer")

			44WC A 1 A_GunFlash
		44WC B 1 A_WEAPONREADY(WRF_NOFIRE)
		44WC C 1 A_WEAPONREADY(WRF_NOFIRE)
		//W44D D 1

		//TNT1 A 0 A_Refire
		44WC DEFGHIJKL 1 A_WEAPONREADY

		Goto Ready



	FireSilencer:

	W44F H 0 A_JumpIfNoAmmo("AltFire")
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	
			W44C A 1 A_GunFlash
		W44C B 1 A_WEAPONREADY(WRF_NOFIRE)
		W44C C 1 A_WEAPONREADY(WRF_NOFIRE)
		//W44D D 1

		//TNT1 A 0 A_Refire
		W44C DEFGHIJKL 1 A_WEAPONREADY

		Goto ReadySilencer




	Unsil:
		W44G ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44H AB 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("USP/Unsil", 6)
		W44H CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44I ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44J ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44K ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44L ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44M ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		
		    TNT1 A 0 A_TakeInventory("USP45AltFire",1)
		
		Goto Ready
	
	
	Sil:
		44WG ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WH ABCDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("USP/Sil", 6)
		44WH IJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WI ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WJ ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WK ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WL ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WM ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)

		    TNT1 A 0 A_GiveInventory("USP45AltFire",1)


		Goto ReadySilencer





//Bot compatibility


	BotReady:
		
		W44F H 1 A_WeaponReady
		TNT1 A 0 A_REFIRE
		Loop

	BotFire:
	
		W44E A 1 A_GunFlash
		W44E B 1 A_WEAPONREADY(WRF_NOFIRE)
		W44E CDEFGHIJKL 1 A_WEAPONREADY(WRF_NOFIRE)


		W44E MNOPQRSTUVWXYZ 1 A_Refire
		W44F ABCDEFGH 1 A_Refire

		Goto Ready






  Altfire:
  TNT1 A 0 A_JumpIfInventory("USP45AltFire",1,"AltfireSilencer")

      TNT1 A 0 A_JumpIfInventory("USPClip",12,"Ready")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadStart")
    goto Ready


  AltfireSilencer:
      TNT1 A 0 A_JumpIfInventory("USPClip",12,"ReadySilencer")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadStart")
    goto ReadySilencer
  


	ReloadStart:
	TNT1 A 0 A_JumpIfInventory("USP45AltFire", 1, "ReloadStartSilencer")
		44WD ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("USP/Reload", 6)
		44WD KLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WE ABCD 1 A_WEAPONREADY(WRF_NOFIRE)
		44WE EFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		44WF ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo
	
	
  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("USPClip",1)
    TNT1 A 0 A_TakeInventory("45acpAmmo",1)
    TNT1 A 0 A_JumpIfInventory("USPClip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadAmmo")
    goto ReloadEnd		

	ReloadEnd:
		44WF GHIJKLMNOPQRSTUVWXY 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_JumpIfInventory("Fire_Holdkey",1,"Fire")//A_Refire
		Goto Ready


	ReloadStartSilencer:
		W44D ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("USP/Reload", 6)
		W44D KLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W44E ABCD 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W44E EFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W44F ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		Goto ReloadAmmoSilencer
	
	
  ReloadAmmoSilencer:
    TNT1 A 0 A_GiveInventory("USPClip",1)
    TNT1 A 0 A_TakeInventory("45acpAmmo",1)
    TNT1 A 0 A_JumpIfInventory("USPClip",0,"ReloadEndSilencer")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadAmmoSilencer")
    goto ReloadEndSilencer		

	ReloadEndSilencer:
		W44F GHIJKLMNOPQ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W44F RSTUVWXY 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_JumpIfInventory("Fire_Holdkey",1,"Fire")//A_Refire
		Goto ReadySilencer




	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 7)
		TNT1 A 0 A_JumpIfInventory("usp45AltFire",1,"FlashSilencer")
	TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,10,5)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters

		TNT1 A 0 A_PlaySound ("USP/FIRE")
		TNT1 A 0 A_PlaySound("USP/Distant", 7)
//		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"FlashFast")
		TNT1 A 3 A_FireBullets(0.3, 0.3, -1, 30.0, "uspBullet")//6.8
		Goto LightDone

	FlashSilencer:
	TNT1 A 0 A_FireCustomMissile("WeaponSMGSILENCEDSmokePuff",0,0,10,5)

		TNT1 A 0 A_PlaySound ("USP/FIRE_sil")
		TNT1 A 0 A_PlaySound("USP/Distant_sil", 7)
//		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
		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 0 A_JumpIfInventory("IsBot",1,"FlashFast")
		TNT1 A 3 A_FireBullets(0.3, 0.3, -1, 30.0, "uspBullet")//6.8
		Goto LightDone
		
		
	FlashFast:
		TNT1 A 3 A_FireBullets(0.3, 0.3, -1, 30.0, "uspBullet")//6.8
		Goto LightDone		
		
		
 	Spawn:
		W44Z A -1
		Stop
	}
}