What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[?] Priority Targeting System

Smarter

Member
Joined
Jan 15, 2010
Messages
763
Reaction score
9
I have been playing with a Priority Targeting System, and was looking for some advice on Optimizing it. I take all units within a set range, and assign them a variable Priority, defaulted at int.MaxValue; Then, subtracting their distance, and one for each criteria, I chip away at that number. Lowest number, is highest priority :-D?

In a CC's Pulse:
Code:
        private List<Target> _potentialTargets = new List<Target>();
        private List<Target> _combatTargets = new List<Target>();

        private readonly WaitTimer _targetListTimer = WaitTimer.OneSecond;
        public override void Pulse()
        {
            if (!_targetListTimer.IsFinished) return;

            GeneratePriority();
            _combatTargets = _potentialTargets.Where(o => o.IsWithinMeleeRange) as List<Target>;
            _potentialTargets.First().Target();
            _targetListTimer.Reset();
        }

The Function/Class:
Code:
private void GeneratePriority()
        {
            lock (_potentialTargets)
            {
                _potentialTargets.Clear();
                _potentialTargets = ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => o.Distance < 50 && o.IsAlive) as List<Target>;
                if (_potentialTargets != null)
                {
                    foreach (var target in _potentialTargets)
                    {
                        target.Priority = target.Priority - (200 - target.Distance);

                        if (target.IsPlayer)
                            target.Priority = target.Priority--;

                        target.Priority = target.Priority - (100 - target.HealthPercent);

                        if (target.Elite)
                            target.Priority = target.Priority--;

                    }
                    _potentialTargets.OrderBy(o => o.Priority);
                }
            }
        }
    }

    public class Target : WoWUnit
    {
        /// <summary/>
        /// <param name="baseAddress">pointer for this object. </param>
        public Target(uint baseAddress) : base(baseAddress)
        {
            Priority = int.MaxValue;
        }

        public double Priority;
    }
 
Last edited:
I would think this would be good as long as you allowed for some other variables to be evaluated.

In a melee, I prefer to hit any healer in range first... then, if no healer is nearby I would then look for a toon that's low in health figuring someone with 20% health hits just as hard as someone with 100% health... until he's dead... and then he doesn't hit at all... ;)

All that being equal, THEN I would select the nearest target... although alot of ppl might select the squishist one... or someone less likley to kite first... you include options and then you've got a great plugin...
 
Also evaluate targets that are actually hitting you.

Scenario, 2 guys are hitting you, 1 is a Mage with 60% health, 1 is DK with 40%, now depending on your class you might want to start with the DK but you might just be a class that 2 or 3 hit the 60% of the mages health.

Another scenario would be lets say you have the mage and the dk as explained above fighting you but they have a healer standing nearby, no matter what you do they are healed, going then for the healer would in many cases be the wise choice, but going for the healer without someone healing you your most likely owned even before you reach the target.
 
If you look in Singular, you might notice how to implement this properly. Specifically Singular.Managers.HealerManager and TankManager and you want to look for WeighTargetsFilter. Obviously these are for selecting and assigning weights to players that need healing and mobs that need tanking/taunting, but the concept is the same for picking targets to dps.
 
I am working on a similar thing to my PvP CC. I prefer to deal with melee (this is my main "weight") and I have used a similar approach. My only concern is how much processing can I do between Pulses. Since I try my CC to be as close to human play as possible (with computer speed reactions), I want simulate this "environment awareness" regarding players (for instance we mouseover silence a healer that heals our target etc). Don't want to to hijack the thread but is it a real issue?
 
Back
Top