-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Script Written by GubbyBlips -- DESCRIPTION: Ladder/Climbing Script -- DESCRIPTION: This script is to be attached to the ladder object? -- DESCRIPTION: Set ladder objects defaultstatic=0, collisionmode=1 in the fpe and turn off gravity and physics in GGMAX local P = require "scriptbank\\physlib" local U = require "scriptbank\\utillib" local Q = require "scriptbank\\quatlib" local ladderactive = {} local moveup = {} local playeratx = {} local playeratz = {} local ladderheight = {} local tryseveral = 0 --local ladnecw, ladnech, ladnecl, ladnecm, ladneccx, ladneccy, ladneccz, ladneccxs, ladneccys, ladnecczs = {} local ladnecw = {} local ladnech = {} local ladnecl = {} local ladnecm = {} local ladneccx = {} local ladneccy = {} local ladneccz = {} local ladneccxs = {} local ladneccys = {} local ladnecczs = {} function ladder_nec_init(e) ladderactive[e] = 0 moveup[e] = 0 ladderheight[e] = 0 end -- init function ladder_nec_main(e) if tryseveral == nil then tryseveral = 0 end if tryseveral < 7 then local xmin, ymin, zmin, xmax, ymax, zmax = GetObjectColBox( g_Entity[e]['obj'] ) local sx, sy, sz = GetObjectScales( g_Entity[e]['obj'] ) ladnecw[e], ladnech[e], ladnecl[e] = (xmax - xmin) * sx, (ymax - ymin) * sy, (zmax - zmin) * sz --ladnecw[e], ladnech[e], ladnecl[e], ladnecm[e], ladneccx[e], ladneccy[e], ladneccz[e], --ladneccxs[e], ladneccys[e], ladnecczs[e] = P.GetObjectDimensions ( g_Entity[e]['obj'] ) tryseveral = tryseveral + 1 end -- assignments playeratx[e] = 0 playeratz[e] = 0 if math.abs(g_PlayerPosX - g_Entity[e]['x']) < 50 then Prompt("Press 'W' to climb up 'S' to climb down") end if math.abs(g_PlayerPosX - g_Entity[e]['x']) < 30 then playeratx[e] = 1 if math.abs(g_PlayerPosZ - g_Entity[e]['z']) < 30 then playeratz[e] = 1 if ladderactive[e] == 0 then --Set ladder height-------------------------------------- ladderheight[e] = ladnech[e] + 30 -- Ladder height + player --End Set ladder height---------------------------------- moveup[e] = g_PlayerPosY ladderactive[e] = 1 end end end if playeratx[e] + playeratz[e] < 2 then ladderactive[e] = 0 end if ladderactive[e] == 1 then --------- on ladder so activate climb Prompt("Press 'A,X,D' to exit ladder") if g_Scancode == 17 then if moveup[e] < g_Entity[e]['y'] + ladderheight[e] then moveup[e] = moveup[e] + 2 end -- 'W' up end if g_Scancode == 31 then if moveup[e] > g_Entity[e]['y'] + 35 then moveup[e] = moveup[e] - 2 end -- 'S' down end if g_Scancode == 45 then ForcePlayer( g_PlayerAngY + 180, 2) end -- 'X' to exit ladder if g_Scancode == 30 then ForcePlayer( g_PlayerAngY - 90, 2) end -- 'A' left if g_Scancode == 32 then ForcePlayer( g_PlayerAngY + 90, 2) end -- 'D' right SetFreezePosition(g_PlayerPosX, moveup[e], g_PlayerPosZ) TransportToFreezePositionOnly() end --------- on ladder so activate climb end -- main