Naum
2009-11-10 12:30:03
Hey all, whilst I was fiddling with MMToMS I stumbled across FindObjThroughMM. After a while I thought I could get it to mine rocks, however it only used dots on the minimap. So I altered the previous function to FindObjThroughMMEx which will allow the scripter to specify a point on the minimap in which to find a certain object in.
For example I want to cut down a tree:
I hope you can all see how useful it would be, the possibilities are endless. Posted a modified version of FindObjThroughMM which uses the same 'dot' principle but the function is based on FindObjThroughMMEx:
Thanks.:)
For example I want to cut down a tree:
For I := 0 To 10 Do
If FindColor(xx, yy, FindTreeColor, MMCX - I, MMCY - I, MMCX + I, MMCY + I) Then
Begin
TP := Point(xx, yy);
FindObjThroughMMEx(Obj.x, Obj.y, TP, [colors], [tolerance], [uptext], 5, 5)
//stuff
End;I hope you can all see how useful it would be, the possibilities are endless. Posted a modified version of FindObjThroughMM which uses the same 'dot' principle but the function is based on FindObjThroughMMEx:
Function FindObjThroughMMEx(var x, y: Integer; MMPoint : TPoint; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
var
ATPA: T2DPointArray;
TPA, TPA2: TPointArray;
I, H, ArrC: 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]);
MMPoint := MMToMS(MMPoint);
H := High(TPA);
SetArrayLength(TPA2, GetArrayLength(TPA));
For I:= 0 to H do
If PointInBox(TPA[i], IntToBox(MMPoint.X-55, MMPoint.Y-55, MMPoint.X+55, MMPoint.Y+55))then
begin
TPA2[ArrC] := TPA[i];
Inc(ArrC);
Break;
end;
SetArrayLength(TPA2, ArrC);
ClearTPAFromTPA(TPA, TPA2);
TPA := CombineTPA(TPA2, 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;
Function FindObjThroughMM(var x, y: Integer; Kind: String; Colors, Tol: TIntegerArray; UpText: TStringArray; Width, Height: Integer): boolean;
Var TPA : TPointArray;
I, H : Integer;
Begin
TPA := GetMiniMapDots(Kind);
H := High(TPA);
For I := 0 To H Do
Begin
Result := FindObjThroughMMEx(X, Y, TPA[I], Colors, Tol, UpText, Width, Height)
If Result Then
Exit;
End;
End;Thanks.:)