print("pvp_cube init") require "lua/entity.lua" require "lua/utilities.lua" myTime = 0 setColorSmooth(1,1,1,0.17,0.1,0.24,0.25) setAlpha(0.78) speed = ft2m(5) eyeFacing = 8 excited = 1 healTimer = myTime + 2 if IsHosting() then randomNumber = math.random(0,30) else randomNumber = 1 end distanceSlide = 0 currentWaypointDestination = 1 firstMove = true waypoints = { object("Cube_waypoint_00"), object("Cube_waypoint_01"), object("Cube_waypoint_02"), object("Cube_waypoint_03"), object("Cube_waypoint_04"), object("Cube_waypoint_05") } function moving() --if distanceSlide == 0 then myPosition = {position()} currentWaypointDestinationPosition = { waypoints[currentWaypointDestination+1].position() } --currentWaypointDestinationPosition = waypointsPositions[currentWaypointDestination+1] if firstMove == true then --print("firstMove") print ( unpack(myPosition) ) print ( unpack(currentWaypointDestinationPosition) ) distanceSlide = math.distance ( myPosition , currentWaypointDestinationPosition ) mathScratch = distanceSlide / speed local dpx = currentWaypointDestinationPosition[1] local dpy = currentWaypointDestinationPosition[2] local dpz = currentWaypointDestinationPosition[3] translateSmooth( dpx, dpy, dpz, mathScratch , 0 , 0 ) --translateSmooth( unpack(currentWaypointDestinationPosition) , mathScratch , 0 , 0 ) --translateSmooth( unpack(currentWaypointDestinationPosition) , mathScratch , 0 , 0 ) --translateSmooth( -4.826 , -0.688 , -2.25 , mathScratch , 0 , 0 ) firstMove = false if IsHosting() then else currentWaypointDestination = RecvSyncCube() end print(distanceSlide) print(mathScratch) end local theDistance = math.distance( myPosition, currentWaypointDestinationPosition ) --print("theDistance " .. theDistance) if randomNumber < 0 then elseif randomNumber >30 then elseif math.distance( myPosition, currentWaypointDestinationPosition ) <= ft2m(1) then --print("snap to destination") myPosition = { position( unpack(currentWaypointDestinationPosition) ) } if currentWaypointDestination == 0 then --print("old destination was 0") if randomNumber <= 15 then currentWaypointDestination = 1 mathScratch = 0 else currentWaypointDestination = 5 mathScratch = 90 end elseif currentWaypointDestination == 1 then --print("old destination was 1") if randomNumber <= 15 then currentWaypointDestination = 0 mathScratch = 0 else currentWaypointDestination = 2 mathScratch = 90 end elseif currentWaypointDestination == 2 then --print("old destination was 2") if randomNumber <= 10 then currentWaypointDestination = 1 mathScratch = 90 elseif randomNumber <= 20 then currentWaypointDestination = 3 mathScratch = 90 else currentWaypointDestination = 5 mathScratch = 0 end elseif currentWaypointDestination == 3 then --print("old destination was 3") if randomNumber <= 15 then currentWaypointDestination = 2 mathScratch = 0 else currentWaypointDestination = 4 mathScratch = 0 end elseif currentWaypointDestination == 4 then --print("old destination was 4") if randomNumber <= 15 then currentWaypointDestination = 3 mathScratch = 0 else currentWaypointDestination = 5 mathScratch = 90 end elseif currentWaypointDestination == 5 then --print("old destination was 5") if randomNumber <= 10 then currentWaypointDestination = 0 mathScratch = 0 elseif randomNumber <= 20 then currentWaypointDestination = 2 mathScratch = 90 else currentWaypointDestination = 4 mathScratch = 90 end end if IsHosting() then randomNumber = math.random(0,30) SyncCube(currentWaypointDestination) else currentWaypointDestination = RecvSyncCube() end --print("new destination is " .. currentWaypointDestination) currentWaypointDestinationPosition = { waypoints[currentWaypointDestination+1].position() } --print( unpack(myPosition) ) --print( unpack(currentWaypointDestinationPosition) ) --print( speed ) distanceSlide = math.distance ( myPosition , currentWaypointDestinationPosition ) mathScratch = distanceSlide / speed local dpx = currentWaypointDestinationPosition[1] local dpy = currentWaypointDestinationPosition[2] local dpz = currentWaypointDestinationPosition[3] translateSmooth( dpx, dpy, dpz, mathScratch , 0 , 0 ) --print(distanceSlide) --print(mathScratch) end speed = ft2m(30) --end end currentBehavior = moving while tick() do myTime = myTime + dt currentBehavior() end