// If your here, that means that you wanna learn yourself some LUA
// so lemme give ya the skinny
	if srb2p return end


freeslot("sfx_dsdash", "sfx_dsbeep")

addHook("PlayerThink", function(player)
	if player.mo.skin == "doomguy"
		if player.DashStateTimer == nil
		player.DashStateTimer = 0
			end
		if player.DashAttackTimer == nil
		player.DashAttackTimer = 0
			end
		if player.DashCounter == nil
		player.DashCounter = 2
		if player.DashBeeped == nil
		player.DashBeeped = 0
			end
		end
	end
end)

addHook("PlayerThink", function(player) // basicly what this checks if your floating by using PF_THOKKED and makes you spin
	if(player.mo.skin == "doomguy")
	and player.DashAttackTimer >= 0
	player.DashAttackTimer = $1 - 1
	end
end)

addHook("PlayerThink", function(player) // basicly what this checks if your floating by using PF_THOKKED and makes you spin
	if(player.mo.skin == "doomguy")
	and player.DashStateTimer >= 0
	player.DashStateTimer = $1 - 1
	end
end)

addHook("PlayerThink", function(player) // basicly what this checks if your floating by using PF_THOKKED and makes you spin
	if player.DashBeeped == 0
	and player.mo.skin == "doomguy"
	and player.DashStateTimer <= 0
	player.DashCounter = 2
	S_StartSound(player.mo, sfx_dsbeep) // the noise
	player.DashBeeped = 1
	end
end)

local function hud_dash(v,player)
if not(player.mo and player.mo.valid and player.mo.skin == "doomguy")
	return
	end
	if player.DashCounter == 2 then
		v.drawScaled(0,0,FRACUNIT/2,v.cachePatch("DSHICON1"),V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_PERPLAYER)
	elseif player.DashCounter == 1 then
		v.drawScaled(0,0,FRACUNIT/2,v.cachePatch("DSHICON2"),V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_PERPLAYER)
	elseif player.DashCounter <= 0 then
		v.drawScaled(0,0,FRACUNIT/2,v.cachePatch("DSHICON3"),V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_PERPLAYER)
	end
end

hud.add(hud_dash)

local function DashAttack(player) // the actual dash
	if player.DashCounter >= 1
	and player.mo.skin == "doomguy"
	and not (player.exiting)
	and not (player.pflags & PF_FULLSTASIS)
	and not (player.pflags & PF_STASIS)
	if (P_IsObjectOnGround(player.mo) == true) // are you on the ground
		player.DashAttackTimer = 5
		player.DashStateTimer = 0
		player.DashCounter = $1 - 1
		player.DashBeeped = 0
		player.DashStateTimer = 35
		player.mo.state = S_PLAY_DASH
		P_InstaThrust(player.mo, player.mo.angle, 60*FRACUNIT)
		P_SpawnGhostMobj(player.mo)
		S_StartSound(player.mo, sfx_dsdash)
		player.mo.state = S_PLAY_STND
	else
		player.DashAttackTimer = 5
		player.DashStateTimer = 0
		player.DashCounter = $1 - 1
		player.DashBeeped = 0
		player.DashStateTimer = 35
		player.mo.state = S_PLAY_DASH
		P_InstaThrust(player.mo, player.mo.angle, 45*FRACUNIT)
		P_SetObjectMomZ(player.mo, 0*FRACUNIT)
		P_SpawnGhostMobj(player.mo)
		S_StartSound(player.mo, sfx_dsdash)
		player.mo.state = S_PLAY_FALL
		end
	end
end


local function DashPress(player)
	if player.mo.skin ~= "doomguy" then
		return
	end

	if (player.cmd.buttons & BT_CUSTOM1) then
		if not player.pressedcustom1
			DashAttack(player)
		end

		player.pressedcustom1 = true
	else -- We are not pressing Custom 1 this frame
		player.pressedcustom1 = false -- Set pressedcustom1 to false
	end
end

addHook("PlayerThink", DashPress)

addHook("PlayerThink", function(player) // basicly what this checks if your floating by using PF_THOKKED and makes you spin
	if(player.mo.skin == "doomguy")
	if player.DashAttackTimer >= 1
	player.pflags = $|PF_SPINNING
	P_SpawnGhostMobj(player.mo)
	elseif not (player.pflags & PF_FULLSTASIS)
	and not (player.pflags & PF_STASIS)
	player.pflags = ($1 & !PF_SPINNING)
		end
	end
end)

sfxinfo[sfx_dsdash].caption = "Dash"

sfxinfo[sfx_dsbeep].caption = "Dash Recharged"
