// --------------------------------------------------------------------------
//
// MP7 (Weapon)
//
// --------------------------------------------------------------------------

ACTOR "MP7" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon mp7_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 300
  weapon.ammotype "MP7Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "9mmAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //30
	obituary "%k killed %o with MP7."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a MP7"
	Tag "MP7"
	Weapon.UpSound "MP7/Ready"
	//AttackSound "MP7/Fire"
	Scale 0.16

	States
	{
	Ready:
		W26E D 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, 220, 0, 0)//Weapon Weight
	W26A B 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")

		W26A CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W26B ABCDEFGHIJK 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		W26A CDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W26B ABCDEFGHIJ 1 A_WEAPONREADY//(WRF_NOFIRE)K
		Goto Ready

	Fire:

	W26E D 0 A_JumpIfNoAmmo("AltFire")
	
	
		W26D A 1 A_GunFlash
		W26D B 1 A_WEAPONREADY(WRF_NOFIRE)
		W26D C 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		W26D DEFGHIJKLMNOPQRSTUVWXYZ 1 A_WeaponReady
		W26E ABCD 1 A_WeaponReady
		Goto Ready



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


	ReloadStart:
		W26F ABCDEFGHIJKLM 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 A_PlaySound("MP7/Reload", 6)
		W26F NOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W26G ABCDEFGHIJKLMNOPQRSTUVWX 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		
		Goto ReloadAmmo

  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("MP7Clip",1)
    TNT1 A 0 A_TakeInventory("9mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("MP7Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("9mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd
	
	
	ReloadEnd:
		W26G YZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		
		W26H ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W26I ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W26I KLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W26J ABCDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		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,16,1)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("MP7/FIRE")
		TNT1 A 0 A_PlaySound("MP7/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(1.3, 1.3, 1, 60.0, "mp7Bullet")//6.25
		Goto LightDone
 	Spawn:
		W26Z A -1
		Stop
	}
}