
local function COSTOM1(p)
if p.mo.skin == "sonic" and p.playerstate == PST_LIVE then
if p.cmd.buttons & BT_CUSTOM1 and p.control and p.blocked == false then

if p.rings >= 10 then

if p.mo.wall == true then
P_WallRuning(p)
else
P_SoundBoost(p)
end

end


end
end
end

addHook("PlayerThink", COSTOM1)


rawset(_G, "P_SoundBoost", function(player)
P_InstaThrust(player.mo, player.drawangle, 100*FRACUNIT)
player.speed = 120*FRACUNIT
player.powers[pw_strong] = $|STR_ANIM|STR_PUNCH|STR_WALL
P_SpawnThokMobj(player)
P_RadiusAttack(player.mo, player.mo, 100*FRACUNIT, 0, true)
end)

rawset(_G, "P_WallRuning", function(player)
P_InstaThrust(player.mo, player.drawangle, 30*FRACUNIT)
player.speed = 35*FRACUNIT
player.mo.momz = 15*FRACUNIT*P_MobjFlip(player.mo)
player.mo.state = S_PLAY_RUN
player.mo.eflags = $|MFE_ONGROUND
P_SpawnThokMobj(player)
player.powers[pw_strong] = $|STR_ANIM|STR_UPPER|STR_WALL
P_RadiusAttack(player.mo, player.mo, 100*FRACUNIT, 0, true)
end)

addHook("MobjLineCollide", function(mo, line)
	if mo.skin == "sonic" and mo.player.control and (mo.player.cmd.buttons & BT_CUSTOM1) and mo.player.rings >= 10 then
		if line and not (line.flags & ML_NOCLIMB) then 
		mo.wall = false
		
		if ((line.frontsector and line.frontsector.floorheight > mo.z and line.frontsector.floorpic ~= "F_SKY1") or (line.backsector and line.backsector.floorheight > mo.z and line.backsector.floorpic ~= "F_SKY1")) or ((line.frontsector and line.frontsector.ceilingheight < mo.z and line.frontsector.ceilingpic ~= "F_SKY1") or (line.backsector and line.backsector.ceilingheight < mo.z and line.backsector.ceilingpic ~= "F_SKY1")) then
		mo.wall = true
		end
		
		if not (line.frontsector or line.backsector) then
		mo.wall = true
		end
		
		if line.frontsector then
		for fof in line.frontsector.ffloors()
		
			if fof.valid and mo.z > fof.bottomheight and mo.z < fof.topheight and (fof.flags & FOF_BLOCKPLAYER) then
			mo.wall = true
			end
		
		end
		end
		
		if line.backsector then
		for fof in line.backsector.ffloors()
		
			if fof.valid and mo.z > fof.bottomheight and mo.z < fof.topheight and (fof.flags & FOF_BLOCKPLAYER) then
			mo.wall = true
			end
		
		end
		end
		
		end
	end
end)

addHook("MobjLineCollide", function(mo, line)
	if mo and line then
	mo.line = line
	mo.linecount = 1
	end
end)

addHook("MobjThinker", function(mo)
	if mo.linecoun == nil then
	mo.linecoun = 0
	end
	if mo.linecount then
	mo.linecount = $ - 1
	end
	if mo.linecount <= 0 then
	mo.linecount = 0
	mo.line = nil
	mo.wall = false
	end
end)