-
Active Member
Who attacked me?
Hello everyone! For a long time can not create logic who attacked me.
For the first time I did it like that:
Code:
public List<WoWUnit> AttakedMe
{
get
{
List<WoWUnit> ret = new List<WoWUnit>();
IntPtr pointer = WoWManager.EntityFirst;
while ((pointer != IntPtr.Zero) && ((pointer.ToInt64() & 1) == 0))
{
WoWUnit unit = new WoWUnit(pointer);
if (unit.Reaction == WoWEnums.UnitReaction.Hostile || unit.Reaction == WoWEnums.UnitReaction.Neutral)
if ((unit.Target == this.Guid) && (unit.EntityType != (uint)WoWEnums.WoWObjectType.Player)) ret.Add(unit);
pointer = unit.NextEntity;
}
return ret;
}
}
I know from experience that regardless of the reaction unit can attack you.
PS: this temporary approach some of the players to select in target you then bot going to kill him
-
Active Member
This is how i do it, its some temporary code a threw together and not a 100% but it has worked well enough for me so far.
Im checking: Am i or my pets in combat?, is the mob in combat? is it targeting me or my pets? My combat loop keeps track of the mobs after that so it wont loose track of them if they start fleeing or gets cc'd etc.
Code:
var myMinions = objMgr.GetWowObjectsOfType<WowUnit>().Where(o => o.CreatedBy == me.Guid && o.InCombat).ToList();
var mobs = objMgr.GetWowObjectsOfType<WowUnit>().Where(o => o.InCombat
&& !o.HasDynamicFlag(WowUnit.UnitDynamicFlags.TaggedByOther)
&& (o.CurrentTarget == _me.Guid || myMinions.Exists(m => o.CurrentTarget == m.Guid))).ToList();
Last edited by squiggy; 07-03-2017 at 03:45 PM.
-
Post Thanks / Like - 1 Thanks
zdohdds (1 members gave Thanks to squiggy for this useful post)