Пример #1
0
        internal static bool SellValidation(string thisinternalname, int thislevel, ItemQuality thisquality, ItemType thisdbitemtype, FollowerType thisfollowertype)
        {
            PluginItemTypes     thisPluginItemType = ItemFunc.DetermineItemType(thisinternalname, thisdbitemtype, thisfollowertype);
            PluginBaseItemTypes thisGilesBaseType  = ItemFunc.DetermineBaseType(thisPluginItemType);

            switch (thisGilesBaseType)
            {
            case PluginBaseItemTypes.WeaponRange:
            case PluginBaseItemTypes.WeaponOneHand:
            case PluginBaseItemTypes.WeaponTwoHand:
            case PluginBaseItemTypes.Armor:
            case PluginBaseItemTypes.Offhand:
            case PluginBaseItemTypes.Jewelry:
            case PluginBaseItemTypes.FollowerItem:
                return(true);

            case PluginBaseItemTypes.Gem:
            case PluginBaseItemTypes.Misc:
            case PluginBaseItemTypes.Unknown:
                if (thisPluginItemType == PluginItemTypes.LegendaryCraftingMaterial)
                {
                    return(true);
                }
                //Sell any plans not already stashed.
                return(thisdbitemtype == ItemType.CraftingPlan);
            }             // Switch giles base item type
            return(false);
        }
Пример #2
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.");
            }
        }
Пример #3
0
        public CacheBalance(CacheItem item)
        {
            try
            {
                BalanceID     = item.ref_DiaItem.CommonData.GameBalanceId;
                _itemLevel    = item.ref_DiaItem.CommonData.Level;
                _type         = item.ref_DiaItem.CommonData.ItemType;
                _base         = item.ref_DiaItem.CommonData.ItemBaseType;
                _followerType = item.ref_DiaItem.CommonData.FollowerSpecialType;

                _pluginType = ItemFunc.DetermineItemType(item.InternalName, _type, _followerType, item.SNOID);
                if (item.ItemDropType.HasValue)
                {
                    _pluginBase = ItemFunc.DetermineBaseItemType(item.ItemDropType.Value);
                }
                else
                {
                    _pluginBase = ItemFunc.DetermineBaseItemType(item.InternalName, item.SNOID);
                }

                _isStackable = ItemFunc.DetermineIsStackable(_pluginType, item.SNOID);

                if (!_isStackable)
                {
                    _isTwoSlot = ItemFunc.DetermineIsTwoSlot(_pluginType);
                }
            }
            catch (Exception ex)
            {
                Logger.Write(LogLevel.Items,
                             String.Format("Failed to create balance data for item {0}", item.DebugStringSimple));
            }
        }
Пример #4
0
        public void LootedItemLog(PluginItemTypes itemType, PluginBaseItemTypes baseitemType, ItemQuality itemQuality)
        {
            if (itemType == PluginItemTypes.HealthPotion)
            {
                return;
            }


            switch (baseitemType)
            {
            case PluginBaseItemTypes.WeaponOneHand:
            case PluginBaseItemTypes.WeaponTwoHand:
            case PluginBaseItemTypes.WeaponRange:
            case PluginBaseItemTypes.Offhand:
            case PluginBaseItemTypes.Armor:
            case PluginBaseItemTypes.Jewelry:
            case PluginBaseItemTypes.FollowerItem:
                if (itemQuality > ItemQuality.Rare6)
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Legendary.Looted++;
                }
                else if (itemQuality > ItemQuality.Magic3)
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Rare.Looted++;
                }
                else
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Magical.Looted++;
                }
                break;

            case PluginBaseItemTypes.Unknown:
            case PluginBaseItemTypes.Misc:
                if (itemType == PluginItemTypes.CraftingMaterial || itemType == PluginItemTypes.CraftingPlan || itemType == PluginItemTypes.CraftTome)
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Crafting.Looted++;
                }
                else if (itemType == PluginItemTypes.InfernalKey)
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Keys.Looted++;
                }
                else if (itemType == PluginItemTypes.KeyStone)
                {
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.KeyStoneFragments.Looted++;
                }
                break;

            case PluginBaseItemTypes.Gem:
                FunkyGame.CurrentStats.CurrentProfile.LootTracker.Gems.Looted++;
                break;
            }
        }
Пример #5
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);
            }
        }
Пример #6
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.");
            }
        }
Пример #7
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);
        }
Пример #8
0
        public void LootedItemLog(PluginItemTypes itemType, PluginBaseItemTypes baseitemType, ItemQuality itemQuality)
        {
            if (itemType == PluginItemTypes.HealthPotion)
                return;

            switch (baseitemType)
            {
                case PluginBaseItemTypes.WeaponOneHand:
                case PluginBaseItemTypes.WeaponTwoHand:
                case PluginBaseItemTypes.WeaponRange:
                case PluginBaseItemTypes.Offhand:
                case PluginBaseItemTypes.Armor:
                case PluginBaseItemTypes.Jewelry:
                case PluginBaseItemTypes.FollowerItem:
                    if (itemQuality > ItemQuality.Rare6)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.Legendary.Looted++;
                    }
                    else if (itemQuality > ItemQuality.Magic3)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.Rare.Looted++;
                    }
                    else
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.Magical.Looted++;
                    }
                    break;

                case PluginBaseItemTypes.Unknown:
                case PluginBaseItemTypes.Misc:
                    if (itemType == PluginItemTypes.CraftingMaterial || itemType == PluginItemTypes.CraftingPlan || itemType == PluginItemTypes.CraftTome)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.Crafting.Looted++;
                    }
                    else if (itemType == PluginItemTypes.InfernalKey)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.Keys.Looted++;
                    }
                    else if (itemType == PluginItemTypes.KeyStone)
                    {
                        FunkyGame.CurrentStats.CurrentProfile.LootTracker.KeyStoneFragments.Looted++;
                    }
                    break;
                case PluginBaseItemTypes.Gem:
                    FunkyGame.CurrentStats.CurrentProfile.LootTracker.Gems.Looted++;
                    break;
            }
        }
Пример #9
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
Пример #10
0
        public CacheBalance(CacheItem item)
        {
            try
            {
                BalanceID = item.ref_DiaItem.CommonData.GameBalanceId;
                _itemLevel = item.ref_DiaItem.CommonData.Level;
                _type = item.ref_DiaItem.CommonData.ItemType;
                _base = item.ref_DiaItem.CommonData.ItemBaseType;
                _followerType = item.ref_DiaItem.CommonData.FollowerSpecialType;

                _pluginType = ItemFunc.DetermineItemType(item.InternalName, _type, _followerType, item.SNOID);
                if (item.ItemDropType.HasValue)
                    _pluginBase = ItemFunc.DetermineBaseItemType(item.ItemDropType.Value);
                else
                    _pluginBase = ItemFunc.DetermineBaseItemType(item.InternalName, item.SNOID);

                _isStackable = ItemFunc.DetermineIsStackable(_pluginType, item.SNOID);

                if (!_isStackable)
                    _isTwoSlot = ItemFunc.DetermineIsTwoSlot(_pluginType);
            }
            catch (Exception ex)
            {
                Logger.Write(LogLevel.Items,
                    String.Format("Failed to create balance data for item {0}", item.DebugStringSimple));

            }
        }
Пример #11
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.");
            }
        }
Пример #12
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.");
            }
        }
Пример #13
0
        internal static bool PickupItemValidation(CacheItem item)
        {
            //if (FunkyTownRunPlugin.ItemRulesEval != null)
            //{
            //	Interpreter.InterpreterAction action = FunkyTownRunPlugin.ItemRulesEval.checkPickUpItem(item.DynamicID.Value, item.BalanceData.thisItemType, item.ref_DiaItem.Name, item.InternalName, item.Itemquality.Value, item.BalanceData.iThisItemLevel, item.BalanceData.bThisOneHand, item.BalanceData.bThisTwoHand, item.BalanceID.Value, ItemEvaluationType.PickUp);
            //	if (action== Interpreter.InterpreterAction.PICKUP)
            //	{
            //		return true;
            //	}
            //}


            // Calculate giles item types and base types etc.
            PluginItemTypes     thisPluginItemType = PluginItemTypes.Unknown;
            PluginBaseItemTypes thisGilesBaseType  = PluginBaseItemTypes.Unknown;

            if (item.BalanceID.HasValue && item.BalanceData != null)
            {
                thisPluginItemType = item.BalanceData.PluginType;
                thisGilesBaseType  = item.BalanceData.PluginBase;
            }
            else
            {
                thisPluginItemType = ItemFunc.DetermineItemType(item.InternalName, ItemType.Unknown, FollowerType.None,
                                                                item.SNOID);
                thisGilesBaseType = ItemFunc.DetermineBaseType(thisPluginItemType);
            }


            if (thisPluginItemType == PluginItemTypes.MiscBook)
            {
                return(FunkyBaseExtension.Settings.Loot.ExpBooks);
            }

            if (thisPluginItemType == PluginItemTypes.RamaladnisGift)
            {
                return(true);
            }

            // Error logging for DemonBuddy item mis-reading
            ItemType gilesDBItemType = ItemFunc.PluginItemTypeToDBItemType(thisPluginItemType);

            if (item.BalanceID.HasValue && item.BalanceData != null && gilesDBItemType != item.BalanceData.Type)
            {
                Logger.DBLog.InfoFormat("GSError: Item type mis-match detected: Item Internal=" + item.InternalName + ". DemonBuddy ItemType thinks item type is=" + item.BalanceData.Type + ". Giles thinks item type is=" +
                                        gilesDBItemType + ". [pickup]", true);
            }

            switch (thisGilesBaseType)
            {
            case PluginBaseItemTypes.WeaponTwoHand:
            case PluginBaseItemTypes.WeaponOneHand:
            case PluginBaseItemTypes.WeaponRange:
            case PluginBaseItemTypes.Armor:
            case PluginBaseItemTypes.Offhand:
            case PluginBaseItemTypes.Jewelry:
            case PluginBaseItemTypes.FollowerItem:

                if (FunkyBaseExtension.Settings.Loot.PickupWhiteItems == 1 &&
                    FunkyBaseExtension.Settings.Loot.PickupMagicItems == 1 &&
                    FunkyBaseExtension.Settings.Loot.PickupRareItems == 1 &&
                    FunkyBaseExtension.Settings.Loot.PickupLegendaryItems == 1)
                {
                    return(true);
                }

                if (item.Itemquality.HasValue && item.BalanceID.HasValue && item.BalanceData != null)
                {
                    switch (item.Itemquality.Value)
                    {
                    case ItemQuality.Inferior:
                    case ItemQuality.Normal:
                    case ItemQuality.Superior:
                        return(FunkyBaseExtension.Settings.Loot.PickupWhiteItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupWhiteItems));

                    case ItemQuality.Magic1:
                    case ItemQuality.Magic2:
                    case ItemQuality.Magic3:
                        return(FunkyBaseExtension.Settings.Loot.PickupMagicItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupMagicItems));

                    case ItemQuality.Rare4:
                    case ItemQuality.Rare5:
                    case ItemQuality.Rare6:
                        return(FunkyBaseExtension.Settings.Loot.PickupRareItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupRareItems));

                    case ItemQuality.Legendary:
                        return(FunkyBaseExtension.Settings.Loot.PickupLegendaryItems > 0 && (item.BalanceData.ItemLevel >= FunkyBaseExtension.Settings.Loot.PickupLegendaryItems));
                    }
                }

                return(false);

            case PluginBaseItemTypes.Gem:
                if (thisPluginItemType == PluginItemTypes.LegendaryGem)
                {
                    return(true);
                }

                GemQualityTypes qualityType  = ItemFunc.ReturnGemQualityType(item.SNOID, item.BalanceData != null?item.BalanceData.ItemLevel:-1);
                int             qualityLevel = (int)qualityType;

                if (qualityLevel < FunkyBaseExtension.Settings.Loot.MinimumGemItemLevel ||
                    (thisPluginItemType == PluginItemTypes.Ruby && !FunkyBaseExtension.Settings.Loot.PickupGems[0]) ||
                    (thisPluginItemType == PluginItemTypes.Emerald && !FunkyBaseExtension.Settings.Loot.PickupGems[1]) ||
                    (thisPluginItemType == PluginItemTypes.Amethyst && !FunkyBaseExtension.Settings.Loot.PickupGems[2]) ||
                    (thisPluginItemType == PluginItemTypes.Topaz && !FunkyBaseExtension.Settings.Loot.PickupGems[3]) ||
                    (thisPluginItemType == PluginItemTypes.Diamond && !FunkyBaseExtension.Settings.Loot.PickupGemDiamond))
                {
                    return(false);
                }
                break;

            case PluginBaseItemTypes.Misc:
                // Note; Infernal keys are misc, so should be picked up here - we aren't filtering them out, so should default to true at the end of this function
                if (thisPluginItemType == PluginItemTypes.CraftingMaterial)
                {
                    return(FunkyBaseExtension.Settings.Loot.PickupCraftMaterials);
                }
                if (thisPluginItemType == PluginItemTypes.LegendaryCraftingMaterial)
                {
                    return(true);
                }

                if (thisPluginItemType == PluginItemTypes.CraftingPlan)
                {
                    if (!FunkyBaseExtension.Settings.Loot.PickupCraftPlans)
                    {
                        return(false);
                    }

                    if (item.BalanceID.HasValue && item.BalanceData != null)
                    {
                        if (item.BalanceData.IsBlacksmithPlanSixProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanSix)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsBlacksmithPlanFiveProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanFive)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsBlacksmithPlanFourProperties && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanFour)
                        {
                            return(false);
                        }

                        if (item.BalanceData.IsBlacksmithPlanArchonSpaulders && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanArchonSpaulders)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsBlacksmithPlanArchonGauntlets && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanArchonGauntlets)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsBlacksmithPlanRazorspikes && !FunkyBaseExtension.Settings.Loot.PickupBlacksmithPlanRazorspikes)
                        {
                            return(false);
                        }


                        if (item.BalanceData.IsJewelcraftDesignAmulet && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignAmulet)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsJewelcraftDesignFlawlessStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignFlawlessStar)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsJewelcraftDesignMarquiseGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignMarquise)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsJewelcraftDesignPerfectStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignPerfectStar)
                        {
                            return(false);
                        }
                        if (item.BalanceData.IsJewelcraftDesignRadiantStarGem && !FunkyBaseExtension.Settings.Loot.PickupJewelerDesignRadiantStar)
                        {
                            return(false);
                        }
                    }
                }

                if (thisPluginItemType == PluginItemTypes.InfernalKey)
                {
                    return(FunkyBaseExtension.Settings.Loot.PickupInfernalKeys);
                }

                if (thisPluginItemType == PluginItemTypes.KeyStone)
                {
                    return(FunkyBaseExtension.Settings.Loot.PickupKeystoneFragments);
                }

                if (thisPluginItemType == PluginItemTypes.BloodShard)
                {
                    return(Backpack.GetBloodShardCount() < 500);
                }

                // Potion filtering
                if (thisPluginItemType == PluginItemTypes.HealthPotion || thisPluginItemType == PluginItemTypes.LegendaryHealthPotion)
                {
                    PotionTypes potionType = ItemFunc.ReturnPotionType(item.SNOID);
                    if (potionType == PotionTypes.Regular)
                    {
                        if (FunkyBaseExtension.Settings.Loot.MaximumHealthPotions <= 0)
                        {
                            return(false);
                        }


                        var BestPotionToUse = Backpack.ReturnBestPotionToUse();
                        if (BestPotionToUse == null)
                        {
                            return(true);
                        }

                        var Potions = Backpack.ReturnRegularPotions();
                        if (Potions.Sum(potions => potions.ThisItemStackQuantity) >= FunkyBaseExtension.Settings.Loot.MaximumHealthPotions)
                        {
                            return(false);
                        }
                    }
                }


                break;

            case PluginBaseItemTypes.HealthGlobe:
                return(false);

            case PluginBaseItemTypes.Unknown:
                return(false);

            default:
                return(false);
            }             // Switch giles base item type
            // Didn't cancel it, so default to true!
            return(true);
        }