Example #1
0
 public static Npc GetNpcNearby(Npc.NpcType type, Npc.FactionType faction, int continentId, Point currentPosition, bool ignoreRadiusSettings = false)
 {
     try
     {
         Npc npcTemp = new Npc();
         foreach (Npc npc in ListNpc)
         {
             if ((npc.Faction != faction && npc.Faction != Npc.FactionType.Neutral) || npc.Type != type || npc.ContinentIdInt != continentId)
             {
                 continue;
             }
             if (!(npcTemp.Position.DistanceTo(currentPosition) > npc.Position.DistanceTo(currentPosition)) && npcTemp.Position.X != 0)
             {
                 continue;
             }
             if (ignoreRadiusSettings || npc.Position.DistanceTo(currentPosition) <= nManagerSetting.CurrentSetting.MaxDistanceToGoToMailboxesOrNPCs)
             {
                 npcTemp = npc;
             }
         }
         return(npcTemp);
     }
     catch (Exception ex)
     {
         Logging.WriteError(
             "QuestersDB > GetNpcNearby(Npc.NpcType type, Npc.FactionType faction, Enums.ContinentId continentId, Point currentPosition, bool ignoreRadiusSettings = false): " +
             ex);
         return(new Npc());
     }
 }
Example #2
0
 public static Npc GetNpcNearby(Npc.NpcType type, bool ignoreRadiusSettings = false)
 {
     try
     {
         Npc.FactionType faction = (Npc.FactionType)Enum.Parse(typeof(Npc.FactionType), ObjectManager.ObjectManager.Me.PlayerFaction);
         return(GetNpcNearby(type, faction, Usefuls.ContinentId, ObjectManager.ObjectManager.Me.Position, ignoreRadiusSettings));
     }
     catch (Exception ex)
     {
         Logging.WriteError("QuestersDB > GetNpcNearby(Npc.NpcType type, bool ignoreRadiusSettings = false): " + ex);
         return(new Npc());
     }
 }