GUnit FindBestTarget() { if (target == null || ppather.IsBlacklisted(target)) UpdateTimer.ForceReady(); else { if (!target.IsValid || target.IsDead) UpdateTimer.ForceReady(); } if (UpdateTimer.IsReady) { GPlayer[] players = GObjectList.GetPlayers(); float[] playerScore = new float[players.Length]; float best_score = 0; GPlayer best_player = null; for (int i = 0; i < players.Length; i++) { GPlayer player = players[i]; if (!player.IsSameFaction || ppather.IsBlacklisted(player) || player == GContext.Main.Me || player.Health < 0.05) { playerScore[i] = -100f; } else { for (int j = 0; j < players.Length; j++) { if (players[j].IsSameFaction && players[j] != GContext.Main.Me && players[j] != player && players[j].Health > 0.05) { double d = players[j].GetDistanceTo(player); if (d < 30) { playerScore[i] += 30f - (float)d; } } } } if (playerScore[i] > best_score) { best_player = player; best_score = playerScore[i]; } } if (best_score > 50) { target = best_player; if (target != null) PPather.WriteLine("follow player " + target.Name + " score " + best_score); } else target = null; UpdateTimer.Reset(); } return target; }
/// <summary> /// Retrieves the quantities of all distinct items in all of your bags. /// </summary> /// <param name="useCache">Whether to use cached data, if possible</param> /// <returns> /// A Dictionary with keys corresponding to the names /// of each distinct item in your inventory and values corresponding /// to the number of that item across all of your bags. /// </returns> public static Dictionary <string, int> CreateItemCount(bool useCache) { // only check it every 30 seconds to try to reduce // overhead if (curItemsCache != null && !curItemCacheTimer.IsReady && useCache) { return(curItemsCache); } Dictionary <string, int> items = new Dictionary <string, int>(StringComparer.InvariantCultureIgnoreCase); long[] AllBags = GPlayerSelf.Me.Bags; for (int bagNr = 0; bagNr < 5; bagNr++) { long[] Contents; int SlotCount; if (bagNr == 0) { Contents = GContext.Main.Me.BagContents; SlotCount = GContext.Main.Me.SlotCount; } else { GContainer bag = (GContainer)GObjectList.FindObject(AllBags[bagNr - 1]); if (bag != null) { Contents = bag.BagContents; SlotCount = bag.SlotCount; } else { SlotCount = 0; Contents = null; } } for (int i = 0; i < SlotCount; i++) { if (Contents[i] == 0) { continue; } GItem CurItem = (GItem)GObjectList.FindObject(Contents[i]); if (CurItem != null) { string ItemName = CurItem.Name; int ItemCount = CurItem.StackSize; int OldCount = 0; items.TryGetValue(ItemName, out OldCount); items.Remove(ItemName); items.Add(ItemName, OldCount + ItemCount); } } } curItemCacheTimer.Reset(); curItemsCache = items; return(curItemsCache); }
public static void Dismount() { if (IsMounted() && dismountTimer.IsReady) { PPather.WriteLine("Dismounting"); GContext.Main.SendKey("Common.Mount"); dismountTimer.Reset(); } }
public override bool Do() { if (em == null) { return(true); // WTF! } // mount if we're really far away if (monster.DistanceToSelf >= mountRange) { if (PPather.PatherSettings.UseMount != "Never Mount") { if (PPather.PatherSettings.UseMount == "Always Mount" || (PPather.PatherSettings.UseMount == "Let Task Decide" && UseMount == true)) { Helpers.Mount.MountUp(); } } } if (GContext.Main.Me.Target != monster && tabSpam.IsReady && monster.DistanceToSelf < 50f && monster.Reaction != GReaction.Friendly) { GContext.Main.SendKey("Common.Target"); tabSpam.Reset(); } if (GetLocation().GetDistanceTo(to) > GContext.Main.MeleeDistance && monster.DistanceToSelf < 30f || updateTimer.IsReady) { // need a new path, monster moved to = GetLocation(); em = new EasyMover(ppather, to, false, true); updateTimer.Reset(); } MoveResult = em.move(howClose); if (MoveResult != EasyMover.MoveResult.Moving) { return(true); // done, can't do more } Location meLocation = new Location(GContext.Main.Me.Location); if (meLocation.GetDistanceTo(to) < howClose) { PPather.mover.Stop(); Helpers.Mount.Dismount(); monster.Face(PPather.PI / 8); return(true); } return(false); }
private static bool GetQuestStatus(string name) { if (updateTimer == null || updateTimer.IsReady) { UpdateQuestStatus(); updateTimer.Reset(); } bool completed = false; if (!questStatus.TryGetValue(name, out completed)) { return(false); } else { return(completed); } }
public static bool MountUp() { if (GPlayerSelf.Me.Level < MIN_MOUNT_LEVEL) { return(false); } if (IsMounted()) { return(true); } if (GPlayerSelf.Me.IsInCombat) { return(false); } if (!HaveMount()) { return(false); } // only try to mount every so often if (!mountTimer.IsReady) { return(false); } // check that we're not inside Spot mySpot = null; try { mySpot = PPather.world.GetSpot( new Location(GPlayerSelf.Me.Location)); if (mySpot.GetFlag(Spot.FLAG_INDOORS)) { //PPather.WriteLine("Not mounting, we're inside"); mountTimer.Reset(); return(false); } } catch { // if we got an exception something must be up return(false); } PPather.mover.Stop(); //PPather.WriteLine("Mount up"); //buff.Snapshot(); //mountBuffID = 0; GContext.Main.CastSpell("Common.Mount"); Thread.Sleep(100); string badMount = null; if (GContext.Main.RedMessage.Contains("while swimming")) { badMount = "Trying to mount while swimming"; } else if (GContext.Main.RedMessage.Contains("can't mount here")) { badMount = "Trying to mount inside"; mySpot.SetFlag(Spot.FLAG_INDOORS, true); } if (null != badMount) { PPather.WriteLine(badMount); mountTimer.Reset(); return(false); } while (GPlayerSelf.Me.IsCasting) { Thread.Sleep(100); } if (!IsMounted()) { mountTimer.Reset(); return(false); } return(true); }
public static void GetBattlefieldState() { if (IsVisible() && CheckDropDown.IsReady) { // get the 1st dropdown frame GInterfaceObject obj = DropDownListFrame.GetFrame(); // check to see if it's already up (possible) if (obj == null || obj.IsVisible == false) { RightClick(); Thread.Sleep(600); } // at this point dropdown is visible, else something blocked the click if (obj != null && obj.IsVisible) { string curBattlefield = null; int foundAt = 0; // index match was found at int lookAt = 0; // num elements past index we looked at Tasks.BGQueueTaskManager.ResetQueueState(); // if the dropdown ever has more than 16 lines this has to be increased // look at the two entries after the name that matches, if one does for (int i = 1; i <= 16; i++) { MiniMapBattlefieldFrameState bfState = MiniMapBattlefieldFrameState.Unknown; string rowText = DropDownListFrame.GetButtonText(i); //if (rowText != null) PPather.WriteLine("rowText=" + rowText); if (rowText != null && rowText.Length > 0 && foundAt == 0) { curBattlefield = rowText; foundAt = i; } else if (foundAt > 0) { if (rowText != null) { // TODO change this to a GetLocale string if (rowText.Equals("Leave Queue", StringComparison.CurrentCultureIgnoreCase)) { bfState = MiniMapBattlefieldFrameState.Queue; } // TODO change this to a GetLocale string else if (rowText.Equals("Enter Battle", StringComparison.CurrentCultureIgnoreCase)) { bfState = MiniMapBattlefieldFrameState.CanEnter; } // TODO change this to a GetLocale string else if (rowText.Equals("Leave Battleground", StringComparison.CurrentCultureIgnoreCase)) { bfState = MiniMapBattlefieldFrameState.Inside; } } lookAt++; } if (lookAt == 2) { Tasks.BGQueueTaskManager.SetQueueState(curBattlefield, bfState); //PPather.WriteLine("GetBattlefieldState: set " + curBattlefield + " to " + bfState); foundAt = 0; lookAt = 0; } } } // send a second right click to close it, we're done with it RightClick(); Thread.Sleep(300); CheckDropDown.Reset(); } }
bool WaitForEngage(GUnit Target, int Time) { GSpellTimer BreakLoop = new GSpellTimer(Time, false); BreakLoop.Reset(); while (!BreakLoop.IsReady) { Thread.Sleep(100); if (Target.DistanceToSelf > PullDistance) Target.Approach(PullDistance - 5, false); if (Target.Target == Me || Target.Target == Me.Pet || Me.Pet.IsInCombat) { return true; } else if (Me.IsUnderAttack) return false; } return false; }
public override bool Do() { bool hide; int minutes = 0; GUnit Player = null; Player = GetClosestPlayer(); if (Player != null && Player.DistanceToSelf < AvoidRange) { GSpellTimer WaitAfterLeave = new GSpellTimer(10 * 1000); // wait an exta 10 s GSpellTimer SpamTimer = new GSpellTimer(60 * 1000); // Spam every 1 min System.Media.SoundPlayer sp = new System.Media.SoundPlayer("PlayerNear.wav"); WaitAfterLeave.Reset(); SpamTimer.Reset(); try { if (PlaySound) { sp.Load(); sp.Play(); } } catch { } do { if (Me.IsInCombat) { PPather.WriteLine("AvoidPlayers: I was attacked while hiding"); return(false); } if (Me.IsDead) { PPather.WriteLine("AvoidPlayers: I died while hiding"); return(false); } hide = false; if (WaitUntilClear == true && GetClosestPlayer() != null) { hide = true; } else if (WaitUntilClear != true && GetClosestPlayer().DistanceToSelf < AvoidRange) { hide = true; } if (hide) { WaitAfterLeave.Reset(); } if (Me.PlayerClass.ToString() == "Rogue" && StealthWhileHiding == true && !GPlayerSelf.Me.IsStealth) { GContext.Main.CastSpell(StealthKey); } if (Me.PlayerClass.ToString() == "Druid" && StealthWhileHiding == true && !GPlayerSelf.Me.IsStealth) { if (!Me.HasWellKnownBuff("CatForm")) { GContext.Main.CastSpell(CatFormKey, true, false); // if we aren't in cat form, then switch before trying to stealth } GContext.Main.CastSpell(StealthKey, true, false); } if (SpamTimer.IsReady) { SpamTimer.Reset(); minutes++; PPather.WriteLine("AvoidPlayers: Waited " + minutes.ToString() + "minutes for players to leave."); if (PlaySound) { sp.Play(); } if (minutes >= TimeUntilExit) { PPather.WriteLine("AvoidPlayers: Time to log out"); GContext.Main.HearthAndExit(); return(false); } } Thread.Sleep(1000); } while (!WaitAfterLeave.IsReady); return(true); } return(false); }
public override bool Do() { Helpers.Mount.Dismount(); while (true) { Functions.Interact(npc); Thread.Sleep(1000); if (GossipFrame.IsVisible()) { //PPather.WriteLine("Buy: Got a gossip frame"); if (GossipFrame.ClickOptionText("browse your") || GossipFrame.ClickOptionText("Sid") || GossipFrame.ClickOptionText("What do you have")) { Thread.Sleep(2000); // Lag } } if (MerchantFrame.IsVisible()) { GMerchant Merchant = new GMerchant(); string[] toBuy; int[] toBuyQuantities; GetShoppingList(out toBuy, out toBuyQuantities); GSpellTimer sanity = new GSpellTimer(5000); for (int i = 0; i < toBuy.Length; i++) { sanity.Reset(); int lastCount = Inventory.GetItemCount(toBuy[i], false); int curCount = lastCount; do { GContext.Main.EnableCursorHook(); if (!Merchant.BuyOnAnyPage(toBuy[i])) { PPather.WriteLine("!Info:Buy: Unable to buy [" + toBuy[i] + "], skipping"); break; } Thread.Sleep(2000); curCount = Inventory.GetItemCount(toBuy[i], false); // inventory went up so reset the timer if (curCount > lastCount) { sanity.Reset(); } // PPather.WriteLine(string.Format(" {0} -> {1} of {2}", lastCount, curCount, toBuyQuantities[i])); lastCount = curCount; if (sanity.IsReady) { PPather.WriteLine("!Info:Buy: Waiting too long buying [" + toBuy[i] + "], skipping"); break; } } while (curCount < toBuyQuantities[i]); GContext.Main.DisableCursorHook(); } if (Merchant.IsRepairEnabled) // Might as well fix it up while we're here. { PPather.WriteLine("Buy: Repairing"); Functions.ClickRepairButton(Merchant); } Functions.Closeit(Merchant); } else { PPather.WriteLine("!Info: Never got merchant frame"); GContext.Main.SendKey("Common.Escape"); // Close whatever frame popped up } return(true); } }
public override bool Do() { if (monster.IsLootable) { Functions.Interact(monster); GSpellTimer bop = new GSpellTimer(500); do { for (int i = 1; i <= 4; i++) { if (Popup.IsVisible(i)) { String text = Popup.GetText(i); PPather.WriteLine("Loot: Got a loot popup ('" + text + "')"); if (text == "Looting this item will bind it to you.") { Popup.ClickButton(i, 1); } else { Popup.ClickButton(i, 2); } } } } while (!bop.IsReadySlow); Thread.Sleep(500); } /*Skinning start*/ if (Skin) { int attempt = 1; GSpellTimer futile = new GSpellTimer(3000); futile.Reset(); // is 3s enough for skinning to be done?! PPather.WriteLine("Want to skin"); while (monster.IsLootable && !futile.IsReadySlow) { ; //Waiting for looting to finish } Thread.Sleep(1000); // Check the type of the cursor if (!monster.IsCursorOnUnit) { Functions.Hover(monster); } PPather.WriteLine("Loot: Cursor Type is: " + GContext.Main.Interface.CursorType); PPather.WriteLine("Loot: Skinnable: " + monster.IsSkinnable); // TODO what cursot types are good? 12=skin, ??=mine, ??=herb while (monster.IsValid && monster.IsSkinnable && attempt <= 3) { PPather.WriteLine("Loot: Skin. Attempt #" + attempt); Functions.Interact(monster); Thread.Sleep(500); if (GContext.Main.Me.IsInCombat) { return(false); } bool casted = false; while (GContext.Main.Me.IsCasting) { casted = true; Thread.Sleep(1500); } if (!casted) { // looks bad string message = GContext.Main.RedMessage; if (message.StartsWith("Requires ")) { // missing skill or too low PPather.WriteLine("Loot: Skill too low to skin: " + message); break; } PPather.WriteLine("Loot: Never entered casting after skin attempt"); break; } if (GContext.Main.Me.IsInCombat) { return(false); } attempt++; Thread.Sleep(800); if (GPlayerSelf.Me.Target == null) { break; // corpse gone, done } } } /*Skinning end*/ ppather.Looted(monster); // Use default postloot key. If undefined does nothing so don't need to check // whether it actually contains a value GContext.Main.SendKey("Common.PostLoot"); return(true); }