much better bot and ocr
This commit is contained in:
parent
bb8f50116a
commit
6257bcf122
25 changed files with 583 additions and 101 deletions
|
|
@ -389,13 +389,18 @@ public class BossRunExecutor : GameExecutor
|
|||
Log.Information("Fight area updated to ({X:F0},{Y:F0})", fightWorldX, fightWorldY);
|
||||
}
|
||||
|
||||
// Wait for death animation before looking for well
|
||||
await Sleep(3000);
|
||||
// Wait for death animation + loot settle, keep updating fight position from YOLO
|
||||
var deathPos = await PollYoloDuringWait(3000);
|
||||
if (deathPos != null)
|
||||
{
|
||||
fightWorldX = deathPos.Value.X;
|
||||
fightWorldY = deathPos.Value.Y;
|
||||
}
|
||||
|
||||
// Walk to well and click the closest match to screen center
|
||||
Log.Information("Phase {Phase} done, walking to well", phase);
|
||||
await WalkToWorldPosition(wellWorldX, wellWorldY);
|
||||
await Sleep(500);
|
||||
await Sleep(1500);
|
||||
await ClickClosestTemplateToCenter(CathedralWellTemplate);
|
||||
await Sleep(200);
|
||||
|
||||
|
|
@ -666,6 +671,7 @@ public class BossRunExecutor : GameExecutor
|
|||
lastBossWorldPos = (
|
||||
wp.X + (boss.Cx - screenCx) * screenToWorld,
|
||||
wp.Y + (boss.Cy - screenCy) * screenToWorld);
|
||||
FightPosition = lastBossWorldPos;
|
||||
|
||||
yoloLogCount++;
|
||||
if (yoloLogCount % 5 == 1) // log every 5th detection
|
||||
|
|
@ -731,6 +737,37 @@ public class BossRunExecutor : GameExecutor
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sleep for the given duration while polling YOLO to keep FightPosition updated
|
||||
/// (e.g., during boss death animation when YOLO still detects the corpse/model).
|
||||
/// Returns last detected position, or null if no detections.
|
||||
/// </summary>
|
||||
private async Task<(double X, double Y)?> PollYoloDuringWait(int durationMs)
|
||||
{
|
||||
const int screenCx = 1280;
|
||||
const int screenCy = 660;
|
||||
const double screenToWorld = 97.0 / 835.0;
|
||||
(double X, double Y)? lastPos = null;
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
while (sw.ElapsedMilliseconds < durationMs)
|
||||
{
|
||||
if (_stopped) break;
|
||||
var snapshot = _bossDetector.Latest;
|
||||
if (snapshot.Bosses.Count > 0)
|
||||
{
|
||||
var boss = snapshot.Bosses[0];
|
||||
var wp = _nav.WorldPosition;
|
||||
lastPos = (
|
||||
wp.X + (boss.Cx - screenCx) * screenToWorld,
|
||||
wp.Y + (boss.Cy - screenCy) * screenToWorld);
|
||||
FightPosition = lastPos;
|
||||
}
|
||||
await Sleep(100);
|
||||
}
|
||||
return lastPos;
|
||||
}
|
||||
|
||||
private async Task AttackAtPosition(int x, int y, int durationMs)
|
||||
{
|
||||
var (combatTask, cts) = StartCombatLoop(x, y, jitter: 20);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue