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

ACTOR "Deagle" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon Deagle_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 600
  weapon.ammotype "DeagleClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "50aeAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //7
	obituary "%k killed %o with Desert eagle."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a Desert eagle."
	Tag "Desert eagle"
	Weapon.UpSound "Deagle/Ready"
	//AttackSound "Deagle/Fire" 
	Scale 0.2
	+NOAUTOFIRE

	States
	{
	Ready:
		W07E S 1 A_WeaponReady
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotReady")
		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, 230, 0, 0)//Weapon Weight
    TNT1 A 1 A_TakeInventory("CrosshairType",2)
TNT1 A 0 A_WeaponReady(WRF_NOFIRE)

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

		W07A BCDEFGHIJKLMNOPQRSTUV 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W07A WXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W07B ABCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready
		
	Rat_TriggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)

		W07A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W07B ABCDEFGHI 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready
		
	Fire:

	W07D U 0 A_JumpIfNoAmmo("AltFire")
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	
		W07D A 1 A_GunFlash
		W07D B 2 A_WEAPONREADY(WRF_NOFIRE)//1
		//W07D CDEFG 1 A_WEAPONREADY(WRF_NOFIRE)
		//W07D D 1

		//TNT1 A 0 A_Refire
		W07D HIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady
		W07E ABCDEFGHIJKLMNOPQR 1 A_WeaponReady

		Goto Ready









//Bot compatibility


	BotReady:
		
		W07E S 1 A_WeaponReady
		TNT1 A 0 A_REFIRE
		Loop

	BotFire:
	
		W07D A 1 A_GunFlash
		W07D B 1 A_WEAPONREADY(WRF_NOFIRE)
		W07D CDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)


		W07D IJKLMNOPQRSTUVWXYZ 1 A_Refire
		W07E ABCDEFGHIJKLMNOPQR 1 A_Refire

		Goto Ready






  Altfire:
    TNT1 A 0 A_JumpIfInventory("DeagleClip",7,"Ready")
    TNT1 A 0 A_JumpIfInventory("50aeAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W07F ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("Deagle/Reload", 6)
		W07F KLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W07G ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo
	
	
  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("DeagleClip",1)
    TNT1 A 0 A_TakeInventory("50aeAmmo",1)
    TNT1 A 0 A_JumpIfInventory("DeagleClip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("50aeAmmo",1,"ReloadAmmo")
    goto ReloadEnd		

	ReloadEnd:
		W07G GHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W07H ABCDEFGHIJKLMNOPQRSTUVWX 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, 1, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 14)
	TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,11,5)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("DEAGLE/FIRE")
		TNT1 A 0 A_PlaySound("DEAGLE/Distant", 7)
		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 3 A_FireBullets(0.16, 0.16, -1, 100, "DeagleBullet")//22
TNT1 A 0 A_SetPitch(pitch-0.5)
TNT1 A 0 A_SetANgle(angle-1.45)
TNT1 A 0 A_SetANgle(angle+0.87)
		Goto LightDone
 	Spawn:
		W07Z A -1
		Stop
	}
}