Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
Changes to MoveToRealms method
Browse files Browse the repository at this point in the history
 - Fixed issue #13 by checking for the amount of players within 2 tiles of each full realm
  • Loading branch information
thomas-crane committed Apr 6, 2017
1 parent c269d8f commit 00ed2d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions FameBot/Core/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,24 @@ private async void MoveToRealms(Client client)
if (client.PlayerData.Pos.Y <= 110 && client.PlayerData.Pos.Y != 0)
{
if (portals.Count != 0)
target = portals.OrderByDescending(p => p.PlayerCount).First().Location;
{
int bestCount = 0;
if(portals.Where(ptl => ptl.PlayerCount == 85).Count() > 1)
{
foreach(Portal ptl in portals.Where(ptl => ptl.PlayerCount == 85))
{
int count = playerPositions.Values.Where(plr => plr.Position.DistanceSquaredTo(ptl.Location) <= 4).Count();
if(count > bestCount)
{
bestCount = count;
target = ptl.Location;
}
}
} else
{
target = portals.OrderByDescending(ptl => ptl.PlayerCount).First().Location;
}
}
else
target = new Location(159, 101);
}
Expand All @@ -641,7 +658,7 @@ private async void MoveToRealms(Client client)
{
Log("Attempting connection.");
gotoRealm = false;
AttemptConnection(client, portals.OrderByDescending(p => p.PlayerCount).First().ObjectId);
AttemptConnection(client, portals.OrderBy(ptl => ptl.Location.DistanceSquaredTo(client.PlayerData.Pos)).First().ObjectId);
}
await Task.Delay(5);
if (gotoRealm)
Expand Down
Binary file modified Release/FameBot.dll
Binary file not shown.

0 comments on commit 00ed2d0

Please sign in to comment.