Exemple #1
0
        internal static void LogJunkItems(CacheACDItem thisgooditem, PluginBaseItemTypes thisPluginBaseItemTypes, PluginItemTypes thisPluginItemType)
        {
            FileStream LogStream  = null;
            string     outputPath = FolderPaths.LoggingFolderPath + @"\JunkLog.log";

            try
            {
                LogStream = File.Open(outputPath, FileMode.Append, FileAccess.Write, FileShare.Read);
                using (StreamWriter LogWriter = new StreamWriter(LogStream))
                {
                    if (!TownRunManager.bLoggedJunkThisStash)
                    {
                        TownRunManager.bLoggedJunkThisStash = true;
                        LogWriter.WriteLine(DateTime.Now.ToString() + ":");
                        LogWriter.WriteLine("====================");
                    }
                    string sLegendaryString = "";
                    if (thisgooditem.ThisQuality >= ItemQuality.Legendary)
                    {
                        sLegendaryString = " {legendary item}";
                    }
                    LogWriter.WriteLine(thisgooditem.ThisQuality.ToString() + " " + thisPluginItemType.ToString() + " '" + thisgooditem.ThisRealName + sLegendaryString);
                    LogWriter.Write(thisgooditem.ItemStatProperties.ReturnPrimaryStatString());
                    LogWriter.WriteLine("");
                }
            }
            catch (IOException)
            {
                DBLog.Info("Fatal Error: File access error for junk log file.");
            }
        }
Exemple #2
0
 public DebugItemDataEntry(CacheACDItem item)
 {
     SNOID   = item.SNO;
     Name    = FormatString(item.ThisRealName);
     Type    = item.ItemType;
     Quality = (PluginItemQuality)Enum.Parse(typeof(PluginItemQuality), item.ThisQuality.ToString());
 }
        public static RunStatus InteractionClickBehavior(object ret)
        {
            if (FunkyGame.GameIsInvalid)
            {
                Logger.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)");
                return(RunStatus.Failure);
            }

            if (!UIElements.InventoryWindow.IsVisible)
            {
                Backpack.InventoryBackPackToggle(true);
                return(RunStatus.Running);
            }

            //Interact with items..
            if (InteractItems.Count > 0)
            {
                if (!TownRunItemLoopsTest(2.5))
                {
                    return(RunStatus.Running);
                }

                CacheACDItem thisitem = InteractItems.FirstOrDefault();

                if (thisitem != null)
                {
                    ZetaDia.Me.Inventory.UseItem(thisitem.ThisDynamicID);
                    if (thisitem.ItemType == PluginItemTypes.HoradricCache && FunkyGame.CurrentStats != null)
                    {
                        //Bot.Game.CurrentGameStats.CurrentProfile.HoradricCacheOpened++;
                        FunkyGame.CurrentStats.CurrentProfile.HoradricCacheOpened++;
                    }
                }
                if (thisitem != null)
                {
                    InteractItems.Remove(thisitem);
                }
                if (InteractItems.Count > 0)
                {
                    return(RunStatus.Running);
                }
            }

            //Add a long wait after interaction!
            if (!TownRunItemLoopsTest(10))
            {
                return(RunStatus.Running);
            }

            //Reset so we can loot!
            FunkyGame.Targeting.Cache.bFailedToLootLastItem = false;
            Logger.DBLog.Info("Interaction Town Run Clicky Finished.");
            return(RunStatus.Success);
        }
Exemple #4
0
        public void CheckEntry(CacheACDItem entry)
        {
            var d = new DebugItemDataEntry(entry);

            if (ItemsData.Entries.Contains(d))
            {
                return;
            }
            ItemsData.Entries.Add(d);
            DebugData_Items.SerializeToXML(ItemsData);
        }
Exemple #5
0
 public void SalvagedItemLog(CacheACDItem i)
 {
     if (i.ThisQuality == ItemQuality.Legendary)
     {
         Legendary.Salvaged++;
     }
     else if (i.ThisQuality > ItemQuality.Magic3)
     {
         Rare.Salvaged++;
     }
     else
     {
         Magical.Salvaged++;
     }
 }
Exemple #6
0
        private static void LogSalvagedItem(CacheACDItem item)
        {
            // Item log for cool stuff stashed
            PluginItemTypes     OriginalGilesItemType = ItemFunc.DetermineItemType(item);
            PluginBaseItemTypes thisGilesBaseType     = ItemFunc.DetermineBaseType(OriginalGilesItemType);

            if (thisGilesBaseType == PluginBaseItemTypes.WeaponTwoHand || thisGilesBaseType == PluginBaseItemTypes.WeaponOneHand || thisGilesBaseType == PluginBaseItemTypes.WeaponRange ||
                thisGilesBaseType == PluginBaseItemTypes.Armor || thisGilesBaseType == PluginBaseItemTypes.Jewelry || thisGilesBaseType == PluginBaseItemTypes.Offhand ||
                thisGilesBaseType == PluginBaseItemTypes.FollowerItem)
            {
                FunkyTownRunPlugin.LogJunkItems(item, thisGilesBaseType, OriginalGilesItemType);
            }
            if (FunkyGame.CurrentStats != null)
            {
                FunkyGame.CurrentStats.CurrentProfile.LootTracker.SalvagedItemLog(item);
            }
        }
Exemple #7
0
        internal static bool SalvageValidation(CacheACDItem thisitem)
        {
            if (!thisitem.IsSalvagable)
            {
                return(false);
            }

            //Only Check items we can actually salvage!
            if (thisitem.BaseItemType == PluginBaseItemTypes.FollowerItem || thisitem.BaseItemType == PluginBaseItemTypes.Armor ||
                thisitem.BaseItemType == PluginBaseItemTypes.Jewelry || thisitem.BaseItemType == PluginBaseItemTypes.Offhand ||
                thisitem.BaseItemType == PluginBaseItemTypes.WeaponOneHand || thisitem.BaseItemType == PluginBaseItemTypes.WeaponRange ||
                thisitem.BaseItemType == PluginBaseItemTypes.WeaponTwoHand)
            {
                if (thisitem.ThisQuality == ItemQuality.Legendary)
                {
                    if (FunkyTownRunPlugin.PluginSettings.SalvageLegendaryItemLevel > 0)
                    {
                        return(FunkyTownRunPlugin.PluginSettings.SalvageLegendaryItemLevel <= thisitem.ThisLevel);
                    }
                }
                else if (thisitem.ThisQuality == ItemQuality.Rare4 || thisitem.ThisQuality == ItemQuality.Rare5 || thisitem.ThisQuality == ItemQuality.Rare6)
                {
                    if (FunkyTownRunPlugin.PluginSettings.SalvageRareItemLevel > 0)
                    {
                        return(FunkyTownRunPlugin.PluginSettings.SalvageRareItemLevel <= thisitem.ThisLevel);
                    }
                }
                else if (thisitem.ThisQuality == ItemQuality.Magic1 || thisitem.ThisQuality == ItemQuality.Magic2 || thisitem.ThisQuality == ItemQuality.Magic3)
                {
                    if (FunkyTownRunPlugin.PluginSettings.SalvageMagicItemLevel > 0)
                    {
                        return(FunkyTownRunPlugin.PluginSettings.SalvageMagicItemLevel <= thisitem.ThisLevel);
                    }
                }
                else if (thisitem.ThisQuality == ItemQuality.Superior || thisitem.ThisQuality == ItemQuality.Inferior || thisitem.ThisQuality == ItemQuality.Normal)
                {
                    if (FunkyTownRunPlugin.PluginSettings.SalvageWhiteItemLevel > 0)
                    {
                        return(FunkyTownRunPlugin.PluginSettings.SalvageWhiteItemLevel <= thisitem.ThisLevel);
                    }
                }
            }
            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
Exemple #8
0
        private List <CacheACDItem> GetGemCacheACDItems()
        {
            List <CacheACDItem> Gems = new List <CacheACDItem>();

            foreach (var gem in ZetaDia.Actors.GetActorsOfType <ACDItem>().Where(item => item.ItemType == ItemType.LegendaryGem))
            {
                var cItem = new CacheACDItem(gem);
                //double SuccessRate = ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, cItem.LegendaryGemRank);
                if (GRiftLevel - cItem.LegendaryGemRank == -7)
                {
                    continue;
                }
                //if (SuccessRate < FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate) continue;
                Gems.Add(new CacheACDItem(gem));
            }

            return(Gems);
        }
Exemple #9
0
 public void SalvagedItemLog(CacheACDItem i)
 {
     if (i.ThisQuality == ItemQuality.Legendary)
     {
         //Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[3]++;
         Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Legendary.Salvaged++;
     }
     else if (i.ThisQuality > ItemQuality.Magic3)
     {
         // Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[2]++;
         Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Rare.Salvaged++;
     }
     else
     {
         //  Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[1]++;
         Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Magical.Salvaged++;
     }
 }
Exemple #10
0
        private void btnRefreshCharacterInventory_Click(object sender, EventArgs e)
        {
            if (BotMain.IsRunning)
            {
                return;
            }
            cacheItems.Clear();
            flowLayout_OutPut.Controls.Clear();

            try
            {
                using (ZetaDia.Memory.SaveCacheState())
                {
                    ZetaDia.Memory.DisableCache();
                    ZetaDia.Actors.Update();
                    flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(
                                                       String.Format("Total Items Found {0}", ZetaDia.Me.Inventory.Backpack.Count())));

                    #region Character Inventory Items
                    foreach (var o in ZetaDia.Me.Inventory.Backpack)
                    {
                        try
                        {
                            CacheACDItem item = new CacheACDItem(o);
                            flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(item.ToString()));
                        }
                        catch (Exception ex)
                        {
                            flowLayout_OutPut.Controls.Add(new UserControlDebugEntry(ex.Message));
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
            }

            flowLayout_OutPut.Focus();
        }
Exemple #11
0
        private static List <CacheACDItem> ReturnCurrentEquippedItems()
        {
            var returnItems = new List <CacheACDItem>();

            try
            {
                using (ZetaDia.Memory.AcquireFrame())
                {
                    ZetaDia.Actors.Update();

                    foreach (ACDItem item in ZetaDia.Me.Inventory.Equipped)
                    {
                        var thiscacheditem = new CacheACDItem(item);
                        returnItems.Add(thiscacheditem);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(returnItems);
        }
Exemple #12
0
        private List <CacheACDItem> GetGemCacheACDItems(List <int> Acdguids)
        {
            List <CacheACDItem> GemList = new List <CacheACDItem>();

            foreach (var item in ZetaDia.Actors.GetActorsOfType <ACDItem>().Where(item => Acdguids.Contains(item.ACDGuid)))
            {
                CacheACDItem cItem       = new CacheACDItem(item);
                double       SuccessRate = ItemFunc.GetLegendaryGemUpgradeChance(GRiftLevel, cItem.LegendaryGemRank);
                if (GRiftLevel - cItem.LegendaryGemRank == -7)
                {
                    continue;
                }
                if (SuccessRate < FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate)
                {
                    continue;
                }
                //if (SuccessRate < FunkyBaseExtension.Settings.AdventureMode.GemUpgradingMinimumSuccessRate) continue;

                GemList.Add(cItem);
            }

            return(GemList);
        }
Exemple #13
0
        internal static void LogJunkItems(CacheACDItem thisgooditem, GilesBaseItemType thisgilesbaseitemtype, GilesItemType thisgilesitemtype, double ithisitemvalue)
        {
            FileStream LogStream = null;

            try
            {
                LogStream = File.Open(LoggingFolderPath + LoggingPrefixString + " -- JunkLog.log", FileMode.Append, FileAccess.Write, FileShare.Read);
                using (StreamWriter LogWriter = new StreamWriter(LogStream))
                {
                    if (!TownRunManager.bLoggedJunkThisStash)
                    {
                        TownRunManager.bLoggedJunkThisStash = true;
                        LogWriter.WriteLine(DateTime.Now.ToString() + ":");
                        LogWriter.WriteLine("====================");
                    }
                    string sLegendaryString = "";
                    if (thisgooditem.ThisQuality >= ItemQuality.Legendary)
                    {
                        sLegendaryString = " {legendary item}";
                    }
                    LogWriter.WriteLine(thisgilesbaseitemtype.ToString() + " - " + thisgilesitemtype.ToString() + " '" + thisgooditem.ThisRealName + "'. Score = " + Math.Round(ithisitemvalue).ToString() + sLegendaryString);
                    if (!String.IsNullOrEmpty(TownRunManager.sJunkItemStatString))
                    {
                        LogWriter.WriteLine("  " + TownRunManager.sJunkItemStatString);
                    }
                    else
                    {
                        LogWriter.WriteLine("  (no scorable attributes)");
                    }
                    LogWriter.WriteLine("");
                }
            }
            catch (IOException)
            {
                DBLog.Info("Fatal Error: File access error for junk log file.");
            }
        }
Exemple #14
0
        private ACDItem GetKeystoneItem()
        {
            IEnumerable <ACDItem> itemEnumerableSource = ZetaDia.Me.Inventory.Backpack;
            List <CacheACDItem>   items = new List <CacheACDItem>();

            foreach (var i in itemEnumerableSource)
            {
                if (i.BaseAddress != IntPtr.Zero)
                {
                    CacheACDItem cacheitem = new CacheACDItem(i);
                    items.Add(cacheitem);
                }
            }

            if (KeyType == KeystoneType.Tiered)
            {
                if (!KeyStoneHighest)
                {
                    items = items.OrderBy(i => i.KeystoneRank).ToList();
                }
                else
                {
                    items = items.OrderByDescending(i => i.KeystoneRank).ToList();
                }
            }

            foreach (var tempitem in items)
            {
                if (tempitem.ItemType == PluginItemTypes.KeyStone)
                {
                    int tieredLevel = tempitem.KeystoneRank;
                    if (KeyType == KeystoneType.Fragment)
                    {
                        if (tieredLevel == -1)
                        {
                            return(tempitem.ACDItem);
                        }

                        continue;
                    }

                    if (KeyType == KeystoneType.Trial)
                    {
                        if (tieredLevel == 0)
                        {
                            return(tempitem.ACDItem);
                        }

                        continue;
                    }

                    if (KeyType == KeystoneType.Tiered)
                    {
                        if (tieredLevel > 0 && tieredLevel <= FunkyBaseExtension.Settings.AdventureMode.MaximumTieredRiftKeyAllowed)
                        {
                            return(tempitem.ACDItem);
                        }
                    }
                }
            }

            return(null);
        }
Exemple #15
0
        internal static RunStatus SellInteraction(object ret)
        {
            if (FunkyGame.GameIsInvalid)
            {
                ActionsChecked = false;
                FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)");
                return(RunStatus.Failure);
            }

            BotMain.StatusText = "Town run: Vendor Routine Interaction";

            if (!UIElements.VendorWindow.IsVisible)
            {
                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Town Run Vednor Behavior Failed! (Vendor Window not visible)");
                return(RunStatus.Failure);
            }


            #region SellItem
            if (townRunItemCache.SellItems.Count > 0)
            {
                BotMain.StatusText = "Town run: Vendor Routine Interaction Selling Items";

                if (!Delay.Test())
                {
                    return(RunStatus.Running);
                }

                CacheACDItem thisitem = townRunItemCache.SellItems.FirstOrDefault();
                // Item log for cool stuff sold
                if (thisitem != null)
                {
                    PluginItemTypes     OriginalPluginItemType = ItemFunc.DetermineItemType(thisitem);
                    PluginBaseItemTypes thisGilesBaseType      = ItemFunc.DetermineBaseType(OriginalPluginItemType);
                    if (thisGilesBaseType == PluginBaseItemTypes.WeaponTwoHand || thisGilesBaseType == PluginBaseItemTypes.WeaponOneHand || thisGilesBaseType == PluginBaseItemTypes.WeaponRange ||
                        thisGilesBaseType == PluginBaseItemTypes.Armor || thisGilesBaseType == PluginBaseItemTypes.Jewelry || thisGilesBaseType == PluginBaseItemTypes.Offhand ||
                        thisGilesBaseType == PluginBaseItemTypes.FollowerItem)
                    {
                        FunkyTownRunPlugin.LogJunkItems(thisitem, thisGilesBaseType, OriginalPluginItemType);
                    }

                    //FunkyTownRunPlugin.TownRunStats.VendoredItemLog(thisitem);
                    if (FunkyGame.CurrentStats != null)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.VendoredItemLog(thisitem);
                    }
                    ZetaDia.Me.Inventory.SellItem(thisitem.ACDItem);
                }
                if (thisitem != null)
                {
                    townRunItemCache.SellItems.Remove(thisitem);
                }
                if (townRunItemCache.SellItems.Count > 0)
                {
                    return(RunStatus.Running);
                }
            }
            #endregion

            #region BuyPotion
            //Check if settings for potion buy is enabled, with less than 99 potions existing!
            if (bBuyingPotions)
            {
                BotMain.StatusText = "Town run: Sell Routine Interaction Buying Potions";
                if (PotionCount >= FunkyTownRunPlugin.PluginSettings.PotionsCount)
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Potion Count Greater Than Setting) Count {0} Setting {1}", PotionCount, FunkyTownRunPlugin.PluginSettings.PotionsCount);
                    bBuyingPotions = false;
                    return(RunStatus.Running);
                }

                //Obey the timer, so we don't buy 100 potions in 3 seconds.
                if (!Delay.Test(1.5))
                {
                    return(RunStatus.Running);
                }


                //Update Dynamic ID
                if (PotionDynamicID == 0)
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion updating Dynamic ID!");

                    foreach (ACDItem item in ZetaDia.Me.Inventory.MerchantItems)
                    {
                        if (item.IsPotion)
                        {
                            PotionMerchantACDItem = item;
                            PotionDynamicID       = item.DynamicId;
                            break;
                        }
                    }

                    //Check we found a potion..
                    if (PotionDynamicID == 0)
                    {
                        FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Failed to find Potion Dynamic ID)");
                        bBuyingPotions = false;
                    }
                    else
                    {
                        FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Buying Potion Dynamic ID {0}", PotionDynamicID);
                    }

                    return(RunStatus.Running);
                }


                //Check we have enough gold!
                if (PotionMerchantACDItem.Gold > ZetaDia.CPlayer.Coinage)
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Potion Buying Finished (Not Enough Gold to buy Potions)");
                    bBuyingPotions = false;
                    return(RunStatus.Running);
                }

                FunkyTownRunPlugin.DBLog.DebugFormat("[Funky] Vendor Buying Potion!");
                ZetaDia.Actors.Me.Inventory.BuyItem(PotionDynamicID);
                //Update counter
                PotionCount++;
                return(RunStatus.Running);
            }

            #endregion

            if (bNeedsEquipmentRepairs)
            {
                BotMain.StatusText = "Town run: Vendor Routine Interaction Repairing";

                if (!Delay.Test())
                {
                    return(RunStatus.Running);
                }

                //int playerCoinage = ZetaDia.Me.Inventory.Coinage;
                //int repairCost = ZetaDia.Me.Inventory.GetRepairCost(false);
                //if (playerCoinage > 0 && playerCoinage < repairCost)
                //{
                //    FunkyTownRunPlugin.DBLog.InfoFormat("Emergency Stop: You need repairs but don't have enough money. Current Coinage {0} -- Repair Cost {1}", playerCoinage, repairCost);
                //    BotMain.Stop(false, "Not enough gold to repair item(s)!");
                //}

                ZetaDia.Me.Inventory.RepairEquippedItems();
                bNeedsEquipmentRepairs = false;
            }



            return(RunStatus.Success);
        }
Exemple #16
0
        }         // Custom stashing routine

        private bool BackpackStashAttempt(CacheACDItem item, out int[] XY)
        {
            XY = new[] { -1, -1 };

            int                 iPlayerDynamicID       = ZetaDia.Me.CommonData.DynamicId;
            int                 iOriginalGameBalanceId = item.ThisBalanceID;
            int                 iOriginalDynamicID     = item.ThisDynamicID;
            int                 iOriginalStackQuantity = (int)item.ThisItemStackQuantity;
            string              sOriginalItemName      = item.ThisRealName;
            string              sOriginalInternalName  = item.ThisInternalName;
            PluginItemTypes     OriginalPluginItemType = ItemFunc.DetermineItemType(item);
            PluginBaseItemTypes thisGilesBaseType      = ItemFunc.DetermineBaseType(OriginalPluginItemType);
            bool                bOriginalTwoSlot       = item.IsTwoSlot;
            bool                bOriginalIsStackable   = item.IsStackableItem;
            int                 iAttempts;

            if (_dictItemStashAttempted.TryGetValue(iOriginalDynamicID, out iAttempts))
            {
                Logger.DBLog.InfoFormat("GSError: Detected a duplicate stash attempt, DB item mis-read error, now forcing this item as a 2-slot item");
                _dictItemStashAttempted[iOriginalDynamicID] = iAttempts + 1;
                bOriginalTwoSlot     = true;
                bOriginalIsStackable = false;
                if (iAttempts > 6)
                {
                    Logger.DBLog.InfoFormat("GSError: Detected an item stash loop risk, now re-mapping stash treating everything as 2-slot and re-attempting");
                    // Array for what blocks are or are not blocked
                    for (int iRow = 0; iRow <= 5; iRow++)
                    {
                        for (int iColumn = 0; iColumn <= 9; iColumn++)
                        {
                            BackpackSlotBlocked[iColumn, iRow] = false;
                        }
                    }
                    // Block off the entire of any "protected stash pages"
                    foreach (InventorySquare iProtPage in CharacterSettings.Instance.ProtectedBagSlots)
                    {
                        BackpackSlotBlocked[iProtPage.Column, iProtPage.Row] = true;
                    }

                    // Map out all the items already in the stash
                    foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack)
                    {
                        if (tempitem.BaseAddress != IntPtr.Zero)
                        {
                            CacheACDItem tempCacheItem = new CacheACDItem(tempitem);

                            int inventoryRow    = tempCacheItem.invRow;
                            int inventoryColumn = tempCacheItem.invCol;
                            // Mark this slot as not-free
                            BackpackSlotBlocked[inventoryColumn, inventoryRow] = true;
                            // Try and reliably find out if this is a two slot item or not
                            //BackpackSlotBlocked[inventoryColumn, inventoryRow + 1] = true;
                            if (inventoryRow != 5 && tempCacheItem.IsTwoSlot)
                            {
                                BackpackSlotBlocked[inventoryColumn, inventoryRow + 1] = true;
                            }
                        }
                    }
                }
                if (iAttempts > 15)
                {
                    Logger.DBLog.InfoFormat("***************************");
                    Logger.DBLog.InfoFormat("GSError: Emergency Stop: No matter what we tried, we couldn't prevent an infinite stash loop. Sorry. Now stopping the bot.");
                    BotMain.Stop();
                    return(false);
                }
            }
            else
            {
                _dictItemStashAttempted.Add(iOriginalDynamicID, 1);
            }
            // Safety incase it's not actually in the backpack anymore

            /*if (item.InventorySlot != InventorySlot.PlayerBackpack)
             * {
             *       FunkyTownRunPlugin.DBLog.InfoFormat("GSError: Diablo 3 memory read error, or item became invalid [StashAttempt-4]", true);
             *       return false;
             * }*/
            int iLeftoverStackQuantity;


            int iPointX = -1;
            int iPointY = -1;

            // First check if we can top-up any already-existing stacks in the stash
            if (bOriginalIsStackable)
            {
                foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack)
                {
                    if (tempitem.BaseAddress == IntPtr.Zero)
                    {
                        Logger.DBLog.InfoFormat("GSError: Diablo 3 memory read error, or stash item became invalid [StashAttempt-5]");
                        return(false);
                    }
                    // Check if we combine the stacks, we won't overfill them
                    if ((tempitem.GameBalanceId == iOriginalGameBalanceId) && (tempitem.ItemStackQuantity < tempitem.MaxStackCount))
                    {
                        iLeftoverStackQuantity = (int)((tempitem.ItemStackQuantity + iOriginalStackQuantity) - tempitem.MaxStackCount);
                        iPointX = tempitem.InventoryColumn;
                        iPointY = tempitem.InventoryRow;

                        // Will we have leftovers?
                        if (iLeftoverStackQuantity <= 0)
                        {
                            goto FoundStashLocation;
                        }
                        goto HandleStackMovement;
                    }
                }
HandleStackMovement:
                if ((iPointX >= 0) && (iPointY >= 0))
                {
                    ZetaDia.Me.Inventory.MoveItem(iOriginalDynamicID, iPlayerDynamicID, InventorySlot.BackpackItems, iPointX, iPointY);
                }
            }
            iPointX = -1;
            iPointY = -1;
            // If it's a 2-square item, find a double-slot free
            if (bOriginalTwoSlot)
            {
                for (int iRow = 0; iRow <= 5; iRow++)
                {
                    bool bBottomPageRow = iRow == 5;
                    for (int iColumn = 0; iColumn <= 9; iColumn++)
                    {
                        // If nothing in the 1st row
                        if (!BackpackSlotBlocked[iColumn, iRow])
                        {
                            bool bNotEnoughSpace = false;
                            // Bottom row of a page = no room
                            if (bBottomPageRow)
                            {
                                bNotEnoughSpace = true;
                            }
                            // Already something in the stash in the 2nd row)
                            else if (BackpackSlotBlocked[iColumn, iRow + 1])
                            {
                                bNotEnoughSpace = true;
                            }
                            if (!bNotEnoughSpace)
                            {
                                iPointX = iColumn;
                                iPointY = iRow;
                                goto FoundStashLocation;
                            }
                        }
                    }
                }
            }             // 2 slot item?
            // Now deal with any leftover 1-slot items
            else
            {
                // First we try and find somewhere "sensible"
                for (int iRow = 0; iRow <= 5; iRow++)
                {
                    bool bTopPageRow    = iRow == 0;
                    bool bBottomPageRow = (iRow == 5);
                    for (int iColumn = 0; iColumn <= 9; iColumn++)
                    {
                        // Nothing in this slot
                        if (!BackpackSlotBlocked[iColumn, iRow])
                        {
                            bool bSensibleLocation = false;
                            if (!bTopPageRow && !bBottomPageRow)
                            {
                                // Something above and below this slot, or an odd-numbered row, so put something here
                                if ((BackpackSlotBlocked[iColumn, iRow + 1] && BackpackSlotBlocked[iColumn, iRow - 1]) ||
                                    (iRow) % 2 != 0)
                                {
                                    bSensibleLocation = true;
                                }
                            }
                            // Top page row with something directly underneath already blocking
                            else if (bTopPageRow)
                            {
                                if (BackpackSlotBlocked[iColumn, iRow + 1])
                                {
                                    bSensibleLocation = true;
                                }
                            }
                            // Bottom page row with something directly over already blocking
                            else
                            {
                                bSensibleLocation = true;
                            }
                            // Sensible location? Yay, stash it here!
                            if (bSensibleLocation)
                            {
                                iPointX = iColumn;
                                iPointY = iRow;
                                // Keep looking for places if it's a stackable to try to stick it at the end
                                if (!bOriginalIsStackable)
                                {
                                    goto FoundStashLocation;
                                }
                            }
                        }
                    }
                }
                // Didn't find a "sensible" place, let's try and force it in absolutely anywhere
                if ((iPointX < 0) || (iPointY < 0))
                {
                    for (int iRow = 0; iRow <= 5; iRow++)
                    {
                        for (int iColumn = 0; iColumn <= 9; iColumn++)
                        {
                            // Nothing in this spot, we're good!
                            if (!BackpackSlotBlocked[iColumn, iRow])
                            {
                                iPointX = iColumn;
                                iPointY = iRow;
                                // Keep looking for places if it's a stackable to try to stick it at the end
                                if (!bOriginalIsStackable)
                                {
                                    goto FoundStashLocation;
                                }
                            }
                        }
                    }
                }
            }
FoundStashLocation:
            if ((iPointX < 0) || (iPointY < 0))
            {
                Logger.DBLog.DebugFormat("Fatal Error: No valid stash location found for '" + sOriginalItemName + "' [" + sOriginalInternalName + " - " + OriginalPluginItemType.ToString() + "]");
                Logger.DBLog.InfoFormat("***************************");
                Logger.DBLog.InfoFormat("GSError: Emergency Stop: You need to stash an item but no valid space could be found. Stash is full? Stopping the bot to prevent infinite town-run loop.");

                BotMain.Stop(true, "No Room To Stash!");
                //ZetaDia.Service.Party.LeaveGame();
                return(false);
            }
            // We have two valid points that are empty, move the object here!
            BackpackSlotBlocked[iPointX, iPointY] = true;
            if (bOriginalTwoSlot)
            {
                BackpackSlotBlocked[iPointX, iPointY + 1] = true;
            }

            XY = new[] { iPointX, iPointY };



            return(true);
        }         // Custom stashing routine
Exemple #17
0
        public override bool GetConditionExec()
        {
            if (Itemsource == ItemSource.Stash)
            {
                foreach (ACDItem tempitem in ZetaDia.Me.Inventory.StashItems)
                {
                    if (tempitem.BaseAddress != IntPtr.Zero)
                    {
                        CacheACDItem cacheItem = new CacheACDItem(tempitem);
                        if (cacheItem.ItemType != PluginItemTypes.KeyStone)
                        {
                            continue;
                        }

                        int tieredLevel = cacheItem.KeystoneRank;
                        if (Type == KeystoneType.Fragment)
                        {
                            if (tieredLevel == -1)
                            {
                                return(!NOT);
                            }

                            continue;
                        }

                        if (Type == KeystoneType.Trial)
                        {
                            if (tieredLevel == 0)
                            {
                                return(!NOT);
                            }

                            continue;
                        }

                        if (Type == KeystoneType.Tiered)
                        {
                            if (tieredLevel > 0 && tieredLevel <= FunkyBaseExtension.Settings.AdventureMode.MaximumTieredRiftKeyAllowed)
                            {
                                return(!NOT);
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (ACDItem tempitem in ZetaDia.Me.Inventory.Backpack)
                {
                    if (tempitem.BaseAddress != IntPtr.Zero)
                    {
                        CacheACDItem cacheItem = new CacheACDItem(tempitem);
                        if (cacheItem.ItemType != PluginItemTypes.KeyStone)
                        {
                            continue;
                        }

                        int tieredLevel = cacheItem.KeystoneRank;
                        if (Type == KeystoneType.Fragment)
                        {
                            if (tieredLevel == -1)
                            {
                                return(!NOT);
                            }

                            continue;
                        }

                        if (Type == KeystoneType.Trial)
                        {
                            if (tieredLevel == 0)
                            {
                                return(!NOT);
                            }

                            continue;
                        }

                        if (Type == KeystoneType.Tiered)
                        {
                            if (tieredLevel > 0 && tieredLevel <= FunkyBaseExtension.Settings.AdventureMode.MaximumTieredRiftKeyAllowed)
                            {
                                return(!NOT);
                            }
                        }
                    }
                }
            }

            return(NOT);
        }
Exemple #18
0
        private void UpdateMovingItemList()
        {
            Logger.DBLog.DebugFormat("Updating Moving Items!");

            IEnumerable <ACDItem> ItemEnumerableSource =
                Itemsource == ItemSource.Stash ? ZetaDia.Me.Inventory.StashItems :
                ZetaDia.Me.Inventory.Backpack;

            List <CacheACDItem> Items = new List <CacheACDItem>();

            foreach (var i in ItemEnumerableSource)
            {
                if (i.BaseAddress != IntPtr.Zero)
                {
                    CacheACDItem cacheItem = new CacheACDItem(i);
                    Items.Add(cacheItem);
                }
            }


            if (KeyType != KeystoneType.None)
            {
                if (!_keyStoneHighest)
                {
                    Items = Items.OrderBy(i => i.KeystoneRank).ThenByDescending(i => i.ThisItemStackQuantity).ToList();
                }
                else
                {
                    Items = Items.OrderByDescending(i => i.KeystoneRank).ThenByDescending(i => i.ThisItemStackQuantity).ToList();
                }
            }

            foreach (var tempitem in Items)
            {
                if (KeyType != KeystoneType.None)
                {
                    int tieredLevel = tempitem.KeystoneRank;
                    if (KeyType == KeystoneType.Fragment)
                    {
                        if (tieredLevel == -1)
                        {
                            MovingItemList.Add(tempitem);
                            if (!All)
                            {
                                break;
                            }
                        }

                        continue;
                    }

                    if (KeyType == KeystoneType.Trial)
                    {
                        if (tieredLevel == 0)
                        {
                            MovingItemList.Add(tempitem);
                            if (!All)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (KeyType == KeystoneType.Tiered)
                    {
                        if (tieredLevel > 0 && tieredLevel <= FunkyBaseExtension.Settings.AdventureMode.MaximumTieredRiftKeyAllowed)
                        {
                            MovingItemList.Add(tempitem);
                            if (!All)
                            {
                                break;
                            }
                        }
                    }
                }
                else if (tempitem.SNO == Sno)
                {
                    MovingItemList.Add(tempitem);
                    if (!All)
                    {
                        break;
                    }
                }
            }

            updatedItemList = true;
            Logger.DBLog.InfoFormat("Found a total of {0} items to be moved!", MovingItemList.Count);
        }
Exemple #19
0
        private bool MoveItems()
        {
            if (MovingItemList.Count > 0)
            {
                //Logger.DBLog.DebugFormat("Moving Items!");

                if (!Delay.Test())
                {
                    return(true);
                }

                CacheACDItem thisitem = MovingItemList.FirstOrDefault();

                if (Itemsource == ItemSource.Backpack)
                {
                    if (LastStashPoint[0] < 0 && LastStashPoint[1] < 0 && LastStashPage < 0)
                    {
                        bool bDidStashSucceed = StashAttempt(thisitem, out LastStashPoint, out LastStashPage);
                        if (!bDidStashSucceed)
                        {
                            Logger.DBLog.DebugFormat("There was an unknown error stashing an item.");
                            //if (OutOfGame.MuleBehavior) return RunStatus.Success;
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        //We have a valid place to stash.. so lets check if stash page is currently open
                        if (ZetaDia.Me.Inventory.CurrentStashPage == LastStashPage)
                        {
                            //FunkyTownRunPlugin.TownRunStats.StashedItemLog(thisitem);
                            ZetaDia.Me.Inventory.MoveItem(thisitem.ThisDynamicID, ZetaDia.Me.CommonData.DynamicId, InventorySlot.SharedStash, LastStashPoint[0], LastStashPoint[1]);
                            LastStashPoint = new[] { -1, -1 };
                            LastStashPage  = -1;

                            MovingItemList.Remove(thisitem);
                            if (MovingItemList.Count > 0)
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            //Lets switch the current page..
                            ZetaDia.Me.Inventory.SwitchStashPage(LastStashPage);
                            return(true);
                        }
                    }
                }
                else
                {
                    if (LastStashPoint[0] < 0 && LastStashPoint[1] < 0)
                    {
                        bool bDidStashSucceed = BackpackStashAttempt(thisitem, out LastStashPoint);
                        if (!bDidStashSucceed)
                        {
                            Logger.DBLog.DebugFormat("There was an unknown error stashing an item.");
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        ZetaDia.Me.Inventory.MoveItem(thisitem.ThisDynamicID, ZetaDia.Me.CommonData.DynamicId, InventorySlot.BackpackItems, LastStashPoint[0], LastStashPoint[1]);
                        LastStashPoint = new[] { -1, -1 };

                        MovingItemList.Remove(thisitem);
                        if (MovingItemList.Count > 0)
                        {
                            return(true);
                        }
                    }
                }
            }

            m_IsDone = true;
            return(false);
        }
Exemple #20
0
        // **********************************************************************************************
        // *****                 Nice smooth one-at-a-time salvaging replacement                    *****
        // **********************************************************************************************
        internal static RunStatus GilesOptimisedSalvage(object ret)
        {
            DiaUnit objBlacksmith         = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.IsSalvageShortcut);
            Vector3 vectorPlayerPosition  = ZetaDia.Me.Position;
            Vector3 vectorSalvageLocation = new Vector3(0f, 0f, 0f);

            if (objBlacksmith == null || objBlacksmith.Distance > 20f)
            {
                switch (ZetaDia.CurrentAct)
                {
                case Act.A1:
                    vectorSalvageLocation = new Vector3(2958.418f, 2823.037f, 24.04533f); break;

                case Act.A2:
                    vectorSalvageLocation = new Vector3(289.6358f, 232.1146f, 0.1f); break;

                case Act.A3:
                case Act.A4:
                    vectorSalvageLocation = new Vector3(379.6096f, 415.6198f, 0.3321424f); break;
                }
            }
            else
            {
                vectorSalvageLocation = objBlacksmith.Position;
            }


            Bot.NavigationCache.RefreshMovementCache();
            //Wait until we are not moving
            if (Bot.NavigationCache.IsMoving)
            {
                return(RunStatus.Running);
            }


            float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSalvageLocation);

            //Out-Of-Range...
            if (objBlacksmith == null || iDistanceFromSell > 12f)            //|| !GilesCanRayCast(vectorPlayerPosition, vectorSalvageLocation, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
            {
                //Use our click movement
                Bot.NavigationCache.RefreshMovementCache();

                //Wait until we are not moving to send click again..
                if (Bot.NavigationCache.IsMoving)
                {
                    return(RunStatus.Running);
                }

                Navigator.PlayerMover.MoveTowards(vectorSalvageLocation);
                return(RunStatus.Running);
            }


            if (!UIElements.SalvageWindow.IsVisible)
            {
                objBlacksmith.Interact();
                return(RunStatus.Running);
            }

            if (!UIElements.InventoryWindow.IsVisible)
            {
                Bot.Character.Data.BackPack.InventoryBackPackToggle(true);
                return(RunStatus.Running);
            }


            iCurrentItemLoops++;
            if (iCurrentItemLoops < iItemDelayLoopLimit * 1.15)
            {
                return(RunStatus.Running);
            }

            iCurrentItemLoops = 0;
            RandomizeTheTimer();

            if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Count > 0)
            {
                CacheACDItem thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.FirstOrDefault();
                if (thisitem != null)
                {
                    // Item log for cool stuff stashed
                    GilesItemType     OriginalGilesItemType = Backpack.DetermineItemType(thisitem.ThisInternalName, thisitem.ThisDBItemType, thisitem.ThisFollowerType);
                    GilesBaseItemType thisGilesBaseType     = Backpack.DetermineBaseType(OriginalGilesItemType);
                    if (thisGilesBaseType == GilesBaseItemType.WeaponTwoHand || thisGilesBaseType == GilesBaseItemType.WeaponOneHand || thisGilesBaseType == GilesBaseItemType.WeaponRange ||
                        thisGilesBaseType == GilesBaseItemType.Armor || thisGilesBaseType == GilesBaseItemType.Jewelry || thisGilesBaseType == GilesBaseItemType.Offhand ||
                        thisGilesBaseType == GilesBaseItemType.FollowerItem)
                    {
                        double iThisItemValue = Backpack.ValueThisItem(thisitem, OriginalGilesItemType);
                        Logger.LogJunkItems(thisitem, thisGilesBaseType, OriginalGilesItemType, iThisItemValue);
                    }
                    Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.SalvagedItemLog(thisitem);
                    ZetaDia.Me.Inventory.SalvageItem(thisitem.ThisDynamicID);
                }
                Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Remove(thisitem);
                if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.Count > 0)
                {
                    thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSalvageItems.FirstOrDefault();
                    if (thisitem != null)
                    {
                        return(RunStatus.Running);
                    }
                }
                else
                {
                    iCurrentItemLoops = 0;
                    return(RunStatus.Running);
                }
            }
            bReachedSafety   = false;
            bCurrentlyMoving = false;
            return(RunStatus.Success);
        }
Exemple #21
0
        internal static bool StashValidation(CacheACDItem thisitem)
        {
            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (thisitem.IsUnidentified)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] = (autokeep unidentified items)");
                return(true);
            }
            // Now look for Misc items we might want to keep
            PluginItemTypes TrueItemType = ItemFunc.DetermineItemType(thisitem);

            if (TrueItemType == PluginItemTypes.KeyStone)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep keystone fragments)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.HoradricCache)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep cache)");
                return(FunkyTownRunPlugin.PluginSettings.StashHoradricCache);
            }
            if (TrueItemType == PluginItemTypes.StaffOfHerding)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep staff of herding)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.CraftingMaterial)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep craft materials)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.CraftingPlan)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep plans)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.Emerald)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.Amethyst)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.Topaz)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.Ruby)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.Diamond)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep gems)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.LegendaryGem)
            {
                return(true);
            }
            if (TrueItemType == PluginItemTypes.RamaladnisGift)
            {
                return(true);
            }
            if (TrueItemType == PluginItemTypes.CraftTome)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep tomes)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.InfernalKey)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep infernal key)");
                return(true);
            }
            if (TrueItemType == PluginItemTypes.HealthPotion || TrueItemType == PluginItemTypes.LegendaryHealthPotion)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (ignoring potions)");
                return(false);
            }

            if (thisitem.ThisQuality >= ItemQuality.Legendary)
            {
                //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = (autokeep legendaries)");
                return(true);
            }

            if (TrueItemType == PluginItemTypes.Dye)
            {
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            //double iNeedScore = ScoreNeeded(TrueItemType);
            //double iMyScore = ValueThisItem(thisitem, TrueItemType);
            //if (bOutputItemScores) FunkyTownRunPlugin.DBLog.InfoFormat(thisitem.ThisRealName + " [" + thisitem.ThisInternalName + "] [" + TrueItemType + "] = " + iMyScore);
            //if (iMyScore >= iNeedScore) return true;

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
Exemple #22
0
        public void VendoredItemLog(CacheACDItem i)
        {
            //if (Bot.BotStatistics.ProfileStats.CurrentProfile==null)
            //return;

            switch (i.ACDItem.ItemType)
            {
            case ItemType.CraftingPage:
            case ItemType.CraftingPlan:
            case ItemType.CraftingReagent:
                Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Crafting.Vendored++;
                //  Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[(int)LootIndex.Crafting]++;
                break;

            case ItemType.Gem:
                Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Gems.Vendored++;
                // Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[(int)LootIndex.Gem]++;
                break;

            case ItemType.Amulet:
            case ItemType.Axe:
            case ItemType.Belt:
            case ItemType.Boots:
            case ItemType.Bow:
            case ItemType.Bracer:
            case ItemType.CeremonialDagger:
            case ItemType.Chest:
            case ItemType.Cloak:
            case ItemType.Crossbow:
            case ItemType.Dagger:
            case ItemType.Daibo:
            case ItemType.FistWeapon:
            case ItemType.FollowerSpecial:
            case ItemType.Gloves:
            case ItemType.HandCrossbow:
            case ItemType.Helm:
            case ItemType.Legs:
            case ItemType.Mace:
            case ItemType.MightyBelt:
            case ItemType.MightyWeapon:
            case ItemType.Mojo:
            case ItemType.Orb:
            case ItemType.Polearm:
            case ItemType.Quiver:
            case ItemType.Ring:
            case ItemType.Shield:
            case ItemType.Shoulder:
            case ItemType.Spear:
            case ItemType.SpiritStone:
            case ItemType.Staff:
            case ItemType.Sword:
            case ItemType.VoodooMask:
            case ItemType.Wand:
            case ItemType.WizardHat:
                if (i.ThisQuality == ItemQuality.Legendary)
                {
                    //Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[3]++;
                    Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Legendary.Vendored++;
                }
                else if (i.ThisQuality > ItemQuality.Magic3)
                {
                    // Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[2]++;
                    Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Rare.Vendored++;
                }
                else
                {
                    //  Bot.BotStatistics.ProfileStats.CurrentProfile.ItemStats.stashedItemTotals[1]++;
                    Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.Magical.Vendored++;
                }
                break;
            }
        }
Exemple #23
0
        public void VendoredItemLog(CacheACDItem i)
        {
            switch (i.ACDItem.ItemType)
            {
            case ItemType.CraftingPage:
            case ItemType.CraftingPlan:
            case ItemType.CraftingReagent:
                Crafting.Vendored++;
                break;

            case ItemType.Gem:
                Gems.Vendored++;
                break;

            case ItemType.Amulet:
            case ItemType.Axe:
            case ItemType.Belt:
            case ItemType.Boots:
            case ItemType.Bow:
            case ItemType.Bracer:
            case ItemType.CeremonialDagger:
            case ItemType.Chest:
            case ItemType.Cloak:
            case ItemType.Crossbow:
            case ItemType.Dagger:
            case ItemType.Daibo:
            case ItemType.FistWeapon:
            case ItemType.FollowerSpecial:
            case ItemType.Gloves:
            case ItemType.HandCrossbow:
            case ItemType.Helm:
            case ItemType.Legs:
            case ItemType.Mace:
            case ItemType.MightyBelt:
            case ItemType.MightyWeapon:
            case ItemType.Mojo:
            case ItemType.Orb:
            case ItemType.Polearm:
            case ItemType.Quiver:
            case ItemType.Ring:
            case ItemType.Shield:
            case ItemType.Shoulder:
            case ItemType.Spear:
            case ItemType.SpiritStone:
            case ItemType.Staff:
            case ItemType.Sword:
            case ItemType.VoodooMask:
            case ItemType.Wand:
            case ItemType.WizardHat:
                if (i.ThisQuality == ItemQuality.Legendary)
                {
                    Legendary.Vendored++;
                }
                else if (i.ThisQuality > ItemQuality.Magic3)
                {
                    Rare.Vendored++;
                }
                else
                {
                    Magical.Vendored++;
                }
                break;
            }
        }
Exemple #24
0
        // **********************************************************************************************
        // *****    Sell Routine replacement for smooth one-at-a-time item selling and handling     *****
        // **********************************************************************************************

        internal static RunStatus GilesOptimisedSell(object ret)
        {
            string sVendorName = "";

            switch (ZetaDia.CurrentAct)
            {
            case Act.A1:
                sVendorName = "a1_uniquevendor_miner"; break;

            case Act.A2:
                sVendorName = "a2_uniquevendor_peddler"; break;

            case Act.A3:
                sVendorName = "a3_uniquevendor_collector"; break;

            case Act.A4:
                sVendorName = "a4_uniquevendor_collector"; break;
            }

            #region Navigation
            DiaUnit objSellNavigation    = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.ToLower().StartsWith(sVendorName));
            Vector3 vectorPlayerPosition = ZetaDia.Me.Position;
            Vector3 vectorSellLocation   = new Vector3(0f, 0f, 0f);

            if (objSellNavigation == null)
            {
                switch (ZetaDia.CurrentAct)
                {
                case Act.A1:
                    vectorSellLocation = new Vector3(2901.399f, 2809.826f, 24.04533f); break;

                case Act.A2:
                    vectorSellLocation = new Vector3(295.2101f, 265.1436f, 0.1000002f); break;

                case Act.A3:
                case Act.A4:
                    vectorSellLocation = new Vector3(410.6073f, 355.8762f, 0.1000005f); break;
                }
            }
            else
            {
                vectorSellLocation = objSellNavigation.Position;
            }


            float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSellLocation);
            //Out-Of-Range...
            if (objSellNavigation == null)
            //!GilesCanRayCast(vectorPlayerPosition, vectorSellLocation, NavCellFlags.AllowWalk))
            {
                Logger.DBLog.InfoFormat("Vendor Obj is Null or Raycast Failed.. using Navigator to move!");
                Navigator.PlayerMover.MoveTowards(vectorSellLocation);
                return(RunStatus.Running);
            }
            if (iDistanceFromSell > 40f)
            {
                Navigator.MoveTo(vectorSellLocation, "Vendor", true);
                //ZetaDia.Me.UsePower(SNOPower.Walk, vectorSellLocation, ZetaDia.Me.WorldDynamicId);
                return(RunStatus.Running);
            }
            if (iDistanceFromSell > 7.5f && !UIElements.VendorWindow.IsValid)
            {
                //Use our click movement
                Bot.NavigationCache.RefreshMovementCache();

                //Wait until we are not moving to send click again..
                if (Bot.NavigationCache.IsMoving)
                {
                    return(RunStatus.Running);
                }

                objSellNavigation.Interact();
                //ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, vectorSellLocation, ZetaDia.Me.WorldDynamicId, objSellNavigation.ACDGuid);
                return(RunStatus.Running);
            }

            if (!UIElements.VendorWindow.IsVisible)
            {
                objSellNavigation.Interact();
                return(RunStatus.Running);
            }

            if (!UIElements.InventoryWindow.IsVisible)
            {
                Bot.Character.Data.BackPack.InventoryBackPackToggle(true);
                return(RunStatus.Running);
            }
            #endregion

            #region SellItem
            if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Count > 0)
            {
                iCurrentItemLoops++;
                if (iCurrentItemLoops < iItemDelayLoopLimit)
                {
                    return(RunStatus.Running);
                }
                iCurrentItemLoops = 0;
                RandomizeTheTimer();

                CacheACDItem thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.FirstOrDefault();
                // Item log for cool stuff sold
                if (thisitem != null)
                {
                    GilesItemType     OriginalGilesItemType = Backpack.DetermineItemType(thisitem.ThisInternalName, thisitem.ThisDBItemType, thisitem.ThisFollowerType);
                    GilesBaseItemType thisGilesBaseType     = Backpack.DetermineBaseType(OriginalGilesItemType);
                    if (thisGilesBaseType == GilesBaseItemType.WeaponTwoHand || thisGilesBaseType == GilesBaseItemType.WeaponOneHand || thisGilesBaseType == GilesBaseItemType.WeaponRange ||
                        thisGilesBaseType == GilesBaseItemType.Armor || thisGilesBaseType == GilesBaseItemType.Jewelry || thisGilesBaseType == GilesBaseItemType.Offhand ||
                        thisGilesBaseType == GilesBaseItemType.FollowerItem)
                    {
                        double iThisItemValue = Backpack.ValueThisItem(thisitem, OriginalGilesItemType);
                        Logger.LogJunkItems(thisitem, thisGilesBaseType, OriginalGilesItemType, iThisItemValue);
                    }
                    Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.VendoredItemLog(thisitem);
                    ZetaDia.Me.Inventory.SellItem(thisitem.ACDItem);
                }
                if (thisitem != null)
                {
                    Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Remove(thisitem);
                }
                if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Count > 0)
                {
                    return(RunStatus.Running);
                }
            }
            #endregion

            #region BuyPotion
            //Check if settings for potion buy is enabled, with less than 99 potions existing!
            if (Bot.Settings.BuyPotionsDuringTownRun && Bot.Character.Data.iTotalPotions < Bot.Settings.Loot.MaximumHealthPotions &&
                !PotionCheck)
            {
                //Obey the timer, so we don't buy 100 potions in 3 seconds.
                iCurrentItemLoops++;
                if (iCurrentItemLoops < iItemDelayLoopLimit)
                {
                    return(RunStatus.Running);
                }
                iCurrentItemLoops = 0;
                RandomizeTheTimer();

                //Buy Potions
                int BestPotionID = 0;
                int LastHPValue  = 0;
                foreach (ACDItem item in ZetaDia.Me.Inventory.MerchantItems)
                {
                    if (item.ItemType == ItemType.Potion && item.HitpointsGranted > LastHPValue &&
                        item.RequiredLevel <= Bot.Character.Data.iMyLevel &&
                        item.Gold < ZetaDia.Me.Inventory.Coinage)
                    {
                        LastHPValue  = item.HitpointsGranted;
                        BestPotionID = item.DynamicId;
                    }
                }
                if (BestPotionID != 0)
                {
                    ZetaDia.Me.Inventory.BuyItem(BestPotionID);
                    //Update counter
                    Bot.Character.Data.iTotalPotions++;
                    return(RunStatus.Running);
                }
                PotionCheck = true;
            }
            else
            {
                PotionCheck = true;
            }
            #endregion

            if (bNeedsEquipmentRepairs)
            {
                iCurrentItemLoops++;
                if (iCurrentItemLoops < iItemDelayLoopLimit)
                {
                    return(RunStatus.Running);
                }
                iCurrentItemLoops = 0;
                RandomizeTheTimer();

                if (ZetaDia.Me.Inventory.Coinage < 40000)
                {
                    Logger.DBLog.InfoFormat("Emergency Stop: You need repairs but don't have enough money. Stopping the bot to prevent infinite death loop.");
                    BotMain.Stop(false, "Not enough gold to repair item(s)!");
                }

                ZetaDia.Me.Inventory.RepairEquippedItems();
                bNeedsEquipmentRepairs = false;
            }


            bCurrentlyMoving = false;
            bReachedSafety   = false;
            return(RunStatus.Success);
        }
Exemple #25
0
        internal static RunStatus StashItems(object ret)
        {
            if (FunkyGame.GameIsInvalid)
            {
                ActionsChecked = false;
                FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)");
                return(RunStatus.Failure);
            }

            if (townRunItemCache.KeepItems.Count > 0)
            {
                if (!Delay.Test())
                {
                    return(RunStatus.Running);
                }


                CacheACDItem thisitem = townRunItemCache.KeepItems.FirstOrDefault();


                if (LastStashPoint[0] < 0 && LastStashPoint[1] < 0 && LastStashPage < 0)
                {
                    bool bDidStashSucceed = GilesStashAttempt(thisitem, out LastStashPoint, out LastStashPage);
                    if (!bDidStashSucceed)
                    {
                        FunkyTownRunPlugin.DBLog.DebugFormat("There was an unknown error stashing an item.");
                        //if (OutOfGame.MuleBehavior) return RunStatus.Success;
                    }
                    else
                    {
                        return(RunStatus.Running);
                    }
                }
                else
                {
                    //We have a valid place to stash.. so lets check if stash page is currently open
                    if (ZetaDia.Me.Inventory.CurrentStashPage == LastStashPage)
                    {
                        //FunkyTownRunPlugin.TownRunStats.StashedItemLog(thisitem);
                        if (FunkyGame.CurrentStats != null)
                        {
                            FunkyGame.CurrentStats.CurrentProfile.LootTracker.StashedItemLog(thisitem);
                        }
                        ZetaDia.Me.Inventory.MoveItem(thisitem.ThisDynamicID, ZetaDia.Me.CommonData.DynamicId, InventorySlot.SharedStash, LastStashPoint[0], LastStashPoint[1]);
                        LastStashPoint = new[] { -1, -1 };
                        LastStashPage  = -1;

                        townRunItemCache.KeepItems.Remove(thisitem);
                        if (townRunItemCache.KeepItems.Count > 0)
                        {
                            return(RunStatus.Running);
                        }
                    }
                    else
                    {
                        //Lets switch the current page..
                        ZetaDia.Me.Inventory.SwitchStashPage(LastStashPage);
                        return(RunStatus.Running);
                    }
                }
            }
            return(RunStatus.Success);
        }
Exemple #26
0
        internal static RunStatus GilesOptimisedSalvage(object ret)
        {
            if (FunkyGame.GameIsInvalid)
            {
                ActionsChecked = false;
                FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Failed! (Not In Game/Invalid Actor/misc)");
                return(RunStatus.Failure);
            }

            DiaUnit objBlacksmith         = ZetaDia.Actors.GetActorsOfType <DiaUnit>(true).FirstOrDefault <DiaUnit>(u => u.Name.StartsWith(SalvageName));
            Vector3 vectorPlayerPosition  = ZetaDia.Me.Position;
            Vector3 vectorSalvageLocation = Vector3.Zero;


            //Normal distance we use to move to specific location before moving to NPC
            float _distanceRequired = CurrentAct != Act.A5 ? 50f : 14f; //Act 5 we want short range only!

            if (Vector3.Distance(vectorPlayerPosition, SafetySalvageLocation) <= 2.5f)
            {
                MovedToSafetyLocation = true;
            }

            if (objBlacksmith == null || (!MovedToSafetyLocation && objBlacksmith.Distance > _distanceRequired))
            {
                vectorSalvageLocation = SafetySalvageLocation;
            }
            else
            {
                //MovedToSafetyLocation = true;
                vectorSalvageLocation = objBlacksmith.Position;
            }

            //if (vectorSalvageLocation == Vector3.Zero)
            //	Character.FindActByLevelID(Bot.Character.Data.CurrentWorldDynamicID);


            //Wait until we are not moving
            if (FunkyGame.Hero.IsMoving)
            {
                return(RunStatus.Running);
            }


            float iDistanceFromSell = Vector3.Distance(vectorPlayerPosition, vectorSalvageLocation);

            //Out-Of-Range...
            if (objBlacksmith == null || iDistanceFromSell > 12f)//|| !GilesCanRayCast(vectorPlayerPosition, vectorSalvageLocation, Zeta.Internals.SNO.NavCellFlags.AllowWalk))
            {
                Navigator.PlayerMover.MoveTowards(vectorSalvageLocation);
                return(RunStatus.Running);
            }


            if (!UIElements.SalvageWindow.IsVisible)
            {
                objBlacksmith.Interact();
                return(RunStatus.Running);
            }

            if (!UIElements.InventoryWindow.IsVisible)
            {
                Backpack.InventoryBackPackToggle(true);
                return(RunStatus.Running);
            }


            //Delays... (so we don't salvage everything in record time)
            if (!Delay.Test(1.15))
            {
                return(RunStatus.Running);
            }

            if (UIElements.SalvageAllWrapper.IsVisible)
            {
                if (UI.Game.Dialog_Confirmation_OK.IsVisible)
                {
                    UI.Game.Dialog_Confirmation_OK.Click();
                    return(RunStatus.Running);
                }

                if (UI.Game.SalvageAllNormal.IsEnabled && UI.Game.SalvageAllNormal.IsVisible && bShouldSalvageAllNormal && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Magic1) && !bSalvageAllNormal)
                {
                    //UI.Game.SalvageAllNormal.Click();
                    Logger.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Normal Items");
                    ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Normal);
                    bSalvageAllNormal = true;
                    var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Magic1).ToList();
                    foreach (var cacheAcdItem in removalList)
                    {
                        LogSalvagedItem(cacheAcdItem);
                    }
                    townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList();
                    return(RunStatus.Running);
                }

                if (UI.Game.SalvageAllMagical.IsEnabled && UI.Game.SalvageAllMagical.IsVisible && bShouldSalvageAllMagical && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Rare4) && !bSalvageAllMagic)
                {
                    //UI.Game.SalvageAllMagical.Click();
                    FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Magical Items");
                    ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Magic);
                    bSalvageAllMagic = true;
                    var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Rare4).ToList();
                    foreach (var cacheAcdItem in removalList)
                    {
                        LogSalvagedItem(cacheAcdItem);
                    }
                    townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList();
                    return(RunStatus.Running);
                }

                if (UI.Game.SalvageAllRare.IsEnabled && UI.Game.SalvageAllRare.IsVisible && bShouldSalvageAllRare && townRunItemCache.SalvageItems.Any(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Legendary) && !bSalvageAllRare)
                {
                    //UI.Game.SalvageAllRare.Click();
                    FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging All Rare Items");
                    ZetaDia.Me.Inventory.SalvageItemsOfRarity(SalvageRarity.Rare);
                    bSalvageAllRare = true;
                    var removalList = townRunItemCache.SalvageItems.Where(i => i.IsSalvagable && i.ThisQuality < ItemQuality.Legendary).ToList();
                    foreach (var cacheAcdItem in removalList)
                    {
                        LogSalvagedItem(cacheAcdItem);
                    }
                    townRunItemCache.SalvageItems = townRunItemCache.SalvageItems.Except(removalList).ToList();
                    return(RunStatus.Running);
                }

                UpdateSalvageItemList();
            }

            if (townRunItemCache.SalvageItems.Count > 0)
            {
                CacheACDItem thisitem = townRunItemCache.SalvageItems.FirstOrDefault();
                if (thisitem != null && thisitem.ACDItem != null)
                {
                    LogSalvagedItem(thisitem);
                    FunkyTownRunPlugin.DBLog.DebugFormat("[FunkyTownRun] Salvaging Individual Item {0}", thisitem.ToString());
                    ZetaDia.Me.Inventory.SalvageItem(thisitem.ThisDynamicID);
                }
                townRunItemCache.SalvageItems.Remove(thisitem);
                if (townRunItemCache.SalvageItems.Count > 0)
                {
                    thisitem = townRunItemCache.SalvageItems.FirstOrDefault();
                    if (thisitem != null)
                    {
                        return(RunStatus.Running);
                    }
                }
                else
                {
                    Delay.Reset();
                    return(RunStatus.Running);
                }
            }


            return(RunStatus.Success);
        }
Exemple #27
0
        internal static void LogGoodItems(CacheACDItem thisgooditem, PluginBaseItemTypes thisPluginBaseItemTypes, PluginItemTypes thisPluginItemType)
        {
            try
            {
                //Update this item
                using (ZetaDia.Memory.AcquireFrame())
                {
                    thisgooditem = new CacheACDItem(thisgooditem.ACDItem);
                }
            }
            catch
            {
                DBLog.DebugFormat("Failure to update CacheACDItem during Logging");
            }
            //double iThisItemValue = ItemFunc.ValueThisItem(thisgooditem, thisPluginItemType);

            FileStream LogStream = null;

            try
            {
                string outputPath = FolderPaths.LoggingFolderPath + @"\StashLog.log";

                LogStream = File.Open(outputPath, FileMode.Append, FileAccess.Write, FileShare.Read);
                using (StreamWriter LogWriter = new StreamWriter(LogStream))
                {
                    if (!TownRunManager.bLoggedAnythingThisStash)
                    {
                        TownRunManager.bLoggedAnythingThisStash = true;
                        LogWriter.WriteLine(DateTime.Now.ToString() + ":");
                        LogWriter.WriteLine("====================");
                    }
                    string sLegendaryString = "";
                    if (thisgooditem.ThisQuality >= ItemQuality.Legendary)
                    {
                        if (!thisgooditem.IsUnidentified)
                        {
                            //Prowl.AddNotificationToQueue(thisgooditem.ThisRealName + " [" + thisPluginItemType.ToString() + "] (Score=" + iThisItemValue.ToString() + ". " + TownRunManager.sValueItemStatString + ")", ZetaDia.Service.Hero.Name + " new legendary!", Prowl.ProwlNotificationPriority.Emergency);
                            sLegendaryString = " {legendary item}";
                            // Change made by bombastic
                            DBLog.Info("+=+=+=+=+=+=+=+=+ LEGENDARY FOUND +=+=+=+=+=+=+=+=+");
                            DBLog.Info("+  Name:       " + thisgooditem.ThisRealName + " (" + thisPluginItemType.ToString() + ")");
                            //DBLog.Info("+  Score:       " + Math.Round(iThisItemValue).ToString());
                            DBLog.Info("+  Attributes: " + thisgooditem.ItemStatString);
                            DBLog.Info("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+");
                        }
                        else
                        {
                            DBLog.Info("+=+=+=+=+=+=+=+=+ LEGENDARY FOUND +=+=+=+=+=+=+=+=+");
                            DBLog.Info("+  Unid:       " + thisPluginItemType.ToString());
                            DBLog.Info("+  Level:       " + thisgooditem.ThisLevel.ToString());
                            DBLog.Info("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+");
                        }
                    }
                    else
                    {
                        // Check for non-legendary notifications
                        bool bShouldNotify = false;
                        switch (thisPluginBaseItemTypes)
                        {
                        case PluginBaseItemTypes.WeaponOneHand:
                        case PluginBaseItemTypes.WeaponRange:
                        case PluginBaseItemTypes.WeaponTwoHand:
                            //if (ithisitemvalue >= settings.iNeedPointsToNotifyWeapon)
                            //  bShouldNotify = true;
                            break;

                        case PluginBaseItemTypes.Armor:
                        case PluginBaseItemTypes.Offhand:
                            //if (ithisitemvalue >= settings.iNeedPointsToNotifyArmor)
                            //bShouldNotify = true;
                            break;

                        case PluginBaseItemTypes.Jewelry:
                            //if (ithisitemvalue >= settings.iNeedPointsToNotifyJewelry)
                            //bShouldNotify = true;
                            break;
                        }
                        //if (bShouldNotify)
                        //Prowl.AddNotificationToQueue(thisgooditem.ThisRealName + " [" + thisPluginItemType.ToString() + "] (Score=" + iThisItemValue.ToString() + ". " + TownRunManager.sValueItemStatString + ")", ZetaDia.Service.Hero.Name + " new item!", Prowl.ProwlNotificationPriority.Emergency);
                    }
                    if (!thisgooditem.IsUnidentified)
                    {
                        LogWriter.WriteLine(thisgooditem.ThisQuality.ToString() + "  " + thisPluginItemType.ToString() + " '" + thisgooditem.ThisRealName + sLegendaryString);
                        LogWriter.WriteLine("  " + thisgooditem.ItemStatString);
                        LogWriter.WriteLine("");
                    }
                    else
                    {
                        LogWriter.WriteLine(thisgooditem.ThisQuality.ToString() + "  " + thisPluginItemType.ToString() + " '" + sLegendaryString);
                        LogWriter.WriteLine("iLevel " + thisgooditem.ThisLevel.ToString());
                        LogWriter.WriteLine("");
                    }
                }
            }
            catch (IOException)
            {
                DBLog.Info("Fatal Error: File access error for stash log file.");
            }
        }
Exemple #28
0
        public static void UpdateItemList()
        {
            List <int> SeenACDGuid = new List <int>();

            //Clear New Item List
            NewItemList.Clear();

            using (ZetaDia.Memory.AcquireFrame())
            {
                foreach (var thisitem in ZetaDia.Me.Inventory.Backpack)
                {
                    var ACDGuid = thisitem.ACDGuid;
                    SeenACDGuid.Add(ACDGuid);

                    if (CacheItemList.ContainsKey(ACDGuid))
                    {
                        var cachedItem = CacheItemList[ACDGuid];

                        //Stackable item that increased
                        if (CacheItemList[ACDGuid].IsStackableItem)
                        {
                            try
                            {
                                if (cachedItem.ThisItemStackQuantity != thisitem.ItemStackQuantity)
                                {
                                    //Update it..
                                    cachedItem.ThisItemStackQuantity = thisitem.ItemStackQuantity;

                                    //Check if stack quanity is maxed to remove it from our list
                                    if (cachedItem.ThisItemStackQuantity >= cachedItem.MaxStackQuanity &&
                                        _stackableItems.Contains(cachedItem.SNO))
                                    {
                                        _stackableItems.Remove(cachedItem.SNO);
                                    }

                                    //Add it to new item list..
                                    NewItemList.Add(CacheItemList[ACDGuid]);
                                }
                            }
                            catch (Exception ex)
                            {
                                //Logger.DBLog.DebugFormat("Item {0} stack quanity threw exception {1}",
                                //CacheItemList[ACDGuid].ThisInternalName, ex.Message);
                            }
                        }

                        continue;
                    }

                    var thiscacheditem = new CacheACDItem(thisitem);
                    CacheItemList.Add(thiscacheditem.ACDGUID, thiscacheditem);

                    //Add it to new item list..
                    NewItemList.Add(thiscacheditem);

                    //
                    _occupiedSlots += thiscacheditem.IsTwoSlot ? 2 : 1;
                    if (thiscacheditem.IsStackableItem &&
                        thiscacheditem.ThisItemStackQuantity < thiscacheditem.MaxStackQuanity &&
                        !_stackableItems.Contains(thiscacheditem.SNO))
                    {
                        _stackableItems.Add(thiscacheditem.SNO);
                    }

                    if (thiscacheditem.invCol >= 0 && thiscacheditem.invCol <= 9 && thiscacheditem.invRow >= 0 &&
                        thiscacheditem.invRow <= 5)
                    {
                        _backpackslotblocked[thiscacheditem.invCol, thiscacheditem.invRow] = true;
                        if (thiscacheditem.IsTwoSlot)
                        {
                            _backpackslotblocked[thiscacheditem.invCol, thiscacheditem.invRow + 1] = true;
                        }
                    }
                }
            }

            //Trim away items missing..
            var UnseenACDGuids = CacheItemList.Keys.Where(k => !SeenACDGuid.Contains(k)).ToList();

            foreach (var unseenAcdguiD in UnseenACDGuids)
            {
                var item = CacheItemList[unseenAcdguiD];

                if (item.IsStackableItem && _stackableItems.Contains(item.SNO))
                {
                    _stackableItems.Remove(item.SNO);
                }

                _occupiedSlots -= item.IsTwoSlot ? 2 : 1;
                _backpackslotblocked[item.invCol, item.invRow] = false;
                if (item.IsTwoSlot)
                {
                    _backpackslotblocked[item.invCol, item.invRow + 1] = false;
                }


                CacheItemList.Remove(unseenAcdguiD);
            }
        }
Exemple #29
0
        public void StashedItemLog(CacheACDItem i)
        {
            PluginItemTypes thisPluginItemType = ItemFunc.DetermineItemType(i);

            if (thisPluginItemType == PluginItemTypes.InfernalKey)
            {
                Keys.Stashed++;
                return;
            }
            if (thisPluginItemType == PluginItemTypes.HoradricCache)
            {
                HoradricCache.Stashed++;
            }
            if (thisPluginItemType == PluginItemTypes.KeyStone)
            {
                KeyStoneFragments.Stashed += i.ThisItemStackQuantity;
            }

            switch (i.ACDItem.ItemType)
            {
            case ItemType.CraftingPage:
            case ItemType.CraftingPlan:
            case ItemType.CraftingReagent:
                Crafting.Stashed++;
                break;

            case ItemType.Gem:
                Gems.Stashed++;
                break;

            case ItemType.Amulet:
            case ItemType.Axe:
            case ItemType.Belt:
            case ItemType.Boots:
            case ItemType.Bow:
            case ItemType.Bracer:
            case ItemType.CeremonialDagger:
            case ItemType.Chest:
            case ItemType.Cloak:
            case ItemType.Crossbow:
            case ItemType.Dagger:
            case ItemType.Daibo:
            case ItemType.FistWeapon:
            case ItemType.FollowerSpecial:
            case ItemType.Flail:
            case ItemType.CrusaderShield:
            case ItemType.Gloves:
            case ItemType.HandCrossbow:
            case ItemType.Helm:
            case ItemType.Legs:
            case ItemType.Mace:
            case ItemType.MightyBelt:
            case ItemType.MightyWeapon:
            case ItemType.Mojo:
            case ItemType.Orb:
            case ItemType.Polearm:
            case ItemType.Quiver:
            case ItemType.Ring:
            case ItemType.Shield:
            case ItemType.Shoulder:
            case ItemType.Spear:
            case ItemType.SpiritStone:
            case ItemType.Staff:
            case ItemType.Sword:
            case ItemType.VoodooMask:
            case ItemType.Wand:
            case ItemType.WizardHat:
                if (i.ThisQuality == ItemQuality.Legendary)
                {
                    Legendary.Stashed++;
                }
                else if (i.ThisQuality > ItemQuality.Magic3)
                {
                    Rare.Stashed++;
                }
                else
                {
                    Magical.Stashed++;
                }
                break;
            }
        }
Exemple #30
0
        internal static RunStatus UnidStashBehavior(object ret)
        {
            if (ZetaDia.Actors.Me == null)
            {
                Logger.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [CoreStash-1]");
                return(RunStatus.Failure);
            }
            Vector3   vectorPlayerPosition = ZetaDia.Me.Position;
            Vector3   vectorStashLocation  = new Vector3(0f, 0f, 0f);
            DiaObject objPlayStash         = ZetaDia.Actors.GetActorsOfType <GizmoPlayerSharedStash>(true).FirstOrDefault <GizmoPlayerSharedStash>();

            if (objPlayStash != null)
            {
                vectorStashLocation = objPlayStash.Position;
            }
            else if (!ZetaDia.IsInTown)
            {
                return(RunStatus.Failure);
            }
            else
            {
                //Setup vector for movement
                switch (ZetaDia.CurrentAct)
                {
                case Act.A1:
                    vectorStashLocation = new Vector3(2971.285f, 2798.801f, 24.04533f); break;

                case Act.A2:
                    vectorStashLocation = new Vector3(323.4543f, 228.5806f, 0.1f); break;

                case Act.A3:
                case Act.A4:
                    vectorStashLocation = new Vector3(389.3798f, 390.7143f, 0.3321428f); break;
                }
            }

            float iDistanceFromStash = Vector3.Distance(vectorPlayerPosition, vectorStashLocation);

            if (iDistanceFromStash > 120f)
            {
                return(RunStatus.Failure);
            }

            //Out-Of-Range...
            if (objPlayStash == null)
            {
                Navigator.PlayerMover.MoveTowards(vectorStashLocation);
                return(RunStatus.Running);
            }
            if (iDistanceFromStash > 40f)
            {
                ZetaDia.Me.UsePower(SNOPower.Walk, vectorStashLocation, ZetaDia.Me.WorldDynamicId);
                return(RunStatus.Running);
            }
            if (iDistanceFromStash > 7.5f && !UIElements.StashWindow.IsVisible)
            {
                //Use our click movement
                Bot.NavigationCache.RefreshMovementCache();

                //Wait until we are not moving to send click again..
                if (Bot.NavigationCache.IsMoving)
                {
                    return(RunStatus.Running);
                }

                ZetaDia.Me.UsePower(SNOPower.Axe_Operate_Gizmo, vectorStashLocation, ZetaDia.Me.WorldDynamicId, objPlayStash.ACDGuid);
                return(RunStatus.Running);
            }

            if (!UIElements.StashWindow.IsVisible)
            {
                objPlayStash.Interact();
                return(RunStatus.Running);
            }

            if (!bUpdatedStashMap)
            {
                // Array for what blocks are or are not blocked
                for (int iRow = 0; iRow <= 29; iRow++)
                {
                    for (int iColumn = 0; iColumn <= 6; iColumn++)
                    {
                        GilesStashSlotBlocked[iColumn, iRow] = false;
                    }
                }
                // Block off the entire of any "protected stash pages"
                foreach (int iProtPage in CharacterSettings.Instance.ProtectedStashPages)
                {
                    for (int iProtRow = 0; iProtRow <= 9; iProtRow++)
                    {
                        for (int iProtColumn = 0; iProtColumn <= 6; iProtColumn++)
                        {
                            GilesStashSlotBlocked[iProtColumn, iProtRow + (iProtPage * 10)] = true;
                        }
                    }
                }
                // Remove rows we don't have
                for (int iRow = (ZetaDia.Me.NumSharedStashSlots / 7); iRow <= 29; iRow++)
                {
                    for (int iColumn = 0; iColumn <= 6; iColumn++)
                    {
                        GilesStashSlotBlocked[iColumn, iRow] = true;
                    }
                }
                // Map out all the items already in the stash
                foreach (ACDItem tempitem in ZetaDia.Me.Inventory.StashItems)
                {
                    if (tempitem.BaseAddress != IntPtr.Zero)
                    {
                        int inventoryRow    = tempitem.InventoryRow;
                        int inventoryColumn = tempitem.InventoryColumn;
                        // Mark this slot as not-free
                        GilesStashSlotBlocked[inventoryColumn, inventoryRow] = true;
                        // Try and reliably find out if this is a two slot item or not
                        GilesItemType tempItemType = Backpack.DetermineItemType(tempitem.InternalName, tempitem.ItemType, tempitem.FollowerSpecialType);
                        if (Backpack.DetermineIsTwoSlot(tempItemType) && inventoryRow != 19 && inventoryRow != 9 && inventoryRow != 29)
                        {
                            GilesStashSlotBlocked[inventoryColumn, inventoryRow + 1] = true;
                        }
                        else if (Backpack.DetermineIsTwoSlot(tempItemType) && (inventoryRow == 19 || inventoryRow == 9 || inventoryRow == 29))
                        {
                            Logger.DBLog.DebugFormat("GSError: DemonBuddy thinks this item is 2 slot even though it's at bottom row of a stash page: " + tempitem.Name + " [" + tempitem.InternalName +
                                                     "] type=" + tempItemType.ToString() + " @ slot " + (inventoryRow + 1).ToString(CultureInfo.InvariantCulture) + "/" +
                                                     (inventoryColumn + 1).ToString(CultureInfo.InvariantCulture));
                        }
                    }
                }         // Loop through all stash items
                bUpdatedStashMap = true;
            }             // Need to update the stash map?


            if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedUnidStashItems.Count > 0)
            {
                iCurrentItemLoops++;
                if (iCurrentItemLoops < iItemDelayLoopLimit)
                {
                    return(RunStatus.Running);
                }
                iCurrentItemLoops = 0;
                RandomizeTheTimer();
                CacheACDItem thisitem = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedUnidStashItems.FirstOrDefault();
                if (LastStashPoint[0] < 0 && LastStashPoint[1] < 0 && LastStashPage < 0)
                {
                    bool bDidStashSucceed = GilesStashAttempt(thisitem, out LastStashPoint, out LastStashPage);
                    if (!bDidStashSucceed)
                    {
                        Logger.DBLog.DebugFormat("There was an unknown error stashing an item.");
                        if (OutOfGame.MuleBehavior)
                        {
                            return(RunStatus.Success);
                        }
                    }
                    else
                    {
                        return(RunStatus.Running);
                    }
                }
                else
                {
                    //We have a valid place to stash.. so lets check if stash page is currently open
                    if (ZetaDia.Me.Inventory.CurrentStashPage == LastStashPage)
                    {
                        //Herbfunk: Current Game Stats
                        Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.StashedItemLog(thisitem);

                        ZetaDia.Me.Inventory.MoveItem(thisitem.ThisDynamicID, ZetaDia.Me.CommonData.DynamicId, InventorySlot.SharedStash, LastStashPoint[0], LastStashPoint[1]);
                        LastStashPoint = new[] { -1, -1 };
                        LastStashPage  = -1;

                        if (thisitem != null)
                        {
                            Bot.Character.Data.BackPack.townRunCache.hashGilesCachedUnidStashItems.Remove(thisitem);
                        }
                        if (Bot.Character.Data.BackPack.townRunCache.hashGilesCachedUnidStashItems.Count > 0)
                        {
                            return(RunStatus.Running);
                        }
                    }
                    else
                    {
                        //Lets switch the current page..
                        ZetaDia.Me.Inventory.SwitchStashPage(LastStashPage);
                        return(RunStatus.Running);
                    }
                }
            }
            return(RunStatus.Success);
        }