From 71768c72aa7c627469c25b08f7eff781d29fd289 Mon Sep 17 00:00:00 2001 From: Egezenn Date: Thu, 15 Oct 2026 12:07:57 +0300 Subject: [PATCH] Throttle dynamic path generation and check area radius - Don't calculate path if player is already within Area.Radius + 50 - Throttle dynamic path calculation attempts to at most once every 30 seconds - Begin loopback when distance to player exceeds Area.Radius + 50 instead of fixed 80 --- Botbases/RSBot.Training/Bundle/Loop/LoopBundle.cs | 11 +++++++++++ Botbases/RSBot.Training/TrainingBase.cs | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Botbases/RSBot.Training/Bundle/Loop/LoopBundle.cs b/Botbases/RSBot.Training/Bundle/Loop/LoopBundle.cs index 8a2041e0..eccfe88b 100644 --- a/Botbases/RSBot.Training/Bundle/Loop/LoopBundle.cs +++ b/Botbases/RSBot.Training/Bundle/Loop/LoopBundle.cs @@ -9,6 +9,8 @@ namespace RSBot.Training.Bundle.Loop; internal class LoopBundle : IBundle { + private System.DateTime _lastAutopathAttempt = System.DateTime.MinValue; + /// /// Gets the configuration. /// @@ -78,6 +80,7 @@ public void Stop() ShoppingManager.Stop(); Running = false; + _lastAutopathAttempt = System.DateTime.MinValue; } /// @@ -165,6 +168,14 @@ public void CheckForWalkbackScript(bool startFromTown = false) if (Config.WalkScript == null || !File.Exists(Config.WalkScript)) { + if (Container.Bot.Area.Position.DistanceToPlayer() <= Container.Bot.Area.Radius + 50) + return; + + if (System.DateTime.UtcNow - _lastAutopathAttempt < System.TimeSpan.FromSeconds(30)) + return; + + _lastAutopathAttempt = System.DateTime.UtcNow; + Log.Notify("No walkback script found. Attempting to generate a dynamic path..."); if (NavigationManager.CalculatePathToTrainingArea()) { diff --git a/Botbases/RSBot.Training/TrainingBase.cs b/Botbases/RSBot.Training/TrainingBase.cs index 2354670d..b6e1aa5b 100644 --- a/Botbases/RSBot.Training/TrainingBase.cs +++ b/Botbases/RSBot.Training/TrainingBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using RSBot.Core; using RSBot.Core.Components; using RSBot.Core.Objects; @@ -34,7 +34,7 @@ public void Tick() return; //Begin the loopback if needed - if (Container.Bot.Area.Position.DistanceToPlayer() > 80) + if (Container.Bot.Area.Position.DistanceToPlayer() > Container.Bot.Area.Radius + 50) Bundles.Loop.Start(); if (Bundles.Loop.Running)