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):
Interact.InteractGameObject(ObjectManager.Target.GetBaseAddress);
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();
else
enemyPlayerList = ObjectManager.GetWoWUnitAlliance();
WoWPlayer nearestPlayerEnemy = ObjectManager.GetNearestWoWPlayer(enemyPlayerList);
if (nearestPlayerEnemy.IsValid && nearestPlayerEnemy.IsAlive && nearestPlayerEnemy.GetDistance < 150)
{
Interact.InteractGameObject(nearestPlayerEnemy.GetBaseAddress);
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))
enemyUnitList.Add(woWUnit);
}
WoWUnit nearestUnitEnemy = ObjectManager.GetNearestWoWUnit(enemyUnitList);
if (nearestUnitEnemy.IsValid && nearestUnitEnemy.IsAlive && nearestUnitEnemy.GetDistance < 150)
{
Interact.InteractGameObject(nearestUnitEnemy.GetBaseAddress);
if (ObjectManager.Me.Target == nearestUnitEnemy.Guid)
{
// OK
}
}
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.