private double GetWeaponWeight(CachedACDItem item) { var classMultiplier = item.IsClassItem && Core.Player.ActorClass == ActorClass.DemonHunter ? 2 : 1; return(item.WeaponDamagePerSecond * classMultiplier + GetAttributeWeight(item) / 5); }
public static bool GetIsClassItem(CachedACDItem cItem) { switch (cItem.ItemType) { case ItemType.Mojo: case ItemType.Quiver: case ItemType.Orb: case ItemType.CrusaderShield: case ItemType.MightyWeapon: case ItemType.MightyBelt: case ItemType.SpiritStone: case ItemType.Daibo: case ItemType.Flail: case ItemType.Cloak: case ItemType.WizardHat: case ItemType.CeremonialDagger: case ItemType.VoodooMask: case ItemType.FistWeapon: case ItemType.Crossbow: case ItemType.HandCrossbow: case ItemType.Bow: case ItemType.Scythe: case ItemType.Phylactery: return(true); } return(false); }
public static CachedACDItem GetTrinityItem(ACDItem item) { try { if (!item.IsValid) { return(default(CachedACDItem)); } CachedACDItem cItem = new CachedACDItem(item.Stats) { AcdItem = item, InternalName = item.InternalName, RealName = item.Name, Level = item.Level, Quality = item.GetItemQuality(), GoldAmount = item.Gold, BalanceId = item.GameBalanceId, DynamicId = item.AnnId, ActorSnoId = item.ActorSnoId, OneHanded = item.IsOneHand, TwoHanded = item.IsTwoHand, DyeType = item.DyeType, ItemType = item.GetItemType(), BaseType = item.ItemBaseType, FollowerType = item.FollowerSpecialType, IsUnidentified = item.IsUnidentified, ItemStackQuantity = item.ItemStackQuantity, InventoryRow = item.InventoryRow, InventoryColumn = item.InventoryColumn, ItemLink = item.ItemLink, GameBalanceId = item.GameBalanceId, TrinityItemType = TypeConversions.DetermineItemType(item.InternalName, item.GetItemType(), item.FollowerSpecialType), IsAncient = item.GetAttribute <int>(ActorAttributeType.AncientRank) > 0, InventorySlot = item.InventorySlot, }; TrinityItemBaseType trinityItemBaseType = TypeConversions .GetTrinityItemBaseType( TypeConversions.DetermineItemType( item.InternalName, item.GetItemType(), item.FollowerSpecialType)); cItem.TrinityItemBaseType = trinityItemBaseType; cItem.IsEquipment = GetIsEquipment(trinityItemBaseType); cItem.IsSalvageable = GetIsSalvageable(cItem); cItem.IsClassItem = GetIsClassItem(cItem); cItem.IsOffHand = GetIsOffhand(cItem); return(cItem); } catch (Exception ex) { Core.Logger.Error("Error getting TrinityItem {0}", ex.Message); return(default(CachedACDItem)); } }
private bool IsUpgrade(CachedACDItem oldItem, CachedACDItem newItem) { if (newItem == null) { return(false); } // Always equip empty slot except if its an offhand and a 2hander is equipped. if (oldItem == null) { if (newItem.IsOffHand) { var equippedMainhand = _equippedItems[InventorySlot.LeftHand]; if (equippedMainhand != null && equippedMainhand.TwoHanded) { return(false); } } return(true); } ; var newItemWeight = GetWeight(newItem); var oldItemWeight = GetWeight(oldItem); // Replacing a mainhand + offhand with a 2hander if (newItem.TwoHanded && !oldItem.TwoHanded) { var equippedOffhand = _equippedItems[InventorySlot.RightHand]; var offHandWeight = GetWeight(equippedOffhand); var result = oldItemWeight + offHandWeight < newItemWeight; Core.Logger.Verbose(" > {0}={1}, MainHand({3})+Offhand({4}) >> {2}", newItem.RealName, newItemWeight, result ? "Upgrade" : "Skip", oldItemWeight, offHandWeight); return(result); } // Replacing a 2hander with mainhand + offhand if (!newItem.TwoHanded && oldItem.TwoHanded) { var bestOffhand = _upgrades[InventorySlot.RightHand]; var offHandWeight = GetWeight(bestOffhand); var result = oldItemWeight < newItemWeight + offHandWeight; Core.Logger.Verbose(" > {0}={1} + Offhand({4}), MainHand({3}) >> {2}", newItem.RealName, newItemWeight, result ? "Upgrade" : "Skip", oldItemWeight, offHandWeight); return(result); } Core.Logger.Verbose(" > {0}={1} >> {2}", newItem.RealName, newItemWeight, oldItemWeight < newItemWeight ? "Upgrade" : "Skip"); return(oldItemWeight < newItemWeight); }
private void UnequipItem(CachedACDItem item) { var location = DefaultLootProvider.FindBackpackLocation(true, false); if (location == DefaultLootProvider.NoFreeSlot) { return; } Core.Logger.Log("Unequipping Item {0} ({1}) from slot {2}", item.RealName, item.ActorSnoId, item.InventorySlot); InventoryManager.MoveItem(item.DynamicId, ZetaDia.Me.CommonData.AnnId, InventorySlot.BackpackItems, (int)location.X, (int)location.Y); }
private static bool GetIsOffhand(CachedACDItem cItem) { switch (cItem.ItemType) { case ItemType.Mojo: case ItemType.Quiver: case ItemType.CrusaderShield: case ItemType.Shield: case ItemType.Orb: return(true); } return(false); }
public static bool GetIsSalvageable(CachedACDItem cItem) { if (!cItem.IsEquipment) { return(false); } if (cItem.AcdItem.IsVendorBought) { return(false); } return(true); }
public int CompareTo(object obj) { CachedACDItem item = (CachedACDItem)obj; if (InventoryRow < item.InventoryRow) { return(-1); } if (InventoryColumn < item.InventoryColumn) { return(-1); } if (InventoryColumn == item.InventoryColumn && InventoryRow == item.InventoryRow) { return(0); } return(1); }
private double GetWeight(CachedACDItem item) { var weight = 0d; if (item == null) { return(weight); } if (item.TrinityItemBaseType == TrinityItemBaseType.Offhand) { weight = GetOffhandWeight(item); } else { switch (item.BaseType) { case ItemBaseType.Jewelry: case ItemBaseType.Armor: weight = GetArmorWeight(item); break; case ItemBaseType.Weapon: weight = GetWeaponWeight(item); break; } } if (item.Quality >= ItemQuality.Legendary && IsModifiedByGemOfEase(item.AcdItem)) { return(weight + 50000); } if (ZetaDia.Me.Level < item.AcdItem.RequiredLevel) { return(0); } return(weight); }
public async Task <bool> Execute() { if (!Core.Settings.Items.AutoEquipItems) { return(false); } if (!Core.Player.IsValid || Core.Player.IsInCombat || !ZetaDia.IsInGame || ZetaDia.Globals.IsLoadingWorld) { return(false); } if (DateTime.UtcNow.Subtract(_lastEquipCheckTime).TotalSeconds < 5) { return(false); } if (!ZetaDia.Me.IsValid || !ZetaDia.Me.CommonData.IsValid || ZetaDia.Me.CommonData.IsDisposed || ZetaDia.Me.Level == 0 || ZetaDia.Me.Level >= 70 && Core.Settings.Items.AutoEquipAutoDisable) { return(false); } if (_lastFreeBackpackSlots == Core.Player.FreeBackpackSlots) { return(false); } await IdentifyLegendaries(); Reset(); _equippedItems = new Dictionary <InventorySlot, CachedACDItem>(); foreach (var item in InventoryManager.Equipped) { // DB's Inventory Equipped collection sometimes gets messed up and has duplicate items. if (_equippedItems.ContainsKey(item.InventorySlot)) { continue; } _equippedItems.Add(item.InventorySlot, CachedACDItem.GetTrinityItem(item)); } _upgrades = _slots.ToDictionary(k => k, v => default(CachedACDItem)); foreach (var slot in _slots) { CachedACDItem currentlyEquipped; if (!_equippedItems.TryGetValue(slot, out currentlyEquipped)) { _equippedItems.Add(slot, null); } var backpackItems = GetBackpackItemsForSlot(slot); if (backpackItems == null) { continue; } Core.Logger.Verbose("{0}: {1}, Weight={2}", slot, currentlyEquipped != null ? currentlyEquipped.RealName : "None", GetWeight(currentlyEquipped)); foreach (var backpackItem in backpackItems) { if (backpackItem.AcdItem.InventorySlot != InventorySlot.BackpackItems) { continue; } // Dont use a 2hander in some situations. if (backpackItem.TwoHanded && ( Core.Player.ActorClass == ActorClass.Crusader || // Crusader uses shield bash ability to level. Core.Player.ActorClass == ActorClass.DemonHunter && !backpackItem.IsClassItem)) { continue; } var bestUpgradeFoundSoFar = _upgrades[slot]; if (IsUpgrade(backpackItem, currentlyEquipped, bestUpgradeFoundSoFar)) { _upgrades[slot] = backpackItem; } } } Core.Logger.Log("Item Evaluation {0} Equipped, {1} Backpack Candidates, {2} Upgrades found", _equippedItems.Count(i => i.Value != null), BackpackEquipment.Count(), _upgrades.Count(i => i.Value != null)); foreach (var upgrade in _upgrades) { if (upgrade.Value == null) { continue; } //if (upgrade.Key == InventorySlot.LeftHand && upgrade.Value.TwoHanded) //{ // var offhand = _equippedItems[InventorySlot.RightHand]; // if (offhand != null) // UnequipItem(offhand); //} await EquipItem(upgrade.Value.AcdItem, upgrade.Key); await Coroutine.Sleep(500); } _lastEquipCheckTime = DateTime.UtcNow; _lastFreeBackpackSlots = Core.Player.FreeBackpackSlots; await EquipWeaponSocket(); await EquipArmorSockets(); return(false); }
private double GetCriticalWeight(CachedACDItem item) { return(item.CritDamagePercent * 2 + item.CritPercent * 10); }
private double GetMiscWeight(CachedACDItem item) { return((int)item.Quality + item.Armor / 20); }
private double GetAttributeWeight(CachedACDItem item) { return((item.HighestPrimary + item.Vitality) / 5); }
private double GetArmorWeight(CachedACDItem item) { return(GetAttributeWeight(item) + GetCriticalWeight(item) + GetMiscWeight(item)); }
private double GetOffhandWeight(CachedACDItem item) { var classMultiplier = item.IsClassItem ? 1.5 : 1; return((GetAttributeWeight(item) + GetCriticalWeight(item) + item.AcdItem.DamageAverageTotalAll) * classMultiplier); }
private bool IsUpgrade(CachedACDItem item, CachedACDItem currentlyEquipped, CachedACDItem bestUpgradeSoFar) { return(IsUpgrade(currentlyEquipped, item) && (bestUpgradeSoFar == null || IsUpgrade(bestUpgradeSoFar, item))); }
protected bool Equals(CachedACDItem other) { return(DynamicId == other.DynamicId && ActorSnoId == other.ActorSnoId); }