ummmm, lets see, its a universal code for TPA Walking, it you simply enter the color, height, width and tol and it will find it on the MM. It results in a TPA giving you the option to SortTPAFrom, or turn it back into a ATPA and do size sorts ect. Some examples from my scripts:
SCAR Code:
Function MoveFishingSpots: Boolean;
var TPA: TpointArray;
begin
TPA := GetMMPoints(MMcx, MMcy, 2216175, 1, 1, 15);
SortTPAFrom(TPA, Point(MMcx, MMcy));
InvertTPA(TPA);
Result := ClickMMPoints(TPA, 0, -5);
Flag;
Wait(1000+random(750));
end;
and
SCAR Code:
Function CreateTPALibrary(Index:Integer): TPointArray;
begin
case Index of
0: Result := GetMMPoints(MMcx, MMy2, FindWaterColor, 5, 5, 5);
1: Result := GetMMPoints(MMcx, MMcy, 14630407, 1, 1, 35);
2: Result := GetMMPoints(MMcx, MMy1, FindWaterColor, 10, 10, 1);
3: Result := GetMMPoints(MMcx, MMcy, 2216175, 1, 1, 15);
4: Result := GetMMPoints(MMcx, MMcy, 861546, 2, 2, 25);
end;
end;
Function FollowWaterTPA: Boolean;
var a, Int1, Int2: Integer;
begin
a := GetSystemTime;
while (Int1 < 5) do
begin
if GetSystemTime-a > 75000 then
Break;
if ClickMMPoints(CreateTPALibrary(0), -RandomRange(8, 18), 0) then Inc(Int1) else Inc(Int2);
if Int1 > 0 then Result := FindFishingSymbol;
if Result then Break;
end;
if Int2 > Int1 then WriteLn('Walking has Failed');
WriteLn('Took ['+IntToStr(Int1+2)+'] Steps to Fishing Area');
if not Result then
begin
WriteLn('Timer Expired, Walking Failed');
NextPlayer(False);
end;
end;
Function WalkToBankingArea: Boolean;
var DTM, int1, int2, k, t: Integer; requiredwait: boolean;
begin
WriteLn('Walk to [Banking] Area Initiated');
DTM := DTMFromString('78DA634C666660B8C600068C108A218053806' +
'1192382CF980B54731B55CD9F3F4C0CFC487CC63CA09ACB04D4E403D' +
'59CC1AF060071FE0C41');
SetRunLevelAt(50);
k := GetsystemTime;
while ((Length(CreateTPALibrary(3)) < 4) or (Length(CreateTPALibrary(4)) < 4)) do
begin
case Int1 of
0..3: t := -5;
4: requiredwait := True;
5: t := -22;
6: break;
end;
if GetSystemTime-k > 120000 then NextPlayer(False);
if ClickMMPoints(CreateTPALibrary(2), t, 0) then Inc(Int1) else Inc(Int2);
if requiredwait then Wait(9500+random(3000));
requiredwait := False;
end;
WriteLn('Bank Symbol Length = '+IntToStr(Length(CreateTPALibrary(3))));
WriteLn('Bank Floor Length = '+IntToStr(Length(CreateTPALibrary(4))));
if Int2 > Int1 then WriteLn('Walking has Failed');
Result := DTMLocate(MMx1, MMy1, MMcx+25, MMy2, DTM, 0, RandomRange(-3, 3), True);
FreeDTM(DTM);
if not Result then Result := ClickMMPoints(CreateTPALibrary(4), 0, 0);
if Result then
begin
WriteLn('Found Bank DTM, entering Bank');
WriteLn('Took ['+IntToStr(Int1+1)+'] Steps to Banking Area');
Players[CurrentPlayer].Loc := 'bank';
Flag;
end;
end;
Sorry I dont really know how to explain it, I guess you could say its universal code that can be used to find pretty much any MM object with a semi unique color, or some proper sorting. Symbols, Autocolors, walls and even roads can be easily found with this function.
edit: an autocolor fix for FindVarrockRoadColors:
SCAR Code:
Function FindVarrockColor: Integer;
var t, i, ii: Integer; TPA: TPointArray; aCol, uCol, tCol: TIntegerArray;
begin
TPA := GetMMPoints(MMcx, MMcy-25, 8488581, 5, 5, 25);
aCol := GetColors(TPA);
uCol := aCol;
ClearSameIntegers(aCol);
SetLength(tCol, high(uCol)+1);
for i := 0 to high(aCol) do
begin
for ii := 0 to high(uCol) do
begin
if aCol[i] = uCol[ii] then
Inc(tCol[ii]);
end;
end;
t := 0;
for i := 0 to high(uCol) do
if tCol[i] > tCol[t] then
t := i;
Result := uCol[t];
end;
I hope this helps to prove this function to be invaluable.