private bool ItemRulesSalvageSell(ACDItem item, ItemEvaluationType evaluationType)
        {
            ItemEvents.ResetTownRun();
            if (!item.IsPotion)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation,
                           "Incoming {0} Request: {1}, {2}, {3}, {4}, {5}",
                           evaluationType, item.ItemQualityLevel, item.Level, item.ItemBaseType,
                           item.ItemType, item.IsOneHand ? "1H" : item.IsTwoHand ? "2H" : "NH");
            }

            Interpreter.InterpreterAction action = Trinity.StashRule.checkItem(item, ItemEvaluationType.Salvage);
            switch (action)
            {
            case Interpreter.InterpreterAction.SALVAGE:
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0}: {1}", evaluationType, (evaluationType == ItemEvaluationType.Salvage));
                return(evaluationType == ItemEvaluationType.Salvage);

            case Interpreter.InterpreterAction.SELL:
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0}: {1}", evaluationType, (evaluationType == ItemEvaluationType.Sell));
                return(evaluationType == ItemEvaluationType.Sell);

            default:
                Logger.Log(TrinityLogLevel.Info, LogCategory.ScriptRule, "Trinity, item is unhandled by ItemRules (SalvageSell)!");
                switch (evaluationType)
                {
                case ItemEvaluationType.Salvage:
                    return(TrinitySalvage(item));

                default:
                    return(TrinitySell(item));
                }
            }
        }
示例#2
0
        internal void ItemPickupEval(CacheItem item)
        {
            if (OnItemPickupEvaluation == null)
            {            //If no event hooked then use default evaluation
                if (Bot.Settings.ItemRules.UseItemRules)
                {
                    Interpreter.InterpreterAction action = ItemRulesEval.checkPickUpItem(item, ItemEvaluationType.PickUp);
                    switch (action)
                    {
                    case Interpreter.InterpreterAction.PICKUP:
                        item.ShouldPickup = true;
                        break;

                    case Interpreter.InterpreterAction.IGNORE:
                        item.ShouldPickup = false;
                        break;
                    }
                }

                if (!item.ShouldPickup.HasValue)
                {
                    //Use Giles Scoring or DB Weighting..
                    item.ShouldPickup =
                        Bot.Settings.ItemRules.ItemRuleGilesScoring ? Backpack.GilesPickupItemValidation(item)
                                                 : ItemManager.Current.EvaluateItem(item.ref_DiaItem.CommonData, ItemEvaluationType.PickUp);;
                }
            }
            else
            {
                OnItemPickupEvaluation(item);
            }
        }
示例#3
0
        internal static bool SellOverlord(object ret)
        {
            townRunItemCache.SellItems.Clear();


            //Not doing Greater Rift?
            if (!ZetaDia.Me.IsParticipatingInTieredLootRun || (!FunkyGame.Bounty.ActiveQuests.ContainsKey(BountyCache.ADVENTUREMODE_RIFTID) || FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step == 34 || FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step == 10))
            {
                //Get new list of current backpack
                var potions = Backpack.ReturnRegularPotions();
                if (potions.Count > 0)
                {
                    Backpack.CurrentPotionACDGUID = potions.First().ACDGUID;
                }

                foreach (var thisitem in Backpack.CacheItemList.Values)
                {
                    if (thisitem.ACDItem.BaseAddress != IntPtr.Zero)
                    {
                        // Find out if this item's in a protected bag slot
                        if (!ItemManager.Current.ItemIsProtected(thisitem.ACDItem))
                        {
                            if (thisitem.ItemType == PluginItemTypes.HealthPotion || thisitem.ItemType == PluginItemTypes.LegendaryHealthPotion || thisitem.ItemType == PluginItemTypes.HoradricCache)
                            {
                                if (thisitem.IsRegularPotion)
                                {
                                    if ((thisitem.ACDGUID != Backpack.CurrentPotionACDGUID && Backpack.CurrentPotionACDGUID != -1) ||
                                        FunkyTownRunPlugin.PluginSettings.PotionsCount == 0)
                                    {
                                        townRunItemCache.SellItems.Add(thisitem);
                                        FunkyTownRunPlugin.DBLog.InfoFormat("Selling Potion -- Current PotionACDGUID=={0}", Backpack.CurrentPotionACDGUID);
                                    }
                                }

                                continue;
                            }

                            if (FunkyTownRunPlugin.PluginSettings.UseItemRules)
                            {
                                Interpreter.InterpreterAction action = FunkyTownRunPlugin.ItemRulesEval.checkItem(thisitem.ACDItem, ItemEvaluationType.Keep);
                                switch (action)
                                {
                                case Interpreter.InterpreterAction.SELL:
                                    townRunItemCache.SellItems.Add(thisitem);
                                    continue;

                                case Interpreter.InterpreterAction.TRASH:
                                    if (SalvageValidation(thisitem))
                                    {
                                        continue;
                                    }
                                    townRunItemCache.SellItems.Add(thisitem);
                                    continue;
                                }
                            }

                            bool bShouldSellThis = false;
                            if (FunkyTownRunPlugin.PluginSettings.UseItemManagerEvaluation)
                            {
                                bShouldSellThis = ItemManager.Current.ShouldSellItem(thisitem.ACDItem);
                            }
                            else
                            {
                                if (SalvageValidation(thisitem))
                                {
                                    continue;
                                }
                                if (thisitem.IsUnidentified)
                                {
                                    continue;
                                }


                                bShouldSellThis = SellValidation(thisitem.ThisInternalName, thisitem.ThisLevel, thisitem.ThisQuality, thisitem.ThisDBItemType, thisitem.ThisFollowerType);
                            }

                            if (bShouldSellThis)
                            {
                                townRunItemCache.SellItems.Add(thisitem);
                            }
                        }
                    }
                    else
                    {
                        FunkyTownRunPlugin.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [StashOver-1]");
                    }
                }
            }

            bool bShouldVisitVendor = townRunItemCache.SellItems.Count > 0;

            if (bShouldVisitVendor)
            {
                FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Vendor Started (Selling Items)");
                townRunItemCache.sortSellList();
                foreach (var item in townRunItemCache.SellItems)
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("Selling Item: {0}({1}) Sno {2}", item.ThisRealName, item.ThisInternalName, item.SNO);
                }
            }


            if (!CheckedVendorActions)
            {
                CheckedVendorActions = true;

                // Check durability percentages
                bNeedsEquipmentRepairs = Equipment.ShouldRepairItems(CharacterSettings.Instance.RepairWhenDurabilityBelow);
                if (bNeedsEquipmentRepairs)
                {
                    FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Vendor Started (Repair Items)");
                }

                if (!bShouldVisitVendor)
                {
                    bShouldVisitVendor = bNeedsEquipmentRepairs;
                }

                // Check Buying Potions?
                if (FunkyTownRunPlugin.PluginSettings.BuyPotionsDuringTownRun && FunkyTownRunPlugin.PluginSettings.PotionsCount > Backpack.CurrentPotionCount)
                {
                    bBuyingPotions = true;
                    PotionCount    = Backpack.CurrentPotionCount;
                    FunkyTownRunPlugin.DBLog.InfoFormat("[Funky] Town Run Behavior Vendor Started (Buying Potions)");
                    if (!bShouldVisitVendor)
                    {
                        bShouldVisitVendor = true;
                    }
                }
            }


            return(bShouldVisitVendor);
        }
示例#4
0
        internal static bool StashOverlord(object ret)
        {
            townRunItemCache.KeepItems.Clear();

            //Doing Greater Rift? (But not completed yet..) then skip stashing.
            if (ZetaDia.Me.IsParticipatingInTieredLootRun &&
                (FunkyGame.Bounty.ActiveQuests.ContainsKey(BountyCache.ADVENTUREMODE_RIFTID) &&
                 (FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step != 34 && FunkyGame.Bounty.ActiveQuests[BountyCache.ADVENTUREMODE_RIFTID].Step != 10)))
            {
                return(false);
            }


            //Get new list of current backpack
            Backpack.UpdateItemList();


            //Update any Unidified items that we may have..
            if (FunkyTownRunPlugin.PluginSettings.IdentifyLegendaries)
            {
                var UnidItemACDGUIDs = Backpack.CacheItemList.Where(i => i.Value.IsUnidentified).Select(i => i.Key).ToList();
                foreach (int unidItemAcdguiD in UnidItemACDGUIDs)
                {
                    using (ZetaDia.Memory.AcquireFrame())
                    {
                        Backpack.CacheItemList[unidItemAcdguiD] = new CacheACDItem(Backpack.CacheItemList[unidItemAcdguiD].ACDItem);
                    }
                }
            }

            foreach (var thisitem in Backpack.CacheItemList.Values)
            {
                if (thisitem.ACDItem.BaseAddress != IntPtr.Zero)
                {
                    // Find out if this item's in a protected bag slot
                    if (!ItemManager.Current.ItemIsProtected(thisitem.ACDItem))
                    {
                        //Don't Stash Potions.
                        if (thisitem.ItemType == PluginItemTypes.HealthPotion ||
                            thisitem.ItemType == PluginItemTypes.LegendaryHealthPotion)
                        {
                            continue;
                        }


                        //Stashing Horadric Caches?
                        if (thisitem.ItemType == PluginItemTypes.HoradricCache)
                        {
                            if (FunkyTownRunPlugin.PluginSettings.StashHoradricCache)
                            {
                                townRunItemCache.KeepItems.Add(thisitem);
                            }

                            continue;
                        }

                        //UnId Items
                        if (thisitem.IsUnidentified && !FunkyTownRunPlugin.PluginSettings.IdentifyLegendaries)
                        {
                            townRunItemCache.KeepItems.Add(thisitem);
                            continue;
                        }

                        if (FunkyTownRunPlugin.PluginSettings.UseItemRules)
                        {
                            Interpreter.InterpreterAction action = FunkyTownRunPlugin.ItemRulesEval.checkItem(thisitem.ACDItem, ItemEvaluationType.Keep);
                            switch (action)
                            {
                            case Interpreter.InterpreterAction.KEEP:
                                townRunItemCache.KeepItems.Add(thisitem);
                                continue;

                            case Interpreter.InterpreterAction.TRASH:
                                continue;
                            }
                        }
                        bool bShouldStashThis = false;

                        if (FunkyTownRunPlugin.PluginSettings.UseItemManagerEvaluation)
                        {
                            ItemManager.Current.ShouldStashItem(thisitem.ACDItem);
                        }
                        else
                        {
                            bShouldStashThis = StashValidation(thisitem);
                        }

                        if (bShouldStashThis)
                        {
                            townRunItemCache.KeepItems.Add(thisitem);
                        }
                    }
                }
                else
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [StashOver-1]");
                }
            }

            return(townRunItemCache.KeepItems.Count > 0);
        }
示例#5
0
        // **********************************************************************************************
        // *****  Sell Overlord - determines if we should visit the vendor for repairs or selling   *****
        // **********************************************************************************************
        internal static bool GilesSellOverlord(object ret)
        {
            Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Clear();



            //Get new list of current backpack
            Bot.Character.Data.BackPack.Update();
            //Setup any extra potions to sell.


            //Refresh item manager if we are not using item rules nor giles scoring.
            if (!Bot.Settings.ItemRules.UseItemRules && !Bot.Settings.ItemRules.ItemRuleGilesScoring)
            {
                ItemManager.Current.Refresh();
            }

            foreach (var thisitem in Bot.Character.Data.BackPack.CacheItemList.Values)
            {
                if (thisitem.ACDItem.BaseAddress != IntPtr.Zero)
                {
                    // Find out if this item's in a protected bag slot
                    if (!ItemManager.Current.ItemIsProtected(thisitem.ACDItem))
                    {
                        if (thisitem.ThisDBItemType == ItemType.Potion)
                        {
                            if (thisitem.ACDGUID != Bot.Character.Data.BackPack.CurrentPotionACDGUID && Bot.Character.Data.BackPack.CurrentPotionACDGUID != -1)
                            {
                                Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Add(thisitem);
                                Logger.DBLog.InfoFormat("Selling Potion -- Current PotionACDGUID=={0}", Bot.Character.Data.BackPack.CurrentPotionACDGUID);
                            }
                            continue;
                        }

                        if (Bot.Settings.ItemRules.ItemRulesSalvaging)
                        {
                            if (Bot.Character.ItemRulesEval.checkSalvageItem(thisitem.ACDItem) == Interpreter.InterpreterAction.SALVAGE)
                            {
                                continue;
                            }
                        }


                        if (Bot.Settings.ItemRules.UseItemRules)
                        {
                            Interpreter.InterpreterAction action = Bot.Character.ItemRulesEval.checkItem(thisitem.ACDItem, ItemEvaluationType.Keep);
                            switch (action)
                            {
                            case Interpreter.InterpreterAction.TRASH:
                                Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Add(thisitem);
                                continue;
                            }
                        }



                        //Logger.DBLog.InfoFormat("GilesTrinityScoring == "+Bot.SettingsFunky.ItemRules.ItemRuleGilesScoring.ToString());

                        bool bShouldSellThis = Bot.Settings.ItemRules.ItemRuleGilesScoring ? Backpack.GilesSellValidation(thisitem.ThisInternalName, thisitem.ThisLevel, thisitem.ThisQuality, thisitem.ThisDBItemType, thisitem.ThisFollowerType) : ItemManager.Current.ShouldSellItem(thisitem.ACDItem);

                        if (bShouldSellThis)
                        {
                            Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Add(thisitem);
                        }
                    }
                }
                else
                {
                    Logger.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [StashOver-1]");
                }
            }

            bool bShouldVisitVendor = Bot.Character.Data.BackPack.townRunCache.hashGilesCachedSellItems.Count > 0;

            if (bShouldVisitVendor)
            {
                Bot.Character.Data.BackPack.townRunCache.sortSellList();
            }
            else
            {
                if (!bCheckedItemDurability)
                {
                    bCheckedItemDurability = true;
                    // Check durability percentages
                    bNeedsEquipmentRepairs = Bot.Character.Data.BackPack.ShouldRepairItems();
                    bShouldVisitVendor     = bNeedsEquipmentRepairs;
                }
            }

            return(bShouldVisitVendor);
        }
        public bool ShouldStashItem(ACDItem item, ItemEvaluationType evaluationType)
        {
            ItemEvents.ResetTownRun();

            if (Current.ItemIsProtected(item))
            {
                return(false);
            }

            // Vanity Items
            if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i)))
            {
                return(false);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.DemonBuddy)
            {
                return(Current.ShouldStashItem(item));
            }

            CachedACDItem cItem = CachedACDItem.GetCachedItem(item);

            // Now look for Misc items we might want to keep
            GItemType     tItemType = cItem.TrinityItemType;     // DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType tBaseType = cItem.TrinityItemBaseType; // DetermineBaseType(trinityItemType);

            bool isEquipment = (tBaseType == GItemBaseType.Armor ||
                                tBaseType == GItemBaseType.Jewelry ||
                                tBaseType == GItemBaseType.Offhand ||
                                tBaseType == GItemBaseType.WeaponOneHand ||
                                tBaseType == GItemBaseType.WeaponRange ||
                                tBaseType == GItemBaseType.WeaponTwoHand);

            if (cItem.TrinityItemType == GItemType.HoradricCache && Trinity.Settings.Loot.TownRun.OpenHoradricCaches)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (ignoring Horadric Cache)", cItem.RealName, cItem.InternalName);
                return(false);
            }

            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (cItem.IsUnidentified)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] = (autokeep unidentified items)", cItem.RealName, cItem.InternalName);
                }
                return(true);
            }
            if (tItemType == GItemType.StaffOfHerding)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep staff of herding)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftingMaterial)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep craft materials)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (tItemType == GItemType.Emerald || tItemType == GItemType.Amethyst || tItemType == GItemType.Topaz || tItemType == GItemType.Ruby || tItemType == GItemType.Diamond)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.CraftTome)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep tomes)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }
            if (tItemType == GItemType.InfernalKey)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep infernal key)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (tItemType == GItemType.HealthPotion)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (ignoring potions)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(false);
            }

            if (tItemType == GItemType.CraftingPlan && cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendary plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                Interpreter.InterpreterAction action = Trinity.StashRule.checkItem(item, evaluationType);

                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (" + action + ")", cItem.AcdItem.Name, cItem.AcdItem.InternalName, cItem.AcdItem.ItemType);
                }
                switch (action)
                {
                case Interpreter.InterpreterAction.KEEP:
                    return(true);

                case Interpreter.InterpreterAction.TRASH:
                    return(false);

                case Interpreter.InterpreterAction.SCORE:
                    break;
                }
            }

            if (tItemType == GItemType.CraftingPlan)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep plans)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Stashing Whites, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashWhites && isEquipment && cItem.Quality <= ItemQuality.Superior)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto-trash
            if (cItem.Quality <= ItemQuality.Superior && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trash whites)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Stashing blues, auto-keep
            if (Trinity.Settings.Loot.TownRun.StashBlues && isEquipment && cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3)
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (stashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(true);
            }
            // Else auto trash
            if (cItem.Quality >= ItemQuality.Magic1 && cItem.Quality <= ItemQuality.Magic3 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (trashing blues)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            // Force salvage Rares
            if (Trinity.Settings.Loot.TownRun.ForceSalvageRares && cItem.Quality >= ItemQuality.Rare4 && cItem.Quality <= ItemQuality.Rare6 && (isEquipment || cItem.TrinityItemBaseType == GItemBaseType.FollowerItem))
            {
                Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (force salvage rare)", cItem.RealName, cItem.InternalName, tItemType);
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    Logger.Log(TrinityLogLevel.Info, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendaries)", cItem.RealName, cItem.InternalName, tItemType);
                }
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            double iNeedScore = Trinity.ScoreNeeded(item.ItemBaseType);
            double iMyScore   = ItemValuation.ValueThisItem(cItem, tItemType);

            if (evaluationType == ItemEvaluationType.Keep)
            {
                Logger.Log(TrinityLogLevel.Verbose, LogCategory.ItemValuation, "{0} [{1}] [{2}] = {3}", cItem.RealName, cItem.InternalName, tItemType, iMyScore);
            }
            if (iMyScore >= iNeedScore)
            {
                return(true);
            }

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
示例#7
0
        public bool ShouldStashItem(ACDItem item, ItemEvaluationType evaluationType)
        {
            if (ItemManager.Current.ItemIsProtected(item))
            {
                return(false);
            }

            GilesCachedACDItem cItem = GilesCachedACDItem.GetCachedItem(item);

            // Now look for Misc items we might want to keep
            GItemType     trinityItemType = cItem.TrinityItemType;     // DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType);
            GItemBaseType trinityBaseType = cItem.TrinityItemBaseType; // DetermineBaseType(trinityItemType);

            if (trinityItemType == GItemType.StaffOfHerding)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep staff of herding)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.CraftingMaterial)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep craft materials)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            if (trinityItemType == GItemType.Emerald)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Amethyst)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Topaz)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.Ruby)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep gems)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.CraftTome)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (autokeep tomes)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.InfernalKey)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep infernal key)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }
            if (trinityItemType == GItemType.HealthPotion)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.ItemValuation, "{0} [{1}] [{2}] = (ignoring potions)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(false);
            }

            // Stash all unidentified items - assume we want to keep them since we are using an identifier over-ride
            if (cItem.IsUnidentified)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] = (autokeep unidentified items)", cItem.RealName, cItem.InternalName);
                }
                return(true);
            }

            if (GilesTrinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
            {
                Interpreter.InterpreterAction action = GilesTrinity.StashRule.checkItem(item, evaluationType);
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (" + action + ")", cItem.AcdItem.Name, cItem.AcdItem.InternalName, cItem.AcdItem.ItemType);
                }
                switch (action)
                {
                case Interpreter.InterpreterAction.KEEP:
                    return(true);

                case Interpreter.InterpreterAction.TRASH:
                    return(false);

                case Interpreter.InterpreterAction.SCORE:
                    break;
                }
            }

            // auto trash blue weapons/armor/jewlery
            if ((item.ItemBaseType == ItemBaseType.Armor ||
                 item.ItemBaseType == ItemBaseType.Weapon ||
                 item.ItemBaseType == ItemBaseType.Jewelry) &&
                item.ItemQualityLevel < ItemQuality.Rare4)
            {
                return(false);
            }

            if (cItem.Quality >= ItemQuality.Legendary)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep legendaries)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            if (trinityItemType == GItemType.CraftingPlan)
            {
                if (evaluationType == ItemEvaluationType.Keep)
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "{0} [{1}] [{2}] = (autokeep plans)", cItem.RealName, cItem.InternalName, trinityItemType);
                }
                return(true);
            }

            // Ok now try to do some decent item scoring based on item types
            double iNeedScore = GilesTrinity.ScoreNeeded(item.ItemBaseType);
            double iMyScore   = ItemValuation.ValueThisItem(cItem, trinityItemType);

            if (evaluationType == ItemEvaluationType.Keep)
            {
                DbHelper.Log(TrinityLogLevel.Verbose, LogCategory.ItemValuation, "{0} [{1}] [{2}] = {3}", cItem.RealName, cItem.InternalName, trinityItemType, iMyScore);
            }
            if (iMyScore >= iNeedScore)
            {
                return(true);
            }

            // If we reached this point, then we found no reason to keep the item!
            return(false);
        }
示例#8
0
        // **********************************************************************************************
        // *****       Stash Overlord values all items and checks if we have anything to stash      *****
        // **********************************************************************************************
        internal static bool GilesStashOverlord(object ret)
        {
            //Clear Cache Item List -- (This is the first to be ran so we want fresh data!)
            //Bot.Character_.Data.BackPack.CacheItemList.Clear();

            Bot.Character.Data.BackPack.townRunCache.hashGilesCachedKeepItems.Clear();

            //Get new list of current backpack
            Bot.Character.Data.BackPack.Update();

            //Refresh item manager if we are not using item rules nor giles scoring.
            if (!Bot.Settings.ItemRules.UseItemRules && !Bot.Settings.ItemRules.ItemRuleGilesScoring)
            {
                ItemManager.Current.Refresh();
            }

            //Update any Unidified items that we may have..
            var UnidItemACDGUIDs = Bot.Character.Data.BackPack.CacheItemList.Where(i => i.Value.IsUnidentified).Select(i => i.Key).ToList();

            foreach (int unidItemAcdguiD in UnidItemACDGUIDs)
            {
                using (ZetaDia.Memory.AcquireFrame())
                {
                    Bot.Character.Data.BackPack.CacheItemList[unidItemAcdguiD] = new CacheACDItem(Bot.Character.Data.BackPack.CacheItemList[unidItemAcdguiD].ACDItem);
                }
            }

            foreach (var thisitem in Bot.Character.Data.BackPack.CacheItemList.Values)
            {
                if (thisitem.ACDItem.BaseAddress != IntPtr.Zero)
                {
                    // Find out if this item's in a protected bag slot
                    if (!ItemManager.Current.ItemIsProtected(thisitem.ACDItem))
                    {
                        //Don't Stash Potions.
                        if (thisitem.ThisDBItemType == ItemType.Potion)
                        {
                            continue;
                        }

                        if (Bot.Settings.ItemRules.UseItemRules)
                        {
                            Interpreter.InterpreterAction action = Bot.Character.ItemRulesEval.checkItem(thisitem.ACDItem, ItemEvaluationType.Keep);
                            switch (action)
                            {
                            case Interpreter.InterpreterAction.KEEP:
                                Bot.Character.Data.BackPack.townRunCache.hashGilesCachedKeepItems.Add(thisitem);
                                continue;

                            case Interpreter.InterpreterAction.TRASH:
                                continue;
                            }
                        }


                        bool bShouldStashThis = (Bot.Settings.ItemRules.ItemRuleGilesScoring ? Backpack.ShouldWeStashThis(thisitem)
                                                        : ItemManager.Current.ShouldStashItem(thisitem.ACDItem));


                        //Logger.DBLog.InfoFormat("GilesTrinityScoring == "+Bot.SettingsFunky.ItemRules.ItemRuleGilesScoring.ToString());



                        if (bShouldStashThis)
                        {
                            Bot.Character.Data.BackPack.townRunCache.hashGilesCachedKeepItems.Add(thisitem);
                        }
                    }
                }
                else
                {
                    Logger.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [StashOver-1]");
                }
            }

            return(Bot.Character.Data.BackPack.townRunCache.hashGilesCachedKeepItems.Count > 0);
        }
示例#9
0
        private static void UpdateSalvageItemList()
        {
            //Get new list of current backpack
            Backpack.UpdateItemList();

            bShouldSalvageAllNormal  = true;
            bShouldSalvageAllMagical = true;
            bShouldSalvageAllRare    = true;

            townRunItemCache.SalvageItems.Clear();

            foreach (var thisitem in Backpack.CacheItemList.Values)
            {
                if (thisitem.ACDItem.BaseAddress != IntPtr.Zero)
                {
                    // Find out if this item's in a protected bag slot
                    if (!ItemManager.Current.ItemIsProtected(thisitem.ACDItem))
                    {
                        if (!thisitem.IsSalvagable)
                        {
                            continue;
                        }

                        if (FunkyTownRunPlugin.PluginSettings.UseItemManagerEvaluation)
                        {
                            //Check if we should keep it!?
                            if (ItemManager.Current.ShouldStashItem(thisitem.ACDItem))
                            {
                                continue;
                            }

                            if (ItemManager.Current.ShouldSalvageItem(thisitem.ACDItem))
                            {
                                townRunItemCache.SalvageItems.Add(thisitem);
                                continue;
                            }

                            if (thisitem.ThisQuality < ItemQuality.Magic1)
                            {
                                bShouldSalvageAllNormal = false;
                            }
                            else if (thisitem.ThisQuality < ItemQuality.Rare4)
                            {
                                bShouldSalvageAllMagical = false;
                            }
                            else if (thisitem.ThisQuality < ItemQuality.Legendary)
                            {
                                bShouldSalvageAllRare = false;
                            }

                            continue;
                        }
                        else
                        {
                            //Check if we should keep it!?
                            if (FunkyTownRunPlugin.PluginSettings.UseItemRules)
                            {
                                Interpreter.InterpreterAction action = FunkyTownRunPlugin.ItemRulesEval.checkItem(thisitem.ACDItem, ItemEvaluationType.Keep);
                                switch (action)
                                {
                                case Interpreter.InterpreterAction.SALVAGE:
                                    townRunItemCache.SalvageItems.Add(thisitem);
                                    continue;

                                case Interpreter.InterpreterAction.TRASH:
                                    if (SalvageValidation(thisitem))
                                    {
                                        townRunItemCache.SalvageItems.Add(thisitem);
                                        continue;
                                    }
                                    break;
                                }
                            }

                            if (StashValidation(thisitem))
                            {
                                continue;
                            }
                        }



                        if (SalvageValidation(thisitem))
                        {
                            townRunItemCache.SalvageItems.Add(thisitem);
                        }
                        else
                        {
                            if (thisitem.ThisQuality < ItemQuality.Magic1)
                            {
                                bShouldSalvageAllNormal = false;
                            }
                            else if (thisitem.ThisQuality < ItemQuality.Rare4)
                            {
                                bShouldSalvageAllMagical = false;
                            }
                            else if (thisitem.ThisQuality < ItemQuality.Legendary)
                            {
                                bShouldSalvageAllRare = false;
                            }
                        }
                    }
                }
                else
                {
                    FunkyTownRunPlugin.DBLog.DebugFormat("GSError: Diablo 3 memory read error, or item became invalid [StashOver-1]");
                }
            }
        }