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

Advanced priority-based targeting - in need ideas of how to implement

strix

New Member
Joined
Feb 13, 2010
Messages
442
Reaction score
18
I recently came up with idea of creating priority based targeting (determining unit weight)

I thought of some poor way:
1. Created array of checks, 0 index being most relevant,
2. the weight starts at float.MaxValue and for each check returning false is lowered by 1,
PHP:
public static float GetAdvancedPriority( this WoWUnit u, bool[] priorityTable )
{
    float ret = float.MaxValue;
    foreach(bool c in priorityTable)
    {
        if(c)
            return ret;
        ret--;
    }
    return 
        ret - (float)HPDistanceWeightCheck(u);
}
3. If all check fails the value gets lowered even further by HP+Distance related weight check,
4. Then i use that function to order units in List<WoWUnit>

The major flaw is that it's too inflexible, simple -1 for each check and nothing else.
Ideally for each check in the array it should lower total by amount determined by this check (and some fixed value for failed check).

Any ideas how to implement that so it would be simple to edit such priority table?

Yea i'm a bit lazy right now, just don't want to make people wait till i find the way myself.
 
Last edited:
Well, I would suggest a point gain system really. Assign each logic statement a value. Add to the units value, highest value is the target? I would of course make a
PHP:
enum
of values so you and users could play with them till a functional weight is established for each?

Such as:
PHP:
using System.Linq;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

namespace RaFBuddy
{
    class PriorityTargeting
    {
        public WoWUnit GetTarget()
        {
            var objList = ObjectManager.GetObjectsOfType<WoWUnit>().Where(o => o.IsAlive && o.IsValid && !o.IsFriendly);
            var targetList = objList.Select(unit => unit as PotentialTarget).ToList();
            
            foreach (var target in targetList)
            {
                if (target.IsTargetingMeOrPet)
                    target.Priority++;
                if (target.IsTargetingMyRaidMember)
                    target.Priority++;
                if (target.HealthPercent > 90)
                    target.Priority = target.Priority + 2;
            }

            targetList.OrderBy(o => o.Priority);
            return targetList.First();
        }
    }

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

        public double Priority { get; set; }
    }
}
 
Last edited:
The thing is if few targets meet same condition, you want to distinguish them by distance/hp/mana or whatever.

Ideally there should never be two targets at same time having same priority values.
 
Last edited:
Why don't you simply create different methods for the checks and include themselves in the main one? In this way you could do something like this:

PHP:
yourWoWUnitList.Sort(f,s => (yourSuperMethod(f) > yourSuperMethod(s)) ? true : (yourSuperMethod(f) == yourSuperMethod(s) && secondCheck(f, s)) ? true : false);

P.S.
I've never sorted a list, don't know what should return (I've used a bool value just as an example).
 
The thing is if few targets meet same condition, you want to distinguish them by distance/hp/mana or whatever.

Ideally there should never be two targets at same time having same priority values.

Hmmm. I see the logical dilemma .... I would just say add their distance, but that would add priority to the furthest mob, when you need to reverse their distance ..... what if you set a max-distance in the initial object grab, let's say 100 yds. You could then do:
PHP:
unit.Priority = unit.Priority + (100 - unit.Distance(Me.Location));
 
Last edited:
Hmmm. I see the logical dilemma .... I would just say add their distance, but that would add priority to the furthest mob, when you need to reverse their distance ..... what if you set a max-distance in the initial object grab, let's say 100 yds. You could then do:
PHP:
unit.Priority = unit.Priority + (100 - unit.Distance(Me.Location));

You do know that we purposely made "Targeting" an instantiated class specifically for this, yes?

Derive from it and just override the stuff that needs overriding. (Check Singular for some examples. TankManager/HealManager)
 
You do know that we purposely made "Targeting" an instantiated class specifically for this, yes?

Derive from it and just override the stuff that needs overriding. (Check Singular for some examples. TankManager/HealManager)

Beautiful :-D.
 
So Targeting.Instance.FirstUnit will be to retrieve target with highest weight?
 
Is it possible to create a BotBase derived from Grind Bot, and just override Targeting?
 
Back
Top