lgbot: debug log says why it isn't steering

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
esefandClaude Opus 5.5 committed 2026-10-15 14:57:28 +03:00
1 parent e7812902a1
commit f494223305
1 file changed
+13 -6
+13 -6
View File
@@ -176,13 +176,20 @@ if minqlx:
self.read_at = now
return self.settings
def idle(self, now, why):
if self.debug and now - self.log_at >= 1.0:
self.log_at = now
self.logger.info("lgbot idle: %s", why)
def tick(self):
players = self.players()
bot = next((p for p in players if is_lgbot(p.clean_name, p.steam_id)), None)
if bot is None or not bot.is_alive:
return
now = time.time()
s = self.read_cvars(now)
players = self.players()
bot = next((p for p in players if is_lgbot(p.clean_name, p.steam_id)), None)
if bot is None:
return self.idle(now, "no lgbot on the server")
if not bot.is_alive:
return self.idle(now, "lgbot is dead")
cands = []
for p in players:
if p.id == bot.id or p.team == "spectator" or not p.is_alive:
@@ -193,8 +200,8 @@ if minqlx:
cands.append(((pos.x, pos.y), p))
bpos = bot.position()
target = pick_target((bpos.x, bpos.y), cands)
if target is None:
return # nobody to duel: stock AI roams
if target is None: # nobody to duel: stock AI roams
return self.idle(now, "no target within %d (%d candidates)" % (MAX_TARGET_DIST, len(cands)))
tpos = target.position()
direction = self.strafer.step(int(now * 1000), s)
want = wanted_range(s, bot.health, target.health)