// --------------------------------------------------------------------------
//
// UMP45 (Demo Weapon)
//
// --------------------------------------------------------------------------

ACTOR "UMP45" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon ump45_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 300
  weapon.ammotype "UMP45Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "45acpAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //25
	obituary "%k killed %o with UMP-45."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Pickep up a UMP-45"
	Tag "UMP-45"
	Weapon.UpSound "UMP45/Ready"
	//AttackSound "UMP45/Fire"
	Scale 0.145

	States
	{
	Ready:
		W39E I 1 A_WeaponReady
		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 
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 1, 0, 0)
    TNT1 A 0 A_JumpIfInventory("RAT_Trigger",1,"RAT_TriggerSelect")

		W39A B 1 A_WEAPONREADY(WRF_NOFIRE)
		W39A CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W39B ABCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready
		
	Rat_TriggerSelect:
    TNT1 A 0 A_TakeInventory("Rat_Trigger",1)

		W39A B 1 A_WEAPONREADY(WRF_NOFIRE)
		W39A CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W39B ABCDEFGHI 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:

	W39E D 0 A_JumpIfNoAmmo("AltFire")
	
	
		W39D A 1 A_GunFlash //1
		W39D B 2 A_WEAPONREADY(WRF_NOFIRE) //1
		W39D C 2 A_WEAPONREADY(WRF_NOFIRE) //1
		TNT1 A 0 A_Refire
		W39D DEFGHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady
		W39E ABCDEFGH 1 A_WeaponReady
		Goto Ready



  Altfire:
    TNT1 A 0 A_JumpIfInventory("UMP45Clip",25,"Ready")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W39F ABCDEFGHIJKLMNO 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("UMP45/Reload", 6)
		W39F PQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W39G ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W39H AB 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo

  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("UMP45Clip",1)
    TNT1 A 0 A_TakeInventory("45acpAmmo",1)
    TNT1 A 0 A_JumpIfInventory("UMP45Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("45acpAmmo",1,"ReloadAmmo")
    goto ReloadEnd
	
	
	ReloadEnd:
		
		W39H CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)//1
		W39I ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)//1
		W39J ABCDEFGHIJKLMNOPQRS 1 A_WEAPONREADY(WRF_NOFIRE)//1
		Goto Ready	
	
	



	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 0, 0, 0)
	TNT1 A 0 A_GiveInventory("CrosshairGrow", 6)
	TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,2)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("UMP45/FIRE")
		TNT1 A 0 A_PlaySound("UMP45/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 2 A_FireBullets(0.7, 0.7, 1, 80.0, "ump45Bullet")//7.5 //50 
TNT1 A 0 A_SetPitch(pitch-0.5)
TNT1 A 0 A_SetANgle(angle-0.2)
TNT1 A 0 A_SetANgle(angle+0.1)
		Goto LightDone
 	Spawn:
		W39Z A -1
		Stop
	}
}