private WoWUnit FindTarget(Vector3 location) { WoWUnit target = null; if (_targetGuid.IsValid) { target = ObjectManager.GetObjectByGuid <WoWUnit>(_targetGuid); } if (target != null && target.IsAlive // if rescuing NPCs then we don't want to include those rescued by other players. && (DropPassengerButton == 0 || !IsRescuedByOtherPlayer(target)) && !Blacklist.Contains(target, BlacklistFlags.Combat | BlacklistFlags.Interact)) { return(target); } target = ObjectManager.GetObjectsOfType <WoWUnit>() .Where(u => !u.IsDead && NpcList.Contains((int)u.Entry) && !Blacklist.Contains(u, BlacklistFlags.Combat | BlacklistFlags.Interact) // if rescuing NPCs then we don't want to include those rescued by other players. && (DropPassengerButton == 0 || !IsRescuedByOtherPlayer(target)) && u.Location.Distance2D(location) < NpcScanRange) .OrderBy(u => location.Distance2DSquared(u.Location)) .FirstOrDefault(); if (target != null) { _targetGuid = target.Guid; } return(target); }
WoWUnit GetNpc() { WoWUnit veh = GetVehicle(); return(ObjectManager.GetObjectsOfType <WoWUnit>().OrderBy(u => veh.Location.Distance2D(u.Location)). FirstOrDefault(u => u.Location.Distance2D(veh.Location) <= NpcScanRange && !u.Dead && NpcList.Contains((int)u.Entry))); }