--this table is only used to give player the same table it player does not have


local runscript
freeslot("MT_LMTGREHORIZ","MT_LMTGREDIAG","MT_LMTGRESPRG",
		 "MT_LMTYELHORIZ","MT_LMTYELDIAG","MT_LMTYELSPRG",
		 "MT_LMTREDHORIZ","MT_LMTREDDIAG","MT_LMTREDSPRG",
		 "MT_LMTBLUHORIZ","MT_LMTBLUDIAG","MT_LMTBLUSPRG")

addHook("ThinkFrame",do
	if leveltime <2 then runscript = nil end --resetthis every map, like, MAKS SURE IT RESETS
	if leveltime >3 then return end

	runscript = mapheaderinfo[gamemap].altsprings
	for l in lines.iterate do
		if not l
		or l and not l.valid
		or l.special ~= 805 then continue end
		runscript = true		
	end

end)
--give springs their properties asap
addHook("MobjThinker",function(spring) --mobjthinker is fucking me up, last resort here
	--this hook runs before map load so, yeah
	if not runscript
	or leveltime < 3 or leveltime > 3 then return end
	if not (spring.type == MT_LMTGREHORIZ or
			spring.type == MT_LMTGREDIAG or
			spring.type == MT_LMTGRESPRG or
			spring.type == MT_LMTYELHORIZ or
			spring.type == MT_LMTYELDIAG or
			spring.type == MT_LMTYELSPRG or
			spring.type == MT_LMTREDHORIZ or
			spring.type == MT_LMTREDDIAG or
			spring.type == MT_LMTREDSPRG or
			spring.type == MT_LMTBLUHORIZ or
			spring.type == MT_LMTBLUDIAG or
			spring.type == MT_LMTBLUSPRG)
			or spring.isspring then return end
	
	spring.isspring = true
		
	--again, linedefs yaay so you can set these
	--without making a mess in your mapheader lol
	local gh,gv,yh,yv,rh,rv,bh,bv,ss
	
	for l in lines.iterate do
		if not l
		or l and not l.valid
		or not(l.special >= 800
		and l.special <= 804) then continue end
		
		if l.special == 800 then
			gh = l.frontside.textureoffset
			gv = l.frontside.rowoffset
		elseif l.special == 801 then
			yh = l.frontside.textureoffset
			yv = l.frontside.rowoffset
		elseif l.special == 802 then
			rh = l.frontside.textureoffset
			rv = l.frontside.rowoffset
		elseif l.special == 803 then
			bh = l.frontside.textureoffset
			bv = l.frontside.rowoffset
		elseif l.special == 804 then
			ss = l.frontside.textureoffset/10
		end
	end
	spring.scale = ss or spring.scale
	spring.radius = FixedMul(spring.radius,spring.scale)
	spring.height = FixedMul(spring.height,spring.scale)
	spring.flags = $ |MF_NOGRAVITY|MF_SPECIAL|MF_NOCLIPHEIGHT --REALLY???
	spring.momz = 0 --REALLY????????????????????????????????
	spring.health = 9999

	
	if spring.type == MT_LMTGRESPRG or spring.type == MT_LMTGREDIAG then spring.info.mass = (gv or spring.info.mass) spring.color = 2 end
	if spring.type == MT_LMTGREDIAG or spring.type == MT_LMTGREHORIZ then spring.info.damage = (gh or spring.info.damage) spring.color = 2 end

	if spring.type == MT_LMTYELSPRG or spring.type == MT_LMTYELDIAG then spring.info.mass = (yv or spring.info.mass) spring.color = 47 end
	if spring.type == MT_LMTYELDIAG or spring.type == MT_LMTYELHORIZ then spring.info.damage = (yh or spring.info.damage) spring.color = 47 end

	if spring.type == MT_LMTREDSPRG or spring.type == MT_LMTREDDIAG then spring.info.mass = (rv or spring.info.mass) spring.color = 22 end
	if spring.type == MT_LMTREDDIAG or spring.type == MT_LMTREDHORIZ then spring.info.damage = (rh or spring.info.damage) spring.color = 22 end

	if spring.type == MT_LMTBLUSPRG or spring.type == MT_LMTBLUDIAG then spring.info.mass = (bv or spring.info.mass) spring.color = 85 end
	if spring.type == MT_LMTBLUDIAG or spring.type == MT_LMTBLUHORIZ then spring.info.damage = (bh or spring.info.damage) spring.color = 85 end
	

end,MT_NULL)

local altsprnglocalver = 2
if altspringver and altspringver < altsprnglocalver then
	return
end
rawset(_G, "altspringver", altsprnglocalver) --load only once because yes

--this is to rawset the object flags (the ones we see in zone builder) THANK YOU LAT

local mtf_flags = {
	"MTF_EXTRA",
	"MTF_OBJECTFLIP",
	"MTF_SPECIAL",
	"MTF_AMBUSH",
}

for i = 1, #mtf_flags
	rawset(_G, mtf_flags[i], 2^(i-1))
end

//ALL OF THESE THREE FUNCTIONS BELOW PORTED FROM VANILLA 2.2
//backportwhen

local function P_GetSlopeZAt(slope,  x,  y)

	local dist = FixedMul(x - slope.o.x, slope.d.x) +
	               FixedMul(y - slope.o.y, slope.d.y)

	return slope.o.z + FixedMul(dist, slope.zdelta)
end


local function L_GetSectorCeilingZAt (sector,  x,  y)
	if sector.c_slope then
		return P_GetSlopeZAt(sector.c_slope, x, y)
	else
		return sector.ceilingheight
	end 
end

local function L_GetFFloorTopZAt(ffloor,  x,  y)
	if ffloor.t_slope then
		return P_GetSlopeZAt(ffloor.t_slope, x, y)
	else
		return floor.topheight
	end
end

local function L_GetFFloorBottomZAt(ffloor,  x,  y)
	if ffloor.b_slope then
		return P_GetSlopeZAt(ffloor.b_slope, x, y)
	else
		return ffloor.bottomheight
	end
end




local function  L_CeilingzAtPos( x,  y,  z,  height)

	local sec = R_PointInSubsector(x, y).sector
	local ceilingz = L_GetSectorCeilingZAt(sec, x, y)
	local i
	for rover in sec.ffloors() do
		if not rover or rover and not rover.valid then continue end
		local delta1, delta2, thingtop = z + height


		local topheight, bottomheight
		if (not(rover.flags & FF_EXISTS)) then continue end
			

		if ((not(rover.flags & FF_SOLID or rover.flags & FF_QUICKSAND) or (rover.flags & FF_SWIMMABLE))) then continue end

		topheight    = L_GetFFloorTopZAt   (rover, x, y)
		bottomheight = L_GetFFloorBottomZAt(rover, x, y)

		if (rover.flags & FF_QUICKSAND) then

			if (thingtop > bottomheight and topheight > z) then
				if (ceilingz > z) then
					ceilingz = z
				end
			end
			continue
		end

		delta1 = z - (bottomheight + ((topheight - bottomheight)/2))
		delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2))
		if (bottomheight < ceilingz and abs(delta1) > abs(delta2)) then
			ceilingz = bottomheight
		end
	end

	return ceilingz
end


local function K_SpawnSparkleTrailL(mo) --this is exposed to lua but iwanted less sparkles
	local rad = (mo.radius*2)>>FRACBITS
	local sparkle
	local i

	for i = 0, 1 do -- way less sparkles

		local newx = mo.x - mo.momx*2 + (P_RandomRange(-rad, rad)<<FRACBITS)
		local newy = mo.y - mo.momy*2 + (P_RandomRange(-rad, rad)<<FRACBITS)
		local newz = mo.z - mo.momz*2 + (P_RandomRange(0, mo.height>>FRACBITS)<<FRACBITS)

		sparkle = P_SpawnMobj(newx, newy, newz, MT_SPARKLETRAIL)
		sparkle.eflags = (sparkle.eflags & ~MFE_VERTICALFLIP)|(mo.eflags & MFE_VERTICALFLIP)
		sparkle.flags2 = (sparkle.flags2 & ~MF2_OBJECTFLIP)|(mo.flags2 & MF2_OBJECTFLIP)

		if (sparkle.eflags & MFE_VERTICALFLIP) then
			sparkle.z = $ + mo.height - FixedMul(mo.scale, sparkle.height)
		end
		
		sparkle.destscale = mo.destscale
		sparkle.scale = mo.scale
		sparkle.color = mo.color
	end
	sparkle.state =  S_KARTINVULN_LARGE1
end

local function L_DoSpring(spring, object) --ported from source code, overrides common behavior
	--//INT32 pflags
	local hscale = mapobjectscale + (mapobjectscale - object.scale)
	local vscale = mapobjectscale + (object.scale - mapobjectscale)
	local offx, offy
	local vertispeed = FixedMul(spring.info.mass,FRACUNIT*(100+(20*spring.spawnpoint.extrainfo))/100)
	local horizspeed = FixedMul(spring.info.damage,FRACUNIT*(100+(20*spring.spawnpoint.extrainfo))/100)
	--this is to make sure is zero
	--even if it multiplies, even if is a zero value, i dunno man lol
	if spring.info.mass == 0 then
		vertispeed = 0
	end
	if spring.info.damage == 0 then
		horizspeed = 0
	end
	
	if object.eflags & MFE_SPRUNG then return true end // Object was already sprung this tic

	// Spectators don't trigger springs.
	if object.player and object.player.spectator then return true end

	--object.standingslope = NULL // Okay, now we can't return - no launching off at silly angles for you.
	-- lol i cant
	
	object.eflags = $ |MFE_SPRUNG --// apply this flag asap!
	spring.flags = $ & ~(MF_SOLID|MF_SPECIAL) --// De-solidify

	if horizspeed and vertispeed then --// Mimic SA
		object.momx, object.momy = 0, 0
		P_TryMove(object, spring.x, spring.y, true)
	end
	

	if spring.eflags & MFE_VERTICALFLIP then
		vertispeed = $ *-1
	end

	if vertispeed > 0 then
		object.z = spring.z + spring.height + 1
	elseif vertispeed < 0 then
		object.z = spring.z - object.height - 1
	else
		// Horizontal springs teleport you in FRONT of them.
		object.momx, object.momy = 0, 0

		// Overestimate the distance to position you at
		offx = P_ReturnThrustX(spring, spring.angle, (spring.radius + object.radius + 1) * 2)
		offy = P_ReturnThrustY(spring, spring.angle, (spring.radius + object.radius + 1) * 2)

		// Make it square by clipping
		if offx > (spring.radius + object.radius + 1) then
			offx = spring.radius + object.radius + 1
		elseif offx < -(spring.radius + object.radius + 1) then
			offx = -(spring.radius + object.radius + 1)
		end

		if offy > (spring.radius + object.radius + 1) then
			offy = spring.radius + object.radius + 1
		elseif offy < -(spring.radius + object.radius + 1) then
			offy = -(spring.radius + object.radius + 1)
		end

		// Set position!
		P_TryMove(object, spring.x + offx, spring.y + offy, true)
	end
	

	if vertispeed then
		-- if you want diagonals to scale vertical speed with player speed
		--because naturally only horizontal speed scales up
		local FinalSpeed =  FixedDiv(vertispeed, vscale)
		local pSpeed = object.player.speed / 3
		if horizspeed and spring.spawnpoint.options & MTF_SPECIAL then
			if pSpeed > FinalSpeed then
				FinalSpeed = pSpeed
				if vertispeed < 0 then
					FinalSpeed = -pSpeed
				end
			end
		end
		object.momz = FixedMul(FinalSpeed,vscale)-- FixedMul(vertispeed,FixedSqrt(FixedMul(vscale, spring.scale)))
	end

	if horizspeed then
		local finalSpeed = FixedDiv(horizspeed, hscale)
		local pSpeed = object.player.speed

		if pSpeed > finalSpeed then
			finalSpeed = pSpeed
		end
		
		--diagonal spring scales up A LOT horizontaly
		--so you can lock to their common speed
		if vertispeed and spring.spawnpoint.options & MTF_EXTRA then
			finalSpeed = FixedDiv(horizspeed, hscale)
		end

		--P_InstaThrust(object, spring.angle, FixedMul(finalSpeed,hscale))-- FixedMul(finalSpeed,FixedSqrt(FixedMul(hscale, spring.scale))))
		object.momx = FixedMul(FixedMul(finalSpeed,hscale),cos(spring.angle))
		object.momy = FixedMul(FixedMul(finalSpeed,hscale),sin(spring.angle))
	end
	

	// Re-solidify
	--spring.flags = $ | (spring.info.flags & (MF_SPECIAL|MF_SOLID))
	spring.flags = spring.info.flags
	spring.flags = $ |MF_SPECIAL|MF_SOLID|MF_NOGRAVITY|MF_NOCLIPHEIGHT
	spring.state = spring.info.raisestate
	
	if horizspeed and object.player.cmd.forwardmove == 0 and object.player.cmd.sidemove == 0 then
		object.angle = spring.angle
	end
	
	P_ResetPlayer(object.player)
	
	--tries to avoid player stuck into slopes
	--if object.standingslope and not vertispeed then
		--local slope = object.standingslope
	if P_IsObjectOnGround(object) then	 
		if P_MobjFlip(object) < 0 then
			object.z = L_CeilingzAtPos(object.x,object.y, object.z, object.height) - object.height --P_GetZAt(slope,object.x,object.y) - object.height
		else
			object.z = P_FloorzAtPos(object.x,object.y, object.z, object.height)
		end
	end	
	--end
	if vertispeed then
		if P_MobjFlip(object) < 0 then
			object.z = $ - FRACUNIT
		else
			object.z = $ + FRACUNIT
		end
	end
	return true
end


local function springcollision(mt, mt2)
	if not mt.isspring then return end
	if not mt2.player then return true end
	if not runscript then return true end
	mt.health = 9999
	L_DoSpring(mt, mt2)
	local maphscale = mapobjectscale + (mapobjectscale - mt2.scale)
	local mapvscale = mapobjectscale + (mt2.scale - mapobjectscale)
	local hsped = mt.info.damage
	local vsped = mt.info.mass
	local p = mt2.player
	p.LAS = {topspeed = FixedMul(FixedMul(hsped,FRACUNIT*(100+(20*mt.spawnpoint.extrainfo))/100),FixedMul(maphscale, mt.scale)),
			 speed = FixedMul(FixedMul(hsped,FRACUNIT*(100+(20*mt.spawnpoint.extrainfo))/100) ,FixedMul(mapvscale, mt.scale)),
			 angle = mt.angle,
			 color = mt.color,
			 sprung = true,
			 wasground = false,
			 fmomz = 0,
			 hori = hsped,
			 vert = vsped,
			 flags = mt.spawnpoint.options,
			 spring = mt}
	--cancel wall launch and dash ring
	p.dashringtimer = 0 
	p.wall = nil 
	--no pogo spring too
	p.kartstuff[k_pogospring] = 0
	--no dashring effect
	if p.DRT then
		p.DRT.hspd = 0
		p.DRT.vspd = 0
		p.DRT.tspd = 0
		p.DRT.dashed = false
	end
	if mt.spawnpoint.options & MTF_AMBUSH and ((hsped and vsped) or (hsped and not vsped)) then --force angle
		--change player angle 
		mt2.angle = mt.angle
	end
	if vsped then 
		--fake speed for effect
		p.LAS.speed =  FixedMul(FixedMul(vsped,FRACUNIT*(100+(20*mt.spawnpoint.extrainfo))/100),FixedMul(mapvscale, mt.scale))
		--prevent getting stuck on springs
		if not hsped then
			mt2.player.antispringsoftlock = ($ or 0) + FRACUNIT
		else
			mt2.player.antispringsoftlock = ($ or 0) + FRACUNIT/4
		end
	end
	
	if mt.spawnpoint.options & MTF_SPECIAL and vsped and not hsped then --stop player movement
		--vertical only
		mt2.momx,mt2.momy = 0,0
	end
	if mt.spawnpoint.options & MTF_AMBUSH and vsped and not hsped then --change move direction
		--vertical only
		--P_InstaThrust(mt2,mt.angle,mt2.player.speed)
		mt2.momx = FixedMul(mt2.player.speed,cos(mt.angle))
		mt2.momy = FixedMul(mt2.player.speed,sin(mt.angle))
		mt2.angle = mt.angle
	end
	return true
end

addHook("TouchSpecial",springcollision,MT_NULL)


addHook("ThinkFrame",do
	--if leveltime >= 1 and not  then return end
	if not runscript then return end
	for p in players.iterate do
		if not p.LAS then 
			p.LAS =  {topspeed = 0,
					 speed = 0,
					 angle = 0,
					 color = 0,
					 sprung = 0,
					 wasground = 0,
					 fmomz = 0,
					 hori = 0,
					 vert = 0,
					 flags = 0,
					 spring = 0,
					 airtime = 0}
		end
		if p.antispringsoftlock == nil then p.antispringsoftlock = 0 end
		if p.LAS then
			--nullify effect
			if p.spectator 
			or (not p.mo or p.mo and not p.mo.valid)
			or p.kartstuff[k_squishedtimer] ~= 0 
			or (p.kartstuff[k_spinouttimer] ~= 0 and p.mo.momz > 0)
			or p.kartstuff[k_respawn]
			or p.exiting ~= 0 then
				p.LAS.speed = 0
			end
			if p.kartstuff[k_justbumped]
			and p.LAS.speed > 0 then
				--lose a bit when you bump someone
				p.LAS.speed = $ - FRACUNIT/22
			end
			
			if p.mo and p.mo.valid and p.mo.eflags & MFE_JUSTBOUNCEDWALL
			and p.LAS.speed > 0 then
				p.LAS.angle = R_PointToAngle2(0,0,p.mo.momx,p.mo.momy)
				--lose some speed
				p.LAS.speed = $ - FRACUNIT/32
			end
			if (p.kartstuff[k_offroad] 
			or p.kartstuff[k_spinouttimer])
			and p.LAS.speed > 0 then
				--lose significant speed if you try to cut offroad
				p.LAS.speed = $ - FRACUNIT/10
			end
		end
	end

	--not available for now 
	--[[
	--bumping shenanigans
	--when a player bumps another one
	--ot trasnfer the spring effect and pushes
	--the other player based on hte spring effect power
	--not the best thing i nthe world ut it works :D
	for p1 in players.iterate do
		if p1.kartstuff[k_justbumped] ~= 6 then continue end
		if not p1.mo or p1.mo and not p1.mo.valid then continue end
		for p2 in players.iterate do
			--if p2.kartstuff[k_justbumped] ~= 6 then continue end
			if not p2.mo or p2.mo and not p2.mo.valid then continue end
			--players are too distant so ignore
			if FixedHypot(p1.mo.x-p2.mo.x,
			p1.mo.y-p2.mo.y) >= 350*FRACUNIT then continue end
			if #p1 ~= #p2 and 
			FixedHypot(p1.mo.x-p2.mo.x,
			p1.mo.y-p2.mo.y)
			<= (p1.mo.radius*2)+(p2.mo.radius*2)  then
				--print('bomp')
				if p1.LAS.speed >= p2.LAS.speed then
					if p1.LAS.speed == 0 then return end
					P_Thrust(p2.mo,p1.LAS.angle,p1.LAS.speed*16/100)
					/*
					p2.LAS.speed = p1.LAS.speed
					p2.LAS.angle = p1.LAS.angle
					p2.LAS.topspeed = p1.LAS.topspeed
					p2.LAS.flags = p1.LAS.flags
					p2.LAS.color = p1.LAS.color
					p2.LAS.vert = p1.LAS.vert
					p2.LAS.hori = p1.LAS.hori
					p2.LAS.moveang = p1.LAS.moveang
					p2.LAS.spring = p1.LAS.spring
					p1.LAS.speed = $ - ($*40/100)
					*/
				else
					if p2.LAS.speed == 0 then return end
					P_Thrust(p1.mo,p2.LAS.angle,p2.LAS.speed*16/100)
					/*
					p1.LAS.speed = p2.LAS.speed
					p1.LAS.angle = p2.LAS.angle
					p1.LAS.topspeed = p2.LAS.topspeed
					p1.LAS.flags = p2.LAS.flags
					p1.LAS.color = p2.LAS.color
					p1.LAS.vert = p2.LAS.vert
					p1.LAS.hori = p2.LAS.hori
					p1.LAS.moveang = p2.LAS.moveang
					p1.LAS.spring = p2.LAS.spring
					p2.LAS.speed = $ - ($*40/100)
					*/
				end
			end
		end	
	end
	]]--
end)


addHook("MobjThinker",function(mo)
	if not runscript then return end
	if mo.player.LAS == nil
	or leveltime == 1 then 
		mo.player.LAS =  {topspeed = 0,
						 speed = 0,
						 angle = 0,
						 color = 0,
						 sprung = 0,
						 wasground = 0,
						 fmomz = 0,
						 hori = 0,
						 vert = 0,
						 flags = 0,
						 spring = 0,
						 airtime = 0} 
		mo.player.antispringsoftlock = 0
	end 
	local p = mo.player
	local ground = P_IsObjectOnGround(mo)
	p.LAS.moveang = R_PointToAngle2(0,0,mo.momx,mo.momy)
	
	--this got moved here because on collision wont work effectively, also
	--the anti spring lock code
	if p.LAS.sprung == true
	and p.LAS.vert and not p.LAS.hori
	and p.LAS.flags & MTF_SPECIAL then
		--stop horizontal speed if desired
		mo.momx,mo.momy = 0,0
	end
	--if you bounce three times you might be stuck
	--then get you off
	--print(p.antispringsoftlock/FRACUNIT)
	if p.antispringsoftlock > 3*FRACUNIT then
		P_InstaThrust(mo,mo.angle,10*FRACUNIT)
		p.antispringsoftlock = 0
	end

	if p.LAS.sprung == true
	and p.LAS.vert and not p.LAS.hori
	and p.LAS.flags & MTF_EXTRA then
		--align horizontaly with vertical springs
		P_TeleportMove(mo,p.LAS.spring.x,p.LAS.spring.y,mo.z)
		
	end

	
	if ground == true then
		p.antispringsoftlock = 0
		--if you break, make effect last less
		if p.cmd.buttons & BT_BRAKE
		or p.kartstuff[k_offroad]then
			p.LAS.speed = $ - FRACUNIT*52/100
		end
		--cap mvoement then uncap
		if p.LAS.hori and not p.LAS.vert then
			--sparkle trail efffect
			if p.LAS.speed > 0 then
				mo.color = p.LAS.color
				K_SpawnSparkleTrailL(mo)
				mo.color = p.skincolor
			end
			if p.LAS.flags & MTF_SPECIAL then
				--your movement is locked
				if p.LAS.speed > p.LAS.topspeed*50/100 then		
					--P_InstaThrust(mo,p.LAS.angle,p.LAS.speed*250/100)
					p.mo.momx = FixedMul(p.LAS.speed*250/100,cos(p.LAS.angle))
					p.mo.momy = FixedMul(p.LAS.speed*250/100,sin(p.LAS.angle))
					p.LAS.speed = $ - (p.LAS.topspeed/84)
				elseif p.LAS.speed > 0 then
					--is not anymore, but youll have some momentum left
					P_Thrust(mo,p.LAS.moveang,p.LAS.speed*10/100)
					p.LAS.speed = $ - (p.LAS.topspeed/112)	
				end
			end
			-- push springs	
			if p.LAS.flags & MTF_EXTRA and p.LAS.speed > 0 then
				--these are a strong push towards spring direction
				--youcan benefit from it in many ways
				--or get punished
				P_Thrust(mo,p.LAS.angle,p.LAS.speed*12/100)
				p.LAS.speed = $ - (p.LAS.topspeed/52)
			end
		end
		if p.LAS.vert then
			--opsie
			p.LAS.speed = $ - (p.LAS.topspeed/32)	
		end
		p.LAS.wasground = true
		p.LAS.fmomz = 0
	else
		--sparkle trail effect
		if p.LAS.speed > 0 then
			mo.color = p.LAS.color
			K_SpawnSparkleTrailL(mo)
			mo.color = p.skincolor
		end
		
		--stop vertical speed if hit horizontal spring midair
		--if you even want this ofc
		if p.LAS.sprung == true
		and p.LAS.hori and not p.LAS.vert and p.LAS.flags & MTF_EXTRA then
			p.LAS.fmomz = FRACUNIT*9
			mo.momz = 0
			p.LAS.wasground = false
		end
		if p.LAS.sprung == true
		and p.LAS.hori
		and not p.LAS.vert
		and p.LAS.flags & MTF_SPECIAL  then
			--stronger horizontal spring midair
			--P_InstaThrust(mo,p.LAS.angle,p.LAS.speed*2)	
			p.mo.momx = FixedMul(p.LAS.speed*2,cos(p.LAS.angle))
			p.mo.momy = FixedMul(p.LAS.speed*2,sin(p.LAS.angle))
		end
		if p.LAS.speed > 0
		and p.LAS.hori
		and not p.LAS.vert
		and p.LAS.flags & MTF_EXTRA then
			--this gives players decreased gravity
			--if you leave the ground or havent hit at all
			--cover more space midair without needing a powerfll spring to do so
			if p.LAS.wasground == false and P_MobjFlip(mo) > 0 then
				p.LAS.fmomz = $ - FRACUNIT/4
				mo.momz = max($,p.LAS.fmomz)
			end
			if p.LAS.wasground == false and P_MobjFlip(mo) < 0 then
				p.LAS.fmomz = $ + FRACUNIT/4
				mo.momz = min($,p.LAS.fmomz)
			end
			--left the ground
			if p.LAS.wasground == true and P_MobjFlip(mo) > 0 then
				p.LAS.fmomz = $ - FRACUNIT/2
				mo.momz = max($,p.LAS.fmomz)
			end
			if p.LAS.wasground == true and P_MobjFlip(mo) < 0 then
				p.LAS.fmomz = $ + FRACUNIT/2
				mo.momz = min($,p.LAS.fmomz)
			end
		end
		p.LAS.speed = $ - (p.LAS.topspeed/48)
	end
	
	p.LAS.sprung = false		
end,MT_PLAYER)

