diff --git a/cmd/debug/main.go b/cmd/debug/main.go index afb07ee..90b8243 100644 --- a/cmd/debug/main.go +++ b/cmd/debug/main.go @@ -35,12 +35,12 @@ func main() { // Define regions for 1080p (from config.go — calibrated from botty reference) regions := map[string]image.Rectangle{ - "health_globe": image.Rect(240, 870, 600, 1080), - "mana_globe": image.Rect(1330, 870, 1690, 1080), - "health_slice": image.Rect(415, 915, 425, 1060), - "mana_slice": image.Rect(1505, 915, 1515, 1060), - "health_orb": image.Rect(240, 870, 600, 1080), - "mana_orb": image.Rect(1330, 870, 1690, 1080), + "health_globe": image.Rect(325, 915, 470, 1040), + "mana_globe": image.Rect(1475, 900, 1655, 1055), + "health_slice": image.Rect(395, 920, 405, 1040), + "mana_slice": image.Rect(1505, 900, 1515, 1055), + "health_orb": image.Rect(325, 915, 470, 1040), + "mana_orb": image.Rect(1475, 900, 1655, 1055), "xp_bar": image.Rect(0, 1058, 1920, 1080), "belt": image.Rect(500, 990, 900, 1040), "minimap": image.Rect(1600, 0, 1920, 320), diff --git a/debug b/debug index d9ada1a..925e488 100755 Binary files a/debug and b/debug differ diff --git a/pkg/api/api.go b/pkg/api/api.go index c5c2146..1575e2d 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -678,15 +678,15 @@ func (s *Server) getExpectedColorRange(regionName string) *vision.ColorRange { switch regionName { case "health_orb": return &vision.ColorRange{ - LowerH: 0, UpperH: 10, - LowerS: 150, UpperS: 255, - LowerV: 150, UpperV: 255, + LowerH: 350, UpperH: 370, + LowerS: 100, UpperS: 255, + LowerV: 80, UpperV: 255, } case "mana_orb": return &vision.ColorRange{ - LowerH: 200, UpperH: 240, + LowerH: 225, UpperH: 245, LowerS: 100, UpperS: 255, - LowerV: 80, UpperV: 255, + LowerV: 60, UpperV: 255, } default: // For other regions, we don't have specific expected color ranges diff --git a/plugins/d2r/config.go b/plugins/d2r/config.go index 8a4d179..037faac 100644 --- a/plugins/d2r/config.go +++ b/plugins/d2r/config.go @@ -59,9 +59,9 @@ func DefaultConfig() Config { // Calibrated from botty reference (720p scaled to 1080p) // Health orb RED: OpenCV H 178-183 → our H 356-366, wraps around 360 // Using H 350-360 + H 0-10 range (handled by wrapping in colorInRange) - HealthFilled: HSVRange{350, 60, 20, 370, 255, 255}, // H wraps: 350-370 means 350-360,0-10 - // Mana orb BLUE: actual H 228-236 from screenshot - ManaFilled: HSVRange{226, 100, 20, 240, 255, 255}, + HealthFilled: HSVRange{350, 100, 80, 370, 255, 255}, // H wraps: 350-370 means 350-360,0-10 + // Mana orb BLUE: actual H 225-245 from screenshot + ManaFilled: HSVRange{225, 100, 60, 245, 255, 255}, ItemUnique: HSVRange{15, 100, 180, 30, 255, 255}, ItemSet: HSVRange{35, 100, 150, 55, 255, 255}, ItemRare: HSVRange{15, 50, 200, 25, 150, 255}, @@ -97,12 +97,12 @@ func RegisterProfiles(registry *resolution.Registry) error { Height: 1080, Label: "1080p", Regions: map[string]image.Rectangle{ - "health_globe": image.Rect(240, 870, 600, 1080), // Full health globe region - "mana_globe": image.Rect(1330, 870, 1690, 1080), // Full mana globe region - "health_slice": image.Rect(415, 915, 425, 1060), // Thin vertical strip through orb center - "mana_slice": image.Rect(1505, 915, 1515, 1060), // Thin vertical strip through orb center - "health_orb": image.Rect(240, 870, 600, 1080), // Alias for backward compat - "mana_orb": image.Rect(1330, 870, 1690, 1080), // Alias for backward compat + "health_globe": image.Rect(325, 915, 470, 1040), // Full health globe region + "mana_globe": image.Rect(1475, 900, 1655, 1055), // Full mana globe region + "health_slice": image.Rect(395, 920, 405, 1040), // Thin vertical strip through orb center + "mana_slice": image.Rect(1505, 900, 1515, 1055), // Thin vertical strip through orb center + "health_orb": image.Rect(325, 915, 470, 1040), // Alias for backward compat + "mana_orb": image.Rect(1475, 900, 1655, 1055), // Alias for backward compat "xp_bar": image.Rect(0, 1058, 1920, 1080), "belt": image.Rect(500, 990, 900, 1040), "minimap": image.Rect(1600, 0, 1920, 320), @@ -118,12 +118,12 @@ func RegisterProfiles(registry *resolution.Registry) error { Height: 720, Label: "720p", Regions: map[string]image.Rectangle{ - "health_globe": image.Rect(160, 580, 400, 720), - "mana_globe": image.Rect(887, 580, 1127, 720), - "health_slice": image.Rect(309, 610, 316, 711), - "mana_slice": image.Rect(961, 610, 968, 711), - "health_orb": image.Rect(160, 580, 400, 720), - "mana_orb": image.Rect(887, 580, 1127, 720), + "health_globe": image.Rect(217, 610, 313, 693), + "mana_globe": image.Rect(983, 600, 1103, 703), + "health_slice": image.Rect(263, 613, 270, 693), + "mana_slice": image.Rect(1003, 600, 1010, 703), + "health_orb": image.Rect(217, 610, 313, 693), + "mana_orb": image.Rect(983, 600, 1103, 703), "xp_bar": image.Rect(0, 705, 1280, 720), "belt": image.Rect(333, 660, 600, 693), "minimap": image.Rect(1067, 0, 1280, 213), diff --git a/plugins/d2r/detector.go b/plugins/d2r/detector.go index e0d50a6..e46e791 100644 --- a/plugins/d2r/detector.go +++ b/plugins/d2r/detector.go @@ -54,12 +54,12 @@ func (d *Detector) DetectState(frame image.Image) plugin.GameState { // ReadVitals reads health and mana from the orbs. func (d *Detector) ReadVitals(frame image.Image) plugin.VitalStats { - healthRegion := d.services.Region("health_orb") - manaRegion := d.services.Region("mana_orb") + healthRegion := d.services.Region("health_slice") + manaRegion := d.services.Region("mana_slice") var healthPct, manaPct float64 - // Read health percentage from red-filled pixels in health orb + // Read health percentage from red-filled pixels in health slice if !healthRegion.Empty() { healthColor := vision.ColorRange{ LowerH: d.config.Colors.HealthFilled.LowerH, @@ -69,10 +69,10 @@ func (d *Detector) ReadVitals(frame image.Image) plugin.VitalStats { LowerV: d.config.Colors.HealthFilled.LowerV, UpperV: d.config.Colors.HealthFilled.UpperV, } - healthPct = d.vision.ReadOrbPercentage(frame, healthRegion, healthColor) + healthPct = d.vision.ReadOrbSlicePercentage(frame, healthRegion, healthColor) } - // Read mana percentage from blue-filled pixels in mana orb + // Read mana percentage from blue-filled pixels in mana slice if !manaRegion.Empty() { manaColor := vision.ColorRange{ LowerH: d.config.Colors.ManaFilled.LowerH, @@ -82,7 +82,7 @@ func (d *Detector) ReadVitals(frame image.Image) plugin.VitalStats { LowerV: d.config.Colors.ManaFilled.LowerV, UpperV: d.config.Colors.ManaFilled.UpperV, } - manaPct = d.vision.ReadOrbPercentage(frame, manaRegion, manaColor) + manaPct = d.vision.ReadOrbSlicePercentage(frame, manaRegion, manaColor) } return plugin.VitalStats{ diff --git a/testdata/debug/debug_health_globe.png b/testdata/debug/debug_health_globe.png index e74e82e..56a8964 100644 Binary files a/testdata/debug/debug_health_globe.png and b/testdata/debug/debug_health_globe.png differ diff --git a/testdata/debug/debug_health_slice.png b/testdata/debug/debug_health_slice.png index ab2c922..edbdbfd 100644 Binary files a/testdata/debug/debug_health_slice.png and b/testdata/debug/debug_health_slice.png differ diff --git a/testdata/debug/debug_mana_globe.png b/testdata/debug/debug_mana_globe.png index 8761f69..79ae6c2 100644 Binary files a/testdata/debug/debug_mana_globe.png and b/testdata/debug/debug_mana_globe.png differ diff --git a/testdata/debug/debug_mana_slice.png b/testdata/debug/debug_mana_slice.png index 9360642..b89793d 100644 Binary files a/testdata/debug/debug_mana_slice.png and b/testdata/debug/debug_mana_slice.png differ