-- LUA Script - Body by Dvader bodyangle={} bodyangledeg={} function body_init(e) CollisionOff(e) bodyangle[e]=0 bodyangledeg[e]=0 idle=1 walk=0 oldx=g_PlayerPosX oldz=g_PlayerPosZ firstrun=0 maxwalkdist=0 end function body_main(e) if firstrun==0 then CollisionOff(e) GravityOff(e) Scale(e,30) firstrun=1 end PlayerDX = oldx - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = oldz - g_PlayerPosZ; WalkDist = math.ceil(math.sqrt((PlayerDX*PlayerDX)+(PlayerDZ*PlayerDZ))); if maxwalkdist>8 then maxwalkdist=0 end if WalkDist > maxwalkdist then maxwalkdist = WalkDist end Prompt(g_Entity[e]['y']) if WalkDist<3 and WalkDist>0 then if walk==0 or walk>2 then -- Prompt(WalkDist) walk=1 idle=0 end if walk==2 then -- idle=0 end end if WalkDist>3 and walk<4 then idle=0 walk=3 end if WalkDist==0 then if idle==0 then idle=1 maxwalkdist=0 end walk=0 end oldx=g_PlayerPosX oldz=g_PlayerPosZ if walk==1 then SetAnimation(1) LoopAnimation(e) walk=2 camdist=12 end if walk==2 then end if walk==3 then SetAnimation(3) LoopAnimation(e) walk=4 camdist=18 end if idle==1 then SetAnimation(0) LoopAnimation(e) idle=2 camdist=12 end PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ; PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ)); bodyx=g_PlayerPosX bodyz=g_PlayerPosZ bodyx = bodyx+math.sin(g_PlayerAngY/180*3.142)*-camdist bodyz = bodyz+math.cos(g_PlayerAngY/180*3.142)*-camdist bodyy = g_PlayerPosY SetPosition(e,bodyx,math.floor(bodyy-63),bodyz) --bodyangle[e]=math.atan2(PlayerDX,PlayerDZ) bodyangle[e]=math.atan2(bodyx-g_PlayerPosX,bodyz-g_PlayerPosZ) bodyangledeg[e]=(bodyangle[e]*180/3.141) -- + g_PlayerAngY if bodyangledeg[e] <0 then bodyangledeg[e]=360+bodyangledeg[e] end SetRotation(e,0,bodyangledeg[e],0) end