-- LUA Script - Body by Dvader local U = require "scriptbank\\utillib" local body = {} local ceil = math.ceil local sqrt = math.sqrt local rad = math.rad function body_init( e ) Include( "utillib.lua" ) CollisionOff( e ) body[ e ] = { state = 'init', camdist = 0, oldx = g_PlayerPosX, oldz = g_PlayerPosZ } end local maxwalkdist = 0 function body_main(e) local b = body[ e ] if b == nil then return end if b.state == 'init' then CollisionOff( e ) GravityOff ( e ) Scale ( e, 50 ) b.state = 'idle' end local Ent = g_Entity[ e ] local PDX = b.oldx - g_PlayerPosX local PDY = Ent.y - g_PlayerPosY local PDZ = b.oldz - g_PlayerPosZ local WalkDist = ceil( sqrt( PDX*PDX + PDZ*PDZ ) ) if WalkDist < 5 and WalkDist > 0 and b.state ~= 'walking' then b.state = 'walk' elseif WalkDist >= 5 and b.state ~= 'running' then b.state = 'run' elseif WalkDist == 0 and b.state ~= 'idle' then b.state = 'idle' SetAnimation( 0 ) LoopAnimation( e ) b.camdist = -12 end b.oldx = g_PlayerPosX b.oldz = g_PlayerPosZ if b.state == 'walk' then SetAnimation( 1 ) LoopAnimation( e ) b.state = 'walking' b.camdist = -12 elseif b.state == 'run' then SetAnimation( 3 ) LoopAnimation( e ) b.state = 'running' b.camdist = -18 end local xo, yo, zo = U.Rotate3D( 0, 0, b.camdist, 0, rad( g_PlayerAngY ), 0 ) local bodyx, bodyz = b.oldx + xo, b.oldz + zo local bodyy = g_PlayerPosY - 63 SetPosition( e, bodyx, bodyy, bodyz ) SetRotation( e, 0, g_PlayerAngY, 0 ) end