internal static void TrinityOnItemSold(object sender, ItemEventArgs e) { ResetTownRun(); try { ACDItem i = e.Item; if (i == null || !i.IsValid || i.IsDisposed) { return; } var cachedItem = CachedACDItem.GetCachedItem(i); switch (i.ItemBaseType) { case ItemBaseType.Gem: case ItemBaseType.Misc: break; default: TownRun.LogJunkItems(cachedItem, cachedItem.TrinityItemBaseType, cachedItem.TrinityItemType, ItemValuation.ValueThisItem(cachedItem, cachedItem.TrinityItemType)); break; } } catch (Exception ex) { if (ex is CoroutineStoppedException) { throw; } } }
/// <summary> /// Determines if we should salvage an item /// </summary> /// <param name="item"></param> /// <returns></returns> private static bool TrinitySalvage(ACDItem item) { CachedACDItem cItem = CachedACDItem.GetCachedItem(item); if (cItem.AcdItem.IsVendorBought) { return(false); } // Vanity Items if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i))) { return(false); } GItemType trinityItemType = Trinity.DetermineItemType(cItem.InternalName, cItem.DBItemType, cItem.FollowerType); GItemBaseType trinityItemBaseType = Trinity.DetermineBaseType(trinityItemType); // Take Salvage Option corresponding to ItemLevel SalvageOption salvageOption = GetSalvageOption(cItem.Quality); // Stashing Whites if (Trinity.Settings.Loot.TownRun.StashWhites && cItem.Quality < ItemQuality.Magic1) { return(false); } // Stashing Blues if (Trinity.Settings.Loot.TownRun.StashBlues && cItem.Quality > ItemQuality.Superior && cItem.Quality < ItemQuality.Rare4) { return(false); } switch (trinityItemBaseType) { case GItemBaseType.WeaponRange: case GItemBaseType.WeaponOneHand: case GItemBaseType.WeaponTwoHand: case GItemBaseType.Armor: case GItemBaseType.Offhand: return(salvageOption == SalvageOption.Salvage); case GItemBaseType.Jewelry: return(salvageOption == SalvageOption.Salvage); case GItemBaseType.FollowerItem: return(salvageOption == SalvageOption.Salvage); case GItemBaseType.Gem: case GItemBaseType.Misc: case GItemBaseType.Unknown: return(false); default: return(false); } }
public override bool ShouldSellItem(ACDItem item) { bool action = ShouldSellItem(item, ItemEvaluationType.Sell); if (action) { ItemStashSellAppender.Instance.AppendItem(CachedACDItem.GetCachedItem(item), "Sell"); } return(action); }
public bool ShouldSellItem(ACDItem item, ItemEvaluationType evaluationType) { ItemEvents.ResetTownRun(); CachedACDItem cItem = CachedACDItem.GetCachedItem(item); if (Current.ItemIsProtected(cItem.AcdItem)) { return(false); } if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.DemonBuddy) { return(Current.ShouldSellItem(item)); } if (Trinity.Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules) { return(ItemRulesSalvageSell(item, evaluationType)); } return(TrinitySell(item)); }
public static void ItemListTest() { Logger.Log("Starting ItemList Backpack Test"); var backpackItems = ZetaDia.Me.Inventory.Backpack.ToList(); var total = backpackItems.Count; var stashCount = 0; foreach (var acdItem in backpackItems) { Logger.Log("{0} ActorSNO={1} GameBalanceId={2}", acdItem.Name, acdItem.ActorSNO, acdItem.GameBalanceId); var cItem = CachedACDItem.GetCachedItem(acdItem); if (ItemList.ShouldStashItem(cItem, true)) { stashCount++; } } Logger.Log("Finished ItemList Backpack Test"); Logger.Log("Finished - Stash {0} / {1}", stashCount, total); }
/// <summary> /// Determines if we should Sell an Item /// </summary> /// <param name="item"></param> /// <returns></returns> private static bool TrinitySell(ACDItem item) { CachedACDItem cItem = CachedACDItem.GetCachedItem(item); // Vanity Items if (DataDictionary.VanityItems.Any(i => item.InternalName.StartsWith(i))) { return(false); } switch (cItem.TrinityItemBaseType) { case GItemBaseType.WeaponRange: case GItemBaseType.WeaponOneHand: case GItemBaseType.WeaponTwoHand: case GItemBaseType.Armor: case GItemBaseType.Offhand: case GItemBaseType.Jewelry: case GItemBaseType.FollowerItem: return(true); case GItemBaseType.Gem: case GItemBaseType.Misc: if (cItem.TrinityItemType == GItemType.HealthPotion && Trinity.Settings.Loot.TownRun.SellExtraPotions) { // Never sell our precious legendary potions! if (cItem.AcdItem.ItemQualityLevel >= ItemQuality.Legendary) { return(false); } bool hasLegendaryPotion = ZetaDia.Me.Inventory.Backpack.Any(i => i.ItemType == ItemType.Potion && i.ItemQualityLevel >= ItemQuality.Legendary); // If we have a legendary potion, sell regular potions if (hasLegendaryPotion && cItem.AcdItem.ItemQualityLevel <= ItemQuality.Legendary) { return(true); } // If we have more than 1 stack of potions // Keep the largest stack until we only have 1 stack int potionStacks = ZetaDia.Me.Inventory.Backpack.Count(i => i.ItemType == ItemType.Potion); if (potionStacks > 1) { // Keep only the highest stack ACDItem acdItem = ZetaDia.Me.Inventory.Backpack .Where(i => i.ItemType == ItemType.Potion && i.ItemQualityLevel == ItemQuality.Normal) .OrderBy(i => i.ItemStackQuantity) .FirstOrDefault(); if (acdItem != null && cItem.AcdItem.ACDGuid == acdItem.ACDGuid) { return(true); } } } if (cItem.TrinityItemType == GItemType.CraftingPlan) { return(true); } return(false); case GItemBaseType.Unknown: return(false); } return(false); }
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); }
public static async Task <bool> CleanTask() { try { if (!ZetaDia.IsInGame) { return(false); } if (ZetaDia.IsLoadingWorld) { return(false); } if (!ZetaDia.Me.IsFullyValid()) { return(false); } if (ZetaDia.Me.IsParticipatingInTieredLootRun) { Logger.LogNormal("Cannot clean stash while in trial/greater rift"); RemoveBehavior("Cannot clean stash while in trial/greater rift"); return(false); } if (TrinityItemManager.FindValidBackpackLocation(true) == new Vector2(-1, -1)) { Trinity.ForceVendorRunASAP = true; return(false); } if (!await TrinityCoroutines.Common.ReturnToStashTask()) { _isFinished = true; return(false); } if (GameUI.IsElementVisible(GameUI.StashDialogMainPage)) { Logger.Log("Cleaning stash..."); foreach (var item in ZetaDia.Me.Inventory.StashItems.Where(i => i.ACDGuid != 0 && i.IsValid).ToList()) { CachedACDItem cItem = CachedACDItem.GetCachedItem(item); // Don't take potions from the stash if (cItem.TrinityItemType == TrinityItemType.HealthPotion) { continue; } try { if (!ItemManager.Current.ShouldStashItem(item)) { Logger.Log("Removing {0} from stash", item.Name); ZetaDia.Me.Inventory.QuickWithdraw(item); await Coroutine.Sleep(ItemMovementDelay); await Coroutine.Yield(); if (TrinityItemManager.FindValidBackpackLocation(true) == new Vector2(-1, -1)) { Trinity.ForceVendorRunASAP = true; return(false); } } } catch (Exception ex) { Logger.LogError(ex.ToString()); } } _isFinished = true; Trinity.ForceVendorRunASAP = true; Logger.Log("Waiting 5 seconds..."); BotMain.StatusText = "Waiting 5 seconds..."; await Coroutine.Sleep(5000); if (TrinityCoroutines.Common.StartedOutOfTown && ZetaDia.IsInTown) { await CommonBehaviors.TakeTownPortalBack().ExecuteCoroutine(); } } if (_isFinished) { RemoveBehavior("finished!"); } return(true); } catch (Exception ex) { _isFinished = true; Logger.LogError(ex.ToString()); return(false); } }