// --------------------------------------------------------------------------
//
// GALILAR (Weapon)
//
// --------------------------------------------------------------------------

ACTOR "GALILAR" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon Galilar_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 200
  weapon.ammotype "GALILARClip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "556mmAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //30
	obituary "%k killed %o with GALIL AR."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Pickep up a GALIL AR"
	Tag "GALIL AR"
	Weapon.UpSound "GALILAR/Ready"
	//AttackSound "GALILAR/Fire"
	Scale 0.16

	States
	{
	Ready:
		W14E 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, 215, 0, 0)//Weapon Weight
	TNT1 A 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")

		W14A A 1 A_WEAPONREADY(WRF_NOFIRE)
		W14A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W14B ABCDEFGHIJK 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		W14A A 1 A_WEAPONREADY(WRF_NOFIRE)
		W14A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W14B ABCDEFGHIJK 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:

	W04E D 0 A_JumpIfNoAmmo("AltFire")
	
	
		W14D A 1 A_GunFlash
		W14D B 2 A_WEAPONREADY(WRF_NOFIRE)//1
		// W14D C 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_Refire
		W14D DEFGHIJKLMNOP 1 A_WeaponReady //QRSTUVWXYZ
		W14E A 1 A_WeaponReady
		Goto Ready



  Altfire:
    TNT1 A 0 A_JumpIfInventory("GALILARClip",50,"Ready")
    TNT1 A 0 A_JumpIfInventory("556mmAmmo",1,"ReloadStart")
    goto Ready


	ReloadStart:
		W14F ABCDEFGHIJKLMNO 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("GALILAR/Reload", 6)
		W14F PQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W14G ABCDEFGHIJKLMN 1 A_WEAPONREADY(WRF_NOFIRE) //1
		Goto ReloadAmmo

  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("GALILARClip",1)
    TNT1 A 0 A_TakeInventory("556mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("GALILARClip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("556mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd
	
	
	ReloadEnd:
		W14G OPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W14H ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE) //1
		W14I ABCDEFGHIJKLMNO 1 A_WEAPONREADY(WRF_NOFIRE) //PQRSTUVWXYZ 1
		W14J AB 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,13,1)
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_PlaySound ("GALILAR/FIRE")
		TNT1 A 0 A_PlaySound("GALILAR/Distant", 7)
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,12,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", frandom(-2.5,2.5), 0, 11, 0, 0, frandom(-2.5,2.5))
		TNT1 A 1 A_FireBullets(0.19, 0.19, 1, 150.0, "galilarBullet")//152
TNT1 A 0 A_SetPitch(pitch-2.15)//-2.35
TNT1 A 0 A_SetANgle(angle-1.05)//-1.05
TNT1 A 0 A_SetANgle(angle+0.67)//0.67
		Goto LightDone
 	Spawn:
		W14Z A -1
		Stop
	}
}