SCAR Code:
FindObjectThroughMM('item', [1478833], [5], ['oin'], 5, 5);
SCAR Code:
{*******************************************************************************
Function MMToMS(MM: TPoint): TPoint;
By: N1ke!
Description: Turns a Minimap point into a close MS point.
*******************************************************************************}
Function MMToMS(MM: TPoint): TPoint;
var
X, Y: Integer;
Dis: TPoint;
begin
X := ((MM.X - 647));
Y := ((MM.Y - 84));
Dis := Point( (MMCX - MM.X)*-1, (MMCY - MM.Y)*-1);
Result := Point(Round((259.5 + X)+ Dis.X*10), Round((170.0 + Y)+ Dis.Y*6.5));
If Not IntInBox(Result.X, Result.Y, IntToBox(MSX1, MSY1, MSX2, MSY2))then
Result := Point(-1, -1);
end;
{*******************************************************************************
Function FindObjectThroughMM(Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
By: N1ke!
Description: Finds a object with the given parameters.
Uses minimap dots to get locations of objects.
Will put the matching areas first in the TPA array,so it hovers those
first.
Note: It still searches the whole screen, but it puts items first in
the array.
Valid kinds are
- npc/yellow
- item/red
- player/white
*******************************************************************************}
Function FindObjectThroughMM(Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
var
ATPA: T2DPointArray;
TPA, TPA2, TPA3: TPointArray;
I, II, H, HH, ArrC, X, Y: Integer;
begin
SetLength(ATPA, Length(Colors));
H := High(Colors);
For I:= 0 to H do
FindColorsTolerance(ATPA[i], Colors[i], MSX1, MSY1, MSX2, MSY2, Tol[i]);
TPA := MergeATPA(ATPA);
ATPA := TPAToATPAEx(TPA, Width, Height);
SetLength(TPA, GetArrayLength(ATPA));
H := High(TPA)
for i:= 0 to H do
TPA[i] := MiddleTPA(ATPA[i]);
TPA2 := GetMiniMapDots(Kind);
H := High(TPA2);
For I:=0 to H do
TPA2[i] := MMToMS(TPA2[i]);
H := High(TPA);
HH := High(TPA2);
SetArrayLength(TPA3, GetArrayLength(TPA));
For I:=0 to H do
For II:=0 to HH do
If IntInBox(TPA[i].X, TPA[i].Y, IntToBox(TPA2[II].X-55, TPA2[II].Y-55, TPA2[II].X+55, TPA2[II].Y+55))then
begin
TPA3[ArrC] := TPA[i];
Inc(ArrC);
Break;
end;
SetArrayLength(TPA3, ArrC);
ClearTPAFromTPA(TPA, TPA3);
TPA := CombineTPA(TPA3, TPA);
H := High(TPA);
For I:=0 to H do
begin
MMouse(TPA[i].X, TPA[i].Y, 4, 4);
If WaitUptextMulti(UpText, 250+Random(100))then
begin
GetMousePos(X, Y);
Result := True;
Exit;
end;
end;
end;