// --------------------------------------------------------------------------
//
// MAG7 (Weapon)
//
// --------------------------------------------------------------------------

ACTOR "MAG7" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon mag7_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 500
  weapon.ammotype1 "MAG7Clip"
  weapon.ammouse1 1
  weapon.ammogive1 0
  weapon.ammotype2 "BuckshotAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //5
	obituary "%k killed %o with MAG7."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up a MAG7."
	Tag "MAG7"
	Weapon.UpSound "MAG7/Ready"
	//AttackSound "MAG7/Fire" 
	Scale 0.14

	States
	{
	Ready:
		W23E B 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, 225, 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)

		W23A ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23B ABCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		W23A ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23B ABCDEFGHI 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:
	
	W23E B 0 A_JumpIfNoAmmo("AltFire")
	
	
		W23D A 1 A_GunFlash
		W23D BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23E ABBBBB 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready





  Altfire:
    TNT1 A 0 A_JumpIfInventory("MAG7Clip",5,"Ready")
    TNT1 A 0 A_JumpIfInventory("BuckshotAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W23F ABCDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("Mag7/Reload", 6)
		W23F IJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23G ABCDEFGH 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo
		
		
		
  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("MAG7Clip",1)
    TNT1 A 0 A_TakeInventory("BuckshotAmmo",1)
    TNT1 A 0 A_JumpIfInventory("MAG7Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("BuckshotAmmo",1,"ReloadAmmo")
    goto ReloadEnd			
		




	ReloadEnd:
		W23G IJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23H ABCDEFGHIJKLMN 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_FireCustomMissile("ShotCaseSpawn",5,0,12,-6)
		W23H OPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W23I ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready



	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 2, 0, 0)
		TNT1 A 0 A_GiveInventory("CrosshairGrow", 40)
TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,12,8)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("MAG7/FIRE")
		TNT1 A 0 A_PlaySound("MAG7/Distant", 7)
		TNT1 AAAAAA 0 A_FireCustomMissile("Tracer", random(-3,3), 0, 11, -2, 0, frandom(-2,2))
		TNT1 A 4 A_FireBullets(7, 7, 14, 34.0, "mag7Bullet")//3.7
		TNT1 A 0 A_FireCustomMissile("ShotCaseSpawn",5,0,12,-6)

		Goto LightDone
 	Spawn:
		W23Z A -1
		Stop
	}
}