Naike
2009-07-03 00:27:46
My latest project ;)
Thanks to Home for the idea.
I explain the "main" function called FindObjectsFromMM.. Depending on the parameters it will get the dots from Minimap. Valid ones are NPCs, Players or Items(It can find one, two or all three of them). When it finds them it creates a nice box of 150*150 pixels around all the items and searches for the colors/tol thats been given on the mainscreen. At the end it hovers these points searching for the giving uptext, if it's found it results true and wolhaa! You found a object using the MM to narrow down your search area ;)
Example of usage:
would search for a feather…
Note: Needs high angle.
Hope you like it.
Thanks to Home for the idea.
I explain the "main" function called FindObjectsFromMM.. Depending on the parameters it will get the dots from Minimap. Valid ones are NPCs, Players or Items(It can find one, two or all three of them). When it finds them it creates a nice box of 150*150 pixels around all the items and searches for the colors/tol thats been given on the mainscreen. At the end it hovers these points searching for the giving uptext, if it's found it results true and wolhaa! You found a object using the MM to narrow down your search area ;)
Example of usage:
FindObjectsFromMM(x, y, ['item'], ['eather'], [12106177], 10);
would search for a feather…
Note: Needs high angle.
Hope you like it.
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Minimap finding Routines --//
//-----------------------------------------------------------------//
// * Function MMToMS(MM: TPoint): TPoint; // * by N1ke! (Thanks to Special Ed for insparation)
// * Function MMToMSBox(MM: TPoint; Space: Integer): TBox; // * by N1ke!
// * Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean; // * by N1ke!
// * Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean; // * by N1ke!
// * Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean; // * by N1ke!
// * Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean; // * by N1ke!
//-----------------------------------------------------------------//
{*******************************************************************************
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 MMToMSBox(MM: TPoint; Space: Integer): TBox;
By: N1ke!
Description: Same as MMToMS but creates a TBox, it size depending on
given parameter(Space).
*******************************************************************************}
Function MMToMSBox(MM: TPoint; Space: Integer): TBox;
var
Cords: TPoint;
begin
Cords := MMToMS(MM);
Result := IntToBox(Cords.X-Space, Cords.Y-Space, Cords.X+Space, Cords.Y+Space);
end;
{*******************************************************************************
Function GetMMDotsTPA(Kind: TStringArray): TPointArray;
By: N1ke!
Description: Gets the a TPA of the all the dots on Minimap.
Valid kinds are
- npc/yellow
- item/red
- player/white
*******************************************************************************}
Function GetMMDotsTPA(Kind: TStringArray): TPointArray;
var
I, H: Integer;
TPA, tTPA: TPointArray;
begin
H := High(Kind);
For I:=0 to H do
begin
tTPA := GetMiniMapDots(Kind[I]);
Result := CombineTPA(Result, tTPA);
end;
end;
{*******************************************************************************
Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
By: N1ke!
Description: Finds multiplie objects using a MM cords to narrow down the used
search area.
*******************************************************************************}
Function FindObjectsMM(var X, Y: integer; MM: TPointArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
var
MSCords: TPoint;
TPA, tTPA: TPointArray;
I, II, H, HH, XX, YY: Integer;
ATPA: T2DPointArray;
begin
Result := False;
H := High(MM);
For I:=0 to H do
begin
MSCords := MMToMS(MM[I]);
If (MSCords.X = -1)then
Continue;
HH := High(Colors);
For II:=0 to HH do
begin
FindColorsTolerance(tTPA, Colors[II], MSCords.X-75, MSCords.Y-75, MSCords.X+75, MSCords.Y+75, Tol);
TPA := CombineTPA(TPA, tTPA);
end;
end;
ClearDoubleTPA(TPA);
If GetArrayLength(TPA) = 0 then
Exit;
ATPA := SplitTPA(TPA, 5);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
H := High(ATPA);
For I:=0 to H do
begin
MiddleTPAEx(ATPA[I], XX, YY);
MMouse(XX, YY, 4, 4);
If WaitUptextMulti(UpTexts, 250+Random(100))then
begin
GetMousePos(X, Y);
Result := True;
Exit;
end;
end;
end;
{*******************************************************************************
Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean;
By: N1ke!
Description: Same as FindObjectsMM, but only finds one.
*******************************************************************************}
Function FindObjectMM(var X, Y: integer; MM: TPoint; UpText: String; Color: Integer; Tol: Integer): Boolean;
begin
Result := FindObjectsMM(X, Y, [MM], [UpText], [Color], Tol);
end;
{*******************************************************************************
Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
By: N1ke!
Description: Finds dots on Minimap and searches for the object.
Valid kinds are
- npc/yellow
- item/red
- player/white
*******************************************************************************}
Function FindObjectsFromMM(var X, Y: Integer; Kind: TStringArray; UpTexts: TStringArray; Colors: TIntegerArray; Tol: Integer): Boolean;
var
I, H: Integer;
TPA: TPointArray;
begin
Result := False;
TPA := GetMMDotsTPA(Kind);
If GetArrayLength(TPA) = 0 then
Exit;
Result := FindObjectsMM(X, Y, TPA, UpTexts, Colors, Tol);
end;
{*******************************************************************************
Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean;
By: N1ke!
Description: Same as FindObjectsFromMM, but only looks for one.
*******************************************************************************}
Function FindObjectFromMM(var X, Y: Integer; Kind: String; UpText: String; Color: Integer; Tol: Integer): Boolean;
begin
Result := FindObjectsFromMM(X, Y, [Kind], [UpText], [Color], Tol);
end;