local function dashmodering(p)
	if p.mo.skin == "rangersonic" --put your skin in these p.mo.skin boxes
	and p.dashmode > 3*TICRATE
	and p.canspawnthering == true
		local dashmodering = P_SpawnMobjFromMobj(p.mo, 0, 0, 0, MT_DASHMODEBOOSTRING)
		dashmodering.color = p.mo.color
		dashmodering.angle = p.cmd.angleturn << 16 + R_PointToAngle2(0, 0, p.cmd.forwardmove*FRACUNIT, -p.cmd.sidemove*FRACUNIT) + ANGLE_90
		dashmodering.scale = p.mo.scale
		dashmodering.destscale = p.mo.scale
		dashmodering.tics = 3
		p.canspawnthering = false
	end
end

addHook("PlayerThink", dashmodering)

local function givememyringbackplease(p)
	if p.mo.skin == "rangersonic"
	and p.dashmode < 3*TICRATE
		p.canspawnthering = true
	end
end

addHook("PlayerThink", givememyringbackplease)

local function dashmodeghost(p)
	if p.mo.skin == "rangersonic"
	and p.dashmode > 3*TICRATE
		local ghost = P_SpawnGhostMobj(p.mo)
		ghost.colorized = true
		ghost.fuse = 5
		ghost.color = p.mo.color
		ghost.blendmode = AST_ADD
	end
end

addHook("PlayerThink", dashmodeghost)

local function extrathokghost(p)
	if p.mo.skin == "rangersonicic"
	and(p.pflags & PF_THOKKED)
		local thokghost = P_SpawnGhostMobj(p.mo)
		thokghost.colorized = true
		thokghost.fuse = 5
		thokghost.color = p.mo.color
		thokghost.blendmode = AST_ADD
	end
end

addHook("PlayerThink", extrathokghost)

local function thokboosteffectidk(p)
	if p.mo.skin == "rangersonic"
	and not (p.pflags & PF_THOKKED)
		local dashmodering = P_SpawnMobjFromMobj(p.mo, 0, 0, 0, MT_DASHMODEBOOSTRING)
		dashmodering.color = p.mo.color
		dashmodering.angle = p.cmd.angleturn << 16 + R_PointToAngle2(0, 0, p.cmd.forwardmove*FRACUNIT, -p.cmd.sidemove*FRACUNIT) + ANGLE_90
		dashmodering.scale = p.mo.scale
		dashmodering.destscale = p.mo.scale
		dashmodering.tics = 3
	end
end

addHook("AbilitySpecial", thokboosteffectidk)