Exemple #1
0
        public static CachedACDItem GetCachedItem(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.DynamicId,
                    ActorSNO          = item.ActorSNO,
                    OneHanded         = item.IsOneHand,
                    TwoHanded         = item.IsTwoHand,
                    DyeType           = item.DyeType,
                    DBItemType        = item.ItemType,
                    DBBaseType        = item.ItemBaseType,
                    FollowerType      = item.FollowerSpecialType,
                    IsUnidentified    = item.IsUnidentified,
                    ItemStackQuantity = item.ItemStackQuantity,
                    Row             = item.InventoryRow,
                    Column          = item.InventoryColumn,
                    ItemLink        = item.ItemLink,
                    GameBalanceId   = item.GameBalanceId,
                    TrinityItemType = TrinityItemManager.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType),
                    IsAncient       = item.GetAttribute <int>(ActorAttributeType.AncientRank) > 0,
                };
                TrinityItemBaseType trinityItemBaseType = TrinityItemManager.DetermineBaseType(TrinityItemManager.DetermineItemType(item.InternalName, item.ItemType, item.FollowerSpecialType));
                cItem.TrinityItemBaseType = trinityItemBaseType;
                cItem.IsEquipment         = GetIsEquipment(trinityItemBaseType);
                cItem.IsSalvageable       = GetIsSalvageable(cItem);

                return(cItem);
            }
            catch (Exception ex)
            {
                Logger.LogError("Error getting CachedItem {0}", ex.Message);
                return(default(CachedACDItem));
            }
        }
Exemple #2
0
        private static bool RefreshItem()
        {
            using (new PerformanceLogger("RefreshItem"))
            {
                bool logNewItem;
                bool AddToCache;

                var diaItem = c_diaObject as DiaItem;

                if (diaItem == null)
                {
                    return(false);
                }

                if (diaItem.CommonData == null)
                {
                    return(false);
                }

                if (!diaItem.IsValid)
                {
                    return(false);
                }

                if (!diaItem.CommonData.IsValid)
                {
                    return(false);
                }

                c_ItemQuality = diaItem.CommonData.ItemQualityLevel;
                ((DiaItem)c_diaObject).CommonData.GetAttribute <int>(ActorAttributeType.ItemQualityLevelIdentified);
                c_ItemDisplayName = diaItem.CommonData.Name;

                CurrentCacheObject.DynamicID     = c_diaObject.CommonData.DynamicId;
                CurrentCacheObject.GameBalanceID = c_diaObject.CommonData.GameBalanceId;

                c_ItemLevel          = diaItem.CommonData.Level;
                c_DBItemBaseType     = diaItem.CommonData.ItemBaseType;
                c_DBItemType         = diaItem.CommonData.ItemType;
                c_IsOneHandedItem    = diaItem.CommonData.IsOneHand;
                c_IsTwoHandedItem    = diaItem.CommonData.IsTwoHand;
                c_item_tFollowerType = diaItem.CommonData.FollowerSpecialType;

                // Calculate item type
                if (_cItemTinityItemType == TrinityItemType.Unknown)
                {
                    _cItemTinityItemType = TrinityItemManager.DetermineItemType(CurrentCacheObject.InternalName, c_DBItemType, c_item_tFollowerType);
                }

                // And temporarily store the base type
                TrinityItemBaseType itemBaseType = TrinityItemManager.DetermineBaseType(_cItemTinityItemType);

                // Compute item quality from item link
                if (!CacheData.ItemLinkQuality.TryGetValue(CurrentCacheObject.ACDGuid, out c_ItemQuality))
                {
                    c_ItemQuality = diaItem.CommonData.GetItemQuality();
                    CacheData.ItemLinkQuality.Add(CurrentCacheObject.ACDGuid, c_ItemQuality);
                }

                if (itemBaseType == TrinityItemBaseType.Gem)
                {
                    c_ItemLevel = (int)diaItem.CommonData.GemQuality;
                }

                CurrentCacheObject.ObjectHash = HashGenerator.GenerateItemHash(
                    CurrentCacheObject.Position,
                    CurrentCacheObject.ActorSNO,
                    CurrentCacheObject.InternalName,
                    Player.WorldID,
                    c_ItemQuality,
                    c_ItemLevel);

                try
                {
                    c_IsAncient = c_ItemQuality == ItemQuality.Legendary && diaItem.CommonData.GetAttribute <int>(ActorAttributeType.AncientRank) > 0;
                }
                catch {}

                float range = 0f;

                // no range check on Legendaries
                if (c_ItemQuality < ItemQuality.Legendary || _cItemTinityItemType == TrinityItemType.ProgressionGlobe || _cItemTinityItemType == TrinityItemType.HoradricRelic)
                {
                    if (c_ItemQuality >= ItemQuality.Rare4)
                    {
                        range = CurrentBotLootRange;
                    }

                    if (_keepLootRadiusExtendedForSeconds > 0)
                    {
                        range += 90f;
                    }

                    if (CurrentCacheObject.Distance > (CurrentBotLootRange + range))
                    {
                        c_IgnoreSubStep = "OutOfRange";
                        // return here to save CPU on reading unncessary attributes for out of range items;
                        return(false);
                    }
                }

                var pickupItem = new PickupItem
                {
                    Name             = c_ItemDisplayName,
                    InternalName     = CurrentCacheObject.InternalName,
                    Level            = c_ItemLevel,
                    Quality          = c_ItemQuality,
                    BalanceID        = CurrentCacheObject.GameBalanceID,
                    DBBaseType       = c_DBItemBaseType,
                    DBItemType       = c_DBItemType,
                    TBaseType        = itemBaseType,
                    TType            = _cItemTinityItemType,
                    IsOneHand        = c_IsOneHandedItem,
                    IsTwoHand        = c_IsTwoHandedItem,
                    ItemFollowerType = c_item_tFollowerType,
                    DynamicID        = CurrentCacheObject.DynamicID,
                    Position         = CurrentCacheObject.Position,
                    ActorSNO         = CurrentCacheObject.ActorSNO,
                    ACDGuid          = CurrentCacheObject.ACDGuid,
                    RActorGUID       = CurrentCacheObject.RActorGuid,
                };

                // Blood Shards == HoradricRelic
                if (_cItemTinityItemType == TrinityItemType.HoradricRelic && ZetaDia.CPlayer.BloodshardCount >= Player.MaxBloodShards)
                {
                    return(false);
                }

                // Treat all globes as a yes
                if (_cItemTinityItemType == TrinityItemType.HealthGlobe)
                {
                    CurrentCacheObject.Type = TrinityObjectType.HealthGlobe;
                    return(true);
                }

                // Treat all globes as a yes
                if (_cItemTinityItemType == TrinityItemType.PowerGlobe)
                {
                    CurrentCacheObject.Type = TrinityObjectType.PowerGlobe;
                    return(true);
                }

                // Treat all globes as a yes
                if (_cItemTinityItemType == TrinityItemType.ProgressionGlobe)
                {
                    CurrentCacheObject.Type = TrinityObjectType.ProgressionGlobe;
                    return(true);
                }

                // Item stats
                logNewItem = RefreshItemStats(itemBaseType);

                // Get whether or not we want this item, cached if possible
                if (!CacheData.PickupItem.TryGetValue(CurrentCacheObject.RActorGuid, out AddToCache))
                {
                    if (pickupItem.IsTwoHand && Settings.Loot.Pickup.IgnoreTwoHandedWeapons && c_ItemQuality < ItemQuality.Legendary)
                    {
                        AddToCache = false;
                    }
                    else if (Settings.Loot.ItemFilterMode == ItemFilterMode.DemonBuddy)
                    {
                        AddToCache = ItemManager.Current.ShouldPickUpItem((ACDItem)c_diaObject.CommonData);
                    }
                    else if (Settings.Loot.ItemFilterMode == ItemFilterMode.TrinityWithItemRules)
                    {
                        AddToCache = TrinityItemManager.ItemRulesPickupValidation(pickupItem);
                    }
                    else // Trinity Scoring Only
                    {
                        AddToCache = TrinityItemManager.PickupItemValidation(pickupItem);
                    }

                    // Pickup low level enabled, and we're a low level
                    if (!AddToCache && Settings.Loot.Pickup.PickupLowLevel && Player.Level <= 10)
                    {
                        AddToCache = TrinityItemManager.PickupItemValidation(pickupItem);
                    }

                    // Ignore if item has existed before in this location
                    if (Settings.Loot.TownRun.DropLegendaryInTown)
                    {
                        if (!CacheData.DroppedItems.Any(i => i.Equals(pickupItem)))
                        {
                            CacheData.DroppedItems.Add(pickupItem);
                            AddToCache = true;
                        }
                        else
                        {
                            Logger.LogDebug("Ignoring Dropped Item = ItemPosition={0} Hashcode={1} DynId={2}", pickupItem.Position, pickupItem.GetHashCode(), pickupItem.DynamicID);
                            AddToCache = false;
                        }
                    }

                    CacheData.PickupItem.Add(CurrentCacheObject.RActorGuid, AddToCache);
                }

                if (AddToCache && ForceVendorRunASAP)
                {
                    c_IgnoreSubStep = "ForcedVendoring";
                }

                // Didn't pass pickup rules, so ignore it
                if (!AddToCache && c_IgnoreSubStep == String.Empty)
                {
                    c_IgnoreSubStep = "NoMatchingRule";
                }

                if (Settings.Advanced.LogDroppedItems && logNewItem && _cItemTinityItemType != TrinityItemType.HealthGlobe && _cItemTinityItemType != TrinityItemType.HealthPotion && _cItemTinityItemType != TrinityItemType.PowerGlobe && _cItemTinityItemType != TrinityItemType.ProgressionGlobe)
                {
                    //LogDroppedItem();
                    ItemDroppedAppender.Instance.AppendDroppedItem(pickupItem);
                }

                return(AddToCache);
            }
        }