// --------------------------------------------------------------------------
//
// G3SG1 (Demo weapon)
//
// --------------------------------------------------------------------------


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

ACTOR "G3SG1" : CSDMOWeapon //5010
{
	Weapon.SisterWeapon G3sg1_rat

+AMMO_OPTIONAL

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

	States
	{
	Ready:
		
		TNT1 A 0 A_JumpIfInventory("G3SG1willzoom",1,"READYZOOM")
		W13E W 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 (1.7) //2.0
      TNT1 A 0 A_JumpIfInventory("G3SG1willzoom", 1, "ToUnzoom")
        TNT1 A 0 A_Playsound("scope/Zoom")
	  SCOP A 0 A_GiveInventory("G3SG1willzoom", 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("G3SG1willzoom", 1)

		SCOP A 3 A_WeaponReady(WRF_NOFIRE|WRF_NOBOB)
			tnt1 a 0 A_TakeInventory("CrosshairZoom", 1)
			W13M A 1 A_TakeInventory("CrosshairType",2)
		W13E W 6 A_WeaponReady(WRF_NOFIRE)
		Goto Ready




	Deselect:
	TNT1 A 0 A_StopSound (6)
	tnt1 a 0 A_TakeInventory("CrosshairZoom", 1)
	TNT1 A 0 A_TakeInventory("G3SG1willzoom", 1)

	TNT1 A 0 ACS_NamedExecuteAlways("HSPreviousWeapon", 0, 2, 0, 0)
				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
	W13A 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")

		W13A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13B ABCDEFGHIJ 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto Ready

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

		W13A BCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13B ABCDEFGHIJ 1 A_WEAPONREADY//(WRF_NOFIRE)
		Goto Ready

	Fire:

	W13F G 0 A_JumpIfNoAmmo("AltFire")	
TNT1 A 0 A_JumpIfInventory("IsBot",1,"BotFire")
	TNT1 A 0 A_JumpIfInventory("G3SG1willzoom",1,"ToFIREZOOM")
TNT1 A 0 A_SetPitch(pitch-0.92)//-2.02
TNT1 A 0 A_SetANgle(angle+0.65)
TNT1 A 0 A_SetANgle(angle-0.40)
		W13D A 1 A_GunFlash
		W13D B 3 A_WEAPONREADY(WRF_NOFIRE) //BCDEFGHI 1
TNT1 A 0 A_Refire
		

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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





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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		W13E W 1 A_WEAPONREADY
        TNT1 A 0 A_JumpIfInventory("IsAltFire",1,"ToZOOM")
		
		Goto Ready








//Bot compatibility


	BotReady:
		
		W13E W 1 A_WeaponReady
		TNT1 A 0 A_REFIRE
		Loop

	BotFire:
		W13D A 1 A_GunFlash
		W13D BCDEFGHI 1 A_WEAPONREADY(WRF_NOFIRE)
		W13D JKLMNOPQRSTUVWXYZ 1 A_REFIRE
		W13E ABCDEFGHIJKLMNOPQRSTUVW 1 A_REFIRE
		Goto Ready





	ToFireZoom:
	SCOP A 0 A_JumpIfNoAmmo("AltFire")
TNT1 A 0 A_SetPitch(pitch-0.56)//-2.02
TNT1 A 0 A_SetANgle(angle+0.50)
TNT1 A 0 A_SetANgle(angle-0.25)	
		SCOP A 1 A_GunFlash
		SCOP A 3 A_WEAPONREADY(WRF_NOFIRE|WRF_NOBOB)//8


		Goto ReadyZoom



  Altfire:
    TNT1 A 0 A_JumpIfInventory("G3SG1Clip",100,"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("G3SG1willzoom", 1)
		W13F ABCDEFGHIJKLMNOPQRSTUVW 1 A_WEAPONREADY(WRF_NOFIRE)
		TNT1 A 0 A_PlaySound("G3SG1/Reload")
		W13F XYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13G ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)//1
		W13H ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13I ABCDEFGHIJKLMNOPQRST 1 A_WEAPONREADY(WRF_NOFIRE)
		Goto ReloadAmmo


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


	ReloadEnd:
		W13I UVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13J ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13K ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 A_WEAPONREADY(WRF_NOFIRE)
		W13L ABCDEFGHIJKLMNOPQR 1 A_WEAPONREADY(WRF_NOFIRE) //1
		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,8,5)
TNT1 A 0 A_PlaySound ("G3SG1/FIRE")
		TNT1 A 0 A_PlaySound("G3SG1/Distant", 7)
	TNT1 A 0 A_JumpIfInventory("G3SG1willzoom", 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.3, 0.3, -1, 105, "g3sg1Bullet")//2.3 28
		Goto LightDone

	ToFlashZoom:
		TNT1 A 0 Bright A_Light1
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_FireCustomMissile("RifleCaseSpawn",5,0,15,-6)
        TNT1 A 0 BRIGHT A_FireCustomMissile("Tracer", 0, 0, 11, 0, 0, 0)
		TNT1 A 4 A_FireBullets(0.1, 0.1, 1, 105, "g3sg1Bullet")//28
		Goto LightDone


 	Spawn:
		W13Z A -1
		Stop
	}
}