/// Ability: Homing Bash
// allow you to home into a enemy while holding a button

// CUSTOMIZE SECTION START
local skin = "jasonfox" // your character here
local thebutton = BT_CUSTOM1 // the button needed to do the homing bash
local sound = sfx_cdfm62 // the sound of the homing bash
local hasthok = true // if this is true, you will spawn a thok mobj while bashing
local hasghost = true // if this is true, you will have a after image while bashing
// CUSTOMIZE SECTION END PROCCED BELOW IF YOU KNOW WHAT YOUR DOING

addHook("PlayerThink", function(player)
	if player.playesound == nil
		player.playesound = false
	end
	if not (player.cmd.buttons & thebutton) 
		player.buttontappready = true
		player.buttontapping = false
	elseif player.buttontappready
		player.buttontapping = true
		player.buttontappready = false
	else
		player.buttontapping = false
	end
	if player.mo and player.mo.skin == skin
	and player.buttontapping
	and not P_IsObjectOnGround(player.mo)
		player.playesound = true
	end
	if player.playesound == true
		player.playesound = false
		S_StartSound(player.mo,sound)
	end
	if player.mo and player.mo.skin == skin
		player.thehoming = P_LookForEnemies(player, true, true)
		if player.thehoming and player.thehoming.valid and player.thehoming.health
			P_SpawnLockOn(player, player.thehoming, S_LOCKON1)
		end
	end
	if player.mo and player.mo.skin == skin
	and (player.cmd.buttons & thebutton)
	and not P_IsObjectOnGround(player.mo)
	and player.thehoming and player.thehoming.valid and player.thehoming.health
		P_HomingAttack(player.mo, player.thehoming)
		if hasthok == true
			local thokeffect = P_SpawnThokMobj(player) 
		end
		if hasghost == true
			local ghosteffect = P_SpawnGhostMobj(player.mo) 
			ghosteffect.colorized = true
			ghosteffect.color = player.mo.color
			ghosteffect.fuse = 15
			ghosteffect.blendmode = AST_ADD 
		end
	end
end)
	