work on first boss
This commit is contained in:
parent
053a016c8b
commit
89c3a0a077
16 changed files with 702 additions and 150 deletions
|
|
@ -38,13 +38,15 @@ public abstract class GameExecutor
|
|||
// ------ Loot pickup ------
|
||||
|
||||
// Tiers to skip (noise, low-value, or hidden by filter)
|
||||
private static readonly HashSet<string> SkipTiers = ["unknown", "gold"];
|
||||
private static readonly HashSet<string> SkipTiers = ["gold"];
|
||||
|
||||
public async Task Loot()
|
||||
{
|
||||
Log.Information("Starting loot pickup");
|
||||
|
||||
const int maxRounds = 5;
|
||||
var totalPicked = 0;
|
||||
|
||||
for (var round = 0; round < maxRounds; round++)
|
||||
{
|
||||
if (_stopped) return;
|
||||
|
|
@ -53,49 +55,58 @@ public abstract class GameExecutor
|
|||
_game.MoveMouseInstant(0, 1440);
|
||||
await Helpers.Sleep(100);
|
||||
|
||||
// Hold Alt to ensure all labels are visible, then capture
|
||||
// Hold Alt, capture, detect
|
||||
await _game.KeyDown(InputSender.VK.MENU);
|
||||
await Helpers.Sleep(250);
|
||||
var capture = _screen.CaptureRawBitmap();
|
||||
|
||||
// Detect magenta-bordered labels directly (no diff needed)
|
||||
using var capture = _screen.CaptureRawBitmap();
|
||||
var labels = _screen.DetectLootLabels(capture, capture);
|
||||
capture.Dispose();
|
||||
|
||||
// Filter out noise and unwanted tiers
|
||||
var pickups = labels.Where(l => !SkipTiers.Contains(l.Tier)).ToList();
|
||||
|
||||
if (pickups.Count == 0)
|
||||
{
|
||||
await _game.KeyUp(InputSender.VK.MENU);
|
||||
Log.Information("No loot labels in round {Round} (total detected: {Total}, filtered: {Filtered})",
|
||||
round + 1, labels.Count, labels.Count - pickups.Count);
|
||||
Log.Information("No loot labels in round {Round} (picked {Total} total)", round + 1, totalPicked);
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Information("Round {Round}: {Count} loot labels ({Skipped} skipped)",
|
||||
round + 1, pickups.Count, labels.Count - pickups.Count);
|
||||
|
||||
foreach (var skip in labels.Where(l => SkipTiers.Contains(l.Tier)))
|
||||
Log.Debug("Skipped: tier={Tier} color=({R},{G},{B}) at ({X},{Y})",
|
||||
skip.Tier, skip.AvgR, skip.AvgG, skip.AvgB, skip.CenterX, skip.CenterY);
|
||||
|
||||
// Click each label center (Alt still held so labels visible)
|
||||
// Click all detected labels (positions are stable)
|
||||
foreach (var label in pickups)
|
||||
{
|
||||
if (_stopped) break;
|
||||
|
||||
Log.Information("Picking up: tier={Tier} color=({R},{G},{B}) at ({X},{Y})",
|
||||
label.Tier, label.AvgR, label.AvgG, label.AvgB, label.CenterX, label.CenterY);
|
||||
await _game.LeftClickAt(label.CenterX, label.CenterY);
|
||||
await Helpers.Sleep(300);
|
||||
totalPicked++;
|
||||
await Helpers.Sleep(200);
|
||||
}
|
||||
|
||||
// Quick check: capture small region around each clicked label to see if
|
||||
// new labels appeared underneath. If none changed, we're done.
|
||||
await Helpers.Sleep(300);
|
||||
_game.MoveMouseInstant(0, 1440);
|
||||
await Helpers.Sleep(100);
|
||||
|
||||
using var recheck = _screen.CaptureRawBitmap();
|
||||
var newLabels = _screen.DetectLootLabels(recheck, recheck);
|
||||
var newPickups = newLabels.Where(l => !SkipTiers.Contains(l.Tier)).ToList();
|
||||
|
||||
await _game.KeyUp(InputSender.VK.MENU);
|
||||
await Helpers.Sleep(500);
|
||||
|
||||
if (newPickups.Count == 0)
|
||||
{
|
||||
Log.Information("Quick recheck: no new labels, done (picked {Total} total)", totalPicked);
|
||||
break;
|
||||
}
|
||||
|
||||
Log.Information("Quick recheck: {Count} new labels appeared, continuing", newPickups.Count);
|
||||
await Helpers.Sleep(300);
|
||||
}
|
||||
|
||||
Log.Information("Loot pickup complete");
|
||||
Log.Information("Loot pickup complete ({Count} items)", totalPicked);
|
||||
}
|
||||
|
||||
// ------ Recovery ------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue