Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script_runner = {
- nRcombo = 0, -- selected destination number (combo box)
- runit = false,
- distDestination = 0,
- useNaveMesh = false,
- enemyObj = nil,-- from script grind
- lastnavIndex = 0,
- nextNodeDistance = 5,
- tx = 0,
- ty = 0,
- tz = 0,
- dx = 0,
- dy = 0,
- dz = 0,
- _x = 0,
- _y = 0,
- _z = 0,
- destination = {},
- destinationName = {},
- destNum = 1,
- isSetup = false,
- tic = 150,
- timer = 0,
- destinationChanged = false,
- genTimer = 0,
- movingToSafespot = false,
- waitTimer = 0,
- generating = false
- }
- function script_runner:setup()
- -- Add Destinations
- script_runner:addDestination("shimmering flats near finish line", -6170.06, -4014.37, -58.75, 1, 400);
- script_runner:addDestination("shimmering flats half way", -5980.17, -4015.87, -58.75, 1, 400);
- script_runner:addDestination("desolace innkeeper ally", 247.23300170898, 1255.0699462891, 192.16200256348, 1, 405);
- script_runner:addDestination("desolace outside niehls point", -58.16849899292, 1217.5465087891, 91.539474487305, 1, 405);
- script_runner:addDestination("wetlands center gob vendor", -3198.2846679688, -2471.3728027344, 10.032402992249, 0, 11);
- script_runner:addDestination("westfal near gy", -10476.274414063, 1190.9742431641, 56.2785987854, 0, 40);
- self.isSetup = true;
- end
- function script_runner:addDestination(name, x, y, z, continentID, mapID)
- -- Extra table for the combo box
- self.destinationName[self.destNum] = name;
- self.destination[self.destNum] = {};
- self.destination[self.destNum]['name'] = name;
- self.destination[self.destNum]['x'] = x;
- self.destination[self.destNum]['y'] = y;
- self.destination[self.destNum]['z'] = z;
- self.destination[self.destNum]['continentID'] = continentID;
- self.destination[self.destNum]['mapID'] = mapID;
- self.destNum = self.destNum + 1;
- end
- local function rP(text, r, g, b)
- r = r or .91
- g = g or .91
- b = b or .91
- local header = "|cFFFC0000[|r|cFFFF7F00oGasai - Runner|r|cFFFC0000]|r "
- DEFAULT_CHAT_FRAME:AddMessage(header .. text, r, g, b)
- end
- local function GetDistance2D(_1x, _1y, _2x, _2y)
- return math.sqrt((_1x - _2x)^2 + (_1y - _2y)^2)
- end
- --short handle for toconsole
- function tc1(text)
- ToConsole(text)
- end
- --short handle for rare toconsole
- function tc2(text)
- ToConsole(text)
- end
- -- for short term debugging "toConsoleTest"
- function tct(text)
- ToConsole(text)
- end
- -- tc for obj table in CheckNextNodeToMobsDistance
- function tcOT1(text)
- --ToConsole(text)
- end
- function script_runner:setWaitTimer(ms)
- self.waitTimer = GetTimeEX() + ms;
- end
- function script_runner:drawAvoidMobTriangle() -- not used atm
- -- need to draw 3 lines my xyz mob xzy safespot xyz
- local x1, y1, onScreen1 = WorldToScreen(triangleDrawdangerMob_x,triangleDrawdangerMob_y,triangleDrawdangerMob_z)
- local x2, y2, onScreen2 = WorldToScreen(triangleDrawMy_x,triangleDrawMy_y,triangleDrawMy_z)
- local x3, y3, onScreen3 = WorldToScreen(triangleDrawSafespot1_x,triangleDrawintersection1_y,triangleDrawSafespot1_z)
- -- if start and end of the line are onscrenn
- if onScreen1 == true and onScreen2 == true then
- DrawLine(x1, y1, x2, y2, 250, 0, 0, 5);
- DrawLine(x2, y2, x3, y3, 250, 0, 0, 5);
- DrawLine(x3, y3, x1, y1, 250, 0, 0, 5);
- end
- end
- function script_runner:DrawMonsterAggroCircles()
- for i,v in pairs(objectTable) do
- -- DRAW CIRCLES AROUND MOBS (AGGRO RANGE)
- if
- -- i:IsDead() == false and
- v.type == 3
- and i:CanAttack() == true
- and i:IsCritter() == false
- then
- script_runner:DrawCircles(v.x,v.y,v.z,v.r, 255, 255, 0, 1, 15)
- end
- end
- end
- function script_runner:DrawCircles(pointX,pointY,pointZ,radius, redVar, greenVar, blueVar, lineThickness, quality)
- local r = 255;
- local g = 2;
- local b = 233;
- -- position
- local x = 25;
- -- info
- if debugText == nil then debugText = "" end;
- -- we will go by radians, not degrees
- local sqrt, sin, cos, PI, theta, points, point = math.sqrt, math.sin, math.cos,math.pi, 0, {}, 0;
- while theta <= 2*PI do
- point = point + 1 -- get next table slot, starts at 0
- points[point] = { x = pointX + radius*cos(theta), y = pointY + radius*sin(theta) }
- theta = theta + 2*PI / quality -- get next theta
- end
- for i = 1, point do
- local firstPoint = i
- local secondPoint = i + 1
- if firstPoint == point then
- secondPoint = 1
- end
- if points[firstPoint] and points[secondPoint] then
- local x1, y1, onScreen1 = WorldToScreen(points[firstPoint].x, points[firstPoint].y, pointZ)
- local x2, y2, onScreen2 = WorldToScreen(points[secondPoint].x, points[secondPoint].y, pointZ)
- -- make boolean string so i can post it to console
- onScreen1String = tostring(onScreen1);
- --ToConsole('x1 inside draw cirlces: ' .. x1 .. 'onScreen1: ' .. onScreen1String .. y1 .. x2 .. y2 .. redVar .. greenVar .. blueVar .. lineThickness);
- if onScreen1 == true and onScreen2 == true then
- DrawLine(x1, y1, x2, y2, redVar, greenVar, blueVar, lineThickness)
- end
- end
- end
- end
- function script_runner:FunkyStuffWithMobtable()
- -- post player distance to mobs in console
- local localObj = GetLocalPlayer();
- local my_x, my_y, my_z = localObj:GetPosition();
- for i,v in pairs(objectTable) do
- if
- --i:IsDead() == false and <- needs debuging
- v.type == 3
- and i:CanAttack() == true
- and i:IsCritter() == false
- then
- -- put my distance to the sourrounding mobs into the console
- MydistToMobs = GetDistance3D(my_x, my_y, my_z, v.x, v.y, v.z);
- ToConsole('my distance to mobs is: ' .. MydistToMobs );
- end
- end
- -- make the console less ugly
- ToConsole('==================');
- end
- function script_runner:triAngleCentroid(x1,y1,x2,y2,x3,y3)
- -- returns x and y of the centroid
- --https://brilliant.org/wiki/triangles-centroid/
- triAngleCentroid_x = (x1+x2+x3)/3
- triAngleCentroid_y = (y1+y2+y3)/3
- return triAngleCentroid_x, triAngleCentroid_y
- end
- function script_runner:CheckNextNodeToMobsDistance()
- -- checks if the next node (1+), next after(2+) etc of the navmeshpath is in aggro range of a mob, if so start FindNewStartLogic
- local NextNavIndex = 1 + self.lastnavIndex;
- --ToConsole( 'Zerger-> nextnavindex :' .. NextNavIndex)
- -- NNI is next nav index
- local NNI_x, NNI_y, NNI_z = GetPathPositionAtIndex(5, NextNavIndex);
- for i,v in pairs(objectTable) do
- if
- --i:IsDead() == false and <- needs debuging
- v.type == 3
- and i:CanAttack() == true
- and i:IsCritter() == false
- then
- -- put next nav index distance to the sourrounding mobs into the console
- NextNavIndexToMobsDistance = GetDistance3D(NNI_x, NNI_y, NNI_z, v.x, v.y, v.z);
- tcOT1('Next Node [' .. NextNavIndex .. '] distance to ' .. v.name .. ' is: ' .. NextNavIndexToMobsDistance );
- dangerMob_x = v.x;
- dangerMob_y = v.y;
- dangerMob_z = v.z;
- dangerMob_r = v.r;
- --
- if
- NextNavIndexToMobsDistance < v.r + 1 --!!!!! important var
- then
- ToConsole(':::::: Danger! index ' .. NextNavIndex .. ' is too close to a mob ::::::')
- script_runner:FindNewStartLogic();
- end
- end
- end
- -- make the console less ugly
- ToConsole('==================');
- end
- function script_runner:FindNewStartLogic()
- --[[ we noticed our next nav spot is too close to a mob so we need to find a new safer spot
- -stop
- -calc distance to the dangerous mob -> use as 1 leg of the trapezoid
- -calc xy of safespot with calcIntersections which will return 2 xy, one left and one right of the mob
- -go to safespots (wp1, wp2)
- -contiune normal script
- todo:
- check dist to mobs, los, ray cast, gen nav path test
- --]]
- local localObj = GetLocalPlayer();
- local my_x, my_y, my_z = localObj:GetPosition();
- local safedistanceVar = 5 -- IMPORTANT!! the distance from the aggo cirlce which is considered safe
- local mob_radius = dangerMob_r + safedistanceVar -- mobradius is NOT mob aggro range, (1 yard outside aggrorange should be safe)
- self.movingToSafespot = false -- it is the distane mob <---> safespot
- if (IsMoving()) then
- StopMoving(); -- stop pathing along normal navpath
- end
- local triangleSideA = math.floor(math.sqrt((my_x-dangerMob_x)*(my_x-dangerMob_x)+(my_y-dangerMob_y)*(my_y-dangerMob_y)));
- local hypothenuse = math.floor(math.sqrt((triangleSideA)^2+mob_radius^2));
- -- this will find me two spots in an right angle from the mob (left and right side)
- --- to do rewrite claclbla so it returns into var like raycast-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ works, make use . self bla
- script_runner:calcIntersections(my_x,my_y,hypothenuse, dangerMob_x, dangerMob_y,mob_radius );
- -- point1 and point2 XY (they are the 'x' in the drawing which are right and left of the mob)
- -- todo is intersection1 always right side?
- local rightPoint_x = intersection1_x
- local rightPoint_y = intersection1_y
- local leftPoint_x = intersection2_x
- local leftPoint_y = intersection2_y
- -- now we use each of these spots
- --safedistance from mob is aggrorange + safedistanceVar
- --[[
- R = aggrorange (the real one ;) )
- \Waypoint 3
- \
- \
- \
- \
- \
- \ Waypoint 2
- | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- | !!!!!!!! MOB <-> X is (aggrorange + safedistanceVar) not R * something!!!!!!!!!!!!!!!!
- |
- | (Waypoint 1 to Waypoint 2 is 1.5*R)
- MOB ------------X "X" is our former triangle safespot and halfway between Waypoint 1 and 2
- | so Waypoint 1 <---> "X" is 1.5*R/2 or 0.75*R and we can calc MOB <---> WP
- | MOB <---> WP1 = sqrRoot((R+safedistanceVar)^2+(0.75*R)^2) = MOB <---> WP2
- | Put these values in our 'calcIntersections' and we get XY of WP1 and WP2
- |
- / Waypoint 1
- /
- /
- /
- /
- /
- /
- /
- Player /
- X _______ Waypoint X <---> Waypoint is 0.75*R
- | / X <---> MOB is R+safedistanceVar
- | / hypothenuse^2 = (R+safedistanceVar)^2 + (0.75*R)^2
- sideA | / hypothenuse
- | /
- | /
- | /
- |/
- MOB
- --]]
- local hypothenuse = math.floor(math.sqrt((dangerMob_r + safedistanceVar)*(dangerMob_r + safedistanceVar)+(0.75*dangerMob_r)*(0.75*dangerMob_r)))
- -- this will find me two spots in an right angle from right side X (WP 1,2)
- script_runner:calcIntersections(dangerMob_x,dangerMob_y,hypothenuse, rightPoint_x, rightPoint_y, 0.75*dangerMob_r );
- -- todo what if its a cave?
- local isVis, _hx, _hy, _hz = Raycast(rightPathWP1_x, rightPathWP1_y, -10000, rightPathWP1_x, rightPathWP1_y, 10000)
- rightPathWP1_x = intersection1_x
- rightPathWP1_y = intersection1_y
- rightPathWP1_z = _hz
- local isVis, _hx, _hy, _hz = Raycast(rightPathWP2_x, rightPathWP2_y, -10000, rightPathWP2_x, rightPathWP2_y, 10000)
- rightPathWP2_x = intersection2_x
- rightPathWP2_y = intersection2_y
- rightPathWP2_z = _hz
- -- this will find me two spots in an right angle from left side X (WP 1,2)
- script_runner:calcIntersections(dangerMob_x,dangerMob_y,hypothenuse, leftPoint_x, leftPoint_y, 0.75*dangerMob_r );
- -- todo is intersection1 always wp1 ? NO! its the opposite for the left side !
- local isVis, _hx, _hy, _hz = Raycast(leftPathWP1_x, leftPathWP1_y, -10000, leftPathWP1_x, leftPathWP1_y, 10000)
- leftPathWP1_x = intersection2_x
- leftPathWP1_y = intersection2_y
- leftPathWP1_z = _hz
- local isVis, _hx, _hy, _hz = Raycast(leftPathWP2_x, leftPathWP2_y, -10000, leftPathWP2_x, leftPathWP2_y, 10000)
- leftPathWP2_x = intersection1_x
- leftPathWP2_y = intersection1_y
- leftPathWP2_z = _hz
- -- decide if we go around the mob left or right ---------------------
- -- can each wp1 wp2 be reached? are there mobs blocking a side? which wp2 is closer to final destination? whats the path lenth for each side
- -- calc direct distance for each wp 2 to final destination for now in 2d
- rightPathWP2toFinalDestination = GetDistance3D(self.tx,self.ty,self.tz,rightPathWP2_x,rightPathWP2_y,rightPathWP2_z)
- leftPathWP2toFinalDestination = GetDistance3D(self.tx,self.ty,self.tz,leftPathWP2_x,leftPathWP2_y,leftPathWP2_z)
- tc1(rightPathWP2toFinalDestination .. ' / ' .. leftPathWP2toFinalDestination .. ' right/left path wp2 distance to final destination')
- if rightPathWP2toFinalDestination > leftPathWP2toFinalDestination then
- goLeft = true
- tc2('left WP2 is closer')
- elseif rightPathWP2toFinalDestination < leftPathWP2toFinalDestination then
- goLeft = false
- tc2('right WP2 is closer')
- end
- local isVis, _hx, _hy, _hz = Raycast(leftPathWP2_x, leftPathWP2_y, -10000, leftPathWP2_x, leftPathWP2_y, 10000)
- -- test if wp2 left side or wp2 right side is closer to the !general destination!
- --GeneratePath(leftPathWP2_x, leftPathWP2_y, leftPathWP2_z, self.tx, self.ty, self.tz);
- tc1('_hz ' .. _hz .. ' self.tz ' .. self.tz)
- --todo fix!!!!!!!!!!!!!!!!!!!!!!!!!!! the green mess
- --local searching = IsSearchingForPath()
- --local rightPathSize = GetPathSize(5);
- if IsPathLoaded(5) then
- tc1('isloaded')
- local PathSize = GetPathSize(5);
- tct('PathSize: ' .. PathSize)
- end
- if (not IsPathLoaded(5)) then
- tc1('is NOT loaded')
- end
- --tc1('are we searching? '.. tostring(searching) .. rightPathSize .. ' isleaoded: ' .. isloaded)
- --[[ wait till we finished genpath todo: get it working
- if searching == true then
- local searching = IsSearchingForPath();
- return
- end
- local rightPathSize = GetPathSize(5);
- --GeneratePath(rightPathWP2_x, rightPathWP2_y, my_z, d_x, d_y, d_z);
- local rightPathSize = GetPathSize(5);
- tc1('rightPathSize ' .. righttPathSize)
- ]]--
- -- move to safespot and stop script for now, need to get a good z also
- local isVis, _hx, _hy, _hz = Raycast(intersection1_x, intersection1_y, -10000, intersection1_x, intersection1_y, 10000)
- ToConsole(tostring(isVis) .. _hz .. ' my_z: ' .. my_z .. ' intersection1_x: ' .. intersection1_x);
- -- decide whic hside we go
- if goLeft == true then
- tct('+++++++++++++++**********************+++++++++++we go left' .. leftPathWP1_x .. leftPathWP1_y .. leftPathWP1_z)
- Move(leftPathWP1_x, leftPathWP1_y, leftPathWP1_z);
- elseif goLeft == false then
- tct('+++++++++++++++**********************+++++++++++we go right' .. rightPathWP1_x .. rightPathWP1_y .. rightPathWP1_z)
- Move(rightPathWP1_x, rightPathWP1_y, rightPathWP1_z);
- end
- self.movingToSafespot = true
- end
- function script_runner:calcIntersections(x1,y1,r1,x2,y2,r2)
- --http://walter.bislins.ch/blog/index.asp?page=Schnittpunkte+zweier+Kreise+berechnen
- --https://translate.google.com/translate?sl=de&tl=en&u=http%3A%2F%2Fwalter.bislins.ch%2Fblog%2Findex.asp%3Fpage%3DSchnittpunkte%2Bzweier%2BKreise%2Bberechnen%2B(JavaScript)
- -- WAS used for triangle safespot, still used to calc a 3rd point in a triangle
- -- calculate the intersections of 2 circles -> "my circle" and "mob circle" which helps us find a safespot to nav from
- -- acutally we are using a right angle triangle where we have A) at mob and rightangle B) our xy and C) is the safespot
- -- so my circle has the hypothenuse as radius and mobradius is is the safedistance
- -- data i take from other function: my_x,my_y,hypothenuse, dangerMob_x, dangerMob_y,mob_radius
- -- (var names are not great, relict from former version of the function)
- local my_x = x1
- local my_y = y1
- local a = r1
- local mob_x = x2
- local mob_y = y2
- local b = r2
- triangleSideA = (math.sqrt((my_x-mob_x)*(my_x-mob_x)+(my_y-mob_y)*(my_y-mob_y)));
- AB0 = (mob_x - my_x); --vector (mobx - my x)
- AB1 = mob_y - my_y ;
- c = math.sqrt( AB0 * AB0 + AB1 * AB1 ); --distance between both cirlce centers so my sideA
- x = (a*a + c*c - b*b) / (2*c);-- )
- y = math.sqrt(a*a - x*x);-- sideC mob <---> safespot
- ex0 = AB0 / c;
- ex1 = AB1 / c;
- ey0 = -ex1;
- ey1 = ex0;
- Q1x = my_x + x * ex0;
- Q1y = my_y + x * ex1;
- -- two intersections
- intersection1_x = Q1x - y * ey0;
- intersection1_y = Q1y - y * ey1;
- intersection2_x = Q1x + y * ey0;
- intersection2_y = Q1y + y * ey1;
- return intersection1_x, intersection1_y, intersection2_x, intersection2_y;
- end
- function script_runner:MobTable()
- -- put enemies in a table
- local me = GetLocalPlayer();
- objectTable = {};
- local obj_, type_ = GetFirstObject();
- while obj_ ~= 0 do
- if type_ == 3 or type_ == 4 then
- local objX, objY, objZ = obj_:GetPosition();
- -- objR is mob aggro ranged, i tested it and it is at least 6 and maximum 46, on same lvl its 21
- local objR = obj_:GetLevel() - me:GetLevel() + 21
- if objR > 46 then objR = 46 end;
- if objR < 6 then objR = 6 end;
- local objGUID = obj_:GetGUID();
- local objName = obj_:GetUnitName();
- objectTable[obj_] = {x = objX, y = objY, z = objZ, type = type_, r = objR, GUID = objGUID, name = objName};
- end
- obj_, type_ = GetNextObject(obj_);
- end
- end
- function script_runner:draw()
- -- setview(3) so the camera is always behindthe bot !!!!
- SetView(3);
- -- put monster in a table for draw and avoid if called, in run its too late for draw
- script_runner:MobTable();
- --[[ draw avoidance triangle
- if self.movingToSafespot == true then
- script_runner:drawAvoidMobTriangle();
- end
- ]]--
- -- Draw path
- if (IsPathLoaded(5)) then
- if (self.lastnavIndex-1 <= GetPathSize(5)-1) then
- for index = self.lastnavIndex-1, GetPathSize(5) - 2 do
- local _x, _y, _z = GetPathPositionAtIndex(5, index);
- local _xx, _yy, _zz = GetPathPositionAtIndex(5, index+1);
- local _tX, _tY, onScreen = WorldToScreen(_x, _y, _z);
- local _tXX, _tYY, onScreens = WorldToScreen(_xx, _yy, _zz);
- if(onScreen and onScreens) then
- DrawLine(_tX, _tY, _tXX, _tYY, 255, 255, 0, 4);
- end
- end
- end
- end
- -- from radar, draw gets executed before run and i put fill monstertables in "run"
- script_runner:DrawMonsterAggroCircles();
- -- Draw destination
- _tX, _tY, onScreen = WorldToScreen(self.tx, self.ty, self.tz);
- if (onScreen) then
- DrawText("Destination:", _tX, _tY-10, 255, 255, 0);
- DrawText(tostring(self.destination[self.nRcombo+1].name), _tX, _tY, 255, 255, 0);
- end
- end
- function script_runner:run()
- --check various things
- --script_runner:FunkyStuffWithMobtable();
- -- Setup destinations
- if (not self.isSetup) then
- script_runner:setup();
- return;
- end
- -- Update player coordinates
- local localObj = GetLocalPlayer();
- local my_x, my_y, my_z = localObj:GetPosition();
- local d_x, d_y, d_z = self.tx, self.ty, self.tz;
- -- Update distance to destination
- self.distDestination = GetDistance3D(my_x, my_y, my_z, self.tx, self.ty, self.tz);
- if (GetTimeEX() < self.timer) then
- return;
- end
- self.timer = GetTimeEX() + self.tic;
- -- If the target destination has changed, generate a new path
- if(self.dx ~= self.tx or self.dy ~= self.ty or self.dz ~= self.tz) then
- -- update destination position
- self.dx, self.dy, self.dz = d_x, d_y, d_z;
- -- reset node index
- self.lastnavIndex = 1;
- -- generate a new path
- GeneratePath(my_x, my_y, my_z, d_x, d_y, d_z);
- end
- -- Return until path has been generated
- -- if there is no navmesh path loaded
- if (not IsPathLoaded(5)) then
- --stop
- if (IsMoving()) then
- StopMoving();
- end
- -- when we are not generating a path and generation timer is less than current time
- if (not self.generating and self.genTimer < GetTimeEX()) then
- rP("Generating path to " .. tostring(self.destination[self.nRcombo+1].name) .. '...');
- self.generating = true;
- self.genTimer = GetTimeEX() + 4500;
- end
- if (GetTimeEX() > self.genTimer and self.generating) then
- self.generating = false;
- self.runit = false;
- self.dx = 0;
- ClearPath(5);
- rP("Failed to generate path to " .. tostring(self.destination[self.nRcombo+1].name) .. '...');
- end
- return;
- else
- self.generating = false;
- end
- -- Get the next node's id
- local _ix, _iy, _iz = GetPathPositionAtIndex(5, self.lastnavIndex);
- --ToConsole('lastnavIndex: ' .. self.lastnavIndex);
- --distance to next node zerger
- local nextNodeDist = (GetDistance3D(my_x, my_y, my_z, _ix, _iy, _iz));
- --ToConsole('my distance to next node: ' .. nextNodeDist);
- if(GetDistance3D(my_x, my_y, my_z, _ix, _iy, _iz) < self.nextNodeDistance) then
- -- check if next node is in aggro cirlce, to do
- script_runner:CheckNextNodeToMobsDistance();--------------------------------------------------------------------------
- if findingNewStart == true then
- ToConsole('----------------------------------------------need to find new start')
- end
- -- If we are close to the next path node, increase our nav node index
- self.lastnavIndex = 1 + self.lastnavIndex;
- ToConsole('we just increased self.lastnavIndex:')
- -- if Destination reached
- if (GetPathSize(5) <= self.lastnavIndex) then
- self.lastnavIndex = GetPathSize(5)-1;
- self.runit = false;
- rP("Destination " .. tostring(self.destination[self.nRcombo+1].name .. ' reached...'));
- end
- end
- -- need to add a good logic to check if we go to safespot and restart navigation
- --ToConsole('self.movingToSafespot: ' .. tostring(self.movingToSafespot));
- if self.movingToSafespot == true then
- --ToConsole('my_x :' .. math.floor(my_x) .. ' intersection1_x: ' .. math.floor(intersection1_x));
- --------------------------------------------------------------- todo move wp 2 pathing into function?
- --all just temp stuff !!
- -- right path stuff
- if goLeft == false then
- -- if we are at a wp 1
- if math.floor(my_x) == math.floor(rightPathWP1_x) or -- 0.5 + 0.5 area
- math.floor(my_x) == math.floor(rightPathWP1_x) +1 or
- math.floor(my_x) == math.floor(rightPathWP1_x) -1
- then
- Move(rightPathWP2_x, rightPathWP2_y, my_z);
- end
- -- if we are at a wp 2
- if math.floor(my_x) == math.floor(rightPathWP2_x) or -- 0.5 + 0.5 area
- math.floor(my_x) == math.floor(rightPathWP2_x) +1 or
- math.floor(my_x) == math.floor(rightPathWP2_x) -1
- then
- --we arrived at savespot, gen path to target again
- ToConsole('we are at savespot');
- self.lastnavIndex = 1;
- GeneratePath(my_x, my_y, my_z, d_x, d_y, d_z);
- self.movingToSafespot = false;
- else
- return
- end
- end
- --- go left pat hstuff
- if goLeft == true then
- -- if we are at a wp 1
- if math.floor(my_x) == math.floor(leftPathWP1_x) or --0.5 + 0.5 area
- math.floor(my_x) == math.floor(leftPathWP1_x) +1 or
- math.floor(my_x) == math.floor(leftPathWP1_x) -1
- then
- Move(leftPathWP2_x, leftPathWP2_y, my_z);
- end
- -- if we are at a wp 2
- if math.floor(my_x) == math.floor(leftPathWP2_x) or -- 0.5 + 0.5 area
- math.floor(my_x) == math.floor(leftPathWP2_x) +1 or
- math.floor(my_x) == math.floor(leftPathWP2_x) -1
- then
- --we arrived at savespot, gen path to target again
- ToConsole('we are at savespot');
- self.lastnavIndex = 1;
- GeneratePath(my_x, my_y, my_z, d_x, d_y, d_z);
- self.movingToSafespot = false;
- else
- return
- end
- end
- end
- -- Move to the next node in the path
- Move(_ix, _iy, _iz);
- ToConsole('end of run')
- end
- function script_runner:menu()
- if (CollapsingHeader("[Rot's Runner - edited by Logitech")) then
- -- Setup destinations
- if (not self.isSetup) then
- script_runner:setup();
- return;
- end
- Separator()
- Text("Choose Destination")
- self.destinationChanged , self.nRcombo = ComboBox("", self.nRcombo, unpack(self.destinationName));
- -- Update destination position
- if self.destinationChanged or self.tx == 0 then
- self.tx = self.destination[self.nRcombo+1].x
- self.ty = self.destination[self.nRcombo+1].y
- self.tz = self.destination[self.nRcombo+1].z
- local x, y, z = GetLocalPlayer():GetPosition();
- self.distDestination = GetDistance3D(x, y, z, self.tx, self.ty, self.tz);
- self.status = "New destination selected...";
- rP("New destination selected " .. tostring(self.destination[self.nRcombo+1].name) .. '...');
- end
- Separator()
- Text("Distance to destination: " .. string.format("%.0f", self.distDestination) .. ' yards.')
- self.useNaveMesh = IsUsingNavmesh();
- if self.useNaveMesh then
- if not self.runit then
- if Button("Run to destination") then
- self.runit = true;
- StartBot();
- end
- else
- if Button("Stop running") then
- self.runit = false;
- StopBot();
- end
- end
- else
- Text("Please enable and load the nav mesh...");
- end
- Separator()
- if Button("save player location to textfile") then
- local localObj = GetLocalPlayer();
- local my_x, my_y, my_z = localObj:GetPosition();
- local myGetContinentID = GetContinentID();
- local myMapID = GetMapID();
- DEFAULT_CHAT_FRAME:AddMessage("Your XYZ coordinates have been saved!");
- DEFAULT_CHAT_FRAME:AddMessage("Check your gasaibot/Logs folder and copy your destination to scripts/script_runner.lua");
- ToFile('script_runner:addDestination("enter destination name here", ' .. my_x ..', '.. my_y .. ', ' .. my_z .. ', ' .. myGetContinentID ..', ' .. myMapID ..');')
- end
- -- Running with StartBot() now instead
- --if (self.runit) then
- -- Run to destination
- -- script_runner:run();
- --end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement