-- LUA Script - precede every function and global member with lowercase name of script + '_main' local U = require "scriptbank\\utillib" local rad = math.rad local sub = string.sub local find = string.find local pad = {} local function GetArgs( str, sep ) local sep = sep or ',' local pos = 1 local list = {} local length = #str while pos < length + 1 do local nextPos = find( str, sep, pos + 1 ) or length if nextPos < length then list[ #list + 1 ] = sub( str, pos, nextPos - 1 ) else list[ #list + 1 ] = sub( str, pos, nextPos ) break end pos = nextPos + 1 end return list end function jump_pad_init_name( e, name ) Include( "utillib.lua" ) pad[ e ] = { state = 'idle', name = name } end local lastTime = 0 local tDiff = 0 local controlEnt = nil local gravity = -0.1 function jump_pad_main(e) if controlEnt == nil then controlEnt = e end local timeNow = g_Time if controlEnt == e then if timeNow > lastTime + 20 then tDiff = ( timeNow - lastTime ) / 20 lastTime = timeNow end end local thisPad = pad[ e ] if thisPad == nil then return end if thisPad.args == nil then thisPad.args = GetArgs( thisPad.name ) thisPad.yc = tonumber( thisPad.args[ 2 ] ) or 10 thisPad.zc = tonumber( thisPad.args[ 3 ] ) or 10 thisPad.tp = tonumber( thisPad.args[ 4 ] ) or 1500 end if U.PlayerCloserThan( e, 80 ) and thisPad.state == 'idle' then thisPad.state = 'active' local xa, ya, za = rad( g_PlayerAngX ), rad( g_PlayerAngY ), rad( g_PlayerAngZ ) thisPad.vx, thisPad.vy, thisPad.vz = U.Rotate3D( 0, thisPad.yc, thisPad.zc, xa, ya, za ) thisPad.timer = timeNow + thisPad.tp SetGamePlayerControlGravityActive( 0 ) end if thisPad.state == 'active' then if timeNow < thisPad.timer then local px, py, pz = g_PlayerPosX, g_PlayerPosY, g_PlayerPosZ local nx, ny, nz = px + thisPad.vx * tDiff, py + thisPad.vy * tDiff, pz + thisPad.vz * tDiff -- check for collision if RayTerrain( px, py, pz, nx, ny, nz ) ~= 0 or IntersectAll( px, py, pz, nx, ny, nz, 0 ) ~= 0 then thisPad.state = 'idle' SetGamePlayerControlGravityActive( 1 ) end SetFreezePosition( nx, ny, nz ) TransportToFreezePositionOnly() -- fake gravity thisPad.vy = thisPad.vy + gravity else thisPad.state = 'idle' SetGamePlayerControlGravityActive( 1 ) end end end