Random speed offset

Brian [2016-08-18 07:46:38]
Random speed offset
Filename
PokemonGo.RocketBot.Logic/ILogicSettings.cs
PokemonGo.RocketBot.Logic/Navigation.cs
PokemonGo.RocketBot.Logic/Settings.cs
PokemonGo.RocketBot.Logic/Tasks/FarmPokestopsTask.cs
diff --git a/PokemonGo.RocketBot.Logic/ILogicSettings.cs b/PokemonGo.RocketBot.Logic/ILogicSettings.cs
index fa27d54..279aa39 100644
--- a/PokemonGo.RocketBot.Logic/ILogicSettings.cs
+++ b/PokemonGo.RocketBot.Logic/ILogicSettings.cs
@@ -46,7 +46,7 @@ namespace PokemonGo.RocketBot.Logic
         {
         }

-        public TransferFilter(int keepMinCp, int keepMinLvl, bool useKeepMinLvl, float keepMinIvPercentage, string keepMinOperator, int keepMinDuplicatePokemon,
+        public TransferFilter(int keepMinCp, int keepMinLvl, bool useKeepMinLvl, float keepMinIvPercentage, string keepMinOperator, int keepMinDuplicatePokemon,
             List<PokemonMove> moves = null, string movesOperator = "or")
         {
             KeepMinCp = keepMinCp;
@@ -83,6 +83,7 @@ namespace PokemonGo.RocketBot.Logic
         bool UseKeepMinLvl { get; }
         string KeepMinOperator { get; }
         double WalkingSpeedInKilometerPerHour { get; }
+        double WalkingSpeedOffSetInKilometerPerHour { get; }
         bool FastSoftBanBypass { get; }
         bool EvolveAllPokemonWithEnoughCandy { get; }
         bool KeepPokemonsThatCanEvolve { get; }
diff --git a/PokemonGo.RocketBot.Logic/Navigation.cs b/PokemonGo.RocketBot.Logic/Navigation.cs
index 5841917..b09a4f3 100644
--- a/PokemonGo.RocketBot.Logic/Navigation.cs
+++ b/PokemonGo.RocketBot.Logic/Navigation.cs
@@ -5,10 +5,10 @@ using System.Globalization;
 using System.Threading;
 using System.Threading.Tasks;
 using GeoCoordinatePortable;
-using PokemonGo.RocketBot.Logic.Utils;
 using PokemonGo.RocketAPI;
-using POGOProtos.Networking.Responses;
 using PokemonGo.RocketBot.Logic.Logging;
+using PokemonGo.RocketBot.Logic.Utils;
+using POGOProtos.Networking.Responses;

 #endregion

@@ -27,23 +27,23 @@ namespace PokemonGo.RocketBot.Logic
         }

         public async Task<PlayerUpdateResponse> Move(GeoCoordinate targetLocation,
-            double walkingSpeedInKilometersPerHour, Func<Task<bool>> functionExecutedWhileWalking,
+            double walkingSpeedInKilometersPerHour, double walkingSpeedOffSetInKilometersPerHour,
+            Func<Task<bool>> functionExecutedWhileWalking,
             CancellationToken cancellationToken, bool disableHumanLikeWalking)
         {
             cancellationToken.ThrowIfCancellationRequested();
             if (!disableHumanLikeWalking)
             {
-                var speedInMetersPerSecond = walkingSpeedInKilometersPerHour/3.6;
-
                 var sourceLocation = new GeoCoordinate(_client.CurrentLatitude, _client.CurrentLongitude);

                 var nextWaypointBearing = LocationUtils.DegreeBearing(sourceLocation, targetLocation);
-                var nextWaypointDistance = speedInMetersPerSecond;
+                var nextWaypointDistance = walkingSpeedInKilometersPerHour/3.6;
+                ;
                 var waypoint = LocationUtils.CreateWaypoint(sourceLocation, nextWaypointDistance, nextWaypointBearing);

                 //Initial walking
                 var requestSendDateTime = DateTime.Now;
-                var result =
+                var result =
                     await
                         _client.Player.UpdatePlayerLocation(waypoint.Latitude, waypoint.Longitude,
                             waypoint.Altitude);
@@ -52,6 +52,15 @@ namespace PokemonGo.RocketBot.Logic

                 do
                 {
+                    var random = new Random();
+                    double offset;
+                    if (random.Next(0, 2) == 1)
+                        offset = random.NextDouble()*walkingSpeedOffSetInKilometersPerHour;
+                    else
+                        offset = -random.NextDouble()*walkingSpeedOffSetInKilometersPerHour;
+                    Logger.Write(offset.ToString());
+
+                    var speedInMetersPerSecond = (walkingSpeedInKilometersPerHour + offset)/3.6;
                     cancellationToken.ThrowIfCancellationRequested();

                     var millisecondsUntilGetUpdatePlayerLocationResponse =
@@ -146,7 +155,7 @@ namespace PokemonGo.RocketBot.Logic
                 var result =
                     await
                         _client.Player.UpdatePlayerLocation(targetLocation.Latitude, targetLocation.Longitude,
-                            LocationUtils.getElevation(targetLocation.Latitude,targetLocation.Longitude));
+                            LocationUtils.getElevation(targetLocation.Latitude, targetLocation.Longitude));
                 UpdatePositionEvent?.Invoke(targetLocation.Latitude, targetLocation.Longitude);
                 if (functionExecutedWhileWalking != null)
                     await functionExecutedWhileWalking(); // look for pokemon
diff --git a/PokemonGo.RocketBot.Logic/Settings.cs b/PokemonGo.RocketBot.Logic/Settings.cs
index 3f3bb33..e7fac0b 100644
--- a/PokemonGo.RocketBot.Logic/Settings.cs
+++ b/PokemonGo.RocketBot.Logic/Settings.cs
@@ -347,6 +347,8 @@ namespace PokemonGo.RocketBot.Logic
         public double DefaultLongitude;
         [DefaultValue(19.0)]
         public double WalkingSpeedInKilometerPerHour;
+        [DefaultValue(2)]
+        public double WalkingSpeedOffSetInKilometerPerHour;
         [DefaultValue(10)]
         public int MaxSpawnLocationOffset;
         //softban related
@@ -1320,6 +1322,7 @@ namespace PokemonGo.RocketBot.Logic
         public float UpgradePokemonCpMinimum => _settings.UpgradePokemonCpMinimum;
         public string UpgradePokemonMinimumStatsOperator => _settings.UpgradePokemonMinimumStatsOperator;
         public double WalkingSpeedInKilometerPerHour => _settings.WalkingSpeedInKilometerPerHour;
+        public double WalkingSpeedOffSetInKilometerPerHour => _settings.WalkingSpeedOffSetInKilometerPerHour;
         public bool FastSoftBanBypass => _settings.FastSoftBanBypass;
         public bool EvolveAllPokemonWithEnoughCandy => _settings.EvolveAllPokemonWithEnoughCandy;
         public bool KeepPokemonsThatCanEvolve => _settings.KeepPokemonsThatCanEvolve;
diff --git a/PokemonGo.RocketBot.Logic/Tasks/FarmPokestopsTask.cs b/PokemonGo.RocketBot.Logic/Tasks/FarmPokestopsTask.cs
index 8f2d85c..254fac1 100644
--- a/PokemonGo.RocketBot.Logic/Tasks/FarmPokestopsTask.cs
+++ b/PokemonGo.RocketBot.Logic/Tasks/FarmPokestopsTask.cs
@@ -44,7 +44,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks

                 await session.Navigation.Move(
                     new GeoCoordinate(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude, LocationUtils.getElevation(session.Settings.DefaultLatitude, session.Settings.DefaultLongitude)),
-                    session.LogicSettings.WalkingSpeedInKilometerPerHour, null, cancellationToken, session.LogicSettings.DisableHumanWalking);
+                    session.LogicSettings.WalkingSpeedInKilometerPerHour, session.LogicSettings.WalkingSpeedOffSetInKilometerPerHour, null, cancellationToken, session.LogicSettings.DisableHumanWalking);
             }

             var pokestopList = await GetPokeStops(session);
@@ -78,7 +78,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
                 session.EventDispatcher.Send(new FortTargetEvent { Name = fortInfo.Name, Distance = distance });

                 await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude, LocationUtils.getElevation(pokeStop.Latitude, pokeStop.Longitude)),
-                session.LogicSettings.WalkingSpeedInKilometerPerHour,
+                session.LogicSettings.WalkingSpeedInKilometerPerHour, session.LogicSettings.WalkingSpeedOffSetInKilometerPerHour,
                 async () =>
                 {
                     // Catch normal map Pokemon
You may download the files in Public Git.