
//Tails Swipe
addHook("PlayerThink", function(player)
	if not (player.spinner)
		player.spinner = 0
	end
	if not (player.vanillatailswipe)
		player.vanillatailswipe = 0
	end
	if (player.mo.skin == "tails")
		if (player.speed > 1000*FRACUNIT)
		or (player.bot == 1)
			player.charability2 = CA2_SPINDASH
		else
			player.charability2 = CA2_SPINDASH
		end
		
		
		if (player.cmd.buttons & BT_CUSTOM2)--set it to which button you want
		and P_IsObjectOnGround(player.mo)
		and (player.speed < 1000*FRACUNIT)
		and not (player.bot == 1)
		and not (player.skidtime > 0) 
		and not (player.pflags & PF_SPINNING)
		and not (player.pflags & PF_STARTDASH)
		or (player.vanillatailswipe == 1)
		and (player.cmd.buttons & BT_CUSTOM2)
			player.vanillatailswipe = 1
		end
		
		
		if not (player.cmd.buttons & BT_CUSTOM2)
		and not (player.pflags & PF_STARTDASH)
		and not (player.pflags & PF_SPINNING)
		or not P_IsObjectOnGround(player.mo)
			player.vanillatailswipe = 0
		end
		
		
		if (player.vanillatailswipe == 1)
			player.mo.state = S_PLAY_RUN
			player.jumpfactor = 0
			player.normalspeed = 36*FRACUNIT
			//player.pflags = $|PF_SPINNING
			player.spinner = ($ % 7) + 1
			if (player.spinner > 7)
				player.spinner = 0
			end
			player.drawangle = player.spinner * ANGLE_45
		end
		
		//Return to normal
		if (player.vanillatailswipe == 0)
			player.jumpfactor = skins[player.mo.skin].jumpfactor
			player.normalspeed = skins[player.mo.skin].normalspeed
		end
	end
end)

local function tvanillaTailSwipe(enemy, mobj)
	local player = mobj.player
	if not (player.mo.skin == "tails")
	and not (player.vanillatailswipe == 1)
		return false
	end                                //This section will make the function damage 
	if (enemy.flags & (MF_ENEMY|MF_BOSS|MF_MONITOR)) 
	and (player.vanillatailswipe == 1)
	--and not (player.powers[pw_super])
	and not (player.powers[pw_invulnerability])
		P_DamageMobj(enemy, mobj, mobj)
		return true
	end
end

addHook("TouchSpecial", tvanillaTailSwipe)

//This makes Tails fly without you spamming the jump button :D Although you can still spam it in game.. welp now you know what you can do.
addHook('JumpSpecial', function(player)
	    if player.mo and player.mo.valid
			if player.mo.skin == "tails"
               if (player.powers[pw_tailsfly] > 0) and (player.cmd.buttons & BT_JUMP)
                player.fly1 = 1
				end
			end
		end
end)

