示例#1
0
        private static bool RefreshUnit()
        {
            bool addToCache = true;

            if (!(c_diaObject is DiaUnit))
            {
                return(false);
            }

            if (CurrentCacheObject.Unit == null)
            {
                return(false);
            }

            if (!CurrentCacheObject.Unit.IsValid)
            {
                return(false);
            }

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

            if (c_diaObject.CommonData.ACDGuid == -1)
            {
                return(false);
            }

            // Always set this, otherwise we divide by zero later
            CurrentCacheObject.KillRange = CurrentBotKillRange;

            // grab this first
            c_CurrentAnimation = CurrentCacheObject.Unit.CommonData.CurrentAnimation;

            // See if this is a boss
            CurrentCacheObject.IsBoss = DataDictionary.BossIds.Contains(CurrentCacheObject.ActorSNO) || CurrentCacheObject.InternalName.ToLower().Contains("boss") || CurrentCacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Boss;
            if (CurrentCacheObject.IsBoss)
            {
                CurrentCacheObject.KillRange = CurrentCacheObject.RadiusDistance + 10f;
            }

            // hax for Diablo_shadowClone
            c_unit_IsAttackable = CurrentCacheObject.InternalName.StartsWith("Diablo_shadowClone");

            try
            {
                if (CurrentCacheObject.Unit.Movement.IsValid)
                {
                    c_IsFacingPlayer                   = CurrentCacheObject.Unit.IsFacingPlayer;
                    CurrentCacheObject.Rotation        = CurrentCacheObject.Unit.Movement.Rotation;
                    CurrentCacheObject.DirectionVector = CurrentCacheObject.Unit.Movement.DirectionVector;
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug(LogCategory.CacheManagement, "Error while reading Rotation/Facing: {0}", ex.ToString());
            }

            /*
             *  TeamID  - check once for all units except bosses (which can potentially change teams - Belial, Cydea)
             */
            string teamIdHash = "teamId.RActorGuid=" + CurrentCacheObject.RActorGuid + ".ActorSNO=" + CurrentCacheObject.ActorSNO + ".WorldId=" + Player.WorldID;

            int teamId;

            if (!CurrentCacheObject.IsBoss && GenericCache.ContainsKey(teamIdHash))
            {
                teamId = (int)GenericCache.GetObject(teamIdHash).Value;
            }
            else
            {
                teamId = CurrentCacheObject.Unit.TeamId;

                GenericCache.AddToCache(new GenericCacheObject
                {
                    Key     = teamIdHash,
                    Value   = teamId,
                    Expires = DateTime.UtcNow.AddMinutes(60)
                });
            }

            CacheObjectIsBountyObjective();

            try
            {
                CurrentCacheObject.IsNPC = CurrentCacheObject.Unit.IsNPC;
            }
            catch (Exception)
            {
                Logger.LogDebug("Error refreshing IsNPC");
            }

            try
            {
                CurrentCacheObject.IsSpawning = CurrentCacheObject.IsBoss && !CurrentCacheObject.Unit.IsAttackable;
            }
            catch (Exception)
            {
                Logger.LogDebug("Error refreshing IsSpawning");
            }

            CacheUnitNPCIsOperatable();

            CacheObjectMinimapActive();

            try
            {
                CurrentCacheObject.IsQuestMonster = CurrentCacheObject.Unit.IsQuestMonster;
                if (CurrentCacheObject.IsQuestMonster)
                {
                    CurrentCacheObject.KillRange = CurrentCacheObject.RadiusDistance + 10f;
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug(LogCategory.CacheManagement, "Error reading IsQuestMonster for Unit sno:{0} raGuid:{1} name:{2} ex:{3}",
                                CurrentCacheObject.ActorSNO, CurrentCacheObject.RActorGuid, CurrentCacheObject.InternalName, ex.Message);
            }

            try
            {
                CurrentCacheObject.IsQuestGiver = CurrentCacheObject.Unit.IsQuestGiver;

                // Interact with quest givers, except when doing town-runs
                if (ZetaDia.CurrentAct == Act.OpenWorld && CurrentCacheObject.IsQuestGiver && !(WantToTownRun || ForceVendorRunASAP || BrainBehavior.IsVendoring))
                {
                    CurrentCacheObject.Type   = TrinityObjectType.Interactable;
                    CurrentCacheObject.Type   = TrinityObjectType.Interactable;
                    CurrentCacheObject.Radius = c_diaObject.CollisionSphere.Radius;
                    return(true);
                }
            }
            catch (Exception)
            {
                Logger.LogDebug("Error refreshing IsQuestGiver");
            }

            if ((teamId == 1 || teamId == 2 || teamId == 17))
            {
                addToCache       = false;
                c_IgnoreSubStep += "IsTeam" + teamId;
                return(addToCache);
            }

            /* Always refresh monster type */
            if (CurrentCacheObject.Type != TrinityObjectType.Player && !CurrentCacheObject.IsBoss)
            {
                switch (c_diaObject.CommonData.MonsterInfo.MonsterType)
                {
                case MonsterType.Ally:
                case MonsterType.Scenery:
                case MonsterType.Helper:
                case MonsterType.Team:
                {
                    addToCache      = false;
                    c_IgnoreSubStep = "AllySceneryHelperTeam";
                    return(addToCache);
                }
                }
            }

            // Only set treasure goblins to true *IF* they haven't disabled goblins! Then check the SNO in the goblin hash list!
            c_unit_IsTreasureGoblin = false;
            // Flag this as a treasure goblin *OR* ignore this object altogether if treasure goblins are set to ignore
            if (DataDictionary.GoblinIds.Contains(CurrentCacheObject.ActorSNO) || CurrentCacheObject.InternalName.ToLower().StartsWith("treasureGoblin"))
            {
                if (Settings.Combat.Misc.GoblinPriority != 0)
                {
                    c_unit_IsTreasureGoblin = true;
                }
                else
                {
                    addToCache      = false;
                    c_IgnoreSubStep = "IgnoreTreasureGoblins";
                    return(addToCache);
                }
            }

            // Pull up the Monster Affix cached data
            RefreshAffixes();
            if (c_MonsterAffixes.HasFlag(MonsterAffixes.Shielding))
            {
                c_unit_HasShieldAffix = true;
            }

            // Only if at full health, else don't bother checking each loop
            // See if we already have this monster's size stored, if not get it and cache it
            if (!CacheData.MonsterSizes.TryGetValue(CurrentCacheObject.ActorSNO, out c_unit_MonsterSize))
            {
                try
                {
                    RefreshMonsterSize();
                }
                catch
                {
                    Logger.LogDebug("Error refreshing MonsterSize");
                }
            }

            RefreshMonsterHealth();

            DebugUtil.LogAnimation(CurrentCacheObject);

            // Unit is already dead
            if (c_HitPoints <= 0d && !CurrentCacheObject.IsBoss)
            {
                addToCache      = false;
                c_IgnoreSubStep = "0HitPoints";
                return(addToCache);
            }

            if (CurrentCacheObject.Unit.IsDead && !DataDictionary.FakeDeathMonsters.Contains(CurrentCacheObject.ActorSNO))
            {
                addToCache      = false;
                c_IgnoreSubStep = "IsDead";
                return(addToCache);
            }

            if (CurrentCacheObject.IsQuestMonster || CurrentCacheObject.IsBountyObjective)
            {
                return(true);
            }

            addToCache = RefreshUnitAttributes(addToCache, CurrentCacheObject.Unit);

            if (!addToCache)
            {
                return(addToCache);
            }

            // Set Kill range
            CurrentCacheObject.KillRange = SetKillRange();

            if (CurrentCacheObject.RadiusDistance <= CurrentCacheObject.KillRange)
            {
                AnyMobsInRange = true;
            }

            return(addToCache);
        }
示例#2
0
        private static bool RefreshItemStats(GItemBaseType tempbasetype)
        {
            bool isNewLogItem = false;

            c_ItemMd5Hash = HashGenerator.GenerateItemHash(CurrentCacheObject.Position, CurrentCacheObject.ActorSNO, CurrentCacheObject.InternalName, CurrentWorldDynamicId, c_ItemQuality, c_ItemLevel);

            if (!GenericCache.ContainsKey(c_ItemMd5Hash))
            {
                GenericCache.AddToCache(new GenericCacheObject(c_ItemMd5Hash, null, new TimeSpan(1, 0, 0)));

                try
                {
                    isNewLogItem = true;
                    if (tempbasetype == GItemBaseType.Armor || tempbasetype == GItemBaseType.WeaponOneHand || tempbasetype == GItemBaseType.WeaponTwoHand ||
                        tempbasetype == GItemBaseType.WeaponRange || tempbasetype == GItemBaseType.Jewelry || tempbasetype == GItemBaseType.FollowerItem ||
                        tempbasetype == GItemBaseType.Offhand)
                    {
                        try
                        {
                            int iThisQuality;
                            ItemsDroppedStats.Total++;
                            if (c_ItemQuality >= ItemQuality.Legendary)
                            {
                                iThisQuality = QUALITYORANGE;
                            }
                            else if (c_ItemQuality >= ItemQuality.Rare4)
                            {
                                iThisQuality = QUALITYYELLOW;
                            }
                            else if (c_ItemQuality >= ItemQuality.Magic1)
                            {
                                iThisQuality = QUALITYBLUE;
                            }
                            else
                            {
                                iThisQuality = QUALITYWHITE;
                            }
                            ItemsDroppedStats.TotalPerQuality[iThisQuality]++;
                            ItemsDroppedStats.TotalPerLevel[c_ItemLevel]++;
                            ItemsDroppedStats.TotalPerQPerL[iThisQuality, c_ItemLevel]++;
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Error Refreshing Item Stats for Equippable Item: " + ex.ToString());
                        }
                    }
                    else if (tempbasetype == GItemBaseType.Gem)
                    {
                        try
                        {
                            int iThisGemType = 0;
                            ItemsDroppedStats.TotalGems++;
                            if (c_item_GItemType == GItemType.Topaz)
                            {
                                iThisGemType = GEMTOPAZ;
                            }
                            if (c_item_GItemType == GItemType.Ruby)
                            {
                                iThisGemType = GEMRUBY;
                            }
                            if (c_item_GItemType == GItemType.Emerald)
                            {
                                iThisGemType = GEMEMERALD;
                            }
                            if (c_item_GItemType == GItemType.Amethyst)
                            {
                                iThisGemType = GEMAMETHYST;
                            }
                            if (c_item_GItemType == GItemType.Diamond)
                            {
                                iThisGemType = GEMDIAMOND;
                            }
                            ItemsDroppedStats.GemsPerType[iThisGemType]++;
                            ItemsDroppedStats.GemsPerLevel[c_ItemLevel]++;
                            ItemsDroppedStats.GemsPerTPerL[iThisGemType, c_ItemLevel]++;
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Error refreshing item stats for Gem: " + ex.ToString());
                        }
                    }
                    else if (c_item_GItemType == GItemType.InfernalKey)
                    {
                        try
                        {
                            ItemsDroppedStats.TotalInfernalKeys++;
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Error refreshing item stats for InfernalKey: " + ex.ToString());
                        }
                    }
                    // See if we should update the stats file
                    if (DateTime.UtcNow.Subtract(ItemStatsLastPostedReport).TotalSeconds > 10)
                    {
                        try
                        {
                            ItemStatsLastPostedReport = DateTime.UtcNow;
                            OutputReport();
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Error Calling OutputReport from RefreshItemStats " + ex.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError("Couldn't do Item Stats" + ex.ToString());
                }
            }
            return(isNewLogItem);
        }