ACTOR SwatFlashbangs : Weapon 
{
	//$Category Weapons
	//$Title "Frag Grenade"
	Tag "Flashbangs"
	Weapon.SelectionOrder 2600
	Inventory.PickupSound "Misc/W_PkUp"
	Inventory.PickupMessage "Picked up a Frag Grenade." 
	Scale 0.7
	Weapon.AmmoType1 "FlashbangGrenadeAmmo"
	Weapon.AmmoType2 "FlashbangGrenadeAmmo"
	Weapon.AmmoUse2 1
	Weapon.AmmoGive 1 //Not picked up if Dropped by enemy (See Ammo Decorates below)
	Weapon.Kickback 150
	+INVENTORY.IGNORESKILL
	+Weapon.Explosive
	+NOAUTOAIM //Off as AUTOAIM restricts the boundries the Grenades, they fly farther if you tilt upward but AutoAim will restrict that.
	+NOALERT
	Inventory.RestrictedTo "SwatClass"
	States 
	{
	Spawn:
		GNA1 A -1
		Stop
	Select:
		SWGR A 1 A_Raise 
		TNT1 A 0 A_Raise
		TNT1 A 0 A_Raise
		Loop
	Deselect:
		TNT1 A 0 A_JumpIfInventory("FlashbangGrenadeAmmo",1,2)
		TNT1 A 1 A_Lower //Deselect With No Ammo
		TNT1 A 0 A_Lower
		Loop 
		SWGR A 1 A_Lower //Deselect With Ammo
		TNT1 A 0 A_Lower
		TNT1 A 0 A_Lower
		Loop
	Ready:
		SWGR A 1 A_WeaponReady(WRF_ALLOWZOOM)
		Loop 
	Fire:
		TNT1 A 0 A_CheckReload
		SWGR A 1 Fast A_PlaySoundEx("FragGrenade/Pin",7)
		SWGR BCDEFGHIJKLMNOP 1 Fast
	SpeedUp: //Increase Projectile Speed. Resulting in larger distance covered & higher bounces on impact.
		SWGR Q 3
		TNT1 A 0 A_GiveInventory("GrenSpeed",1)
		SWGR Q 3 A_Refire("SpeedUp")
		HGT2 A 1 A_PlaySound("FragGrenade/throw")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",12,"Throw12")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",11,"Throw11")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",10,"Throw10")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",9,"Throw9")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",8,"Throw8")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",7,"Throw7")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",6,"Throw6")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",5,"Throw5")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",4,"Throw4")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",3,"Throw3")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",2,"Throw2")
		TNT1 A 0 A_JumpIfInventory("GrenSpeed",1,"Throw1")
	Throw1:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade01",0,1,0,0)
		Goto FireEnd
	Throw2:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade02",0,1,0,0)
		Goto FireEnd
	Throw3:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade03",0,1,0,0)
		Goto FireEnd
	Throw4:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade04",0,1,0,0)
		Goto FireEnd
	Throw5:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade05",0,1,0,0)
		Goto FireEnd
	Throw6:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade06",0,1,0,0)
		Goto FireEnd
	Throw7:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade07",0,1,0,0)
		Goto FireEnd
	Throw8:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade08",0,1,0,0)
		Goto FireEnd
	Throw9:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade09",0,1,0,0)
		Goto FireEnd
	Throw10:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade10",0,1,0,0)
		Goto FireEnd
	Throw11:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade11",0,1,0,0)
		Goto FireEnd
	Throw12:
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade12",0,1,0,0)
		Goto FireEnd
	AltFire: //Throw a grenade instantly, distance depends on Player's pitch.
		TNT1 A 0 A_CheckReload
		SWGR A 1 Fast A_PlaySound("FragGrenade/Pin")
		SWGR BCDEFGHIJKLMNOP 1 Fast
		SWGR Q 3
		HGT2 A 1 A_PlaySound("FragGrenade/throw")
		HGT2 B 1 A_FireCustomMissile("FlashbangGrenade2",0,1,0,0)
	FireEnd:
		TNT1 A 0 A_TakeInventory("GrenSpeed",999) //Resets the Charge distance
		HGT2 CDEF 2
		HGT2 GHIJ 2
		TNT1 A 0 A_CheckReload
		HGT2 J 3 Fast A_Lower
		TNT1 A 10
		SWGR A 3 Fast A_Raise
		Goto Ready
  Zoom:
    TNT1 A 0 A_JumpIfInventory("HasSwatGrenades", 1, "CheckAmmo")
    Goto DontThrow
  CheckAmmo:
    TNT1 A 0 A_JumpIfInventory("SwatGrenadeAmmo", 1, "DoThrow")
    Goto DontThrow
  DoThrow:
    TNT1 A 0
    Goto ThrowFrag
	ThrowFrag:
	FGGN BCD 2
	TNT1 A 0 A_TakeInventory("SwatGrenadeAmmo", 1) // ONLY grenade ammo removed
	FGGN E 2 A_PlaySound("weapons/grnpullpin")
	FGGN FGHH 2
	FGGN J 0 A_FireCustomMissile("ThrownGrenade30", 0, 0, 0, 0)
	FGGN J 0 A_PlaySound("weapons/grntoss")
	FGGN JKLMNOPQ 2
	FGGN A 0
	NULL A 12 A_CheckReload
		Goto RaiseAfterThrow
	RaiseAfterThrow:
    SWGR A 1 Offset(0, 60)
    SWGR A 1 Offset(0, 50)
    SWGR A 1 Offset(0, 40)
		Goto Ready
	DontThrow:
		SWGR A 1
		Goto Ready
	}
}


ACTOR FlashbangGrenade1
{
    Damage 1
	Speed 8 //Default Speed. Fast enough to roll the grenade, so it won't blow up underneath the player.
	Height 2
	Radius 12
	Mass 9
	Damage 0
	Scale 0.6
	BounceType "Doom" //actor bounces off planes and walls.
	BounceSound "FragGrenade/Bounce"
	WallBounceSound "FragGrenade/Bounce"
	PROJECTILE
	-NOGRAVITY
	+CANBOUNCEWATER
	+FORCERADIUSDMG
	Species "Player"
	BounceFactor 0.8
	WallBounceFactor 0.5
	BounceCount 6
	ReactionTime 9 //About 3 Seconds
	RenderStyle NORMAL
	Decal Scorch

    States
    {
    Spawn:
        SWGP A 4 A_Countdown
        SWGP BCD 4
        Loop

Death:
    TNT1 A 0 A_SetScale(1, 1)
    TNT1 A 0 A_ChangeFlag("NoGravity", 1)
    TNT1 A 0 A_AlertMonsters
    TNT1 A 0 A_PlaySound("Character/SwatEnforcer/FlashExplode")
    TNT1 A 0 A_Explode(1, 256, 0)
    TNT1 A 0 A_SpawnItemEx("FlashbangAOE", 0, 0, 0, 0, 0, 0, 0, 1)
    EXP3 CDEFGHIJKLMNOPQRSTUVWXYZ 1 BRIGHT
    Stop
    }
}

ACTOR FlashbangGrenade01 : FlashbangGrenade1 { Speed 8 } //Default
ACTOR FlashbangGrenade02 : FlashbangGrenade1 { Speed 10 }
ACTOR FlashbangGrenade03 : FlashbangGrenade1 { Speed 12 }
ACTOR FlashbangGrenade04 : FlashbangGrenade1 { Speed 14 }
ACTOR FlashbangGrenade05 : FlashbangGrenade1 { Speed 16 }
ACTOR FlashbangGrenade06 : FlashbangGrenade1 { Speed 18 }
ACTOR FlashbangGrenade07 : FlashbangGrenade1 { Speed 20 }
ACTOR FlashbangGrenade08 : FlashbangGrenade1 { Speed 22 }
ACTOR FlashbangGrenade09 : FlashbangGrenade1 { Speed 24 }
ACTOR FlashbangGrenade10 : FlashbangGrenade1 { Speed 26 }
ACTOR FlashbangGrenade11 : FlashbangGrenade1 { Speed 28 }
ACTOR FlashbangGrenade12 : FlashbangGrenade1 { Speed 30 }
//THROW SPEED

//Alternative Fire
ACTOR FlashbangGrenade2 : FlashbangGrenade1	//Throw a Grenade at full speed that won't bounce as much.
{	
	Speed 30
	BounceCount 3
}

Actor FlashbangGrenadeAmmo : Ammo	// use this instead of the weapon as DropItem
{
	//$Category Ammunition
	//$Title "Frag Grenade"
	Inventory.Amount 1
	Inventory.MaxAmount 10
	ammo.backpackamount 1
	ammo.backpackmaxamount 20
	+INVENTORY.IGNORESKILL
	Inventory.PickupMessage "you shouldn't ever see this message because this item will be replaced by the actual weapon"
	States
	{
	Spawn:
		TNT1 A 0
		Stop
	}
}



actor FlashbangAOE
{
    +NOINTERACTION +NOBLOCKMAP +NOCLIP +ForcePain +ForceRadiusDMG
    Radius 1
    Height 1
	Species "Player"
	+FRIENDLY
    States
    {
    Spawn:
        TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
		TNT1 A 3 A_Explode(1, 256, 1) // causes pain, but nearly no damage
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)
        TNT1 A 3 A_Explode(1, 256, 1)


        Stop
    }
}
