//Bomb Throw Ability - By Simon_T
//This is free to be used in other people's mods
//But it would be great if you credit me as the original creator ;)

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin == "s3knuckles" //If you're Fang
			if not player.exiting //If you're leaving a level, you won't need them, right?
				if not (P_PlayerInPain(player) or (player.playerstate == PST_DEAD)) //Hurt/dead weasels can't throw bombs
					if ((player.cmd.buttons & BT_CUSTOM2) and not (player.weapondelay)) //If you press Toss Flag...
						S_StartSound(player.mo, sfx_s3k51) //...Play the bomb throwing sound...
						local bomb = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + player.mo.height, MT_FBOMB) //...And spawn the bomb itself
						bomb.target = player.mo //The bomb can't hurt its user
						if (player.mo.momz > 0) //If you're jumping/springing/bouncing...
							bomb.momz = (player.mo.momz)+(10*FRACUNIT) //...The bomb gets some height boost
						else //But if you're falling...
							bomb.momz = 10*FRACUNIT //...The bomb just flies at this fixed height
						end
						P_InstaThrust(bomb, player.mo.angle, ((player.speed)+(10*FRACUNIT))) //The bomb describes an arc while flying, affected by your current speed
						if (player.powers[pw_super]) //If you're Super Fang...
							player.weapondelay = TICRATE*1 //...You can throw bombs 3X faster
						else //But if that's not the case...
							player.weapondelay = TICRATE*3 //...You have to wait three seconds between bombs
						end
					end
				end
			end
		end
	end
end)