// --------------------------------------------------------------------------
//
// XM1014 (Demo weapon)
//
// --------------------------------------------------------------------------

ACTOR "XM1014" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon xm1014_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 500
  weapon.ammotype "XM1014Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "BuckshotAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //7
	obituary "%k killed %o with XM1014."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a XM1014."
	Tag "XM1014"
	Weapon.UpSound "XM1014/Ready"
	//AttackSound "XM1014/Fire" 
	Scale 0.125

	States
	{
	Ready:
		W40E E 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, 215, 0, 0)//Weapon Weight
    TNT1 A 0 A_TakeInventory("CrosshairType",2)
    TNT1 A 0 A_GiveInventory("CrosshairType",1)

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

		TNT1 A 11 A_WEAPONREADY(WRF_NOFIRE)
		W40A NOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W40B ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		TNT1 A 11 A_WEAPONREADY(WRF_NOFIRE)
		W40A NOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W40B ABCDEFGHIJ 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:
	
	W40D Q 0 A_JumpIfNoAmmo("AltFire")
	
	
		W40D A 1 A_GunFlash
		W40D BCDEFGHIJKLMN 1 A_WEAPONREADY(WRF_NOFIRE)
		W40D OPQRSTUVWXYZ 1 A_WEAPONREADY//(WRF_NOFIRE)
		W40E ABCD 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready





  Altfire:
    TNT1 A 0 A_JumpIfInventory("XM1014Clip",7,"Ready")
    TNT1 A 0 A_JumpIfInventory("BuckshotAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W40F ABCDEFGHIJKLMNOPQR 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo
		
  ReloadAmmo:
		W40G ABCDEFG 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("XM1014/ShellIn", 6)
W40G HI 1 A_WEAPONREADY(WRF_NOFIRE)
    TNT1 A 0 A_GiveInventory("XM1014Clip",1)
    TNT1 A 0 A_TakeInventory("BuckshotAmmo",1)
		W40G JKLMNOPQRS 1 A_WEAPONREADY(WRF_NOSECONDARY)
    TNT1 A 0 A_JumpIfInventory("XM1014Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("BuckshotAmmo",1,"ReloadAmmo2")
    goto ReloadEnd		

  ReloadAmmo2:
		W40G ABCDEFG 1 A_WEAPONREADY(WRF_NOSECONDARY)
		TNT1 A 0 A_PlaySound("XM1014/ShellIn", 6)
W40G HI 1 A_WEAPONREADY(WRF_NOSECONDARY)
    TNT1 A 0 A_GiveInventory("XM1014Clip",1)
    TNT1 A 0 A_TakeInventory("BuckshotAmmo",1)
		W40G JKLMNOPQRS 1 A_WEAPONREADY(WRF_NOSECONDARY)
    TNT1 A 0 A_JumpIfInventory("XM1014Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("BuckshotAmmo",1,"ReloadAmmo2")
    goto ReloadEnd	



	ReloadEnd:

		W40H ABCDEFGHIJK 1 A_WEAPONREADY(WRF_NOSECONDARY)//(WRF_NOFIRE)
		Goto Ready



	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 1, 0, 0)
		TNT1 A 0 A_GiveInventory("CrosshairGrow", 13)
TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,8,9)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("XM1014/FIRE")
		TNT1 A 0 A_PlaySound("XM1014/Distant", 7)
		TNT1 A 0 A_FireCustomMissile("ShotCaseSpawn",5,0,12,-6)
		TNT1 AAAAAA 0 A_FireCustomMissile("Tracer", frandom(-3,3), 0, 11, -2, 0, frandom(-2,2))
		TNT1 A 4 A_FireBullets(7, 7, 12, 28.0, "xm1014Bullet")//3.325
		Goto LightDone
 	Spawn:
		W40Z A -1
		Stop
	}
}