Advertisement
RulerOf

waypointing in bot.cs

May 27th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. private bool CheckWaypoint(string WPName, out string WPTarget)
  2.         {
  3.             WPTarget = "";
  4.  
  5.             Game.Print("Checking Waypoint Availability");
  6.  
  7.             var warps = UIElement.Get().Where(u => u.Name.Contains("waypoints_dialog") && u.Name.EndsWith("wrapper.text")); // Return all the waypoint text entries.
  8.  
  9.             foreach (UIElement u in warps)
  10.             {
  11.                
  12.                 if (u.Text.ToLower().Contains(WPName.ToLower())) // Let's see if we can find a waypoint that matches the text we were given.
  13.                 {
  14.                     WPTarget = u.Name.Replace("wrapper.text", "wrapper.button"); // Fill out the name of the UIElement we need to click on.
  15.                     return true;
  16.                 }
  17.             }
  18.  
  19.             return false;
  20.         }
  21.  
  22.         private bool WarpTo(string warp_target)
  23.         {
  24.            
  25.             Game.Print("Running WarpTo");
  26.  
  27.             string warp_button = "";
  28.  
  29.             if (!CheckWaypoint(warp_target, out warp_button)) //Check to see if we can actually warp there...
  30.                 return false;
  31.            
  32.         if (warp_button == "") // We didn't find it, return.
  33.                 return false;
  34.             Game.Print("Okay, clicking the button...");
  35.  
  36.             clickUI(warp_button, true); // Clicky wait for level change...
  37.  
  38.             uint _lvlArea = (uint)Me.LevelArea;
  39.  
  40.             Game.Print("Waiting for level change...");
  41.             while ((uint)Me.LevelArea == _lvlArea)
  42.             {
  43.                 Thread.Sleep(400);
  44.             }
  45.  
  46.             Game.Print("Done!");
  47.             return true;
  48.  
  49.         }
  50.  
  51.  
  52.         public bool TakeWaypointTo(string warp_target)
  53.         {
  54.             var Waypoint = Unit.Get().Where(u => u.Name.ToLower().Contains("waypoint")).FirstOrDefault();
  55.  
  56.             if (!Waypoint.Name.ToLower().Contains("waypoint"))
  57.             {
  58.                 Game.Print("Unable to locate Waypoint!");
  59.                 return false;
  60.             }
  61.  
  62.             interact(Waypoint, true);
  63.         Thread.Sleep(500);
  64.  
  65.            
  66.             bool WarpAction = WarpTo(warp_target);
  67.             return WarpAction;
  68.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement