King
2013-05-29 07:50:42
Okay so my main goal here is to use the MM to find a Oak Tree (all trees on the MS have the same top colours, but the MM symbol for Oaks is unique, at least in my area.) This function finds the Oaks perfectly, the only issue comes to when the Oak is chopped down and is no longer on the MS but is on the MM, so I want this when it cant find the uptext to find the DTM again, but I am lost at this point, it seems to get stuck just clicking the same area of tree (searching the same box) for the color then uptext when it isnt there. So I need it exit, then refind the DTM and look for it, then repeat every time it doesnt find it, but in my head this works, in real life it doesnt. :P
Video of what it does:
(Will upload tomorrow, tired as balls right now, probably part of my problem XD );
Video of what it does:
(Will upload tomorrow, tired as balls right now, probably part of my problem XD );
function ChopOaks: Boolean;
var
TPA: TPointArray;
ATPA, OakATPA: T2DPointArray;
i, L, OX, OY, Tries, tmpCTS: Integer;
Oak, OldOakPoint: TPoint;
OakTPA: TPointArray;
OakBox: TBox;
aFound: T2DExtendedArray;
begin
Tries := 0;
tmpCTS := GetColorToleranceSpeed;
if InvFull then
exit;
result := false;
OakMM := DTMFromString('mWAAAAHicY2FgYGBmgAB2IGYBYlYozQIVj1JlYND0ZGAwimEFYy6gmAgSZkTDIAAAb4oCgQ==');
MakeCompass('N');
if FindDTMsRotatedSE(OakMM, OakTPA, 633, 69, 679, 104, - Pi / 2, Pi / 2, Pi / 30, aFound) then
begin
FreeDTM(OakMM);
L := High(OakTPA) for i := 0 to L do
if GetArrayLength(OakTPA) >= 1 then
begin
Oak := MMtoMSEx(10, 0, OakTPA[i]);
SMART_ClearCanvas;
WriteDebug('Finding the tree');
begin
OakBox := IntToBox(Oak.x - 50, Oak.y - 50, Oak.x + 50, Oak.y + 50);
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.09, 0.88);
if FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2446159, OakBox.x1, OakBox.y1, OakBox.x2, OakBox.Y2, 22) then
begin
WriteDebug('Clicking Tree');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.02, 0.02);
ATPA := TPAtoATPAEx(TPA, 25, 25);
SortATPAFrom(ATPA, MiddleBox(OakBox));
if debug then
DebugATPA(ATPA, '');
L := High(ATPA) for i := 0 to L do
if GetArrayLength(ATPA[i]) >= 1 then
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 3);
if WaitUptext('Oak', 500) then
begin
ClickMouse2(false);
if WaitOption('Oak', 500) then
begin
SMART_ClearCanvas;
marktime(x);
wait(RandomRange(500, 600));
while IsChopping do
begin
FindNormalRandoms;
wait(RandomRange(50, 60));
end;
result := true;
exit;
end
else
begin
Inc(Tries);
WriteDebug(' Could not find Tree Uptext');
ColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
end;
end
else
begin
WriteDebug(' Could not find Tree Uptext');
ColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
Inc(Tries);
end;
end
else
begin
Inc(Tries);
WriteDebug('Could not find the chop option');
end;
end
else
begin
WriteDebug('Could not find the tree');
ColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
Inc(Tries);
end;
end;
end;
end
else
begin
WriteDebug('Could not find the Oak MM symbol');
FreeDTM(OakMM);
TerminateScript;
end;
end;