Example #1
0
        /// <summary>
        /// Finds units within range of each other that need healing
        /// </summary>
        /// <param name="minAverageHealth">Minimum Average health of the Party Members</param>
        /// <param name="maxAverageHealth">MaximumAverage health of the Party Members</param>
        /// <param name="maxDistanceBetweenPlayers">The maximum distance between other members from the targeted member</param>
        /// <param name="minUnits">Minumum units to be affected</param>
        /// <param name="label">A descriptive label for the clients GUI logging output</param>
        /// <returns>A Riad/Party member</returns>
        private Composite FindAreaHealSubroutine(int minAverageHealth, int maxAverageHealth, float maxDistanceBetweenPlayers, int minUnits, string label)
        {
            return(new Action(a =>
            {
                var targetAreaPerformanceTimer = new Stopwatch(); // lets see if we can get some performance on this one.
                targetAreaPerformanceTimer.Start();               // lets see if we can get some performance on this one

                // copy
                List <HealableUnit> grp = HealableUnit.ListofHealableUnits.ToList();

                // gtfo if there is no heal list.
                if (!grp.Any())
                {
                    HealableUnit.HealTarget = null;
                    return RunStatus.Failure;
                }

                // setup a quick filter and exctract our players.
                RefineFilter refineFilter = x => x.ToUnit().Location.DistanceSqr(Me.Location) < 40 * 40 && ObjectManager.ObjectList.Any(y => y.Guid == x.ToUnit().Guid) && x.ToUnit().IsAlive&& !x.ToUnit().ToPlayer().IsGhost&& x.ToUnit().IsPlayer&& x.ToUnit().ToPlayer() != null && !x.ToUnit().IsFlying&& !x.ToUnit().OnTaxi;

                var players = grp.Where(x => refineFilter(x) && !x.Blacklisted && !x.ToUnit().HasAura("Deep Corruption"));

                // Nothing to heal.
                if (!players.Any())
                {
                    {
                        HealableUnit.HealTarget = null;
                        return RunStatus.Failure;
                    }
                }

                HealableUnit best = null;
                int score = minUnits - 1;
                foreach (var player in players)
                {
                    var hits = players.Where(p => p.Location.Distance2DSqr(player.Location) < maxDistanceBetweenPlayers * maxDistanceBetweenPlayers);

                    if (hits.Any())
                    {
                        var avgHealth = hits.Average(p => p.CurrentHealth * 100 / p.MaxHealth);
                        var count = hits.Count();
                        if (avgHealth >= minAverageHealth && avgHealth < maxAverageHealth && count > score)
                        {
                            best = player;
                            score = count;
                        }
                    }
                }

                if (best != null)
                {
                    Logparty(label + " Time Taken: " + targetAreaPerformanceTimer.ElapsedMilliseconds + " ms", CLULogger.SafeName(best.ToUnit()));

                    //best.ToUnit().Target();
                    HealableUnit.HealTarget = best;
                    return RunStatus.Success;
                }
                HealableUnit.HealTarget = null;
                return RunStatus.Failure;
            }));
        }
Example #2
0
 public Composite FindLowHealth(CanRunDecoratorDelegate cond, RefineFilter filter, Comparison <HealableUnit> compare, string reason, params Composite[] children)
 {
     return(FindTarget(cond, TargetFilter.LowHealth, filter, compare, "[CLU TARGETING] " + CLU.Version + ": " + "Targeting LOW HEALTHER {0}:  Max {1}, Current {2}, Defecit {3}, TimeTaken: {4} ms, REASON: " + reason, children));
 }
Example #3
0
        private static Composite FindTarget(CanRunDecoratorDelegate cond, TargetFilter filter, RefineFilter refineFilter, Comparison<HealableUnit> compare, string label, params Composite[] children)
        {
            return new Decorator(
                       cond,
                       new Sequence(
                         // get a target
                           new Action(
                            delegate
                            {
                                var targetPerformanceTimer = new Stopwatch(); // lets see if we can get some performance on this one.
                                targetPerformanceTimer.Start(); // lets see if we can get some performance on this one.

                                //CrabbyProfiler.Instance.Runs.Add(new Run("FindTarget"));

                                // Nothing to filter against
                                if (!UnitsFilter(filter).Any())
                                {
                                    HealableUnit.HealTarget = null;
                                    return RunStatus.Failure;
                                }

                                // Filter the Healable Units
                                var raid = UnitsFilter(filter).Where(x => x != null && (ObjectManager.ObjectList.Any(y => y.Guid == x.ToUnit().Guid) && refineFilter(x)) && x.ToUnit().Distance2DSqr < 40 * 40 && !x.ToUnit().ToPlayer().IsGhost && !x.ToUnit().HasAura("Deep Corruption")).ToList();

                                // Nothing to heal.
                                if (!IsPlayingWoW() || !raid.Any())
                                {
                                    HealableUnit.HealTarget = null;
                                    return RunStatus.Failure;
                                }

                                raid.Sort(compare);
                                var target = raid.FirstOrDefault();
                                if (target != null)
                                {
                                    Log(
                                        label,
                                        CLULogger.SafeName(target.ToUnit()),
                                        target.MaxHealth,
                                        target.CurrentHealth,
                                        target.MaxHealth - target.CurrentHealth,
                                        targetPerformanceTimer.ElapsedMilliseconds); // lets see if we can get some performance on this one.

                                    //target.ToUnit().Target();
                                    HealableUnit.HealTarget = target;
                                    return RunStatus.Success;
                                }
                                HealableUnit.HealTarget = null;
                                //CrabbyProfiler.Instance.EndLast();
                                return RunStatus.Failure;
                            }),
                           new Action(a => StyxWoW.SleepForLagDuration()),
                // if success, keep going. Else quit sub routine
                           new PrioritySelector(children)));
        }
Example #4
0
        private static Composite FindTarget(CanRunDecoratorDelegate cond, TargetFilter filter, RefineFilter refineFilter, Comparison <HealableUnit> compare, string label, params Composite[] children)
        {
            return(new Decorator(
                       cond,
                       new Sequence(

                           // get a target
                           new Action(
                               delegate
            {
                var targetPerformanceTimer = new Stopwatch();   // lets see if we can get some performance on this one.
                targetPerformanceTimer.Start();                 // lets see if we can get some performance on this one.

                //CrabbyProfiler.Instance.Runs.Add(new Run("FindTarget"));

                // Nothing to filter against
                if (!UnitsFilter(filter).Any())
                {
                    HealableUnit.HealTarget = null;
                    return RunStatus.Failure;
                }

                // Filter the Healable Units
                var raid = UnitsFilter(filter).Where(x => x != null && (ObjectManager.ObjectList.Any(y => y.Guid == x.ToUnit().Guid) && refineFilter(x)) && x.ToUnit().Distance2DSqr < 40 * 40 && !x.ToUnit().ToPlayer().IsGhost&& !x.ToUnit().HasAura("Deep Corruption")).ToList();

                // Nothing to heal.
                if (!IsPlayingWoW() || !raid.Any())
                {
                    HealableUnit.HealTarget = null;
                    return RunStatus.Failure;
                }

                raid.Sort(compare);
                var target = raid.FirstOrDefault();
                if (target != null)
                {
                    Log(
                        label,
                        CLULogger.SafeName(target.ToUnit()),
                        target.MaxHealth,
                        target.CurrentHealth,
                        target.MaxHealth - target.CurrentHealth,
                        targetPerformanceTimer.ElapsedMilliseconds);                 // lets see if we can get some performance on this one.

                    //target.ToUnit().Target();
                    HealableUnit.HealTarget = target;
                    return RunStatus.Success;
                }
                HealableUnit.HealTarget = null;

                //CrabbyProfiler.Instance.EndLast();
                return RunStatus.Failure;
            }),
                           new Action(a => StyxWoW.SleepForLagDuration()),

                           // if success, keep going. Else quit sub routine
                           new PrioritySelector(children))));
        }
Example #5
0
 public Composite FindThreats(CanRunDecoratorDelegate cond, RefineFilter filter, Comparison<HealableUnit> compare, string reason, params Composite[] children)
 {
     return FindTarget(cond, TargetFilter.Threats, filter, compare, "[CLU TARGETING] " + CLU.Version + ": " + "Targeting THREAT {0}:  Max {1}, Current {2}, Defecit {3}, TimeTaken: {4} ms, REASON: " + reason, children);
 }