lgbot: debug log says why it isn't steering
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e7812902a1
commit
f494223305
1 file changed
+13
-6
@@ -176,13 +176,20 @@ if minqlx:
|
|||||||
self.read_at = now
|
self.read_at = now
|
||||||
return self.settings
|
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):
|
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()
|
now = time.time()
|
||||||
s = self.read_cvars(now)
|
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 = []
|
cands = []
|
||||||
for p in players:
|
for p in players:
|
||||||
if p.id == bot.id or p.team == "spectator" or not p.is_alive:
|
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))
|
cands.append(((pos.x, pos.y), p))
|
||||||
bpos = bot.position()
|
bpos = bot.position()
|
||||||
target = pick_target((bpos.x, bpos.y), cands)
|
target = pick_target((bpos.x, bpos.y), cands)
|
||||||
if target is None:
|
if target is None: # nobody to duel: stock AI roams
|
||||||
return # nobody to duel: stock AI roams
|
return self.idle(now, "no target within %d (%d candidates)" % (MAX_TARGET_DIST, len(cands)))
|
||||||
tpos = target.position()
|
tpos = target.position()
|
||||||
direction = self.strafer.step(int(now * 1000), s)
|
direction = self.strafer.step(int(now * 1000), s)
|
||||||
want = wanted_range(s, bot.health, target.health)
|
want = wanted_range(s, bot.health, target.health)
|
||||||
|
|||||||
Reference in new issue
Block a user