Jump to content

GetUnitAttackPlayer overload


Ke1ka

Recommended Posts

What exactly does ObjectManager.GetUnitAttackPlayer(List<WoWUnit>); method does? Simple one is obvious: rets list of attacking our player mobs, but whats about that list passing into? Im seeking a way to handle sort of "tanking" profile, and want to get mobs which are not aggroed by me, but someone from party to get them off from other party members. I thought this method is a key, casted Party to WoWUnit list, and getting empty list after call after return in any cases, even when party member got aggro.

Link to comment
Share on other sites

Hello @Ke1ka, i had also problems to getting a list from party, so i made a similar method to acquire a general list from objectmanager:

If a hostile npc doesn't target the tank (not tested):

    public static List<WoWUnit> GetNoAggroUnits(float range)
    {
        WoWLocalPlayer me = ObjectManager.Me;
        List<WoWUnit> u = new List<WoWUnit>();
        Parallel.ForEach(ObjectManager.GetWoWUnitHostile(), delegate(WoWUnit unit)
        {
            if (unit.Target != me.Guid
            && unit.Target != 0
            && unit.InCombat
            && unit.IsAlive
            && unit.GetDistance < range
            && !TraceLine.TraceLineGo(unit.Position, me.Position)) //slow part
            {
                u.Add(unit);
            }
        });
        return u.OrderBy(i => i.TargetObject.HealthPercent).ToList();//first object in the returned list will contain the target with the lowest health
    }

You could also do something like this:

    public static List<WoWUnit> GetNoAggroUnitsExplicit(float range)
    {
        WoWLocalPlayer me = ObjectManager.Me;
        var u = new List<WoWUnit>();
        var p = ObjectManager.GetObjectWoWPlayer().Where(woWPlayer => woWPlayer.PlayerFaction == me.PlayerFaction && woWPlayer.IsAlive).Select(i => i.Guid);
        Parallel.ForEach(ObjectManager.GetWoWUnitHostile(), delegate (WoWUnit unit)
        {
            if (p.Contains(unit.Target)
            && unit.Target != 0
            && unit.InCombat
            && unit.IsAlive
            && unit.GetDistance < range
            && !TraceLine.TraceLineGo(unit.Position, me.Position)) //slow part
            {
                u.Add(unit);
            }
        });
        return u.OrderBy(i => i.TargetObject.HealthPercent).ToList();
    }

But i don't think that's necessary, except you would use a party / raid list as "p" (which didn't worked for me last time).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...