Jump to content

Hi ... Have you an easy tip for :

Recommended Posts



I'm looking for a tip to :


Attack only a player Target. I have that to avoid neutral targets :

if (ObjectManager.Target.IsValid && ObjectManager.Target.Reaction <= Reaction.Neutral && UnitCanAttack.CanAttack(ObjectManager.Target.GetBaseAddress, ObjectManager.Me.GetBaseAddress))

Perhaps we can do better to test if a target is an hostile Player ?




Anymore, is there a code to target "ObjectManager.Me.Target" ?



I've tryed this :


but  we can't adapt this with "ObjectManager.Me.Target"


So perhaps you have another solution ?


Instead of that i use a Lua code to scan targets \targetEnnemyPlayer until obtain the good target. It's not the best choice.


Thank you very much :)))

Link to comment
Share on other sites



To get if it is enemy player:

        if (ObjectManager.Target.Type == WoWObjectType.Player)
            if (((WoWPlayer) ObjectManager.Target).PlayerFaction != ObjectManager.Me.PlayerFaction)
                // Is enemy player

To interact with your current target (this is useless because it is already your target):


I ignore exactly what is your objective, but if you want search and interact with an enemy player you can use code like:

        List<WoWPlayer> enemyPlayerList;

        if (ObjectManager.Me.IsAlliance)
            enemyPlayerList = ObjectManager.GetWoWUnitHorde();
            enemyPlayerList = ObjectManager.GetWoWUnitAlliance();

        WoWPlayer nearestPlayerEnemy = ObjectManager.GetNearestWoWPlayer(enemyPlayerList);

        if (nearestPlayerEnemy.IsValid && nearestPlayerEnemy.IsAlive && nearestPlayerEnemy.GetDistance < 150)

            if (ObjectManager.Me.Target == nearestPlayerEnemy.Guid)
                // OK

To get the nearest attackable NPC:

        List<WoWUnit> unitList = ObjectManager.GetObjectWoWUnit();
        List<WoWUnit> enemyUnitList = new List<WoWUnit>();

        foreach (var woWUnit in unitList)
            if (woWUnit.IsValid && woWUnit.IsAlive && woWUnit.Reaction <= Reaction.Neutral && UnitCanAttack.CanAttack(woWUnit.GetBaseAddress, ObjectManager.Me.GetBaseAddress))

        WoWUnit nearestUnitEnemy = ObjectManager.GetNearestWoWUnit(enemyUnitList);

        if (nearestUnitEnemy.IsValid && nearestUnitEnemy.IsAlive && nearestUnitEnemy.GetDistance < 150)

            if (ObjectManager.Me.Target == nearestUnitEnemy.Guid)
                // OK
Link to comment
Share on other sites

Hi and thank you very much for your very quick answer.


Yes perhaps you need more informations but you gived me the right answer.


I'm working for a script


-On battlegrounds a list of ennemy players is build and always updated with their Pv

-If several members of this list are at good range, the choosed target will be the lesser PV target and the choosed target will be always targeted first


That's why i need this code to target something with his ID.




I just want to be more efficient and sometimes to be efficient we must choose the right target.

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...