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; }
public override Activity GetActivity() { if (walkTask != null) { // check result of walking if (walkTask.MoveResult != EasyMover.MoveResult.Moving && walkTask.MoveResult != EasyMover.MoveResult.GotThere) { PPather.WriteLine("Can't reach " + target.Name + ". blacklist. " + walkTask.MoveResult); ppather.Blacklist(target.GUID, 120); return null; } } // check distance if (target.DistanceToSelf < Distance) { PPather.mover.Stop(); if (waitTask == null) waitTask = new ActivityWait(this, "GroupFollow"); walkTask = null; return waitTask; } else { // walk over there if (walkTask == null) walkTask = new ActivityApproach(this, target, Distance, UseMount); waitTask = null; return walkTask; } }
public override bool Do() { Functions.Interact(npc); PPather.WriteLine("Interact: Clicking NPC - " + npc.Name); Thread.Sleep(1000); // Give it a sec in case of lag. return(true); }
public void OpenBag(int nr) { if (nr == CurrentOpenBag) { // verify it is open GInterfaceObject CurBag = GContext.Main.Interface.GetByName(BagButtonNames[nr]); if (CurBag == null || !CurBag.IsFiring) { PPather.WriteLine("BagManager: Something is very fishy with the bags. Close them all and try again"); CloseAllBags(); } } if (nr != CurrentOpenBag) { CloseAllBags(); GInterfaceObject CurBag = GContext.Main.Interface.GetByName(BagButtonNames[nr]); if (CurBag != null) { Functions.Click(CurBag, false); //Thread.Sleep(300); CurrentOpenBag = nr; //PPather.WriteLine("BagManager: Open bag " + BagButtonNames[nr]); } } }
public static bool EquipNewBag(GItem Item) { BagManager bm = new BagManager(); GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID); if (bag != null) { bm.ClickItem(Item, true); for (int p = 1; p <= 4; p++) { if (Popup.IsVisible(p)) { String text = Popup.GetText(p); PPather.WriteLine("Inventory: Got a popup ('" + text + "')"); if (text.Contains("will bind it to you")) { Popup.ClickButton(p, 1); } else { Popup.ClickButton(p, 2); } } } bm.CloseAllBags(); return(true); } bm.CloseAllBags(); return(false); }
public override Activity GetActivity() { // check distance if (node.DistanceToSelf < 5.0 && Math.Abs(node.Location.Z - GContext.Main.Me.Location.Z) < 5.0) { if (walkTask != null) { walkTask.Stop(); } if (lootTask == null) { lootTask = new ActivityPickup(this, node); } walkTask = null; return(lootTask); } else { // walk over there if (walkTask == null) { walkTask = new ActivityWalkTo(this, new Location(node.Location), 2f, UseMount); PPather.WriteLine("new walk task to node " + node.Name); } else { // check status of mover } lootTask = null; return(walkTask); } }
public static void CheckForBetterGear() { List <EasyItem> containers = new List <EasyItem>(); PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Inventory: Reading Inventory Items"); Character.GetInventoryItems(); PPather.Debug("\n=====================================\n=== CHECK OF {0} BAG ITEMS START ===\n=====================================\n", Character.InventoryItems.Count); foreach (KeyValuePair <long, EasyItem> e in Character.InventoryItems) { //PPather.WriteLine("AutoEquipTask: Got " + e.Key + " from InventoryItems"); EasyItem E = e.Value; PPather.Debug("\n\n=== AUTOEQUIP FOR {0} START ===", E.RealName); if (E.Item.Type.Equals("Containers")) { PPather.Debug("AutoEquip: {0} saved for CompareAndEquipBags()", E.RealName); containers.Add(E); PPather.Debug("\n=== AUTOEQUIP FOR {0} END ===\n", E.RealName); continue; } if (ItemCompare.CompareGear(E, E.RealName)) { PPather.WriteLine(LOG_CATEGORY.DEBUG, "AutoEquip: Equipped better gear [{0}]", E.RealName); } PPather.Debug("\n=== AUTOEQUIP FOR {0} END ===\n", E.RealName); } if (containers.Count > 0) { EasyItem[] C = containers.ToArray(); Inventory.CompareAndEquipBags(C); containers.Clear(); } PPather.Debug("\n=====================================\n=== CHECK OF {0} BAG ITEMS END ===\n=====================================\n", Character.InventoryItems.Count); }
public override bool WantToDoSomething() { MinLevel = nodetask.GetValueOfId("MinLevel").GetIntValue(); MaxLevel = nodetask.GetValueOfId("MaxLevel").GetIntValue(); GUnit prevMonster = monster; monster = FindMobToPull(); if (monster != prevMonster) { if (prevMonster != null && prevMonster.IsValid && !prevMonster.IsDead) { PPather.WriteLine("new monster to attack. ban old one: " + prevMonster.Name + ""); ppather.Blacklist(prevMonster.GUID, 45); // ban for 45 seconds } attackTask = null; walkTask = null; } if (monster == null) { attackTask = null; walkTask = null; } return(monster != null); }
public static void ReplaceCurrentlyEquipped(EasyItem E, string slot) { if (E == null) { return; } EasyItem w = null; if (CurrentlyEquipped == null || CurrentlyEquipped.Count < 1) { return; } if (CurrentlyEquipped.ContainsKey(slot)) { w = GetCurrent(slot); CurrentlyEquipped.Remove(slot); } SetCurrent(slot, E); string oldName = "null"; if (w != null && w.Item != null) { oldName = w.GItem.Name; } if (w != null && w.GItem != null) { PPather.AutoEquipForceSell.Add(w.GItem.GUID); GContext.Main.Debug(String.Format("Character: Added {0} to ForceSell list", w.GItem.Name)); } PPather.WriteLine(String.Format("Character: Replaced {0} with {1} in CurrentlyEquipped", oldName, E.GItem.Name)); }
public void OpenBag(int nr) { if (nr == CurrentOpenBag) { // verify it is open GInterfaceObject CurBag = GContext.Main.Interface.GetByName(BagButtonNames[nr]); if (CurBag == null || !CurBag.IsFiring) { PPather.WriteLine(LOG_CATEGORY.INFORMATION, "BagManager: Something is very fishy with the bags. Close them all and try again"); CloseAllBags(); CurrentOpenBag = -1; Thread.Sleep(250); // allow a short wait after closing the bag and opening the new one. } } if (nr != CurrentOpenBag) { CloseAllBags(); Thread.Sleep(250); GInterfaceObject CurBag = GContext.Main.Interface.GetByName(BagButtonNames[nr]); if (CurBag != null) { Functions.Click(CurBag, false); //Thread.Sleep(300); CurrentOpenBag = nr; Thread.Sleep(125); //PPather.WriteLine("BagManager: Open bag " + BagButtonNames[nr]); } } }
public override bool Do() { Functions.Interact(unit); Thread.Sleep(2000); if (GossipFrame.IsVisible()) { if (!GossipFrame.ClickOptionText("training")) { return(false); } Thread.Sleep(2000); } if (TrainerFrame.IsVisible()) { TrainerFrame.LearnAllSkills(); PPather.WriteLine("Train: Learned new skills"); GContext.Main.SendKey("Common.Escape"); // Clear up // Stop it from trying to execute again on the same level PPather.ToonData.Set("TrainLevel" + trainType, GPlayerSelf.Me.Level.ToString()); } else { GContext.Main.SendKey("Common.Escape"); return(false); } // ? Try again? return(true); }
// Find a buff not present in last BuffSnapshot public GBuff FindNew() { if (BuffSnap == null) { return(null); } GBuff[] buffs = GPlayerSelf.Me.GetBuffSnapshot(); for (int i = 0; i < buffs.Length; i++) { GBuff b = buffs[i]; // O(n^2) FTW GBuff old = null; for (int j = 0; j < BuffSnap.Length && old == null; j++) { GBuff b2 = BuffSnap[j]; if (b2.SpellID == b.SpellID) { old = b; } } if (old == null) { PPather.WriteLine("BuffHelper: New buff: " + b.SpellName); return(b); } } return(null); }
public override Activity GetActivity() { if (walkTask != null) { // check result of walking if (walkTask.MoveResult != EasyMover.MoveResult.Moving && walkTask.MoveResult != EasyMover.MoveResult.GotThere) { PPather.WriteLine("Can't reach " + monster.Name + ". blacklist. " + walkTask.MoveResult); ppather.Blacklist(monster); return(null); } } // check distance if (monster.DistanceToSelf < ppather.PullDistance) { PPather.mover.Stop(); if (attackTask == null) { attackTask = new ActivityAttack(this, monster); } walkTask = null; return(attackTask); } else { // walk over there if (walkTask == null) { walkTask = new ActivityApproach(this, monster, ppather.PullDistance, UseMount); } attackTask = null; return(walkTask); } }
public override bool Do() { // keep mailing as long as there is something to mail in // our inventory int mailed = 0; while (true) { int i = SendMail(); if (i == 0) { break; } mailed += i; PPather.WriteLine("Mail: Sent mail, checking for more..."); } PPather.WriteLine("Mail: Done mailing, sent " + mailed + " items"); //ppather.Blacklist(mailbox.GUID, 15 * 60); // Don't use for another 15 minutes. return(true); }
public override bool Do() { if (waitfor.Equals("BG", StringComparison.InvariantCultureIgnoreCase) && !Buffs.HaveBuff("Preparation")) { PPather.WriteLine("Wait: BG Starting. Stopping Wait"); return(true); } bool DoWait = KeepOnWaiting(); if (DoWait && ActionTimer.IsReady) { int action = GContext.Main.RNG.Next(3); if (action == 0) { GContext.Main.SendKey("Common.RotateRight"); } else if (action == 1) { GContext.Main.SendKey("Common.RotateLeft"); } else if (action == 2) { GContext.Main.SendKey("Common.Jump"); } ActionTimer = new GSpellTimer(30000 + GContext.Main.RNG.Next(10000)); } return(!DoWait); }
private bool IsValidTargetName(String name) { if (names == null) { return(true); } foreach (string tst_name in names) { if (tst_name == name) { return(true); } } if (ignore != null) { foreach (string tst_ignore in ignore) { if (tst_ignore == name) { PPather.WriteLine("Skipping (ignore): " + name); return(false); // Ignore the mob. } } } return(false); }
public static Boolean setLoots(int posBeforeLoot) { NewLoot = false; String[] tmp = null; if (posBeforeLoot > chatPos) { _LootAmount = BUFSIZE - (posBeforeLoot - chatPos); //PPather.WriteLine(String.Format("ChannelLogs: LootAmount = {0}", _LootAmount)); } else { _LootAmount = chatPos - posBeforeLoot; //PPather.WriteLine(String.Format("ChannelLogs: LootAmount = {0}", _LootAmount)); } if (_LootAmount != 0) { if (LootID < 0) { LootID = 0; } tmp = getNChatLines(_LootAmount); } else { return(false); } //if(tmp.Length > 0) // LastLoot.Clear(); for (int i = 0; i < tmp.Length; i++) { String line = tmp[i]; if ((line == "") || (line == null)) { continue; } Match m = receiveNewLootPattern.Match(line); if (m.Success) { string item = m.Groups["item"].Value; //PPather.WriteLine(String.Format("ChannelLogs: item = {0}", item)); NewLoot = true; LootID++; try { LastLoot.Add(item); LootBuffer.Add(item); PPather.WriteLine("ChannelLogs: Added " + item + " to Loot Buffers"); GContext.Main.Debug("ChannelLogs: Added " + item + " to Loot Buffers"); } catch (ArgumentException) { //PPather.WriteLine("ChannelLogs: " + item + " already added to Loot Buffers (skipping)"); } } } return(NewLoot); }
public static string GetCompleteTitle() { GInterfaceObject QuestDetailScrollChildFrame = GContext.Main.Interface.GetByName("QuestRewardScrollChildFrame"); GInterfaceObject QuestTitle = QuestDetailScrollChildFrame.GetChildObject("QuestRewardTitleText"); PPather.WriteLine("Reward title: {0}, v: {1}", QuestTitle.LabelText, QuestTitle.IsVisible); return(QuestTitle.LabelText); }
public override bool ActivityDone(Activity task) { PPather.WriteLine("ActDone need next"); currentHotSpot = GetNextLocation(); currentWalker = null; task.Stop(); return(false); }
public static string GetAcceptTitle() { GInterfaceObject QuestDetailScrollChildFrame = GContext.Main.Interface.GetByName("QuestDetailScrollChildFrame"); GInterfaceObject QuestTitle = QuestDetailScrollChildFrame.GetChildObject("QuestTitleText"); PPather.WriteLine("Quest title: " + QuestTitle.LabelText + " v: " + QuestTitle.IsVisible); return(QuestTitle.LabelText); }
public void Error(string msg) { string s = "Line " + tn.line + ": " + msg; PPather.WriteLine("Line " + tn.line + ": " + msg); System.Windows.Forms.MessageBox.Show(s, "Error parsing task file", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); }
private static void TestSlotName(string slot) { GItemHelper GIH = new GItemHelper(); long guid = GIH.GetEquippedGUID(slot); string name = G2I(guid); PPather.WriteLine(String.Format("{0} [{1}] -> {2}", slot, guid, name)); }
public TaxiTask(PPather pather, NodeTask node) : base(pather, node) { if (GetLocationOfNPC() == null) { PPather.WriteLine("*** NPC " + NPC + " is unknown"); } }
public static void Dismount() { if (IsMounted()) { PPather.WriteLine("Dismounting"); GContext.Main.SendKey("Common.Mount"); } }
public RestTask(PPather pather, NodeTask node) : base(pather, node) { RestHealth = GContext.Main.RestHealth; RestMana = GContext.Main.RestMana; PPather.WriteLine("Rest health: " + RestHealth + " mana: " + RestMana); }
public static void GetEquippedItems() { GItemHelper GIH = new GItemHelper(); if (CharacterSlots == null) { CharacterSlots = GetCharacterSlots(); } CharacterFrame.ShowFrame(); foreach (string slot in CharacterSlots) { string tooltipName = "none"; PPather.Debug("\n\n == SLOT LOOKUP FOR {0} START ==", slot); List <string> tooltip = CharacterFrame.GetTooltip(slot); if (tooltip != null && tooltip.Count > 0) { //foreach (string tip in tooltip) // PPather.WriteLine("Character: Tooltip[{0}]\t=>\t{1}", slot, tip); tooltipName = tooltip[tooltip.Count - 1]; } PPather.Debug("Character: Name for {0} = {1}", slot, tooltipName); if (tooltip == null || IsEmptySlotName(tooltipName)) { AddNullSlot(slot); } else { Item i = ItemManager.get(tooltipName); if (i == null) { AddNullSlot(slot); } else { GItem Item = (GItem)GObjectList.FindObject(GIH.GetEquippedGUID(slot)); if (Item == null) { continue; } EasyItem E = new EasyItem(Item, i, Item.GUID, tooltipName); try { CurrentlyEquipped.Add(slot, E); PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Character: Item [{0}] equipped in '{1}'", tooltipName, slot); PPather.Debug(String.Format("ToolTip[{0}]: {1}", i.Name, CleanToolTip(tooltip))); } catch (ArgumentException) { PPather.Debug("Character: " + tooltipName + " is already added to CurrentlyEquipped (skipping)"); } } } PPather.Debug("\n=== SLOT LOOKUP FOR {0} END ===\n", slot); } CharacterFrame.HideFrame(); }
public static void Dismount() { if (IsMounted() && dismountTimer.IsReady) { PPather.WriteLine("Dismounting"); GContext.Main.SendKey("Common.Mount"); dismountTimer.Reset(); } }
public override Location GetLocation() { if (currentHotSpot == null) { currentHotSpot = GetNextLocation(); PPather.WriteLine("GetLoc need next . got " + currentHotSpot); } return(currentHotSpot); }
GUnit FindMobToPull() { // Find stuff to pull GUnit closest = null; // only assist players //GMonster[] monsters = GObjectList.GetMonsters(); GPlayer[] players = GObjectList.GetPlayers(); List <GUnit> units = new List <GUnit>(); //units.AddRange(monsters); units.AddRange(players); float me_z = GContext.Main.Me.Location.Z; foreach (GUnit cur in units) { GUnit unit = cur.Target; if (cur.Reaction != GReaction.Friendly || !cur.IsInCombat || unit == null) { continue; } if (!unit.IsDead && unit.Reaction != GReaction.Friendly && unit.IsInCombat && unit.DistanceToSelf < Distance && !ppather.IsBlacklisted(unit) && !PPather.IsStupidItem(unit)) { Location ml = new Location(unit.Location); float dz = (float)Math.Abs(ml.Z - me_z); if (dz < 30.0f) { if (PPather.world.IsUnderwaterOrInAir(ml)) { PPather.WriteLine(unit.Name + " is underwater or flying"); ppather.Blacklist(unit); } else { if (closest == null || unit.DistanceToSelf < closest.DistanceToSelf) { closest = unit; } } } } } //PPather.WriteLine("Returning unit: " + (closest == null ? "null" : closest.Name)); return(closest); }
public override bool Do() { int option = 0; int maxtries = 3; // ToDo: Have this use GossipFrame.ClickOptionText(). while (maxtries > 0) { Functions.Interact(npc); Thread.Sleep(5000); if (GossipFrame.IsVisible()) { //PPather.WriteLine(this.name + ": attempt to skip gossip"); GInterfaceObject[] options = GossipFrame.VisibleOptions(); if (option >= options.Length) { PPather.WriteLine("Queue: no battleground option in gossip frame"); return(true); } GossipFrame.ClickOption(options[option]); option++; Thread.Sleep(1000); } if (BattlefieldFrame.IsVisible()) { PPather.WriteLine("Queue: got battlefield frame"); if (BattlefieldFrame.IsJoin()) { BattlefieldFrame.Join(); BGQueueTaskManager.SetQueueState(battlefield, MiniMapBattlefieldFrameState.Queue); Thread.Sleep(3000); } else { PPather.WriteLine("Queue: can't join, no button?"); } BattlefieldFrame.Close(); Thread.Sleep(1000); return(true); } else { GContext.Main.SendKey("Common.Escape"); // Close whatever frame popped up } maxtries--; } return(true); }