Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <CustomBehavior File="RunCode" Type="Definition" ><![CDATA[
  2. private List<WoWGuid> _treasureBlacklist = new List<WoWGuid>();
  3. private bool _treasureIsLogged = false;
  4. private Styx.TreeSharp.Composite _treasureHuntComposite;
  5. private WoWGameObject _treasurePoi;
  6. private Vector3 _treasureLocation;
  7.  
  8. public async Task<bool> TreasureHunt()
  9. {
  10. if (!Settings.Instance.FarmTreasures) return false;
  11.  
  12. if (!_treasureLocation.Equals(new Vector3(0,0,0)) && _treasureLocation.DistanceSquared((WoWMovement.ActiveMover ?? StyxWoW.Me).Location) > 5 * 5)
  13. {
  14. TreeRoot.StatusText = $"Moving to interact with treasure: {_treasurePoi.Name}";
  15. return (await CommonCoroutines.MoveTo(_treasureLocation)).IsSuccessful();
  16. }
  17.  
  18. if (_treasurePoi == null || !_treasurePoi.IsValid)
  19. {
  20. _treasurePoi = ObjectManager.GetObjectsOfType<WoWGameObject>().OrderBy(obj => obj.DistanceSqr).FirstOrDefault(obj => !_treasureBlacklist.Contains(obj.Guid) && !BlackspotManager.IsBlackspotted(obj.Location) && obj.SubType == WoWGameObjectType.Chest && obj.LockType == WoWLockType.Open && obj.CanUse() && obj.DistanceSqr <= 40f*40f);
  21. if (_treasurePoi == null) return false;
  22. if (Navigator.LookupPathInfo(_treasurePoi).Navigability != PathNavigability.Navigable)
  23. {
  24. _treasureBlacklist.Add(_treasurePoi.Guid);
  25. Logging.Write(System.Windows.Media.Colors.DeepSkyBlue, $"[ProfileBase]: Treasure detected near us, but we can't navigate to it!\n Name :: {_treasurePoi.Name}\n Entry :: {_treasurePoi.Entry}\n Location :: {_treasurePoi.Location}");
  26. _treasurePoi = null;
  27. return false;
  28. }
  29. _treasureLocation = _treasurePoi.Location;
  30. return true;
  31. }
  32.  
  33. if (!_treasureIsLogged)
  34. {
  35. _treasureIsLogged = true;
  36. Logging.Write(System.Windows.Media.Colors.DeepSkyBlue, $"[ProfileBase]: Treasure detected near us!\n Name :: {_treasurePoi.Name}\n Entry :: {_treasurePoi.Entry}\n Location :: {_treasurePoi.Location}");
  37. }
  38.  
  39. TreeRoot.StatusText = $"Interacting with treasure: {_treasurePoi.Name}";
  40. await CommonCoroutines.LandAndDismount();
  41. await CommonCoroutines.StopMoving();
  42. _treasurePoi.Interact();
  43. await Coroutine.Wait(2000, () => LootFrame.Instance.IsVisible);
  44. LootFrame.Instance.LootAll();
  45. await Coroutine.Wait(2000, () => _treasurePoi == null || !_treasurePoi.IsValid);
  46.  
  47. _treasureIsLogged = false;
  48. _treasureLocation = new Vector3(0,0,0);
  49. _treasureBlacklist.Add(_treasurePoi.Guid);
  50.  
  51. return true;
  52. }
  53. ]]>
  54. </CustomBehavior>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement