예제 #1
0
 public static bool HasBetterBag()
 {
     GItem[] Items = GObjectList.GetItems();
     foreach (GItem Item in Items)
     {
         if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID))
         {
             GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);
             if (bag != null)
             {
                 long[] AllBags = GPlayerSelf.Me.Bags;
                 foreach (long CurrentBag in AllBags)
                 {
                     GContainer cbag = (GContainer)GObjectList.FindObject(CurrentBag);
                     if (cbag != null)
                     {
                         if (cbag.SlotCount < bag.SlotCount && !cbag.Name.ToString().ToLower().Contains("ammo") && !cbag.Name.ToString().ToLower().Contains("quiver"))
                         {
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
예제 #2
0
파일: Character.cs 프로젝트: uvbs/babbot
 private static string G2I(long guid)
 {
     GObject[] items = GObjectList.GetItems();
     foreach (GObject item in items)
     {
         if (item.GUID.Equals(guid))
         {
             return(item.Name);
         }
     }
     return(null);
 }
예제 #3
0
 public static GItem GetItem(string name)
 {
     GItem[] Items = GObjectList.GetItems();
     foreach (GItem Item in Items)
     {
         if (Item.Name.Equals(name))
         {
             return(Item);
         }
     }
     return(null);
 }
예제 #4
0
        private GItem FindItem()
        {
            GItem[] items = GObjectList.GetItems();
            foreach (GItem i in items)
            {
                if (i.Name == Item)
                {
                    return(i);
                }
            }

            return(null);
        }
예제 #5
0
 public static bool EquipBetterBag()
 {
     GItem[] Items = GObjectList.GetItems();
     foreach (GItem Item in Items)
     {
         if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID))
         {
             GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);
             if (bag != null)
             {
                 long[] AllBags = GPlayerSelf.Me.Bags;
                 for (int i = 0; i < AllBags.Length; i++)
                 {
                     GContainer cbag = (GContainer)GObjectList.FindObject(AllBags[i]);
                     if (cbag != null)
                     {
                         if (cbag.SlotCount < bag.SlotCount && !cbag.Name.ToString().ToLower().Contains("ammo") && !cbag.Name.ToString().ToLower().Contains("quiver"))
                         {
                             GInterfaceObject OldBag = GContext.Main.Interface.GetByName("CharacterBag" + i + "Slot");
                             BagManager       bm     = new BagManager();
                             bm.ClickItem(Item, false);
                             Functions.Click(OldBag, false);
                             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);
                                     }
                                 }
                             }
                             return(true);
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
예제 #6
0
 public static bool EquipNewBag()
 {
     if (HasFreeBagSlot())
     {
         GItem[] Items = GObjectList.GetItems();
         foreach (GItem Item in Items)
         {
             if (Item.Type.ToString() == "Container" && !IsEquippedBag(Item.GUID))
             {
                 GContainer bag = (GContainer)GObjectList.FindObject(Item.GUID);
                 if (bag != null)
                 {
                     BagManager bm = new BagManager();
                     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);
                 }
             }
         }
     }
     return(false);
 }
예제 #7
0
        public static void CompareAndEquipBags(EasyItem[] C)
        {
            RankedBag[] RankedBags = new RankedBag[C.Length + 4];
            //PPather.WriteLine(String.Format("AutoEquip: RankedBags.Length = {0}", RankedBags.Length));
            //PPather.WriteLine(String.Format("AutoEquip: containers.Count = {0}", C.Length));
            //PPather.WriteLine(String.Format("AutoEquip: GPlayerSelf.Me.Bags.Length = {0}", 4));

            /* add bags found in inventory */
            GItem[]     Items = GObjectList.GetItems();
            List <long> added = new List <long>();
            int         nr    = 0;

            for (nr = 0; nr < C.Length; nr++)
            {
                if (!Inventory.IsEquippedBag(C[nr].GUID) && !added.Contains(C[nr].GUID))
                {
                    GContainer bag      = (GContainer)GObjectList.FindObject(C[nr].GUID);
                    string     SlotName = Inventory.GetBagSlotName(C[nr].GItem);
                    RankedBag  b        = new RankedBag(1, bag.SlotCount, bag, C[nr].GItem, SlotName);
                    RankedBags[nr] = b;
                    //PPather.WriteLine("AutoEquip: (inventory) RankedBags[{0}] = {1} (SlotCount={2}, GUID={3})", nr, C[nr].Item.Name, bag.SlotCount, C[nr].GUID);
                    added.Add(C[nr].GUID);
                }
            }

            /* add already equipped bags */
            nr = C.Length;
            foreach (GItem Item in Items)
            {
                if (Item.Type.ToString() == "Container" && Inventory.IsEquippedBag(Item.GUID) && !added.Contains(Item.GUID))
                {
                    GContainer bag      = (GContainer)GObjectList.FindObject(Item.GUID);
                    string     SlotName = Inventory.GetBagSlotName(Item);
                    RankedBag  b        = new RankedBag(0, bag.SlotCount, bag, Item, SlotName);
                    RankedBags[nr] = b;
                    //PPather.WriteLine("AutoEquip: (eqiupped) RankedBags[{0}] = {1} (SlotCount={2}, GUID={3})", nr, Item.Name, bag.SlotCount, Item.GUID);
                    added.Add(Item.GUID);
                    nr++;
                }
            }

            /* add the empty slots */
            int freeslots = 0;

            while (nr < (C.Length + 4))
            {
                RankedBag b = new RankedBag(0, 0, null, null, null);
                RankedBags[nr] = b;
                nr++;
                freeslots++;
            }

            /* sort bags on slotcount */
            Array.Sort(RankedBags);

            /* DEBUG print of ranks */
            //for (int k = 0; k < RankedBags.Length; k++)
            //{
            //    RankedBag rb = RankedBags[k];
            //    if (rb != null)
            //    {
            //        string name = "null";
            //        if (rb.item != null) name = rb.item.Name;
            //        PPather.WriteLine(String.Format("AutoEquip: Rank {0} => {1}({2})", k, name, rb.slots));
            //    }
            //}

            /* get the bag slot names to replace (reverse sort) */
            List <string> slots = new List <string>();

            for (int j = RankedBags.Length - 1; j >= 0; j--)
            {
                RankedBag r = RankedBags[j];
                if (r == null)
                {
                    continue;
                }
                if (r.slotname == null)
                {
                    continue;
                }
                string name = "null";
                if (r.item != null)
                {
                    name = r.item.Name;
                }
                slots.Add(r.slotname);
                //PPather.WriteLine("AutoEquip: Rank {0} of BagSlot to replace is {1} ({2})", slots.Count, r.slotname, name);
            }
            String[] BagSlots         = slots.ToArray();
            int      ReplaceSlotIndex = 0;

            /* go through RankedBags and make sure the top 4 ranked bags are equipped */
            int index = 0; int equipped = 0;

            while (index < 4)
            {
                //PPather.WriteLine("AutoEquip: index={0}, equipped={1}, freeslots={2}", index, equipped, freeslots);
                RankedBag r = RankedBags[index];
                if (r != null)
                {
                    string name = "null";
                    if (r.item != null)
                    {
                        name = r.item.Name;
                    }
                    if (r.location == 0)
                    {
                        //PPather.WriteLine("AutoEquip: {0} rank[{1}] is equipped", name, index);
                    }
                    else if (freeslots > 0)
                    {
                        //PPather.WriteLine("AutoEquip: {0} rank[{1}] is new bag", name, index);
                        EquipBag(r.item, true, null);
                        equipped++;
                        freeslots--;
                    }
                    else
                    {
                        //PPather.WriteLine("AutoEquip: {0} rank[{1}] is better bag", name, index);
                        EquipBag(r.item, false, BagSlots[ReplaceSlotIndex]);
                        equipped++;
                        ReplaceSlotIndex++;
                    }
                }
                index++;
            }
        }