Skip to content

Commit

Permalink
Fix GetDots for local player. Detect what's under.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackydev authored Aug 12, 2023
1 parent bf048ff commit 77026b2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions osr/minimap.simba
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,17 @@ begin
end;
end;

function TRSMinimap.GetDotsBitmap(BMP: TMufasaBitmap; Dots: ERSMinimapDots): TPointArray;
function TRSMinimap.GetDotsBitmap(BMP: TMufasaBitmap; Dots: ERSMinimapDots): TPointArray; override;
var
Blacks: TPointArray;

function FindDots(Blacks: TPointArray; Color, T: Int32): TPointArray;
var
i: Int32;
p: TPoint;
c,p: TPoint;
left, right: Boolean;
begin
c := BMP.GetCenter();
for i:=0 to High(Blacks)-1 do
begin
left := ((BMP.GetPixel(Blacks[i].x+3,Blacks[i].y+0) = 65536) and (BMP.GetPixel(Blacks[i].x+1,Blacks[i].y-1) <> 65536)) or
Expand All @@ -399,6 +400,20 @@ var
if Result.Find(p) > -1 then
Continue;

if (p+Point(2,2)).DistanceTo(c) <= 2 then
begin
// match corner pixel colors instead to see what's under our character
if SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+0), t) and
SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+0), t) and
SimilarColors(Color, BMP.GetPixel(p.x+0,p.y+1), t) and
SimilarColors(Color, BMP.GetPixel(p.x+0,p.y+2), t) then
begin
Result += p;
end;
//skip further center checks as they will lead to false positives.
continue;
end;

if Ord(SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+0), t)) +
Ord(SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+0), t)) +
Ord(SimilarColors(Color, BMP.GetPixel(p.x+0,p.y+1), t)) +
Expand Down Expand Up @@ -447,7 +462,7 @@ begin
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.2, 0.2);
end;
end;
end;

function TRSMinimap.GetDots(Dots: ERSMinimapDots): TPointArray; overload;
var
Expand Down

0 comments on commit 77026b2

Please sign in to comment.