Beispiel #1
0
        private static void RecordTargetHistory()
        {
            string targetMd5Hash = HashGenerator.GenerateObjecthash(CurrentTarget);

            // clean up past targets
            if (!GenericCache.ContainsKey(targetMd5Hash))
            {
                CurrentTarget.HasBeenPrimaryTarget      = true;
                CurrentTarget.TimesBeenPrimaryTarget    = 1;
                CurrentTarget.FirstTargetAssignmentTime = DateTime.Now;
                GenericCache.AddToCache(new GenericCacheObject(targetMd5Hash, CurrentTarget, new TimeSpan(0, 10, 0)));
            }
            else if (GenericCache.ContainsKey(targetMd5Hash))
            {
                GilesObject cTarget = (GilesObject)GenericCache.GetObject(targetMd5Hash).Value;
                if (!cTarget.IsBoss && cTarget.TimesBeenPrimaryTarget > 15 && !(cTarget.Type == GObjectType.Item && cTarget.ItemQuality >= ItemQuality.Legendary))
                {
                    DbHelper.Log(TrinityLogLevel.Normal, LogCategory.UserInformation, "Blacklisting target {0} ActorSNO={1} RActorGUID={2} due to possible stuck/flipflop!",
                                 CurrentTarget.InternalName, CurrentTarget.ActorSNO, CurrentTarget.RActorGuid);

                    hashRGUIDBlacklist60.Add(CurrentTarget.RActorGuid);

                    // Add to generic blacklist for safety, as the RActorGUID on items and gold can change as we move away and get closer to the items (while walking around corners)
                    // So we can't use any ID's but rather have to use some data which never changes (actorSNO, position, type, worldID)
                    GenericBlacklist.AddToBlacklist(new GenericCacheObject()
                    {
                        Key     = CurrentTarget.ObjectHash,
                        Value   = null,
                        Expires = DateTime.Now.AddSeconds(60)
                    });
                }
                else
                {
                    cTarget.TimesBeenPrimaryTarget++;
                    GenericCache.UpdateObject(new GenericCacheObject(targetMd5Hash, cTarget, new TimeSpan(0, 10, 0)));
                }
            }
        }
Beispiel #2
0
        private static bool RefreshUnitAttributes(bool AddToCache = true, DiaUnit unit = null)
        {
            /*
             *  TeamID  - check once for all units except bosses (which can potentially change teams - Belial, Cydea)
             */
            string teamIdHash = HashGenerator.GetGenericHash("teamId.RActorGuid=" + c_RActorGuid + ".ActorSNO=" + c_ActorSNO + ".WorldId=" + PlayerStatus.WorldID);

            int teamId = 0;

            if (!c_unit_IsBoss && GenericCache.ContainsKey(teamIdHash))
            {
                teamId = (int)GenericCache.GetObject(teamIdHash).Value;
            }
            else
            {
                teamId = c_CommonData.GetAttribute <int>(ActorAttributeType.TeamID);

                GenericCache.AddToCache(new GenericCacheObject()
                {
                    Key     = teamIdHash,
                    Value   = teamId,
                    Expires = DateTime.Now.AddMinutes(60)
                });
            }
            if (teamId == 1)
            {
                AddToCache       = false;
                c_IgnoreSubStep += "IsTeam1+";
                return(AddToCache);
            }



            if (unit.IsUntargetable)
            {
                AddToCache      = false;
                c_IgnoreSubStep = "IsUntargetable";
                return(AddToCache);
            }

            // don't check for invulnerability on shielded units, they are treated seperately
            if (!c_unit_IsShielded && unit.IsInvulnerable)
            {
                AddToCache      = false;
                c_IgnoreSubStep = "IsInvulnerable";
                return(AddToCache);
            }

            bool isBurrowed = false;

            if (!dictGilesBurrowedCache.TryGetValue(c_RActorGuid, out isBurrowed))
            {
                isBurrowed = unit.IsBurrowed;
                // if the unit is NOT burrowed - we can attack them, add to cache (as IsAttackable)
                if (!isBurrowed)
                {
                    dictGilesBurrowedCache.Add(c_RActorGuid, isBurrowed);
                }
            }

            if (isBurrowed)
            {
                AddToCache      = false;
                c_IgnoreSubStep = "IsBurrowed";
                return(AddToCache);
            }

            // only check for DotDPS/Bleeding in certain conditions to save CPU for everyone else
            // barbs with rend
            // All WD's
            // Monks with Way of the Hundred Fists + Fists of Fury
            if (AddToCache &&
                ((PlayerStatus.ActorClass == ActorClass.Barbarian && Hotbar.Contains(SNOPower.Barbarian_Rend)) ||
                 PlayerStatus.ActorClass == ActorClass.WitchDoctor ||
                 (PlayerStatus.ActorClass == ActorClass.Monk && HotbarSkills.AssignedSkills.Any(s => s.Power == SNOPower.Monk_WayOfTheHundredFists && s.RuneIndex == 0)))
                )
            {
                ////bool hasdotDPS = c_CommonData.GetAttribute<int>(ActorAttributeType.DOTDPS) != 0;
                //bool isBleeding = c_CommonData.GetAttribute<int>(ActorAttributeType.Bleeding) != 0;
                //c_HasDotDPS = hasdotDPS && isBleeding;
                bool hasdotDPS = c_CommonData.GetAttribute <int>(ActorAttributeType.DOTDPS) != 0;
                c_HasDotDPS = hasdotDPS;
            }
            return(AddToCache);
        }
Beispiel #3
0
        private static bool RefreshItemStats(GItemBaseType tempbasetype)
        {
            bool isNewLogItem = false;

            c_ItemMd5Hash = HashGenerator.GenerateItemHash(c_Position, c_ActorSNO, c_InternalName, CurrentWorldDynamicId, c_ItemQuality, c_ItemLevel);

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

                isNewLogItem = true;
                if (tempbasetype == GItemBaseType.Armor || tempbasetype == GItemBaseType.WeaponOneHand || tempbasetype == GItemBaseType.WeaponTwoHand ||
                    tempbasetype == GItemBaseType.WeaponRange || tempbasetype == GItemBaseType.Jewelry || tempbasetype == GItemBaseType.FollowerItem ||
                    tempbasetype == GItemBaseType.Offhand)
                {
                    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]++;
                }
                else if (tempbasetype == GItemBaseType.Gem)
                {
                    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;
                    }
                    ItemsDroppedStats.GemsPerType[iThisGemType]++;
                    ItemsDroppedStats.GemsPerLevel[c_ItemLevel]++;
                    ItemsDroppedStats.GemsPerTPerL[iThisGemType, c_ItemLevel]++;
                }
                else if (c_item_GItemType == GItemType.HealthPotion)
                {
                    ItemsDroppedStats.TotalPotions++;
                    ItemsDroppedStats.PotionsPerLevel[c_ItemLevel]++;
                }
                else if (c_item_GItemType == GItemType.InfernalKey)
                {
                    ItemsDroppedStats.TotalInfernalKeys++;
                }
                // See if we should update the stats file
                if (DateTime.Now.Subtract(ItemStatsLastPostedReport).TotalSeconds > 10)
                {
                    ItemStatsLastPostedReport = DateTime.Now;
                    OutputReport();
                }
            }
            return(isNewLogItem);
        }