Skip to content

Commit

Permalink
Teleport AI (Updated) (MobBotTeam#628)
Browse files Browse the repository at this point in the history
This will add an auto learning Teleport method which will automatically
detect the amount of delay you need to now get softbanned, It also
includes randomized teleporting so you dont always land on the same
spot.
  • Loading branch information
inburst21 authored and DurtyFree committed Aug 6, 2016
1 parent 65d3918 commit 9effb45
Show file tree
Hide file tree
Showing 6 changed files with 499 additions and 7 deletions.
8 changes: 7 additions & 1 deletion PoGo.PokeMobBot.Logic/Common/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public enum TranslationString
WebErrorGatewayTimeout,
WebErrorBadGateway,
SkipLaggedTimeout,
SkipLaggedMaintenance
SkipLaggedMaintenance,
TeleAI,
TeleAIBan
}

public class Translation : ITranslation
Expand All @@ -171,6 +173,10 @@ public class Translation : ITranslation
new KeyValuePair<TranslationString, string>(TranslationString.MasterPokeball, "MasterBall"),
new KeyValuePair<TranslationString, string>(TranslationString.WrongAuthType,
"Unknown AuthType in config.json"),
new KeyValuePair<TranslationString, string>(TranslationString.TeleAI,
"We are teleporting {0} meters so we will wait {1}ms"),
new KeyValuePair<TranslationString, string>(TranslationString.TeleAIBan,
"SoftBanned From Jumping {0} meters. Adding 100ms delay. Total: {1}ms."),
new KeyValuePair<TranslationString, string>(TranslationString.FarmPokestopsOutsideRadius,
"You're outside of your defined radius! Walking to start ({0}m away) in 5 seconds. Is your Coords.ini file correct?"),
new KeyValuePair<TranslationString, string>(TranslationString.FarmPokestopsNoUsableFound,
Expand Down
1 change: 1 addition & 0 deletions PoGo.PokeMobBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public interface ILogicSettings

//coords and movement
bool Teleport { get; }
bool TeleAI { get; }
double WalkingSpeedInKilometerPerHour { get; }
int MaxTravelDistanceInMeters { get; }
bool UseGpxPathing { get; }
Expand Down
1 change: 1 addition & 0 deletions PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
<Compile Include="Tasks\TransferPokemonTask.cs" />
<Compile Include="Tasks\UseIncubatorsTask.cs" />
<Compile Include="Tasks\UseNearbyPokestopsTask.cs" />
<Compile Include="TeleportAI.cs" />
<Compile Include="Utils\DelayingEvolveUtils.cs" />
<Compile Include="Utils\DelayingUtils.cs" />
<Compile Include="Utils\EggWalker.cs" />
Expand Down
125 changes: 125 additions & 0 deletions PoGo.PokeMobBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public class LocationSettings
{
//coords and movement
public bool Teleport = false;
//TeleAI will override Teleport if both enabled
public bool TeleAI = false;
public double DefaultLatitude = 40.785091;
public double DefaultLongitude = -73.968285;
public double DefaultAltitude = 10;
Expand Down Expand Up @@ -555,6 +557,8 @@ public class GlobalSettings

public static GlobalSettings Default => new GlobalSettings();

public bool TeleAI { get; internal set; }

public static GlobalSettings Load(string path)
{
GlobalSettings settings;
Expand Down Expand Up @@ -615,6 +619,7 @@ public static GlobalSettings Load(string path)

settings.Save(configFile);
settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json"));
TeleSettings.Load(path);

if (firstRun)
{
Expand Down Expand Up @@ -818,6 +823,7 @@ public LogicSettings(GlobalSettings settings)
public int TotalAmountOfRevivesToKeep => _settings.RecycleSettings.TotalAmountOfRevivesToKeep;
public int TotalAmountOfMaxRevivesToKeep => _settings.RecycleSettings.TotalAmountOfRevivesToKeep;
public bool Teleport => _settings.LocationSettings.Teleport;
public bool TeleAI => _settings.TeleAI;
public int DelayCatchIncensePokemon => _settings.DelaySettings.DelayCatchIncensePokemon;
public int DelayCatchNearbyPokemon => _settings.DelaySettings.DelayCatchNearbyPokemon;
public int DelayPositionCheckState => _settings.DelaySettings.DelayPositionCheckState;
Expand All @@ -843,5 +849,124 @@ public LogicSettings(GlobalSettings settings)

public bool CatchWildPokemon => _settings.CatchSettings.CatchWildPokemon;

}
public class TeleSettings
{
[JsonIgnore]
public string GeneralConfigPath;
[JsonIgnore]
public string ProfilePath;
[JsonIgnore]
public string ProfileConfigPath;

//bot start
public int waitTime50 = 0;
public int waitTime100 = 0;
public int waitTime200 = 0;
public int waitTime300 = 0;
public int waitTime400 = 0;
public int waitTime500 = 0;
public int waitTime600 = 0;
public int waitTime700 = 0;
public int waitTime800 = 0;
public int waitTime900 = 0;
public int waitTime1000 = 0;
public int waitTime1250 = 0;
public int waitTime1500 = 0;
public int waitTime2000 = 0;




public static TeleSettings Load(string path)
{
TeleSettings settings2;
var profilePath = Path.Combine(Directory.GetCurrentDirectory(), path);
var profileConfigPath = Path.Combine(profilePath, "config");
var configFile = Path.Combine(profileConfigPath, "TeleAI.json");

if (File.Exists(configFile))
{
try
{
//if the file exists, load the settings
var input = File.ReadAllText(configFile);

var jsonSettings = new JsonSerializerSettings();
jsonSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true });
jsonSettings.ObjectCreationHandling = ObjectCreationHandling.Replace;
jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate;

settings2 = JsonConvert.DeserializeObject<TeleSettings>(input, jsonSettings);
}
catch (JsonReaderException exception)
{
Logger.Write("JSON Exception: " + exception.Message, LogLevel.Error);
return null;
}
}
else
{
settings2 = new TeleSettings();
}



settings2.ProfilePath = profilePath;
settings2.ProfileConfigPath = profileConfigPath;
settings2.GeneralConfigPath = Path.Combine(Directory.GetCurrentDirectory(), "config");

var firstRun = !File.Exists(configFile);

settings2.Save(configFile);

if (firstRun)
{
return null;
}

return settings2;
}

public void Save(string path)
{
var output = JsonConvert.SerializeObject(this, Formatting.Indented,
new StringEnumConverter { CamelCaseText = true });

var folder = Path.GetDirectoryName(path);
if (folder != null && !Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}

File.WriteAllText(path, output);
}

}
public class TeleLogicSettings
{
public TeleSettings _settings;


public TeleLogicSettings(TeleSettings settings)
{
_settings = settings;
}

public int waitTime50 => _settings.waitTime50;
public int waitTime100 => _settings.waitTime100;
public int waitTime200 => _settings.waitTime200;
public int waitTime300 => _settings.waitTime300;
public int waitTime400 => _settings.waitTime400;
public int waitTime500 => _settings.waitTime500;
public int waitTime600 => _settings.waitTime600;
public int waitTime700 => _settings.waitTime700;
public int waitTime800 => _settings.waitTime800;
public int waitTime900 => _settings.waitTime900;
public int waitTime1000 => _settings.waitTime1000;
public int waitTime1250 => _settings.waitTime1250;
public int waitTime1500 => _settings.waitTime1500;
public int waitTime2000 => _settings.waitTime2000;
}
}

29 changes: 23 additions & 6 deletions PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio

public static async Task Teleport(ISession session, CancellationToken cancellationToken)
{
TeleportAI tele = new TeleportAI();
int stopsToHit = 20; //We should return to the main loop after some point, might as well limit this.
//Not sure where else we could put this? Configs maybe if we incorporate
//deciding how many pokestops in a row we want to hit before doing things like recycling?
Expand Down Expand Up @@ -92,19 +93,31 @@ await session.Navigation.HumanLikeWalking(
session.Client.CurrentLongitude, i.Latitude, i.Longitude)).ToList();
var pokeStop = pokestopList[0];
pokestopList.RemoveAt(0);

var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,

Random rand = new Random();
int MaxDistanceFromStop = 25;
var distance = LocationUtils.CalculateDistanceInMeters(session.Client.CurrentLatitude,
session.Client.CurrentLongitude, pokeStop.Latitude, pokeStop.Longitude);
var randLat = pokeStop.Latitude + rand.NextDouble() * ((double)MaxDistanceFromStop / 111111);
var randLong = pokeStop.Longitude + rand.NextDouble() * ((double)MaxDistanceFromStop / 111111);
var fortInfo = await session.Client.Fort.GetFort(pokeStop.Id, pokeStop.Latitude, pokeStop.Longitude);

session.EventDispatcher.Send(new FortTargetEvent { Id = fortInfo.FortId, Name = fortInfo.Name, Distance = distance, Latitude = fortInfo.Latitude, Longitude = fortInfo.Longitude, Description = fortInfo.Description, url = fortInfo.ImageUrls[0] });
if (session.LogicSettings.Teleport)
await session.Client.Player.UpdatePlayerLocation(fortInfo.Latitude, fortInfo.Longitude,
if (session.LogicSettings.TeleAI)

{
//test purposes
Logger.Write("We are within " + distance + " meters of the PokeStop.");
await session.Client.Player.UpdatePlayerLocation(randLat, randLong, session.Client.Settings.DefaultAltitude);
tele.getDelay(distance);
}
else if (session.LogicSettings.Teleport)
await session.Client.Player.UpdatePlayerLocation(randLat, randLong,
session.Client.Settings.DefaultAltitude);

else
{
await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude),
await session.Navigation.HumanLikeWalking(new GeoCoordinate(randLat, randLong),
session.LogicSettings.WalkingSpeedInKilometerPerHour,
async () =>
{
Expand Down Expand Up @@ -177,7 +190,11 @@ await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, p
}
} while (fortTry < retryNumber - zeroCheck);
//Stop trying if softban is cleaned earlier or if 40 times fort looting failed.

if (fortTry > 1)
{
int distance2 = (int)distance;
tele.addDelay(distance2);
}

if (session.LogicSettings.Teleport)
await Task.Delay(session.LogicSettings.DelayPokestop);
Expand Down
Loading

0 comments on commit 9effb45

Please sign in to comment.