//FRAG GRENADE
///////////////////////////////////////////////////////////////////////////////


// Grenade Weapon (Or rather the arm that toss the thing..)

Actor gren_flashreset : Inventory { Inventory.MaxAmount 1 }
Actor gren_flash0to1 : Inventory { Inventory.MaxAmount 1 }
Actor gren_flash1to2 : Inventory { Inventory.MaxAmount 1 }
Actor gren_flash2to3 : Inventory { Inventory.MaxAmount 1 }
Actor gren_flash3toMAX : Inventory { Inventory.MaxAmount 1 }
Actor gren_flash5max : Inventory { Inventory.MaxAmount 1 }
Actor gren_PowThl1_end : Inventory { Inventory.MaxAmount 1 }
Actor gren_PT1_glow : Inventory { Inventory.MaxAmount 1 }
Actor gren_PowThl2_end : Inventory { Inventory.MaxAmount 1 }
Actor gren_PT2_glow : Inventory { Inventory.MaxAmount 1 }
Actor gren_PowThl3_end : Inventory { Inventory.MaxAmount 1 }
Actor gren_PT3_glow : Inventory { Inventory.MaxAmount 1 }
Actor gren_PowThMax_end : Inventory { Inventory.MaxAmount 1 }
Actor gren_PTMAX_glow : Inventory { Inventory.MaxAmount 1 }


actor gtoss_weaponmemory : inventory {
	/* Original idea from WildWeasels's and Marty Kirra's "Agent Hernandez"
	10 - Fist
	11 - Pistol
	12 - Autoshotgun
	13 - Assault Rifle
	14 - NailShotgun
	15 - AutoCannon
	16 - Concussion Rifle
	17 - Gauss Rifle
	*/
	inventory.maxamount 99
}

Actor PlayerNotJustSpawned : Inventory { Inventory.MaxAmount 1 }

actor grenade_toss : weapon {
	Tag "Grenade"
	Weapon.SelectionOrder 9000
	//weapon.bobstyle inverse\
	//weapon.bobrangeX 0.4
	//weapon.bobrangeY 0.9
	//weapon.bobspeed 2.5
	Weapon.preferredSkin "FistsSkin"
	
	+Weapon.NoAlert
	+WEAPON.NOAUTOAIM
	+AMMO_OPTIONAL
	states {
		
		Flash:
			NULL A 0 A_JumpIfInventory("gren_flashreset", 1, "flashreset")
			NULL A 0 A_JumpIfInventory("gren_flash0to1", 1, "flash0to1")
			NULL A 0 A_JumpIfInventory("gren_flash1to2", 1, "flash1to2")
			NULL A 0 A_JumpIfInventory("gren_flash2to3", 1, "flash2to3")
			NULL A 0 A_JumpIfInventory("gren_flash3toMAX", 1, "flash3toMAX")
			NULL A 0 A_JumpIfInventory("gren_flash5max", 1, "flash5max")
			NULL A 0 A_JumpIfInventory("gren_PowThl1_end", 1, "PowThl1_end")
			NULL A 0 A_JumpIfInventory("gren_PT1_glow", 1, "PT1_glow")
			NULL A 0 A_JumpIfInventory("gren_PowThl2_end", 1, "PowThl2_end")
			NULL A 0 A_JumpIfInventory("gren_PT2_glow", 1, "PT2_glow")
			NULL A 0 A_JumpIfInventory("gren_PowThl3_end", 1, "PowThl3_end")
			NULL A 0 A_JumpIfInventory("gren_PT3_glow", 1, "PT3_glow")
			NULL A 0 A_JumpIfInventory("gren_PowThMax_end", 1, "PowThMax_end")
			NULL A 0 A_JumpIfInventory("gren_PTMAX_glow", 1, "PTMAX_glow")
			Stop
		AltFlash:
			Goto Flash
	
		select:
			TNT1 A 1 A_Raise
			loop
		deselect:
			TNT1 A 1 A_lower 
			loop
		ready:
			TNT1 A 0 //A_SetCrosshair(10)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"PowThrowStart")
			TNT1 A 0 A_JumpIfInventory("PlayerNotJustSpawned", 1, 2)
			TNT1 A 0 A_JumpIfInventory("grenades", 1, 1)
			Goto checkweapon_toreturn
			TNT1 A 5 A_PlaySound("grenade/pin", CHAN_WEAPON)
			GTOS A 1 A_PlaySound("grenade/toss",CHAN_WEAPON) 
			GTOS B 1 
			GTOS C 1 A_FireCustomMissile("frag_grenade",0,0,-5,10,0,5)
			TNT1 A 0 A_TakeInventory("grenades", 1/*, TIF_NOTAKEINFINITE*/)
			GTOS DEFGHIJK 1
			
			TNT1 A 2 //A_JumpIfInventory("EvadingPlayer", 1, "EvdLoop")
			goto checkweapon_toreturn
		
		PowThrowStart:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 1, 1)
			goto ready+2
			
			GPTS EDCBA 1
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"ChargeStart")
		PowThrowQuickEnd:
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)

			NULL A 0 A_GiveInventory("gren_flashreset", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 A_TakeInventory("SuitIsPowered",9)
			TNT1 A 0 A_TakeInventory("powthrow_counter",999)
			GPTS ABCDE 1
			goto ready+2 
			
		ChargeStart:
			//TNT1 A 0 ACS_Terminate(911,0)
			TNT1 A 0 A_PlaySound("weapons/powpstart",CHAN_AUTO)
			TNT1 A 0 A_PlaySound("weapons/powchrg0", CHAN_WEAPON)
			TNT1 A 0 A_GiveInventory("SuitIsPowered",1)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_flash0to1", 1)
			TNT1 A 0 A_GunFlash
		loop_chrgStart:
			TNT1 A 0 A_JumpIfInventory("powthrow_counter", 20, "chrg_l1")
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPTC A 2 A_GiveInventory("powthrow_counter",2)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"loop_chrgStart")
			goto PowThrowQuickEnd
		flash0to1:
			GCP1 ABCDEFGHIJKLMNOPQRSTT 1 bright
			stop
		
		
		chrg_l1:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl1
		
			TNT1 A 0 A_TakeInventory("PlayerStamina", 20)
			TNT1 A 0 A_PlaySound("weapons/powchrg1", CHAN_WEAPON)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_flash1to2", 1)
			TNT1 A 0 A_GunFlash
		loop_cl1:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl1
			
			TNT1 A 0 A_JumpIfInventory("powthrow_counter", 40, "chrg_l2")
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPTC A 2 A_GiveInventory("powthrow_counter",2)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"loop_cl1")
			goto PowThrow_lvl1
		flash1to2:
			GCP2 ABCDEFGHIJKLMNOPQRSTT 1 bright
			stop
		
		chrg_l2:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl2
			
			TNT1 A 0 A_TakeInventory("PlayerStamina", 20)
			TNT1 A 0 A_PlaySound("weapons/powchrg2", CHAN_WEAPON)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
		
			NULL A 0 A_GiveInventory("gren_flash2to3", 1)
			TNT1 A 0 A_GunFlash
		loop_cl2:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl2
			
			TNT1 A 0 A_JumpIfInventory("powthrow_counter", 60, "chrg_l3")
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPTC A 2 A_GiveInventory("powthrow_counter",2)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"loop_cl2")
			goto PowThrow_lvl2
		flash2to3:
			GCP3 ABCDEFGHIJKLMNOPQRSTT 1 bright
			stop
		
		chrg_l3:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl3
		
			TNT1 A 0 A_TakeInventory("PlayerStamina", 20)
			TNT1 A 0 A_PlaySound("weapons/powchrg3", CHAN_WEAPON)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_flash3toMAX", 1)
			TNT1 A 0 A_GunFlash
		loop_cl3:
			TNT1 A 0 A_JumpIfInventory("PlayerStamina", 11, 1)
			goto PowThrow_lvl3
			
			TNT1 A 0 A_JumpIfInventory("powthrow_counter", 80, "chrg_max")
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPTC A 2 A_GiveInventory("powthrow_counter",2)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"loop_cl3")
			goto PowThrow_lvl3
		flash3toMAX:
			GCP4 ABCDEFGHIJKLMNOPQRSTT 1 bright
			stop
		
		chrg_max:
			TNT1 A 0 A_SetBlend("99 80 45",1.0,24)
			TNT1 A 0 A_GiveInventory("SuitIsOvercharged",1)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_flash5max", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,160,0,0)
			//TNT1 A 0 A_TakeInventory("BasicArmor", 400)
			TNT1 A 0 A_TakeInventory("PlayerStamina", 40)
			TNT1 A 0 A_PlaySound("weapons/powpmax", CHAN_AUTO)
			TNT1 A 0 ACS_ExecuteAlways(set_powf_bonusdamage, 0, 0, 0, 0)
		chrg_maxhold1:
			TNT1 A 0 A_PlaySound("weapons/powchrg5", CHAN_WEAPON)
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPMC A 2 Offset(3,35) 
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"chrg_maxhold2")
			goto PowThrow_Max
		chrg_maxhold2:	
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPMC A 2 Offset(0,29) 
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"chrg_maxhold3")
			goto PowThrow_Max
		chrg_maxhold3:	
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPMC A 2 Offset(-3,32)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"chrg_maxhold4")
			goto PowThrow_Max
		chrg_maxhold4:	
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPMC A 2 Offset(0,35)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"chrg_maxhold5")
			goto PowThrow_Max
		chrg_maxhold5:	
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			GPMC A 2 Offset(-3,29)
			TNT1 A 0 A_JumpIfInventory("TossGrenade",1,"chrg_maxhold1")
			goto PowThrow_Max
		flash5max:
			TNT1 A 0
			GPM1 ABCDEFGHIJKLMNO 1 bright
			GPM2 ABCDEFGHIJKLMNO 1 bright
			loop
		
		
		PowThrow_lvl1:
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_powThl1_end", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 A_SetBlend("0 48 99",0.3,18)
			GPTC A 1 Offset(-17,39)
			GPTC A 1 Offset(-39,58)
			GPTC A 1 Offset(-58,94)
			GPTC A 1 Offset(-80,141)
			
			TNT1 A 0 A_TakeInventory("TossGrenade",9)
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			TNT1 A 1 A_PlayWeaponSound("grenade/pin")
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PT1_glow", 1)
			TNT1 A 0 A_GunFlash
			GTOS A 1 A_PlayWeaponSound("weapons/powattack2") 
			GTOS B 1 
			GTOS C 1 A_FireCustomMissile("pow_frag-l1",0,0,-5,10,0,5)
			TNT1 A 0 A_TakeInventory("grenades", 1/*, TIF_NOTAKEINFINITE*/)
			GTOS DEFGHIJK 1
			TNT1 A 0 A_TakeInventory("SuitIsPowered", 9)
			TNT1 A 0 A_TakeInventory("powthrow_counter",999)
			TNT1 A 6
			goto checkweapon_toreturn
		PT1_glow:
			GPG1 ABCDEFGHIJK 1 bright
			stop
		PowThl1_end:
			GCP2 A 4 bright
			stop
			
		PowThrow_lvl2:
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PowThl2_end", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 A_SetBlend("0 48 99",0.5,18)
			GPTC A 1 Offset(-17,39)
			GPTC A 1 Offset(-39,58)
			GPTC A 1 Offset(-58,94)
			GPTC A 1 Offset(-80,141)
			
			TNT1 A 0 A_TakeInventory("TossGrenade",9)
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH|WRF_ALLOWRELOAD|WRF_ALLOWZOOM)
			TNT1 A 1 A_PlayWeaponSound("grenade/pin")
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PT2_glow", 1)
			TNT1 A 0 A_GunFlash
			GTOS A 1 A_PlayWeaponSound("weapons/powattack3") 
			GTOS B 1 
			GTOS C 1 A_FireCustomMissile("pow_frag-l2",0,0,-5,10,0,0)
			TNT1 A 0 A_TakeInventory("grenades", 1/*, TIF_NOTAKEINFINITE*/)
			GTOS DEFGHIJK 1
			TNT1 A 0 A_TakeInventory("SuitIsPowered", 9)
			TNT1 A 0 A_TakeInventory("powthrow_counter",999)
			TNT1 A 6 
			goto checkweapon_toreturn
		PT2_glow:
			GPG2 ABCDEFGHIJK 1 bright
			stop
		PowThl2_end:
			GCP3 A 4 bright
			stop
		
		PowThrow_lvl3:
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PowThl3_end", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 A_SetBlend("0 48 99",0.7,18)
			GPTC A 1 Offset(-17,39)
			GPTC A 1 Offset(-39,58)
			GPTC A 1 Offset(-58,94)
			GPTC A 1 Offset(-80,141)
			
			TNT1 A 0 A_TakeInventory("TossGrenade",9)
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			TNT1 A 1 A_PlayWeaponSound("grenade/pin")
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PT3_glow", 1)
			TNT1 A 0 A_GunFlash
			GTOS A 1 A_PlayWeaponSound("weapons/powattack4") 
			GTOS B 1 
			GTOS C 1 A_FireCustomMissile("pow_frag-l3",0,0,-5,10,0,0)
			TNT1 A 0 A_TakeInventory("grenades", 1/*, TIF_NOTAKEINFINITE*/)
			GTOS DEFGHIJK 1
			TNT1 A 0 A_TakeInventory("SuitIsPowered", 9)
			TNT1 A 0 A_TakeInventory("powthrow_counter",999)
			TNT1 A 6 
			goto checkweapon_toreturn
		PT3_glow:
			GPG3 ABCDEFGHIJK 1 bright
			stop
		PowThl3_end:
			GCP4 A 4 bright
			stop
		
		PowThrow_max:
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PowThMax_end", 1)
			TNT1 A 0 A_GunFlash
			TNT1 A 0 A_SetBlend("99 54 0",0.9,25)
			
			GPMC A 1 Offset(-17,19)
			GPMC A 1 Offset(-39,38)
			GPMC A 1 Offset(-58,74)
			GPMC A 1 Offset(-83,128)
			
			TNT1 A 0 A_TakeInventory("TossGrenade",9)
			TNT1 A 0 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
			TNT1 A 1 A_PlayWeaponSound("weapons/powattack5")
			NULL A 0 A_TakeInventory("gren_flashreset", 1)
			NULL A 0 A_TakeInventory("gren_flash0to1", 1)
			NULL A 0 A_TakeInventory("gren_flash1to2", 1)
			NULL A 0 A_TakeInventory("gren_flash2to3", 1)
			NULL A 0 A_TakeInventory("gren_flash3toMAX", 1)
			NULL A 0 A_TakeInventory("gren_flash5max", 1)
			NULL A 0 A_TakeInventory("gren_PowThl1_end", 1)
			NULL A 0 A_TakeInventory("gren_PT1_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl2_end", 1)
			NULL A 0 A_TakeInventory("gren_PT2_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThl3_end", 1)
			NULL A 0 A_TakeInventory("gren_PT3_glow", 1)
			NULL A 0 A_TakeInventory("gren_PowThMax_end", 1)
			NULL A 0 A_TakeInventory("gren_PTMAX_glow", 1)
			
			NULL A 0 A_GiveInventory("gren_PTMAX_glow", 1)
			TNT1 A 0 A_GunFlash
			GTOS A 1 //A_PlayWeaponSound("grenade/toss") 
			GTOM A 1 A_FireCustomMissile("pthrow_wave_spawner",0,0,-5,10,0,0)
			GTOM B 1 A_FireCustomMissile("pow_frag-MAX",0,0,-5,10,0,0)
			TNT1 A 0 A_TakeInventory("grenades", 1/*, TIF_NOTAKEINFINITE*/)
			GTOM CDEFFGHIJKLMNOPQRST 1
			TNT1 A 0 ACS_ExecuteAlways(Player_ChangeSpeed,0,100,0,0)
			
			TNT1 A 0 A_TakeInventory("SuitIsPowered", 9)
			TNT1 A 0 A_TakeInventory("SuitIsOvercharged", 9)
			TNT1 A 0 A_TakeInventory("powthrow_counter",999)
			TNT1 A 0 A_TakeInventory("SuitIsPowered",9)
			TNT1 A 6 
			goto checkweapon_toreturn
		PTMAX_glow:
			GCPM ABCDEFGHIJKLMNOPQRSTU 1 bright
			stop
		PowThMax_end:
			GPM1 A 4 bright
			stop
			
		flashreset:
			TNT1 AA 1
			stop
		
		checkweapon_toreturn:
			TNT1 A 0
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 17, "returnto_sgaussr")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 16, "returnto_conrifle")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 15, "returnto_acannon")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 14, "returnto_nailshot")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 13, "returnto_arifle")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 12, "returnto_autoshot")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 11, "returnto_pistol")
			TNT1 A 0 A_JumpIfInventory("gtoss_weaponmemory", 10, "returnto_fists")
			
			TNT1 A 1 A_SelectWeapon("golampistol")
			goto deselect
		returnto_fists:	
			TNT1 A 1 A_SelectWeapon("regularfists")
			goto deselect
		returnto_pistol:	
			TNT1 A 1 A_SelectWeapon("golampistol")
			goto deselect
		returnto_autoshot:
			TNT1 A 1 A_SelectWeapon("hydrashotgun")
			goto deselect
		returnto_arifle:
			TNT1 A 1 A_SelectWeapon("barracudarifle")
			goto deselect
		returnto_nailshot:
			TNT1 A 1 A_SelectWeapon("raptorshotgun")
			goto deselect
		returnto_acannon:
			TNT1 A 1 A_SelectWeapon("tauruscannon")
			goto deselect
		returnto_conrifle:
			TNT1 A 1 A_SelectWeapon("chimerarifle")
			goto deselect
		returnto_sgaussr:
			TNT1 A 1 A_SelectWeapon("orionSniper")
			goto deselect
		fire:
			TNT1 A 1
			goto ready
		hold:
			TNT1 A 3
			goto ready
	}
}

actor powthrow_counter : inventory{
	inventory.maxamount 102
}

actor pthrow_wave_spawner {
	+NOGRAVITY
	+NOINTERACTION
	states {
		spawn:
			TNT1 A 0
			TNT1 A 0 
		death:
			TNT1 AA 3 A_SpawnItemEx ("pthrow_wave", 30, 0, 0, 0, 0, 0, 0, 0)
			stop
	}
}

actor pthrow_wave {
	//var int user_scale;
	alpha 1.0
	renderstyle add
	+NOINTERACTION
	+NOGRAVITY
	+FORCEXYBILLBOARD
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",1) 
		scaledown:			   
			TNT1 A 0 //A_SetScale((user_scale*0.005)) //Start scale
			TNT1 A 0 //A_JumpIf(user_scale>=40,"LoopEnd") //Maximum Scale
			BSW1 A 1 bright A_FadeOut(0.04)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+4) //Speed
			loop
		loopend:
			BSW1 A 1 Bright A_FadeOut(0.1)
			wait
			
	}
}



//Grenade projectile (The grenade itself)
actor frag_grenade {
    radius 3
	height 3  
	mass 50
	damage 0
	speed 21
	scale 0.11
	gravity 0.7
	RenderStyle normal
	PROJECTILE
	+BLOODLESSIMPACT
	+NOEXPLODEFLOOR
	+FORCEXYBILLBOARD
	+BOUNCEONACTORS
	//+ALLOWBOUNCEONACTORS
	-FLOORHUGGER
	-NOGRAVITY
	-NOBLOCKMAP
	-NOTELEPORT
	
	+THRUSPECIES
	Species "Player"
	
	bouncetype "doom"
	bouncecount 2
	bouncefactor 0.48
	damagetype "frag_explosion"
	/*bouncesound*/ 
	SeeSound "grenade/bounce"
	deathsound ""
	States{
	
		
	
		Spawn:
			FRGR A 2 
		spawnloop:
			FRGR A 0 A_JumpIfInventory("frag_timer", 10, "death")
		  	FRGR ABCDEFGH 1 A_SpawnItemEx("frag_grenadesmoke", 0,0,0, 0,random(-1,1),1)			
			//FRGR A 0 A_ScaleVelocity(0.90)
			FRGR A 0 A_GiveInventory("frag_timer", 1)
			loop
		Death:
			TNT1 A 0 A_PlaySound("grenade/explosion")
			TNT1 A 0 A_AlertMonsters
   			TNT1 A 0 A_Explode(600, 200, 1, 1/*, 100*/)
			TNT1 A 0 A_SpawnItemEx("frag_flash", 0,0,0,0,0,0)
			TNT1 AAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,4),random(6,9),random(1,360))
			TNT1 AAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,4),random(6,9),random(1,360))
			TNT1 A 0 A_SpawnItemEx("frag_boom", 0,0,20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_lboom", 0,0,-20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boomsmkspawner", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boomshockwave", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-20,-60) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(20,60) , random(60,80) ,0,0,0)
			TNT1 A 1
			Stop
   	}

}

actor pow_frag-l1 : frag_grenade {
	damage 20
	speed 36
	gravity 0.34
	bouncefactor 0.58
	bouncecount 5
	-BLOODLESSIMPACT
	//+BOUNCEAUTOOFFFLOORONLY
	States{
		Spawn:
			FRGR AA 1 A_SpawnItemEx("pfragFlare", 0,0,0,0,0,0)
		spawnloop:
			FRGR A 0 A_JumpIfInventory("frag_timer", 10, "death")
		  	FRGR ABCDEFGH 1 A_SpawnItemEx("pfragL1_trail_spawner", 0,0,0, 0,random(-1,1),1)			
			//FRGR A 0 A_ScaleVelocity(0.90)
			FRGR A 0 A_GiveInventory("frag_timer", 1)
			loop
		Death:
			TNT1 A 0 A_PlaySound("grenade/explosion")
			TNT1 A 0 A_AlertMonsters
   			TNT1 A 0 A_Explode(650, 200, 1, 1/*, 100*/)
			TNT1 A 0 A_Explode(150, 300, 0, 1/*, 200*/)
			TNT1 A 0 A_SpawnItemEx("frag_flash-l1", 0,0,0,0,0,0)
			TNT1 AAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,4),random(6,9),random(1,360))
			TNT1 AAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,4),random(6,9),random(1,360))
			TNT1 AAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark2", 0,0,0,0,random(4,5),random(7,10),random(1,360))
			TNT1 A 0 A_SpawnItemEx("frag_boom", 0,0,20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_lboom", 0,0,-20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boomsmkspawner2", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomshock1", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-20,-60) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(20,60) , random(60,80) ,0,0,0)
			TNT1 A 2
			TNT1 A 0 A_SpawnItemEx("frag_boomsmkspawner", 0,0,0,0,0,0)
			TNT1 A 0
			Stop
	}
}

actor pow_frag-l2 : frag_grenade {
	damage (300+random(1,32))
	radius 6
	height 6 
	speed 55
	gravity 0.06
	+BLOODLESSIMPACT
	-NOEXPLODEFLOOR
	-BOUNCEONACTORS
	//-ALLOWBOUNCEONACTORS
	+NOTELEPORT
	bouncetype "none"	
	/*bouncesound*/ SeeSound " "
	deathsound " "	
	
	States{
		Spawn:
			FRGR AA 1 A_SpawnItemEx("pfragFlare_l2", 0,0,0,0,0,0)
		spawnloop:
			FRGR A 0 A_JumpIfInventory("frag_timer", 10, "death")
		  	FRGR ABCDEFGH 1 A_SpawnItemEx("pfragL2_trail_spawner", 0,0,0, 0,0,0)			
			//FRGR A 0 A_ScaleVelocity(0.90)
			FRGR A 0 A_GiveInventory("frag_timer", 1)
			loop
		Death:
			TNT1 A 0 A_ChangeVelocity(0,0,0,CVF_REPLACE)
			TNT1 A 0 A_PlaySound("grenade/explosion")
			TNT1 A 0 A_AlertMonsters
   			TNT1 A 0 A_Explode(750, 225, 1, 1/*, 100*/)
			TNT1 A 0 A_Explode(250, 400, 0, 1/*, 200*/)
			TNT1 A 0 A_SpawnItemEx("frag_flash", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_powflash-l2", 0,0,0,0,0,0)
			
			TNT1 A 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(1,90), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(91,180), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12), random(0,8) , random(181,270), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(271,360), 0)
			TNT1 AA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random (4,6), random(12,16) , random(0,360), 0)
				
			
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,5),random(6,10),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,5),random(6,10),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark2", 0,0,0,0,random(4,6),random(7,11),random(1,360))
			
			TNT1 A 0 A_SpawnItemEx("frag_boom", 0,0,20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_lboom", 0,0,-20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomsmkspawn", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomshock1", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-20,-60) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(20,60) , random(60,80) ,0,0,0)
			TNT1 A 2
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(20,40) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boomsmkspawner2", 0,0,0,0,0,0)
			TNT1 A 4 A_SpawnItemEx("frag_boom4", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			TNT1 A 0
			Stop		
   	}

}
actor pow_frag-l3 : frag_grenade {
	damage (700+random(1,64))
	radius 8
	height 8 
	speed 70
	gravity 0.01
	+BLOODLESSIMPACT
	-NOEXPLODEFLOOR
	-BOUNCEONACTORS
	//-ALLOWBOUNCEONACTORS
	+NOTELEPORT
	bouncetype "none"	
	/*bouncesound*/ SeeSound " "
	deathsound " "	
	
	States{
		Spawn:
			FRGR AA 1 A_SpawnItemEx("pfragFlare_l3", 0,0,0,0,0,0)
		spawnloop:
			FRGR A 0 A_JumpIfInventory("frag_timer", 10, "death")
		  	FRGR ABCDEFGH 1 A_SpawnItemEx("pfragL3_trail_spawner", 0,0,0, 0,0,0, 0,SXF_TRANSFERPITCH)		
			FRGR A 0 A_GiveInventory("frag_timer", 1)
			loop
		Death:
			TNT1 A 0 A_ChangeVelocity(0,0,0,CVF_REPLACE)
			TNT1 A 0 A_PlaySound("grenade/explosion")
			TNT1 A 0 A_AlertMonsters
   			TNT1 A 0 A_Explode(950, 250, 1, 1/*, 125*/)
			TNT1 A 0 A_Explode(450, 450, 0, 1/*, 225*/)
			TNT1 A 0 A_SpawnItemEx("frag_flash-l3", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_powflash-l3", 0,0,0,0,0,0)
			
			TNT1 AA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(1,90), 0)
			TNT1 AA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(91,180), 0)
			TNT1 AA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12), random(0,8) , random(181,270), 0)
			TNT1 AA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(271,360), 0)
			TNT1 AAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random (4,6), random(12,16) , random(0,360), 0)
			
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,6),random(6,11),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,6),random(6,11),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark2", 0,0,0,0,random(4,7),random(7,12),random(1,360))
			
			TNT1 A 0 A_SpawnItemEx("frag_boom", 0,0,20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_lboom", 0,0,-20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomsmkspawn2", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomshock2", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-20,-60) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(20,60) , random(60,80) ,0,0,0)			
			TNT1 A 2
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(20,40) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomsmkspawn", 0,0,0,0,0,0)
			TNT1 A 4 A_SpawnItemEx("frag_boom4", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			TNT1 A 4 A_SpawnItemEx("frag_boom4", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)			
			TNT1 A 0
			Stop		
   	}

}

actor pow_frag-MAX : fastprojectile {
	damage ( (1500+random(1,128)) + (ACS_ExecuteWithResult(get_powf_bonusdamage,0,0,0)/4))
	radius 8
	height 8
	mass 50
	speed 80
	scale 0.75
	gravity 0
	RenderStyle add
	PROJECTILE
	+BLOODLESSIMPACT
	-NOEXPLODEFLOOR
	-BOUNCEONACTORS
	//-ALLOWBOUNCEONACTORS
	+NOTELEPORT
	-NOGRAVITY
	-NOBLOCKMAP
	-FLOORHUGGER
	+FORCEXYBILLBOARD
	
	+THRUSPECIES
	Species "Player"
	
	damagetype "frag_explosion"
	
	MissileType "pfragMAX_trail_spawner"
	MissileHeight 8
	
	States{
		Spawn:
			TNT1 A 0 A_JumpIfInventory("powfrag_timer", 80, "death")
			FLR1 A 1 bright A_SpawnItemEx("powfragMAX_wavetrail", 0,0,0,0,0,0,0)
			TNT1 A 0 A_GiveInventory("powfrag_timer", 1)
			loop
		Death:
			TNT1 A 0 A_ChangeVelocity(0,0,0,CVF_REPLACE)
			TNT1 A 0 A_PlaySound("grenade/explosion")
			TNT1 A 0 A_AlertMonsters
   			TNT1 A 0 A_Explode(1400+(ACS_ExecuteWithResult(get_powf_bonusdamage, 1 ,0,0)/3), 350, 1, 1/*, 125*/)
			TNT1 A 0 A_Explode(800+(ACS_ExecuteWithResult(get_powf_bonusdamage, 1 ,0,0)/4), 550+(ACS_ExecuteWithResult(get_powf_bonusdamage, 1 ,0,0)/10), 0, 1/*, 250*/)
			TNT1 A 0 A_SpawnItemEx("frag_flash-MAX", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_powflash-MAX", 0,0,0,0,0,0)
			
			TNT1 AAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(1,90), 0)
			TNT1 AAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(91,180), 0)
			TNT1 AAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12), random(0,8) , random(181,270), 0)
			TNT1 AAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random(9,12) , random(0,8) , random(271,360), 0)
			TNT1 AAAA 0 A_SpawnItemEx ("frag_boomfireSpark", 0, 0, 0, 0, random (4,6), random(12,16) , random(0,360), 0)
			
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,7),random(6,12),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark", 0,0,0,0,random(3,7),random(6,12),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark2", 0,0,0,0,random(4,8),random(7,13),random(1,360))
			TNT1 AAAAAAAAAAAAA 0 A_SpawnItemEx("frag_boomspark2", 0,0,0,0,random(4,8),random(7,13),random(1,360))
			
			TNT1 A 0 A_SpawnItemEx("frag_boom", 0,0,20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_lboom", 0,0,-20,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomsmkspawn2", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomshock2", 0,0,0,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-20,-60) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(20,60) , random(60,80) ,0,0,0)
			TNT1 A 3
			TNT1 A 0 A_SpawnItemEx("powfrag_boomshock2", 0,0,0,0,0,0)	
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(20,40) ,0,0,0)			
			TNT1 A 4 A_SpawnItemEx("frag_boom4", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfrag_boomsmkspawn", 0,0,0,0,0,0)
			
			
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , 8 ,random(1,80), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , 8 ,random(101,170), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , 8 ,random(191,260), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , 8 ,random(281,350), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , -8 ,random(1,80), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , -8 ,random(101,170), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , -8 ,random(191,260), 0)
			TNT1 A 0 A_SpawnItemEx ("frag_fastboomsmoke", 0, 0, 0, 0, random(20,30) , -8 ,random(281,350), 0)
			
			
			
			
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(-60,-50) , random(60,80) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(50,60) , random(-80,-60) ,0,0,0)
			
			TNT1 A 4 A_SpawnItemEx("frag_lboom", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)
			
			TNT1 A 0 A_SpawnItemEx("frag_boom2", random(-30,30), random(50,60) , random(-80,-60) ,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_boom3", random(-30,30), random(-60,-50) , random(60,80) ,0,0,0)
			
			TNT1 A 4 A_SpawnItemEx("frag_boom4", random(-30,30), random(-40,40) , random(-40,-20) ,0,0,0)	
			

			TNT1 A 0
			Stop		
   	}

}


// Grenade SFX
actor pfragL1_trail_spawner {
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("pfragFlare", 0,0,1,0,0,0)
			TNT1 A 0 A_SpawnItemEx("frag_grenadesmoke", 0,0,0, 0,random(-1,1),1)
			stop
	}
}

actor pfragL2_trail_spawner {
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("pfragFlare_l2", 0,0,1,0,0,0)
			TNT1 A 0 A_SpawnItemEx("powfragl2_smoke", 0,0,0, 0,/*f*/random(-0.3,0.3),0.2)
			stop
	}
}

actor pfragL3_trail_spawner {
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("pfragFlare_l3", 0,0,1,0,0,0)
			TNT1 AA 0 A_SpawnItemEx("powfragl2_smoke", 0,0,0, 0,/*f*/random(-0.8,0.8),0.6)
			TNT1 AAAAAAAA 0 A_SpawnItemEx("powfrag_smoke", 0,0,0, /*f*/random(0.6,1.2),/*f*/random(-0.5,0.5),/*f*/random(-0.5,0.5), 0,SXF_TRANSFERPITCH)
			TNT1 AAAAAAAA 0 A_SpawnItemEx("powfrag_smoke", 0,0,0, /*f*/random(-1.2,-0.6),/*f*/random(-0.5,0.5),/*f*/random(-0.5,0.5), 0,SXF_TRANSFERPITCH)
			stop
	}
}

//(sin(pitch)/cos(pitch))*10

actor pfragMAX_trail_spawner {
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 A_SpawnItemEx("powfragMAX_trail", 0,0,0,0,0,0)
			TNT1 AA 0 A_SpawnItemEx("powfragMAX_smoke", 0,0,0, 0,/*f*/random(-0.8,0.8),/*f*/random(-0.8,0.8))	
			stop
	}
}

actor frag_timer : Inventory {
	Inventory.MaxAmount 10
}

actor powfrag_timer : Inventory {
	Inventory.MaxAmount 80
}

actor frag_grenadesmoke {
	scale 0.09
	renderstyle translucent
	alpha 0.5
	damage 0
	speed 0
	+NOTELEPORT
	+NOCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			SMK4 ABCDEFGHIJ 1 bright 
		endloop:			
			SMK4 J 2 bright A_FadeOut (0.1) 
			TNT1 A 0 A_ScaleVelocity(0.9)
			loop
	}
}

actor powfragl2_smoke : frag_grenadesmoke {
	renderstyle add
	alpha 0.8
}


actor pfragFlare {
	alpha 0.45
	scale 0.25
	renderstyle add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			FLR2 A 1 bright
			stop
	}
}

actor pfragFlare_l2 : pfragFlare{
	alpha 0.65
	scale 0.25
}

actor pfragFlare_l3 : pfragFlare{
	alpha 0.85
	scale 0.25
}


actor powfragMAX_trail {
	scale 0.09
	renderstyle add
	alpha 0.9
	damage 0
	speed 0
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			PGNT A 4 bright
		endloop:
			PGNT A 3 bright A_FadeOut (0.1)
			loop
	}

}

actor powfragMAX_wavetrail {
	//var int user_scale;
	alpha 1.0
	renderstyle add
	+NOINTERACTION
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",1) 
		scaledown:			   
			TNT1 A 0 //A_SetScale((user_scale*0.01)) //Start scale
			TNT1 A 0 //A_JumpIf(user_scale>=20,"LoopEnd") //Maximum Scale
			BSW2 A 1 bright A_FadeOut(0.05)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+2) //Speed
			loop
		loopend:
			BSW2 A 1 Bright A_FadeOut(0.05)
			wait
			
	}
}


//EXPLOSIONS
actor frag_flash {
	scale 2.0
	alpha 1.0
	renderstyle add
	+NOTELEPORT
	+NOCLIP
	+FLOORCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			BFSH A 3 bright
		endloop:
			BFSH A 1 A_FadeOut (0.2)
			loop
	}
}

actor frag_flash-l1 : frag_flash {
	scale 2.2
}

actor frag_flash-l2 : frag_flash {
	scale 2.4
}

actor frag_flash-l3 : frag_flash {
	scale 2.6
}

actor frag_flash-MAX : frag_flash {
	scale 2.9
}


actor frag_powflash-l2 {
	scale 1.2
	alpha 1.0
	renderstyle add
	+NOTELEPORT
	+NOCLIP
	+FLOORCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			BFSH B 4 bright
		endloop:
			BFSH B 1 A_FadeOut (0.1)
			loop
	}
}

actor frag_powflash-l3 : frag_powflash-l2 {
	scale 1.35
}

actor frag_powflash-MAX : frag_powflash-l2 {
	scale 1.55
}


actor frag_boomshockwave {
	//scale 0.27
	//var int user_scale;
	renderstyle add
	+NOTELEPORT
	+NOCLIP
	+FLOORCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",1) 
		scaledown:			   
			TNT1 A 0 //A_SetScale((user_scale*0.03)) //Start scale
			TNT1 A 0 //A_JumpIf(user_scale>=40,"LoopEnd") //Maximum Scale
			BSW0 A 1 bright A_FadeOut(0.1)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+4) //Speed
			loop
		loopend:
			BSW0 A 1 Bright A_FadeOut(0.1)
			wait
	}
}

actor powfrag_boomshock1 : frag_boomshockwave {
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",1) 
		scaledown:			   
			TNT1 A 0 //A_SetScale((user_scale*0.04)) //Start scale
			TNT1 A 0 //A_JumpIf(user_scale>=44,"LoopEnd") //Maximum Scale
			BSW0 A 1 bright A_FadeOut(0.1)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+4) //Speed
			loop
		loopend:
			BSW0 A 1 Bright A_FadeOut(0.1)
			wait
	}
}

actor powfrag_boomshock2 : frag_boomshockwave {
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_scale",1) 
		scaledown:			   
			TNT1 A 0 //A_SetScale((user_scale*0.05)) //Start scale
			TNT1 A 0 //A_JumpIf(user_scale>=48,"LoopEnd") //Maximum Scale
			BSW0 A 1 bright A_FadeOut(0.1)
			TNT1 A 0 //A_SetUserVar("user_scale",user_scale+4) //Speed
			loop
		loopend:
			BSW0 A 1 Bright A_FadeOut(0.1)
			wait
	}
}

actor frag_boom {
	radius 2
	height 2
	scale 1.6
	alpha 0.7
	renderstyle add
	+NOTELEPORT
	+NOCLIP
	+FLOORCLIP
	+NOGRAVITY
	+FORCEXYBILLBOARD
	+NOINTERACTION
	+CLIENTSIDEONLY
	states{
		spawn:
			TNT1 A 0
		    TNT1 A 0 //A_Quake(5, 12, 0, 612, " ")		
			SX03 ABC 1 bright
			SX03 DEFG 1 bright	
			SX03 HIJKLMNOPQRSTWXYZ 1 bright
			stop
	}	
}



actor frag_lboom : frag_boom {
	states{
		spawn:
			SX03 ABCDEFG 1 bright
			SX03 HIJKLMNOPQRSTWXYZ  1 bright
			stop
	}	
}


actor frag_boom2 : frag_boom{
	scale 1.3
	states{
		spawn:
			SX02 ABCDEFGHIJKLMNOPQRSTU 1 bright
			stop
	}
} 

actor frag_boom3 : frag_boom2 {
	scale 1
	states{
		spawn:
			SX04 ABCDEFGHIJKLMNOPQ 1 bright
			stop
	}
}

actor frag_boom4 : frag_boom {
	states{
		spawn:
			TNT1 A 0
			SX06 ABCDEFGHIJKLMNOPQRSTWX 1 bright
			stop
	}	
}

const int user_spwn = 10;
const int user_svel = 4;

actor frag_boomsmkspawner {
	speed 0
	+NOCLIP
	+NOINTERACTION
	+CLIENTSIDEONLY
	//var int user_spwn;
	//var int user_svel;

	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_spwn",10)
			TNT1 A 0 //A_SetUserVar("user_svel",4)
			TNT1 A 3
			goto boom
		boom:
			//
			//X-ring	
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",  user_spwn,  0,0,  user_svel,  0,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", -user_spwn,  0,0, -user_svel,  0,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   0, user_spwn,0,  0,  user_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   0,-user_spwn,0,  0, -user_svel,0,0,32)
		
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   -user_spwn, user_spwn/2,0,   -user_svel, user_svel/2,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", -user_spwn/2,   user_spwn,0, -user_svel/2,   user_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",  user_spwn/2,   user_spwn,0,  user_svel/2,   user_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",    user_spwn, user_spwn/2,0,    user_svel, user_svel/2,0,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",    user_spwn, -user_spwn/2,0,    user_svel, -user_svel/2,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",  user_spwn/2,   -user_spwn,0,  user_svel/2,   -user_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", -user_spwn/2,   -user_spwn,0, -user_svel/2,   -user_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   -user_spwn, -user_spwn/2,0,   -user_svel, -user_svel/2,0,0,32)
			//
			//Z-ring
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   0,0,  0,  0,0, user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   0,0,-user_spwn,  0,0,-user_svel,0,32)
		
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   -user_spwn,0, user_spwn/2,   -user_svel,0, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", -user_spwn/2,0,   user_spwn, -user_svel/2,0,   user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",  user_spwn/2,0,   user_spwn,  user_svel/2,0,   user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",    user_spwn,0, user_spwn/2,    user_svel,0, user_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",    user_spwn,0, -user_spwn/2,    user_svel,0, -user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",  user_spwn/2,0,   -user_spwn,  user_svel/2,0,   -user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", -user_spwn/2,0,   -user_spwn, -user_svel/2,0,   -user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke",   -user_spwn,0, -user_spwn/2,   -user_svel,0, -user_svel/2,0,32)
			//
			//Y
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,   -user_spwn, user_spwn/2, 0,   -user_svel, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0, -user_spwn/2,   user_spwn, 0, -user_svel/2,   user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,  user_spwn/2,   user_spwn, 0,  user_svel/2,   user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,    user_spwn, user_spwn/2, 0,    user_svel, user_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,    user_spwn, -user_spwn/2, 0,    user_svel, -user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,  user_spwn/2,   -user_spwn, 0,  user_svel/2,   -user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0, -user_spwn/2,   -user_spwn, 0, -user_svel/2,   -user_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,   -user_spwn, -user_spwn/2, 0,   -user_svel, -user_svel/2,0,32)
			
			//
			//Inter ring
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0,  user_svel/2, user_svel/2, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0,  user_svel/2, user_svel/2,-user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0,  user_svel/2,-user_svel/2, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0,  user_svel/2,-user_svel/2,-user_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0, -user_svel/2, user_svel/2, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0, -user_svel/2, user_svel/2,-user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0, -user_svel/2,-user_svel/2, user_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke", 0,0,0, -user_svel/2,-user_svel/2,-user_svel/2,0,32)			
			stop
	}
}


actor frag_boomsmkspawner2 : frag_boomsmkspawner {
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_spwn",12)
			TNT1 A 0 //A_SetUserVar("user_svel",6)
			TNT1 A 3
			goto boom
	}
}

const int user_pow_spwn = 12;
const int user_pow_svel = 6;

actor powfrag_boomsmkspawn {
	speed 0
	+NOCLIP
	+NOINTERACTION
	+CLIENTSIDEONLY
	//var int user_spwn;
	//var int user_svel;
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_spwn",12)
			TNT1 A 0 //A_SetUserVar("user_svel",6)
			TNT1 A 3
			goto boom
		boom:
			//
			//X-ring	
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",  user_pow_spwn,  0,0,  user_pow_svel,  0,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", -user_pow_spwn,  0,0, -user_pow_svel,  0,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   0, user_pow_spwn,0,  0,  user_pow_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   0,-user_pow_spwn,0,  0, -user_pow_svel,0,0,32)
		
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   -user_pow_spwn, user_pow_spwn/2,0,   -user_pow_svel, user_pow_svel/2,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", -user_pow_spwn/2,   user_pow_spwn,0, -user_pow_svel/2,   user_pow_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",  user_pow_spwn/2,   user_pow_spwn,0,  user_pow_svel/2,   user_pow_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",    user_pow_spwn, user_pow_spwn/2,0,    user_pow_svel, user_pow_svel/2,0,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",    user_pow_spwn, -user_pow_spwn/2,0,    user_pow_svel, -user_pow_svel/2,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",  user_pow_spwn/2,   -user_pow_spwn,0,  user_pow_svel/2,   -user_pow_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", -user_pow_spwn/2,   -user_pow_spwn,0, -user_pow_svel/2,   -user_pow_svel,0,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   -user_pow_spwn, -user_pow_spwn/2,0,   -user_pow_svel, -user_pow_svel/2,0,0,32)
			//
			//Z-ring
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   0,0,  0,  0,0, user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   0,0,-user_pow_spwn,  0,0,-user_pow_svel,0,32)
		
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   -user_pow_spwn,0, user_pow_spwn/2,   -user_pow_svel,0, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", -user_pow_spwn/2,0,   user_pow_spwn, -user_pow_svel/2,0,   user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",  user_pow_spwn/2,0,   user_pow_spwn,  user_pow_svel/2,0,   user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",    user_pow_spwn,0, user_pow_spwn/2,    user_pow_svel,0, user_pow_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",    user_pow_spwn,0, -user_pow_spwn/2,    user_pow_svel,0, -user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",  user_pow_spwn/2,0,   -user_pow_spwn,  user_pow_svel/2,0,   -user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", -user_pow_spwn/2,0,   -user_pow_spwn, -user_pow_svel/2,0,   -user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2",   -user_pow_spwn,0, -user_pow_spwn/2,   -user_pow_svel,0, -user_pow_svel/2,0,32)
			//
			//Y
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,   -user_pow_spwn, user_pow_spwn/2, 0,   -user_pow_svel, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0, -user_pow_spwn/2,   user_pow_spwn, 0, -user_pow_svel/2,   user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,  user_pow_spwn/2,   user_pow_spwn, 0,  user_pow_svel/2,   user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,    user_pow_spwn, user_pow_spwn/2, 0,    user_pow_svel, user_pow_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,    user_pow_spwn, -user_pow_spwn/2, 0,    user_pow_svel, -user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,  user_pow_spwn/2,   -user_pow_spwn, 0,  user_pow_svel/2,   -user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0, -user_pow_spwn/2,   -user_pow_spwn, 0, -user_pow_svel/2,   -user_pow_svel,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,   -user_pow_spwn, -user_pow_spwn/2, 0,   -user_pow_svel, -user_pow_svel/2,0,32)
			
			//
			//Inter ring
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0,  user_pow_svel/2, user_pow_svel/2, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0,  user_pow_svel/2, user_pow_svel/2,-user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0,  user_pow_svel/2,-user_pow_svel/2, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0,  user_pow_svel/2,-user_pow_svel/2,-user_pow_svel/2,0,32)
			
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0, -user_pow_svel/2, user_pow_svel/2, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0, -user_pow_svel/2, user_pow_svel/2,-user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0, -user_pow_svel/2,-user_pow_svel/2, user_pow_svel/2,0,32)
			TNT1 A 0  A_SpawnItemEx("frag_boomsmoke2", 0,0,0, -user_pow_svel/2,-user_pow_svel/2,-user_pow_svel/2,0,32)			
			stop
	}
}

actor powfrag_boomsmkspawn2 : powfrag_boomsmkspawn {
	states{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_spwn",14)
			TNT1 A 0 //A_SetUserVar("user_svel",8)
			TNT1 A 3
			goto boom
	}
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
actor frag_fastboomsmoke {
	radius 2
	height 2
	speed  0
	damage 0
	gravity 0
	RenderStyle add
	Alpha 1
	Scale 0.4
	Mass 0
	+MISSILE
	+FLOORCLIP
	+DONTSPLASH
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	
	States
	{
		spawn:
			TNT1 A 0
			TNT1 AAAA 2 A_SpawnItemEx("frag_boomsmoke2",0,0,0, 0,0,0,0,0)
		death:
			TNT1 A 0
			stop
	}
}




actor frag_boomspark {
	radius 2
	height 2
	scale 0.04
	gravity 0.4
	renderstyle add
	+NOTELEPORT
	+FLOORCLIP
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	bouncetype "doom"
	bouncefactor 0.2
	states{
		spawn:
			SPRK A 40
		spawnloop:
			SPRK A 1 A_FadeOut(0.1)
			loop
	}
}

actor frag_boomspark2 : frag_boomspark {
	scale 0.07
	gravity 0.38
	states{
		spawn:
			SPRK C 50
		spawnloop:
			SPRK C 1 A_FadeOut(0.1)
			loop
	}
}

///
actor frag_boomfireSpark {
	radius 1
	height 1
	speed  4
	damage 0
	RenderStyle add
	Alpha 1
	Scale 0.4
	Mass 0
	+MISSILE
	+FLOORCLIP
	+DONTSPLASH
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	BounceType "doom"
	gravity 0.8
	BounceFactor 0.2
	//var int user_i;
	States
	{
		spawn:
			TNT1 A 0
			TNT1 A 0 //A_SetUserVar("user_i", 1)
		sploop:
			TNT1 A 0 //A_JumpIf(user_i>=60, "death")
			TNT1 A 1 A_SpawnItemEx ("f_bfireSpark-trail", 0, 0, 2, 0 , 0 , 0 , 0)
			TNT1 A 0 A_SpawnItemEx ("f_bfireSpark-smoke", 0, 0, 0, /*f*/random(-0.6,0.6) , /*f*/random(-0.6,0.6) , /*f*/random(0.6,0.8) , 0)
			TNT1 A 0 //A_SetUserVar("user_i",user_i+1)
			loop
		death:
			TNT1 A 0
			stop
	}
}


actor f_bfireSpark-trail {
	radius 1
	height 1
	alpha 1.0
	+FLOORCLIP
	+NOTELEPORT
	+FORCEXYBILLBOARD
	+CLIENTSIDEONLY
	renderstyle add
	scale 0.65
	gravity 0
	states {
		spawn:
			TNT1 A 0
			TNT1 A 0 A_Jump (255,"trail1","trail2","trail3","trail4","trail5")
		trail1:
			EXP6 AABCDEFGH 2 bright
			stop
		trail2:
			EXP7 AABCDEFGH 2 bright
			stop
		trail3:
			EXP8 AABCDEFGH 2 bright
			stop
		trail4:
			EXP9 AABCDEFGH 2 bright
			stop
		trail5:
			EXP0 AABCDEFGH 2 bright
			stop
	}
}




//Ammo
actor grenades : ammo 26112 {
  radius 16
  height 8
  scale 0.11
  //Slinger TDG-47 Fragmentation Grenade
  inventory.pickupmessage "Single Frag Grenade"
  inventory.pickupsound "grenade/pickup"
  inventory.amount 1
  inventory.maxamount 10
  ammo.backpackamount 1
  ammo.backpackmaxamount 15
  states
  {
  Spawn:
    FRGW ABCDEFGFEDCBA 2
    loop
  }
}

actor grenade_box : grenades 26113 {
	radius 16
	height 8
	scale 0.35
	inventory.pickupmessage "Box of Frag Grenades"
	inventory.pickupsound "grenade/pickup"
	inventory.amount 3
	
	states{
		Spawn:
			FRBX A -1
			stop
	}
}


//
//grenades of the enemies
actor GruntGrenade : frag_grenade {
	-THRUSPECIES
 	speed 19
	gravity 0.8
}

