Пример #1
0
        /// <summary>
        /// Remove invalid healableunits.
        /// </summary>
        public static void Remove()
        {
            try
            {
                if (Adding)
                {
                    return;
                }

                Removing = true;

                var grp = ListofHealableUnits.Where(n => !HealableUnit.Filter(n.ToUnit())).ToList();
                foreach (var unit in grp.Where(unit => ListofHealableUnits.IndexOf(unit) != -1))
                {
                    ListofHealableUnits.RemoveAt(ListofHealableUnits.IndexOf(unit)); // remove
                    CLULogger.TroubleshootLog(" Success Removed: {0} no longer a valid healableunit.", CLULogger.SafeName(unit.ToUnit()));
                }

                Removing = false;
            }
            catch (Exception ex)
            {
                CLULogger.DiagnosticLog("Remove : {0}", ex);
            }
        }
Пример #2
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;
            }));
        }