public static bool ShouldStash(TrinityItem i) { if (i.IsUnidentified) { return(true); } if (Core.Player.IsInventoryLockedForGreaterRift) { return(false); } if (Cache.ContainsKey(i.AnnId)) { return(Cache[i.AnnId]); } if (i.IsProtected()) { return(false); } var decision = Combat.TrinityCombat.Loot.ShouldStash(i); Cache.Add(i.AnnId, decision); return(decision); }
private static bool CanStackOnPage(TrinityItem item, int stashPageNumber, ref int col, ref int row, InventoryMap itemsOnStashPage) { if (item.IsUnidentified) { return(false); } if (item.MaxStackCount <= 0 || item.IsTradeable || SpecialCaseNonStackableItems.Contains(item.RawItemType)) { return(false); } for (var i = 0; i < 10; i++) { for (var c = 0; c < 7; c++) { var r = stashPageNumber * 10 + i; if (TryGetStackLocation(item, stashPageNumber, c, r, itemsOnStashPage, ref col, ref row)) { return(true); } } } return(false); }
public static bool ShouldDrop(TrinityItem i) { if (Cache.ContainsKey(i.AnnId)) { return(Cache[i.AnnId]); } if (i.IsProtected()) { return(false); } var action = ItemEvaluationType.Keep; if (StashItems.ShouldStash(i)) { action = ItemEvaluationType.Keep; } else if (SellItems.ShouldSell(i)) { action = ItemEvaluationType.Sell; } else if (SalvageItems.ShouldSalvage(i)) { action = ItemEvaluationType.Salvage; } var decision = Combat.TrinityCombat.Loot.ShouldDrop(i, action) && !i.IsAccountBound; Cache.Add(i.AnnId, decision); return(decision); }
public static bool CanPickupItem(TrinityItem actor) { if (actor.InventorySlot != InventorySlot.None) { return(false); } if (actor.Attributes?.ItemBoundToACDId != -1) { return(actor.Attributes != null && actor.Attributes.ItemBoundToACDId == Core.Actors.Me?.AcdId); } if (actor.ItemQualityLevel >= ItemQuality.Legendary || actor.IsCraftingReagent) { if (actor.Attributes?.ItemBoundToACDId == -1) { return(true); } return(actor.Attributes != null && actor.IsTradeable); } if (actor.IsEquipment && actor.ItemQualityLevel <= ItemQuality.Rare6) { return(true); } return(false); }
private static async Task <bool> ExtractPower(TrinityItem item) { if (item == null) { return(false); } var itemName = item.Name; var itemDynamicId = item.AnnId; var itemInternalName = item.InternalName; var itemSnoId = item.ActorSnoId; var affixDescription = item.Reference.LegendaryAffix; await Transmute.Execute(item, TransmuteRecipe.ExtractLegendaryPower); await Coroutine.Sleep(1500); var shouldBeDestroyedItem = InventoryManager.Backpack.FirstOrDefault(i => i.AnnId == itemDynamicId); if (shouldBeDestroyedItem == null && ZetaDia.Storage.PlayerDataManager.ActivePlayerData.KanaisPowersExtractedActorSnoIds.Contains(itemSnoId)) { Core.Logger.Log($"[ExtractLegendaryPowers] Item Power Extracted! '{itemName}' ({itemSnoId}) Description={affixDescription}"); Core.Inventory.InvalidAnnIds.Add(itemDynamicId); _itemsTakenFromStashAnnId.Remove(itemDynamicId); return(true); } Core.Logger.Log($"[ExtractLegendaryPowers] Failed to Extract Power! '{itemName}' ({itemSnoId}) {itemInternalName} DynId={itemDynamicId}"); _blacklistedActorSnoIds.Add(itemSnoId); return(false); }
/// <summary> /// Drop item in town and record it so we can avoid picking it up again. /// </summary> public static async Task <bool> Drop(TrinityItem item) { if (!ZetaDia.IsInGame || !ZetaDia.IsInTown || item.IsAccountBound) { return(false); } Core.Logger.Log($"[DropItems] --> Dropping {item.Name} ({item.ActorSnoId}) in town. AnnId={item.AnnId} "); bool dropResult = false; try { dropResult = item.Drop(); } catch (InjectionSEHException) { Core.Logger.Log($"[DropItems] --> Failed to Drop {item.Name} ({item.ActorSnoId}) in town. AnnId={item.AnnId} "); DroppedItemAnnIds.Add(item.AnnId); } if (dropResult) { DroppedItemAnnIds.Add(item.AnnId); ItemEvents.FireItemDropped(item); await Coroutine.Sleep(500); return(true); } return(false); }
private bool ShouldCacheItem(TrinityItem cacheObject) { if (!cacheObject.IsPickupNoClick && TrinityCombat.Loot.IsBackpackFull) { cacheObject.AddCacheInfo("BackpackFull"); return(false); } if (cacheObject.IsMyDroppedItem) { cacheObject.AddCacheInfo("DroppedItem"); return(false); } if (cacheObject.IsUntargetable) { cacheObject.AddCacheInfo("Untargetable"); return(false); } if (!cacheObject.IsCosmeticItem && cacheObject.ItemQualityLevel <= ItemQuality.Rare4 && cacheObject.Distance > 60f) { cacheObject.AddCacheInfo($"OutOfRange Limit={CharacterSettings.Instance.LootRadius}"); return(false); } if (!TrinityCombat.Loot.ShouldPickup(cacheObject)) { cacheObject.AddCacheInfo("LootProvider.ShouldPickup"); return(false); } return(true); }
public string LogTemplate(ItemAction action, TrinityItem item) => $"{Environment.NewLine}" + $"{DateTime.UtcNow.ToLocalTime():f} {Environment.NewLine}" + $"{item.Name} ({item.ActorSnoId}), {item.RawItemType} {Environment.NewLine}" + $"{item.ItemBaseType}: {item.TrinityItemType}, {item.TrinityItemQuality}" + $"{(item.IsAncient ? ", Ancient" : string.Empty)}, {item.Attributes}" + $"{Environment.NewLine}";
public static bool ShouldIgnoreGlobe(TrinityItem actor, out string reason) { reason = string.Empty; if (actor == null) { return(false); } switch (Core.Settings.Weighting.GlobeWeighting) { case SettingMode.Disabled: reason = "Ignore(Globes=Disabled)"; return(true); case SettingMode.None: reason = "Keep(Globes=None)"; return(false); case SettingMode.Enabled: reason = "Keep(Globes=Enabled)"; return(false); } var item = actor.ToAcdItem(); if (Core.Settings.Weighting.GlobeTypes.HasFlag(item.GetGlobeType())) { return(false); } reason = $"Ignore({item.GetGlobeType()}=Disabled)"; return(true); }
public static bool CanPickupItem(TrinityItem actor) { if (actor.InventorySlot != InventorySlot.None) { return(false); } if (actor.Attributes != null) { if (actor.Attributes.ItemBoundToAnnId != 0 && actor.Attributes.ItemBoundToAnnId != -1) { return(actor.Attributes.ItemBoundToAnnId == Core.Actors.Me?.AnnId); } if (actor.Attributes.ItemAssignedHero == ZetaDia.Service.Hero?.HeroId) { return(true); } } if (actor.ItemQualityLevel >= ItemQuality.Legendary || actor.IsCraftingReagent) { return(actor.Attributes != null && (!actor.Attributes.IsTradeable || actor.Attributes.ItemTradePlayerLow.Any(a => a == ZetaDia.Storage.PlayerDataManager.ActivePlayerData.TradingPlayerACDId))); } if (actor.IsEquipment && actor.ItemQualityLevel <= ItemQuality.Rare6) { return(true); } return(false); }
private Dictionary <string, string> ItemTemplate(TrinityItem item) { var kvplist = new Dictionary <string, string> { { "entry", item.EntryId.ToString() }, { "name", SqlQuery.CleanText(item.Name) }, { "description", SqlQuery.CleanText(item.Quote) }, { "class", item.Class.Id.ToString() }, { "subclass", item.ItemSubClass.Id.ToString() }, { "displayid", item.DisplayId.ToString() }, { "Quality", item.Quality.Id.ToString() }, { "bonding", item.Binds.Id.ToString() }, { "RequiredLevel", item.MinLevel.ToString() }, { "maxcount", item.MaxAllowed.ToString() }, { "AllowableClass", item.AllowedClass.BitmaskValue.ToString() }, { "AllowableRace", item.AllowedRace.BitmaskValue.ToString() }, { "BuyPrice", item.ValueBuy.ToString() }, { "SellPrice", item.ValueSell.ToString() }, { "InventoryType", item.InventoryType.Id.ToString() }, { "Material", item.ItemSubClass.Material.Id.ToString() }, { "sheath", item.InventoryType.Sheath.ToString() }, { "Flags", item.Flags.BitmaskValue.ToString() }, { "BuyCount", item.BuyCount.ToString() }, { "stackable", item.Stackable.ToString() }, { "ContainerSlots", item.ContainerSlots.ToString() }, { "dmg_min1", item.DamageInfo.MinDamage.ToString() }, { "dmg_max1", item.DamageInfo.MaxDamage.ToString() }, { "dmg_type1", item.DamageInfo.Type.Id.ToString() }, { "delay", item.DamageInfo.Speed.ToString() }, { "MaxDurability", item.Durability.ToString() }, { "ammo_type", item.AmmoType.ToString() }, { "armor", item.Armor.ToString() }, { "block", item.Block.ToString() }, { "BagFamily", item.BagFamily.BitmaskValue.ToString() }, { "socketBonus", item.SocketBonus.Id.ToString() }, { "FlagsExtra", item.FlagsExtra.BitmaskValue.ToString() }, { "StatsCount", item.StatsCount.ToString() }, }; item.GemSockets.AddValues(kvplist, "socketColor_", "socketContent_"); item.Stats.AddValues(kvplist, "stat_type", "stat_value"); try // resistances { // loops unique keys foreach (var kvp in item.Resistances.GetUserInput()) { var type = (DamageType)kvp.Key; var value = int.Parse(kvp.Value); // validate int kvplist.Add(type.Description + "_res", value.ToString()); } } catch { throw new Exception("Invalid value in magic resistance."); } return(kvplist); }
public static int GetStashPage(TrinityItem item) { if (item.InventorySlot != InventorySlot.SharedStash) { return(-1); } return((int)Math.Floor(item.InventoryRow / 10d)); }
private static void UpdateAfterItemMove(TrinityItem item) { if (item.IsValid && item.CommonData.IsValid && !item.CommonData.IsDisposed) { item.OnCreated(); } Core.Actors.Update(); }
public static string GenerateQuery(TrinityItem item) { if (item.EntryId == 0) { throw new Exception("Please choose an entry ID."); } return(SelectedEmulator.GenerateQuery(item)); }
public static void Update(TrinityItem actor) { if (actor.ActorType != ActorType.Item) { return; } if (!actor.IsAcdBased || !actor.IsAcdValid) { return; } var commonData = actor.CommonData; actor.AcdId = commonData.ACDId; var slot = ZetaDia.Memory.Read <InventorySlot>(commonData.BaseAddress + 0x164); var col = ZetaDia.Memory.Read <int>(commonData.BaseAddress + 0x168); var row = ZetaDia.Memory.Read <int>(commonData.BaseAddress + 0x16c); var columnChanged = col != actor.InventoryColumn; var rowChanged = row != actor.InventoryRow; var slotChanged = slot != actor.InventorySlot; actor.LastInventorySlot = actor.InventorySlot; actor.LastInventoryRow = actor.InventoryRow; actor.LastInventoryColumn = actor.InventoryColumn; actor.InventorySlot = slot; actor.InventoryRow = row; actor.InventoryColumn = col; //if (!actor.IsEquipment && Core.Player.IsInTown) //{ actor.ItemStackQuantity = actor.Attributes.ItemStackQuantity; //} if (actor.LastInventorySlot == InventorySlot.None && actor.InventorySlot == InventorySlot.BackpackItems) { UpdateBasicProperties(actor); actor.Attributes = new AttributesWrapper(commonData); Create(actor); actor.OnPickedUp(); } if (columnChanged || rowChanged || slotChanged) { actor.OnMoved(); } if (actor.InventorySlot == InventorySlot.BackpackItems && actor.IsUnidentified && !actor.Attributes.IsUnidentified) { //actor.Attributes = new AttributesWrapper(commonData); UpdateBasicProperties(actor); Create(actor); actor.OnIdentified(); } }
private bool UpdateInventoryItem(TrinityItem item, ACD commonData) { item.OnUpdated(); if (!item.IsValid) { return(false); } return(true); }
public bool ShouldDrop(TrinityItem item, ItemEvaluationType scheduledAction) { if (item.IsProtected() || item.IsAccountBound) { return(false); } if (item.IsGem || item.IsCraftingReagent || item.TrinityItemType == TrinityItemType.CraftingPlan) { return(false); } if (!item.IsUnidentified && (item.IsPotion || item.RawItemType == RawItemType.GeneralUtility || item.IsMiscItem)) { return(false); } if (item.ItemQualityLevel >= ItemQuality.Legendary) { if (Core.Settings.Items.DropInTownMode == DropInTownOption.All) { Core.Logger.Verbose($"Should Drop {item.Name} - Setting='{Core.Settings.Items.DropInTownMode}'"); return(true); } switch (scheduledAction) { case ItemEvaluationType.Keep: if (Core.Settings.Items.DropInTownMode == DropInTownOption.Keep) { Core.Logger.Verbose($"Should Drop {item.Name} - Setting='{Core.Settings.Items.DropInTownMode}' and item is scheduled for {scheduledAction}"); return(true); } break; case ItemEvaluationType.Salvage: case ItemEvaluationType.Sell: if (Core.Settings.Items.DropInTownMode == DropInTownOption.Vendor) { Core.Logger.Verbose($"Should Drop {item.Name} - Setting='{Core.Settings.Items.DropInTownMode}' and item is scheduled for {scheduledAction}"); return(true); } break; } } return(false); }
private bool UpdateInventoryItem(TrinityItem item, ACD commonData) { _timer.Start(); item.CommonData = commonData; item.OnUpdated(); if (!item.IsValid) { return(false); } _timer.Stop(); item.UpdateTime = _timer.Elapsed.TotalMilliseconds; return(true); }
private bool ShouldIncludeGold(TrinityItem cacheObject) { if (!Core.Settings.Items.PickupGold) { cacheObject.AddCacheInfo("GoldPickupDisabled"); return(false); } if (cacheObject.GoldAmount < Core.Settings.Items.MinGoldStack) { cacheObject.AddCacheInfo("NotEnoughGold"); return(false); } return(true); }
public static int GetBestStashLocation(TrinityItem item, out int col, out int row) { col = 0; row = 0; var stashPageOffset = GetIdealStashPage(item); if (stashPageOffset != -1) { int stashpage; if (stashPageOffset < 0) { stashpage = (-1 + TotalStashPages) + stashPageOffset; } else if (stashPageOffset > TotalStashPages - 1) { stashpage = TotalStashPages - 1; } else { stashpage = stashPageOffset; } if (CanPutItemInStashPage(item, stashpage, out col, out row)) { return(stashpage); } } if (item.ItemBaseType >= ItemBaseType.Misc) { for (var i = TotalStashPages - 1; i >= 0; i--) { if (CanPutItemInStashPage(item, i, out col, out row)) { return(i); } } } else { for (var j = 0; j < TotalStashPages - 1; j++) { if (CanPutItemInStashPage(item, j, out col, out row)) { return(j); } } } return(-1); }
private static bool CanPlaceOnPage(TrinityItem item, int stashPageNumber, ref int col, ref int row, InventoryMap itemsOnStashPage) { for (var i = 0; i < 10; i++) { for (var c = 0; c < 7; c++) { var r = stashPageNumber * 10 + i; if (TryGetStashingLocation(item, stashPageNumber, c, r, itemsOnStashPage, ref col, ref row)) { return(true); } } } return(false); }
/// <summary> /// Get the stash page where items should ideally be placed, ignoring if it can actually be placed there. /// </summary> public static int GetIdealStashPage(TrinityItem item) { if (item.IsEquipment && Core.Settings.Items.UseTypeStashingEquipment && ItemTypeMap.ContainsKey(item.RawItemType)) { return(ItemTypeMap[item.RawItemType]); } else if (Core.Settings.Items.UseTypeStashingOther && ItemTypeMap.ContainsKey(item.RawItemType)) { return(ItemTypeMap[item.RawItemType]); } if (item.ItemBaseType >= ItemBaseType.Misc) { return(TotalStashPages - 1); } return(-1); }
internal static bool ShouldStashItem(Item referenceItem, TrinityItem cItem, bool test = false) { var id = referenceItem.Id; if (cItem.IsCrafted) { Core.Logger.Debug(" >> Crafted Item {0} {1} - Auto-keeping", cItem.Name, id); return(true); } if (test) { var props = ItemDataUtils.GetPropertiesForItem(referenceItem); Core.Logger.Verbose($"------- Starting Test of {props.Count} supported properties for {cItem.Name}"); foreach (var prop in props) { if (prop == ItemProperty.Attribute) { continue; } var range = ItemDataUtils.GetItemStatRange(referenceItem, prop); float newValue; var testrule = new LRule(prop) { Value = (float)range.AncientMax, }; EvaluateProperty(testrule, cItem, out newValue); } Core.Logger.Verbose("------- Finished Test for {0} against max value", cItem.Name); } var itemSetting = Core.Settings.ItemList.SelectedItems.FirstOrDefault(i => referenceItem.Id == i.Id); if (itemSetting != null) { return(EvaluateRules(cItem, itemSetting, test)); } Core.Logger.Log($" >> Unselected ListItem {cItem.Name} {cItem.ActorSnoId} GbId={cItem.GameBalanceId} IsValid={cItem.IsValid}"); return(false); }
internal static bool ShouldStashItem(TrinityItem cItem, bool test = false) { if (ShouldStashItemType(cItem, test)) { return(true); } var item = Legendary.GetItem(cItem); if (item == null) { Core.Logger.Verbose(" >> Unknown Item {0} {1} - Auto-keeping", cItem.Name, cItem.ActorSnoId); return(true); } return(ShouldStashItem(item, cItem, test)); }
internal static bool ShouldStashItemType(TrinityItem cItem, bool test = false) { var typeEntry = Core.Settings.ItemList.GetitemTypeRule(cItem.TrinityItemType); if (typeEntry == null) { Core.Logger.Verbose($" >> {cItem.Name} did not match any item types"); return(false); } if (!typeEntry.IsSelected) { Core.Logger.Verbose($" >> {cItem.Name} ({cItem.TrinityItemType}) is not a selected item type - {typeEntry.Type}"); return(false); } return(typeEntry.IsSelected && EvaluateRules(cItem, typeEntry, test)); }
public static bool ShouldSell(TrinityItem i) { if (i.IsProtected()) { return(false); } if (Core.Player.IsInventoryLockedForGreaterRift) { return(false); } if (i.IsUnidentified) { return(false); } return(Combat.TrinityCombat.Loot.ShouldSell(i) && !Combat.TrinityCombat.Loot.ShouldSalvage(i) && !Combat.TrinityCombat.Loot.ShouldStash(i)); }
private static bool TryGetStackLocation(TrinityItem item, int stashPageNumber, int col, int row, InventoryMap map, ref int placeAtCol, ref int placeAtRow) { var loc = new Tuple <int, int>(col, row); if (col == placeAtCol && row == placeAtRow) { return(false); } var isSquareEmpty = !map.ContainsKey(loc); if (isSquareEmpty) { return(false); } if (item.IsTwoSquareItem) { return(false); } if (item.MaxStackCount <= 0) { return(false); } var existingItem = map[loc]; var existingStackQuantity = existingItem.ItemStackQuantity; var itemStackQuantity = item.ItemStackQuantity; var newStackSize = existingStackQuantity + itemStackQuantity; if (item.ActorSnoId == existingItem.ActorSnoId && newStackSize <= item.MaxStackCount && item.AnnId != existingItem.AnnId) { Core.Logger.Debug($"Can stash item {item.Name} on page {stashPageNumber} at [col={col},row={row}] (stack on existing {existingStackQuantity} + {itemStackQuantity} ({newStackSize}) / {item.MaxStackCount})"); placeAtCol = col; placeAtRow = row; return(true); } return(false); }
public static bool CanPutItemInStashPage(TrinityItem item, int stashPageNumber, out int col, out int row) { var itemsOnStashPage = GetInventoryMap(); col = 0; row = 0; if (stashPageNumber == 0 && !UIElements.StashDialogMainPageTab1.IsEnabled) { return(false); } if (stashPageNumber == 1 && !UIElements.StashDialogMainPageTab2.IsEnabled) { return(false); } if (stashPageNumber == 2 && !UIElements.StashDialogMainPageTab3.IsEnabled) { return(false); } if (stashPageNumber == 3 && !UIElements.StashDialogMainPageTab4.IsEnabled) { return(false); } if (stashPageNumber == 4 && !UIElements.StashDialogMainPageTab5.IsEnabled) { return(false); } if (CharacterSettings.Instance.ProtectedStashPages.Contains(stashPageNumber)) { return(false); } if (CanStackOnPage(item, stashPageNumber, ref col, ref row, itemsOnStashPage)) { return(true); } if (CanPlaceOnPage(item, stashPageNumber, ref col, ref row, itemsOnStashPage)) { return(true); } return(false); }
public AdventurerGem(TrinityItem gem, int riftLevel) { Guid = gem.AnnId; SNO = gem.ActorSnoId; Rank = gem.Attributes.JewelRank; Name = gem.Name; CurrentRiftLevel = riftLevel; Settings = PluginSettings.Current.Gems.GemSettings.FirstOrDefault(g => g.Sno == gem.ActorSnoId); if (Settings == null) { Core.Logger.Error($"Gems Settings Entry not found for {gem.Name} ({gem.ActorSnoId}), if its a new gem, it needs to be added to Trinity's Gems.cs reference"); return; } MaxRank = Settings.MaxRank; IsMaxRank = Rank >= Settings.MaxRank; HasRankCap = Settings.MaxRank > 0; IsEquiped = !IsMaxRank && gem.InventorySlot == InventorySlot.Socket; }
private static bool TryGetStashingLocation(TrinityItem item, int stashPageNumber, int col, int row, InventoryMap map, ref int placeAtCol, ref int placeAtRow) { var loc = new Tuple <int, int>(col, row); var isSquareEmpty = !map.ContainsKey(loc); var isLastRow = (row + 1) % 10 == 0; if (isLastRow && item.IsTwoSquareItem) { return(false); } if (item.IsTwoSquareItem) { var locBelow = new Tuple <int, int>(col, row + 1); if (map.ContainsKey(locBelow)) { return(false); } } var locAbove = new Tuple <int, int>(col, row - 1); var isItemAbove = map.ContainsKey(locAbove); if (isItemAbove && map[locAbove].IsTwoSquareItem) { return(false); } if (isSquareEmpty) { Core.Logger.Verbose($"Can stash item {item.Name} on page {stashPageNumber} at [col={col},row={row}]"); placeAtCol = col; placeAtRow = row; return(true); } return(false); }