January 19, 20188 yr ObjectManager.GetWoWUnitHostile is useful function in many cases. To select lowest HP enemy, to multi dot, etc. But useless in pvp, because returns List<WoWUnit> objects with WoWPlayer exclusion (there is woWObject.Type==WoWObjectType.Unit condition inside this function). So, proper GetWoWUnitHostile is: public static List<WoWUnit> GetWoWPlayerHostile() { List<WoWUnit> result = new List<WoWUnit>(); try { foreach (WoWObject woWObject in ObjectManager.ObjectList) { if (!woWObject.IsValid || woWObject.IsInvisible) continue; WoWUnit o; switch (woWObject.Type) { //case WoWObjectType.Unit: // o = new WoWUnit(woWObject.GetBaseAddress); // break; case WoWObjectType.Player: o = new WoWPlayer(woWObject.GetBaseAddress); break; default: continue; } if (woWObject.IsInvisible) continue; if (o.Reaction <= Reaction.Unfriendly && !o.IsDead) { result.Add(o); } } } catch (Exception arg) { Logging.WriteError("GetWoWPlayerHostile error " + arg, true); } return result; } public static List<WoWUnit> GetWoWUnitHostile() { List<WoWUnit> enemies = GetWoWPlayerHostile(); if (enemies.Count == 0) enemies = ObjectManager.GetWoWUnitHostile(); return enemies; } This function selects enemy players first, and if nothing found, selects hostile units. I left some commented code in GetWoWPlayerHostile so you can see my 1st variant - 1 list with players and units together. But i think final variant is better for PVP and even for all cases
January 20, 20188 yr Hello, .Reaction work only on Npc, for the player check faction (o.PlayerFaction != ObjectManager.Me.PlayerFaction)
Create an account or sign in to comment