Beispiel #1
0
        public override bool UpdateData()
        {
            if (ref_DiaItem == null)
            {
                try
                {
                    ref_DiaItem = (DiaItem)ref_DiaObject;
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Failure to convert obj {0} to DiaItem!", InternalName);
                    NeedsRemoved = true;
                    BlacklistFlag=BlacklistType.Temporary;
                    return false;
                }
            }

            bool skippingCommonDataUpdates = false;
            //Check if item is not a misc item (requires common data)
            if (ItemDropType.HasValue)
            {

                var baseItemType = ItemFunc.DetermineBaseItemType(ItemDropType.Value);
                var isstackable = ItemFunc.DetermineIsStackable(ItemDropType.Value);
                IsTwoSlot=ItemFunc.DetermineIsTwoSlot(ItemDropType.Value);

                skippingCommonDataUpdates = (baseItemType == PluginBaseItemTypes.Misc ||
                                             baseItemType == PluginBaseItemTypes.Gem ||
                                             baseItemType == PluginBaseItemTypes.HealthGlobe ||
                                             (FunkyBaseExtension.Settings.Loot.PickupWhiteItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupMagicItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupRareItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupLegendaryItems == 1));

                if (!skippingCommonDataUpdates)
                {
                    if (!IsStillValid())
                    {
                        NeedsRemoved = true;
                        return false;
                    }
                }
            }
            else if (!IsStillValid())
            {
                NeedsRemoved = true;
                return false;
            }

            if (targetType.Value == TargetType.Item)
            {
                #region Item

                //#region DynamicID
                //if (!DynamicID.HasValue)
                //{
                //    try
                //    {

                //        DynamicID = ref_DiaItem.CommonData.DynamicId;

                //    }
                //    catch
                //    {
                //        Logger.Write(LogLevel.Cache, "Failure to get Dynamic ID for {0}", InternalName);

                //        return false;
                //    }
                //}
                //#endregion

                //Gamebalance Update
                if (!skippingCommonDataUpdates && !BalanceID.HasValue)
                {
                    try
                    {
                        BalanceID = ref_DiaItem.CommonData.GameBalanceId;
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to get gamebalance ID for item {0}", InternalName);
                        return false;
                    }
                }

                //Check if game balance needs updated
                #region GameBalance
                if (!skippingCommonDataUpdates && (BalanceData == null || BalanceData.bNeedsUpdated))
                {
                    CacheBalance thisnewGamebalance;

                    try
                    {
                        thisnewGamebalance = new CacheBalance(this);
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to add/update gamebalance data for item {0}", InternalName);
                        NeedsRemoved = true;
                        return false;
                    }

                    if (BalanceData == null)
                    {
                        CacheIDLookup.dictGameBalanceCache.Add(BalanceID.Value, thisnewGamebalance);
                    }
                    else
                    {
                        CacheIDLookup.dictGameBalanceCache[BalanceID.Value] = thisnewGamebalance;
                    }

                }
                #endregion

                //Item Quality / Recheck
                #region ItemQuality
                if (!skippingCommonDataUpdates && (!Itemquality.HasValue || ItemQualityRechecked == false))
                {

                    try
                    {
                        Itemquality = ref_DiaItem.CommonData.ItemQualityLevel;
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to get item quality for {0}", InternalName);
                        return false;
                    }

                    if (!ItemQualityRechecked)
                        ItemQualityRechecked = true;
                    else
                        NeedsUpdate = false;
                }
                #endregion

                //Pickup?
                // Now see if we actually want it
                #region PickupValidation
                if (!ShouldPickup.HasValue)
                {
                    //Logger.DBLog.InfoFormat Dropped Items Here!!
                    if (BalanceData!=null && Itemquality.HasValue)
                    {
                        if (FunkyGame.CurrentStats != null)
                            FunkyGame.CurrentStats.CurrentProfile.LootTracker.DroppedItemLog(BalanceData.PluginType, Itemquality.Value);
                    }

                    //Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.DroppedItemLog(this);

                    FunkyGame.ItemPickupEval(this);
                    NeedsUpdate = false;
                }
                else
                {
                    NeedsUpdate = false;
                }
                #endregion

                #endregion
            }
            else if (targetType.Value == TargetType.Globe || targetType.Value == TargetType.PowerGlobe)
            {
                NeedsUpdate = false;
            }
            else
            {
                #region Gold
                //Get gold value..
                if (!GoldAmount.HasValue)
                {
                    try
                    {
                        GoldAmount = ref_DiaItem.CommonData.GetAttribute<int>(ActorAttributeType.Gold);
                    }
                    catch
                    {
                        //Logger.Write(LogLevel.Cache, "Failure to get gold amount for gold pile!");
                        return false;
                    }
                }
                FunkyGame.Hero.UpdateCoinage = true;
                NeedsUpdate = false;
                #endregion
            }
            return true;
        }
Beispiel #2
0
        public override bool UpdateData()
        {
            if (ref_DiaItem == null)
            {
                try
                {
                    ref_DiaItem = (DiaItem)ref_DiaObject;
                }
                catch
                {
                    Logger.Write(LogLevel.Cache, "Failure to convert obj {0} to DiaItem!", InternalName);
                    NeedsRemoved  = true;
                    BlacklistFlag = BlacklistType.Temporary;
                    return(false);
                }
            }

            bool skippingCommonDataUpdates = false;

            //Check if item is not a misc item (requires common data)
            if (ItemDropType.HasValue)
            {
                var baseItemType = ItemFunc.DetermineBaseItemType(ItemDropType.Value);
                var isstackable  = ItemFunc.DetermineIsStackable(ItemDropType.Value);
                IsTwoSlot = ItemFunc.DetermineIsTwoSlot(ItemDropType.Value);

                skippingCommonDataUpdates = (baseItemType == PluginBaseItemTypes.Misc ||
                                             baseItemType == PluginBaseItemTypes.Gem ||
                                             baseItemType == PluginBaseItemTypes.HealthGlobe ||
                                             (FunkyBaseExtension.Settings.Loot.PickupWhiteItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupMagicItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupRareItems == 1 &&
                                              FunkyBaseExtension.Settings.Loot.PickupLegendaryItems == 1));

                if (!skippingCommonDataUpdates)
                {
                    if (!IsStillValid())
                    {
                        NeedsRemoved = true;
                        return(false);
                    }
                }
            }
            else if (!IsStillValid())
            {
                NeedsRemoved = true;
                return(false);
            }


            if (targetType.Value == TargetType.Item)
            {
                #region Item

                //#region DynamicID
                //if (!DynamicID.HasValue)
                //{
                //    try
                //    {

                //        DynamicID = ref_DiaItem.CommonData.DynamicId;

                //    }
                //    catch
                //    {
                //        Logger.Write(LogLevel.Cache, "Failure to get Dynamic ID for {0}", InternalName);

                //        return false;
                //    }
                //}
                //#endregion

                //Gamebalance Update
                if (!skippingCommonDataUpdates && !BalanceID.HasValue)
                {
                    try
                    {
                        BalanceID = ref_DiaItem.CommonData.GameBalanceId;
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to get gamebalance ID for item {0}", InternalName);
                        return(false);
                    }
                }

                //Check if game balance needs updated
                #region GameBalance
                if (!skippingCommonDataUpdates && (BalanceData == null || BalanceData.bNeedsUpdated))
                {
                    CacheBalance thisnewGamebalance;


                    try
                    {
                        thisnewGamebalance = new CacheBalance(this);
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to add/update gamebalance data for item {0}", InternalName);
                        NeedsRemoved = true;
                        return(false);
                    }


                    if (BalanceData == null)
                    {
                        CacheIDLookup.dictGameBalanceCache.Add(BalanceID.Value, thisnewGamebalance);
                    }
                    else
                    {
                        CacheIDLookup.dictGameBalanceCache[BalanceID.Value] = thisnewGamebalance;
                    }
                }
                #endregion

                //Item Quality / Recheck
                #region ItemQuality
                if (!skippingCommonDataUpdates && (!Itemquality.HasValue || ItemQualityRechecked == false))
                {
                    try
                    {
                        Itemquality = ref_DiaItem.CommonData.ItemQualityLevel;
                    }
                    catch
                    {
                        Logger.Write(LogLevel.Cache, "Failure to get item quality for {0}", InternalName);
                        return(false);
                    }


                    if (!ItemQualityRechecked)
                    {
                        ItemQualityRechecked = true;
                    }
                    else
                    {
                        NeedsUpdate = false;
                    }
                }
                #endregion


                //Pickup?
                // Now see if we actually want it
                #region PickupValidation
                if (!ShouldPickup.HasValue)
                {
                    //Logger.DBLog.InfoFormat Dropped Items Here!!
                    if (BalanceData != null && Itemquality.HasValue)
                    {
                        if (FunkyGame.CurrentStats != null)
                        {
                            FunkyGame.CurrentStats.CurrentProfile.LootTracker.DroppedItemLog(BalanceData.PluginType, Itemquality.Value);
                        }
                    }

                    //Bot.Game.CurrentGameStats.CurrentProfile.LootTracker.DroppedItemLog(this);

                    FunkyGame.ItemPickupEval(this);
                    NeedsUpdate = false;
                }
                else
                {
                    NeedsUpdate = false;
                }
                #endregion

                #endregion
            }
            else if (targetType.Value == TargetType.Globe || targetType.Value == TargetType.PowerGlobe)
            {
                NeedsUpdate = false;
            }
            else
            {
                #region Gold
                //Get gold value..
                if (!GoldAmount.HasValue)
                {
                    try
                    {
                        GoldAmount = ref_DiaItem.CommonData.GetAttribute <int>(ActorAttributeType.Gold);
                    }
                    catch
                    {
                        //Logger.Write(LogLevel.Cache, "Failure to get gold amount for gold pile!");
                        return(false);
                    }
                }
                FunkyGame.Hero.UpdateCoinage = true;
                NeedsUpdate = false;
                #endregion
            }
            return(true);
        }