public static bool IsNavBlocking(this TrinityCacheObject o)
        {
            if (_currentCacheObject != null && _currentCacheObject.RActorGuid == o.RActorGuid)
                return _isNavBlocking;

            _isNavBlocking = Trinity.LastTargetACDGuid != o.ACDGuid && CacheData.NavigationObstacles.Any(ob => MathUtil.IntersectsPath(ob.Position, ob.Radius, CacheData.Player.Position, o.Position));
            _currentCacheObject = o;
            return _isNavBlocking;
        }
Exemple #2
0
        public static bool IsNavBlocking(this TrinityCacheObject o)
        {
            if (_currentCacheObject != null && _currentCacheObject.RActorGuid == o.RActorGuid)
            {
                return(_isNavBlocking);
            }

            _isNavBlocking      = Trinity.LastTargetACDGuid != o.ACDGuid && CacheData.NavigationObstacles.Any(ob => MathUtil.IntersectsPath(ob.Position, ob.Radius, CacheData.Player.Position, o.Position));
            _currentCacheObject = o;
            return(_isNavBlocking);
        }
Exemple #3
0
 /// <summary>
 /// Get an attribute, exceptions get swallowed and default returned
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="actor">The actor.</param>
 /// <param name="type">The type.</param>
 /// <returns>T.</returns>
 public static T GetAttributeOrDefault <T>(this TrinityCacheObject actor, ActorAttributeType type) where T : struct
 {
     try
     {
         actor.CommonData.GetAttribute <T>(type);
     }
     catch (Exception ex)
     {
         Logger.LogDebug(LogCategory.CacheManagement, "Exception on {0} accessing {1} attribute: {2}", actor.InternalName, type, ex);
     }
     return(default(T));
 }
Exemple #4
0
        public static void LogAnimation(TrinityCacheObject cacheObject)
        {
            if (!LogCategoryEnabled(LogCategory.Animation) || cacheObject.CommonData == null || !cacheObject.CommonData.IsValid || !cacheObject.CommonData.AnimationInfo.IsValid)
                return;

            var state = cacheObject.CommonData.AnimationState.ToString();
            var name = cacheObject.CommonData.CurrentAnimation.ToString();

            // Log Animation
            if (!_seenAnimationCache.ContainsKey(name))
            {
                Logger.Log(LogCategory.Animation, "{0} State={1} By: {2} ({3})", name, state, cacheObject.InternalName, cacheObject.ActorSNO);
                _seenAnimationCache.Add(name, DateTime.UtcNow);
            }

            CacheMaintenance();
        }
Exemple #5
0
        public static void LogAnimation(TrinityCacheObject cacheObject)
        {
            if (!LogCategoryEnabled(LogCategory.Animation) || cacheObject.CommonData == null || !cacheObject.CommonData.IsValid || !cacheObject.CommonData.AnimationInfo.IsValid)
            {
                return;
            }

            var state = cacheObject.CommonData.AnimationState.ToString();
            var name  = cacheObject.CommonData.CurrentAnimation.ToString();

            // Log Animation
            if (!_seenAnimationCache.ContainsKey(name))
            {
                Logger.Log(LogCategory.Animation, "{0} State={1} By: {2} ({3})", name, state, cacheObject.InternalName, cacheObject.ActorSNO);
                _seenAnimationCache.Add(name, DateTime.UtcNow);
            }

            CacheMaintenance();
        }
Exemple #6
0
        /// <summary>
        /// Checks if a unit is currently being tracked with a given SNOPower. When the spell is properly configured, this can be used to set a "timer" on a DoT re-cast, for example.
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="power"></param>
        /// <returns></returns>
        public static bool IsUnitTracked(TrinityCacheObject unit, SNOPower power)
        {
            if (unit == null)
            {
                return(false);
            }

            if (unit.Type != TrinityObjectType.Unit)
            {
                return(false);
            }
            bool result = TrackedUnits.Any(t => t.ACDGuid == unit.ACDGuid && t.Power == power);

            //if (result)
            //    Technicals.Logger.LogNormal("Unit {0} is tracked with power {1}", unit.ACDGuid, power);
            //else
            //    Technicals.Logger.LogNormal("Unit {0} is NOT tracked with power {1}", unit.ACDGuid, power);
            return(result);
        }
Exemple #7
0
        public static bool ShouldIgnore(TrinityCacheObject cacheObject)
        {
            if (TownRun.IsTryingToTownPortal())
            {
                return(false);
            }

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

            if (!cacheObject.IsFullyValid())
            {
                return(true);
            }

            var isRare     = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Rare;
            var isMinion   = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Minion;
            var isChampion = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Champion;

            if ((cacheObject.IsEliteRareUnique || cacheObject.IsBoss || isMinion) && cacheObject.HitPointsPct <= Settings.Combat.Misc.ForceKillElitesHealth)
            {
                return(false);
            }

            if (Trinity.Settings.Combat.Misc.IgnoreHighHitePointTrash && cacheObject.IsTrashMob)
            {
                var unitName = cacheObject.InternalName.ToLower();
                if (HighHitPointTrashMobNames.Any(name => unitName.Contains(name)))
                {
                    return(true);
                }
            }

            if ((Trinity.Settings.Combat.Misc.IgnoreRares && (isRare | isMinion) || Trinity.Settings.Combat.Misc.IgnoreChampions && isChampion) && !cacheObject.IsBoss)
            {
                return(true);
            }

            return(false);
        }
Exemple #8
0
        internal static TrinityCacheObject GetNewHavePowerNonePowerChargeTarget(SNOPower power1, SNOPower power2)
        {
            var StaticChareDistance = Settings.Combat.Monk.StaticChargeDistance;
            var bestTarget = TargetUtil.ClosestUnit(StaticChareDistance, t => t.IsBoss && t.HasDebuff(power1) && !t.HasDebuff(power2));
            if (bestTarget == null)
            {
                bestTarget = TargetUtil.ClosestUnit(StaticChareDistance, t => t.HasDebuff(power1) && !t.HasDebuff(power2));
                if (bestTarget == null)
                    return CurrentTarget;
            }

            _lastTargetChange = DateTime.UtcNow;
            LastSpecialTarget = bestTarget;
            Logger.Log(LogCategory.Behavior, "Blacklisting {0} {1} for 1 second", CurrentTarget.InternalName, CurrentTarget.CommonData.ACDGuid);
            Trinity.Blacklist1Second.Add(CurrentTarget.RActorGuid);
            Logger.Log(LogCategory.Behavior, "Changing target to {0} {1} (Health={2:0.##}%)", bestTarget.InternalName, bestTarget.CommonData.ACDGuid, bestTarget.HitPointsPct * 100);
            return bestTarget;
        }
Exemple #9
0
 /// <summary>
 /// Cast this skill at the specified target
 /// </summary>
 public void Cast(TrinityCacheObject target)
 {
     Cast(target.Position, target.ACDGuid);
 }
Exemple #10
0
 /// <summary>
 /// Checks if a unit is currently being tracked with a given SNOPower. When the spell is properly configured, this can be used to set a "timer" on a DoT re-cast, for example.
 /// </summary>
 public bool IsTrackedOnUnit(TrinityCacheObject unit)
 {
     return unit.HasDebuff(SNOPower);
 }
Exemple #11
0
 /// <summary>
 /// Cast this skill at the specified target
 /// </summary>
 public void Cast(TrinityCacheObject target)
 {
     Cast(target.Position, target.ACDGuid);
 }
Exemple #12
0
 /// <summary>
 /// Checks if a unit is currently being tracked with a given SNOPower. When the spell is properly configured, this can be used to set a "timer" on a DoT re-cast, for example.
 /// </summary>
 public bool IsTrackedOnUnit(TrinityCacheObject unit)
 {
     return(unit.HasDebuff(SNOPower));
 }
Exemple #13
0
        public static bool ShouldIgnore(TrinityCacheObject cacheObject)
        {
            if (TownRun.IsTryingToTownPortal())
                return false;

            if (cacheObject == null)
                return false;

            if (!cacheObject.IsFullyValid())
                return true;

            var isRare = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Rare;
            var isMinion = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Minion;
            var isChampion = cacheObject.CommonData.MonsterQualityLevel == Zeta.Game.Internals.Actors.MonsterQuality.Champion;

            if ((cacheObject.IsEliteRareUnique || cacheObject.IsBoss || isMinion) && cacheObject.HitPointsPct <= Settings.Combat.Misc.ForceKillElitesHealth)
                return false;

            if (Trinity.Settings.Combat.Misc.IgnoreHighHitePointTrash && cacheObject.IsTrashMob)
            {
                var unitName = cacheObject.InternalName.ToLower();
                if (HighHitPointTrashMobNames.Any(name => unitName.Contains(name)))
                {
                    return true;
                }
            }

            if ((Trinity.Settings.Combat.Misc.IgnoreRares && (isRare | isMinion) || Trinity.Settings.Combat.Misc.IgnoreChampions && isChampion) && !cacheObject.IsBoss)
            {
                return true;
            }

            return false;
        }
Exemple #14
0
        /**************
         * 
         * WARNING
         * 
         * ALWAYS surround your RoutedEventHandlers in try/catch. Failure to do so will result in Demonbuddy CRASHING if an exception is thrown.
         * 
         * WARNING
         *  
         *************/

        private static void CacheTestCacheEventHandler(object sender, RoutedEventArgs routedEventArgs)
        {
            try
            {
                var testUnit = CacheManager.Units.FirstOrDefault();
                if (testUnit != null)
                {
                    var rActorGuid = testUnit.RActorGuid;
                    var ACDGuid = testUnit.ACDGuid;
                    var accessCount = 25;
                    var timerA = new Stopwatch();
                    var timerB = new Stopwatch();

                    var timerBResults = new List<double>();

                    Logger.Log("Starting NOT-CACHED Test for {0}, {1} cycles", testUnit.InternalName, accessCount);

                    // Not Cached

                    timerA.Start();
                    var zetaObj = ZetaDia.Actors.GetActorsOfType<DiaUnit>(true).FirstOrDefault(o => o.RActorGuid == rActorGuid);
                    timerA.Stop();

                    for (int i = 0; i < accessCount; i++)
                    {
                        timerB.Reset();
                        timerB.Start();  
                        var position = zetaObj.Position;
                        var distance = zetaObj.Distance;
                        var actorType = zetaObj.ActorType;
                        var los = NavHelper.CanRayCast(position);
                        timerB.Stop();
                        timerBResults.Add(timerB.Elapsed.TotalMilliseconds);
                        Logger.Log("Position={0} Distance={1} los={2} type={3} time={4:00.0000}ms", position, distance, los, actorType, timerB.Elapsed.TotalMilliseconds);
                    }

                    Logger.Log("FindTime={0:00.0000}ms Cycles={1:00.0000}ms CycleAVG={2:00.0000}ms", timerA.Elapsed.TotalMilliseconds, timerBResults.Sum(), timerBResults.Average());

                    Logger.Log("Starting LAZYCACHE Test for {0}, {1} cycles", testUnit.InternalName, accessCount);

                    // LazyCache

                    timerA.Reset();
                    timerBResults.Clear();

                    timerA.Start();
                    var trinityObject = CacheManager.GetActorByACDGuid<TrinityUnit>(ACDGuid);
                    timerA.Stop();

                    if (trinityObject == null)
                    {
                        Logger.Log("Actor not found. RActorGuid={0}", rActorGuid);
                    }
                    else
                    {
                        for (int x = 0; x < accessCount; x++)
                        {
                            timerB.Reset();
                            timerB.Start();
                            var position = trinityObject.Position;
                            var distance = trinityObject.Distance;
                            var actorType = trinityObject.ActorType;
                            var los = trinityObject.IsInLineOfSight;
                            timerB.Stop();
                            timerBResults.Add(timerB.Elapsed.TotalMilliseconds);
                            Logger.Log("Position={0} Distance={1} los={2} type={3} time={4:00.0000}ms", position, distance, los, actorType, timerB.Elapsed.TotalMilliseconds);
                        }

                        Logger.Log("FindTime={0:00.0000}ms Cycles={1:00.0000}ms CycleAVG={2:00.0000}ms", timerA.Elapsed.TotalMilliseconds, timerBResults.Sum(), timerBResults.Average());
                    }


                    Logger.Log("Starting TRINITYCACHEOBJECT Test for {0}, {1} cycles", testUnit.InternalName, accessCount);

                    // existing TrinityCacheObject

                    timerA.Reset();
                    timerBResults.Clear();
                    timerA.Start();
                    zetaObj = ZetaDia.Actors.GetActorsOfType<DiaUnit>(true).FirstOrDefault(o => o.RActorGuid == rActorGuid);
                    TrinityCacheObject trinObj = new TrinityCacheObject();
                    timerA.Stop();

                    if (zetaObj == null)
                    {
                        Logger.Log("Actor not found. RActorGuid={0}", rActorGuid);
                    }
                    else
                    {
                        for (int i = 0; i < accessCount; i++)
                        {
                            timerB.Reset();
                            timerB.Start();
                            if (i == 0)
                            {
                                trinObj.Position = zetaObj.Position;
                                trinObj.Distance = zetaObj.Distance;
                                trinObj.HasBeenInLoS = NavHelper.CanRayCast(trinObj.Position);
                            }
                            var position = trinObj.Position;
                            var distance = trinObj.Distance;
                            var actorType = trinObj.ActorType;
                            var los = trinObj.HasBeenInLoS;
                            timerB.Stop();
                            timerBResults.Add(timerB.Elapsed.TotalMilliseconds);
                            Logger.Log("Position={0} Distance={1} los={2} type={3} time={4:00.0000}ms", position, distance, los, actorType, timerB.Elapsed.TotalMilliseconds);
                        }

                        Logger.Log("FindTime={0:00.0000}ms Cycles={1:00.0000}ms CycleAVG={2:00.0000}ms", timerA.Elapsed.TotalMilliseconds, timerBResults.Sum(), timerBResults.Average());
                        
                    }


                }
                Logger.Log("Finished Cache Test");
            }
            catch (Exception ex)
            {
                Logger.LogError("Exception {0}", ex);
            }
        }