Log in

View Full Version : GetMiniMapDotsIn help



BigFate
08-01-2012, 03:47 PM
I want to modify the function GetMiniMapDotsIn so it returns a boolean instead of TPA. I want to search the minimap for a particular dot in a set area and if it is found then it results true.

Here is the function from the include
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then
begin
UnFreeze;
Exit;
end;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;

Is it just a case of changing TPointArray; to Boolean; and changing the Result[C]... to Result := True;

Thanks!

P1ng
08-01-2012, 04:07 PM
Wouldn't this work and be much simpler?
function GetMMDotsIn(Color, x1, y1, x2, y2: Integer): Boolean;
var
L: Integer;
TPA: TPointArray;
begin
Freeze;
if FindColors(TPA, Color, x1, y1, x2, y2) then
begin
L := Length(TPA);
if L > 0 then
Result := True else
Result := False;
end;
UnFreeze;
end;

masterBB
08-01-2012, 04:40 PM
if Length(GetMiniMapDotsIn('npc', MMX1, MMY1, MMX2, MMY2)) > 0 then

Example how to use this as a Boolean without creating a new function.

Le Jingle
08-01-2012, 04:49 PM
^^ masterBB has it down.
Perhaps, this might be how to create a new function for it;

function Stuff(search: variant; howmany: integer): Boolean;
var
tpa: TPointArray;
begin
result := false;
if not loggedin then
exit;
tpa := GetMiniMapDotsIn(search, MMX1, MMY1, MMX2, MMY2);
if (Length(tpa) >= 1) then
Result := True;
end;

begin
Setupsrl;
if stuff('npc', 1) then
writeln('good');
end.

BigFate
08-01-2012, 05:46 PM
Thank-you for all the replies, I think I will do what masterBB said for now and maybe use p1ng's to get it more efficient. Thanks again!