SRL Archive - Research & Development Lounge

WizzyPlugin Learning Progress


King

2013-02-18 11:26:08

Well, been reading LowDown on the WizzyPlugin by Naum, excellent tutorial btw!

Here is my first real TPA Object finding function, it is supposed to find the well and click on it(:
Let me know what you think? Ill be posting all f my functions made after his tutorial here!

WellFinding
Procedure FindWell;
var
OldCTS, x, y, I:integer;
WellTPA:TPointArray;
WellTPAA: T2DPointArray;
begin
OldCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.11, 0.03);
FindColorsSpiralTolerance(267, 180, WellTPA, 6253166, MSX1, MSY1, MSX2, MSY2, 11)// Searches for the well starting mainscreen center
// DebugTPA(WellTPA, '');
SetColorToleranceSpeed(OldCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
if Length(WellTPA) = 0 then
begin
writeln('Could not find well, exiting');
TerminateScript;
end;
WellTPAA := TPAToATPAEx(WellTPA, 25, 35);//Splits the TPA's into 25 x 35 Boxes
SortATPAFrom(WellTPAA, Point(MMCX, MMCY)); //Sorts Closest to the player to avoid similar colors
For I := 0 To High(WellTPAA) Do // Goes through the ATPA of 25 x 35 boxes until it finds it.
If GetArraylength(WellTPAA[i]) > 25 then //Makes sure it is bigger than 50..
begin
MiddleTPAEx(WellTPAA[i], x, y); //Finds the middle of the ATPA to avoid the edge
MMouse(x, y, 3, 3); //Moves to the middle
If WaitUpText('ell', 300) then
begin
ClickMouse2(true);
break;
end
else
begin
writeln('Could not find the well');
TerminateScript;
end;
end;
end;