From e3397936d6a2673420f1dca2f73a37d50cfb1f3b Mon Sep 17 00:00:00 2001 From: alexpolo1 Date: Fri, 4 Sep 2026 09:51:03 +0200 Subject: [PATCH] fix(baal_xp): self-heal the leech loop when no route is armed on_maintenance: when run_baal_xp is the only route and nothing is armed, re-arm the leech and go again instead of falling through to end_game. The old path handed off to the controller, which restarted D2R into a brand new game that the next on_init immediately left again - burning a game and a cycle for nothing. The _BAAL_XP_MAX_CONSECUTIVE_FAILS breaker in _baal_xp_rearm still hands off to end_game after enough real failures. on_end_run: a pure leech ends its cycle on the character screen, not in a town - _verify_town_location() would burn template searches for a town that is not there. Re-enter the own game and go straight to maintenance. params.ini: document that run_baal_xp must stay out of order= (the profile layer re-arms it between cycles). --- config/params.ini | 4 ++++ src/bot.py | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/config/params.ini b/config/params.ini index 4bd0040..501861a 100644 --- a/config/params.ini +++ b/config/params.ini @@ -217,6 +217,10 @@ skill_mistake_chance = 0.015 ; run_mephisto (Act 3 Durance of Hate) ; run_baal (Act 5 Throne of Destruction) ; run_baal_xp (Join public Baal games, hide, collect XP, leave — see [baal_xp]) +; The leech is self-contained: it leaves the public game and re-enters its own +; game inside the cycle, so it must NOT sit between real runs in the rotation. +; Keep it out of order= (the profile layer may re-arm it between cycles) and +; enable it with run_baal_xp=1 in the profile's [routes] section. order=run_pindle [char] diff --git a/src/bot.py b/src/bot.py index b4cce9c..530263a 100644 --- a/src/bot.py +++ b/src/bot.py @@ -481,6 +481,20 @@ class Bot: if self._do_runs[key]: self.trigger_or_stop(key) return + # No route is armed. A healthy leech re-arms itself from on_end_run + # (_baal_xp_rearm), but a failure path that skipped the rearm (or a + # profile [routes] section that does not list run_baal_xp) leaves the + # flag down and this branch would end_game - the controller then + # restarts D2R into a brand new game that is immediately left again, + # burning a game and a cycle for nothing. Re-arm and go again; the + # _BAAL_XP_MAX_CONSECUTIVE_FAILS breaker in _baal_xp_rearm still + # hands off to end_game after enough real failures in a row. + if self._baal_xp_only(): + Logger.info("baal_xp: no route armed - re-arming the leech for another cycle") + self._do_runs["run_baal_xp"] = True + Config().routes["run_baal_xp"] = True + self.trigger_or_stop("run_baal_xp") + return self.trigger_or_stop("end_game") return @@ -965,7 +979,10 @@ class Bot: # for a town that is not there. if self._baal_xp_only(): self._baal_xp_reenter_own_game() - elif not self._curr_loc: + set_pause_state(True) + self.trigger_or_stop("maintenance") + return + if not self._curr_loc: self._curr_loc = self._verify_town_location() set_pause_state(True) self.trigger_or_stop("maintenance")