// --------------------------------------------------------------------------
//
// Scar20 (Weapon)
//
// --------------------------------------------------------------------------


//Weapon Auxiliar
Actor Scar20willzoom: Inventory
{
Inventory.MaxAmount 1
}

ACTOR "Scar20" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon scar20_rat

+AMMO_OPTIONAL

	Weapon.SelectionOrder 400
  weapon.ammotype "Scar20Clip"
  weapon.ammouse 1
  weapon.ammogive 0
  weapon.ammotype2 "762mmAmmo"
  weapon.ammouse2 0
  weapon.ammogive2 0 //20
	obituary "%k killed %o with Scar20."
	+WEAPON.WIMPY_WEAPON
	Inventory.Pickupmessage "Picked up an Scar20."
	Tag "Scar20"
	Weapon.UpSound "Scar20/Ready"
	//AttackSound "Scar20/Fire" 
	Scale 0.1425
	//+NOAUTOFIRE

	States
	{
	Ready:
		
		TNT1 A 0 A_JumpIfInventory("Scar20willzoom",1,"READYZOOM")
		W33E E 1 A_WeaponReady
	TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotReady")
		TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")
		Loop



		
	ReadyZoom:
		SCOP A 1 A_WEAPONREADY(WRF_NOBOB)
		TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")
		Loop		
		








	ToZoom:
					TNT1 A 0 A_ZoomFactor (2.0)
      TNT1 A 0 A_JumpIfInventory("Scar20willzoom", 1, "ToUnzoom")
        TNT1 A 0 A_Playsound("scope/Zoom")
	  SCOP A 0 A_GiveInventory("Scar20willzoom", 1)
			tnt1 a 0 A_GiveInventory("CrosshairZoom", 1)
	  		SCOP A 1 A_GiveInventory("CrosshairZoom", 1)//A_TakeInventory(EnableCrosshair,999)
		SCOP A 9 A_WeaponReady(WRF_NOFIRE|WRF_NOBOB)

		Goto ReadyZoom
		




		
		
	ToUnzoom:
        TNT1 A 0 A_ZoomFactor (1.0)
	  TNT1 A 0 A_TakeInventory("Scar20willzoom", 1)

		SCOP A 3 A_WeaponReady(WRF_NOFIRE|WRF_NOBOB)
		tnt1 a 0 A_TakeInventory("CrosshairZoom", 1)
	W33K A 1 A_TakeInventory("CrosshairType",2)
		W33E E 6 A_WeaponReady(WRF_NOFIRE)
		Goto Ready




	Deselect:
	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
    TNT1 A 1 
	TNT1 A 0 A_StopSound (6)
	tnt1 a 0 A_TakeInventory("CrosshairZoom", 1)
	TNT1 A 0 A_TakeInventory("Scar20willzoom", 1)
				TNT1 A 1 A_ZoomFactor(1.0)
                TNT1 AAAAAAAAAAAAAAAAA 0 A_Lower
                TNT1 AAAAAA 1 A_Lower
		Loop


		
	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")

		TNT1 A 2 A_WEAPONREADY(WRF_NOFIRE)
		W33A EFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33B ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		TNT1 A 2 A_WEAPONREADY(WRF_NOFIRE)
		W33A EFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33B ABCDEFGHIJ 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:
	W33F G 0 A_JumpIfNoAmmo("AltFire")	
TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")

	TNT1 A 0 A_JumpIfInventory("Scar20willzoom",1,"ToFIREZOOM")
TNT1 A 0 A_SetPitch(pitch-1.82)//-2.02
TNT1 A 0 A_SetANgle(angle+0.85)
TNT1 A 0 A_SetANgle(angle-0.45)
		W33D A 1 A_GunFlash
		W33D B 2 A_WEAPONREADY(WRF_NOFIRE) //BCDEFGHI
		
		
		
		W33D J 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D K 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D L 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D M 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D N 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D O 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D P 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D Q 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D R 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D S 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D T 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D U 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D V 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D W 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D X 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D Y 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33D Z 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")





		W33E A 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33E B 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33E C 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33E D 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		W33E E 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")

		Goto Ready








//Bot compatibility


	BotReady:
		
		W33E E 1 A_WeaponReady
		TNT1 A 0 A_REFIRE
		Loop

	BotFire:
		W33D A 1 A_GunFlash
		W33D BCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		W33D JKLMNOPQRSTUVWXYZ 1 A_REFIRE
		W33E ABCDE 1 A_REFIRE
		Goto Ready





	ToFireZoom:
	SCOP A 0 A_JumpIfNoAmmo("AltFire")
TNT1 A 0 A_SetPitch(pitch-1.04)//-2.02
TNT1 A 0 A_SetANgle(angle+0.60)
TNT1 A 0 A_SetANgle(angle-0.30)	
		SCOP A 1 A_GunFlash
		SCOP A 8 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		Goto ReadyZoom



  Altfire:
    TNT1 A 0 A_JumpIfInventory("Scar20Clip",20,"Ready")
    TNT1 A 0 A_JumpIfInventory("762mmAmmo",1,"ReloadStart")
    goto Ready

	ReloadStart:
							TNT1 A 0 A_ZoomFactor (1.0)
							tnt1 a 0 A_TakeInventory("CrosshairZoom", 1)
							TNT1 A 0  A_TakeInventory("CrosshairType",2)
	TNT1 A 0 A_TakeInventory("Scar20willzoom", 1)
		W33F ABCDEFGHIJKLMNOP 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 A_PlaySound("Scar20/Reload")
		W33F QR 1 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)
		W33F STUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33G ABCDEFGHIJKLMNOPQRSTUVW 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo


  ReloadAmmo:
    TNT1 A 0 A_GiveInventory("Scar20Clip",1)
    TNT1 A 0 A_TakeInventory("762mmAmmo",1)
    TNT1 A 0 A_JumpIfInventory("Scar20Clip",0,"ReloadEnd")
    TNT1 A 0 A_JumpIfInventory("762mmAmmo",1,"ReloadAmmo")
    goto ReloadEnd


	ReloadEnd:
		W33G XYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33H ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33I ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W33J ABCDEF 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready



	Flash:
	TNT1 A 0 ACS_ExecuteAlways(799, 0, 7, 0, 0)
		TNT1 A 0 A_GiveInventory("CrosshairGrow", 12)
	TNT1 A 0 A_FireCustomMissile("WeaponSmokePuff",0,0,10,3)
TNT1 A 0 A_PlaySound ("Scar20/FIRE")
		TNT1 A 0 A_PlaySound("SCAR20/Distant", 7)
	TNT1 A 0 A_JumpIfInventory("Scar20willzoom", 1, "ToFlashzoom")
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		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 4 A_FireBullets(0.4, 0.4, -1, 200, "scar20Bullet")//3.0 28
		Goto LightDone

	ToFlashZoom:
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,16,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", 0, 0, 11, 0, 0, 0)
		TNT1 A 4 A_FireBullets(0.17, 0.17, 1, 200, "scar20Bullet")//28
		Goto LightDone


 	Spawn:
		W33Z A -1
		Stop
	}
}