Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 public NPCInteractTask(PPather pather, NodeTask node)
     : base(pather, node)
 {
     NPC      = node.GetValueOfId("NPC").GetStringValue();
     location = node.GetValueOfId("Location").GetLocationValue();
     UseMount = node.GetBoolValueOfId("UseMount");
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 public static bool CompareGear(EasyItem E, string item)
 {
     eq_item_score  = 0;
     new_item_score = 0;
     if (!initialized)
     {
         return(false);
     }
     if (E == null && E.Item == null)
     {
         return(false);
     }
     if (IsEquippable(E))
     {
         if (IsWanted(E))
         {
             if (!IsProtected(E))
             {
                 if (IsUsable(E))
                 {
                     PPather.Debug("CompareGear: checking {0} (Type={1}, SubType={2}, Slot={3})", E.RealName, E.Item.Type, E.Item.SubType, E.Item.Slot);
                     return(Compare(E, item));
                 }
             }
         }
     }
     return(false);
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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));
        }
Esempio n. 10
0
        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]);
                }
            }
        }
Esempio n. 11
0
        public static bool ClickOptionText(string text)
        {
            GInterfaceObject[] options = VisibleOptions();
            if (options.Length < 1)
            {
                return(false);
            }


            PPather.Debug("ClickOptionText() options.Length={0}, text={1}", options.Length, text);

            foreach (GInterfaceObject button in options)
            {
                if (button != null && button.IsVisible && Functions.LogCleaner(button.LabelText).ToLower().Contains(text.ToLower()))
                {
                    Functions.Click(button);
                    return(true);
                }
                foreach (GInterfaceObject child in button.Children)
                {
                    if (child != null && child.IsVisible && Functions.LogCleaner(child.LabelText).ToLower().Contains(text.ToLower()))
                    {
                        Functions.Click(button);
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
 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);
     }
 }
Esempio n. 15
0
        // 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);
        }
Esempio n. 16
0
 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);
     }
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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]);
                }
            }
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
 public UntilTask(PPather pather, NodeTask node)
     : base(pather, node)
 {
     if (node.subTasks.Count == 1)
     {
         childTask = pather.CreateTaskFromNode(node.subTasks[0], this);
     }
 }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
 public TaxiTask(PPather pather, NodeTask node)
     : base(pather, node)
 {
     if (GetLocationOfNPC() == null)
     {
         PPather.WriteLine("*** NPC " + NPC + " is unknown");
     }
 }
Esempio n. 25
0
 public static void Dismount()
 {
     if (IsMounted())
     {
         PPather.WriteLine("Dismounting");
         GContext.Main.SendKey("Common.Mount");
     }
 }
Esempio n. 26
0
        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));
        }
Esempio n. 27
0
        public RestTask(PPather pather, NodeTask node)
            : base(pather, node)
        {
            RestHealth = GContext.Main.RestHealth;
            RestMana   = GContext.Main.RestMana;

            PPather.WriteLine("Rest  health: " + RestHealth + " mana: " + RestMana);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
 public override bool IsFinished()
 {
     if (PPather.GetQuestStatus(ID) == "completed" || PPather.GetQuestStatus(ID) == "failed" || PPather.GetQuestStatus(ID) == "completedr")
     {
         return(true);
     }
     return(false);
 }
Esempio n. 30
0
 public override bool ActivityDone(Activity task)
 {
     PPather.WriteLine("ActDone need next");
     currentHotSpot = GetNextLocation();
     currentWalker  = null;
     task.Stop();
     return(false);
 }