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))); } } }
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); }