--Relative Teleport script for the mess that is the tornado.
local function TornadoTeleport(l,mo,s)
	if not mo.tornadotimer
		mo.tornadotimer = 55
	end
end
addHook("LinedefExecute",TornadoTeleport,"TORNTEL")

local finalx = 4464 * FRACUNIT
local finalymin = 5664 * FRACUNIT
local finalz = 6216 * FRACUNIT
local tel1 = 3256 * FRACUNIT
local tel2 = -128*FRACUNIT

addHook("PlayerThink", function(p)
	if p.mo and p.mo.valid
		if p.mo.tornadotimer
			--print(p.mo.tornadotimer)
			local tel3 = p.mo.x + tel1
			local tel4 = p.mo.z + tel2
			p.mo.tornadotimer = $1 - 1
			if p.mo.tornadotimer <= 0 or p.mo.momz < 0
				if tel3 < finalx
					tel3 = finalx
				end
				if tel4 < finalz
					tel4 = finalz
				end
				P_SetOrigin(p.mo,tel3,p.mo.y,tel4)
				p.mo.tornadotimer = nil
			end
		end
	end
	
end)

