-- Boombox Buddy --

-- ABOUT: FL Chan's bot ability.

if srb2p return end

addHook("BotTiccmd", function(bot, cmd)
	local player = players[0]
	local mo = players[0].mo
	
	if player.exiting then
		return
	end
	
	if bot.mo and bot.mo.skin == "flchan" and players[0].mo
	
		if bot.mo.kbind
			if P_AproxDistance(bot.mo.z-mo.z,P_AproxDistance(bot.mo.x-mo.x,bot.mo.y-mo.y)) <= bot.mo.radius*2
			and player.speed == 0 and P_IsObjectOnGround(bot.mo)
			and not bot.mo.boomboxbuddy
				bot.mo.kbind.flags2 = $ & ~MF2_DONTDRAW 
				bot.jumpfactor = FRACUNIT
			else
				bot.mo.kbind.flags2 = $|MF2_DONTDRAW
				bot.jumpfactor = skins[bot.mo.skin].jumpfactor
			end
		else
			local bbind = P_SpawnMobj(bot.mo.x, bot.mo.y, bot.mo.z, MT_OVERLAY)
			bbind.target = bot.mo
			bbind.state = S_KABOOMBOX_INDICATOR
			bbind.flags2 = $|MF2_DONTDRAW
			bot.mo.kbind = bbind
		end
		
		if player.cmd.buttons & BT_CUSTOM1
		and P_IsObjectOnGround(bot.mo)
		and P_AproxDistance(bot.mo.z-mo.z,P_AproxDistance(bot.mo.x-mo.x,bot.mo.y-mo.y)) <= bot.mo.radius*2
			cmd.buttons = $ | BT_CUSTOM1
		end
	end
end)