SRL Archive - OSR Help

Not repeating when it should


Element17

2013-06-04 20:21:51

This is the procedure that should repeat but its not. (Will post other functions)
It goes to the first dot and picks up the item, then click the second dot on the MM and then the script ends. Not sure why. Probably something obvious.

procedure blah;
var
count: integer;
begin
repeat
if (FindDot) then
begin
while (IsMoving) do
begin
Wait(1000+Random(250));

end;
end;

count := InvCount
if Not(IsMoving) then
if (FindItem) and (WaitInvCount(count +1, 5000, ExactCT)) then
Writeln('Got it');
until (not FindDot) or (InvCount = 7) or (not FindItem);

end;

function FindDot: Boolean;
var
P: TPointArray;
ATPA: array of TPointArray;
begin

P := getminimapdots('red');


ATPA := SplitTPAEx(P, 5, 5);
SortATPAFromFirstPoint(ATPA, Point(MMCX,MMCY));
DeBugATPABounds(ATPA);
for i := 0 to Low(ATPA) do
begin
if (GetArrayLength(ATPA) < 0) then
Exit;
MiddleTPAEx(ATPA[i], x, y);
HumanMMouse(x,y, 2, 2);
ClickMouse2(True);
{if DeBug then Writeln('Found dots, flag present');
if (IsMoving) then
repeat
if DeBug then Writeln('Still Moving');
Wait(500 +Random(750));
until(WaitNotMoving(true) or not FlagPresent);
if DeBug then Writeln('Not moving, should be on dot');}
Result := True;
Exit;
end;
end;

function FindItem: Boolean;
var
CTS: Integer;
TPA: TPointArray;
ATPA: array of TPointArray;

begin
if (not (LoggedIn)) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2); //.25 .33
SetColorSpeed2Modifiers(0.06 ,0.39);

FindColorsSpiralTolerance(MSCX, MSCY, TPA, 9254494, MSX1, MSY1, MSX2, MSY2, 20);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

RAaSTPA(TPA, 5);
ATPA := SplitTPAEx(TPA, 15, 15);
SortATPAFromFirstPoint(ATPA, Point(MSCX,MSCY)); //just changed from MSY1 to MSCY maybe the problem??
DeBugATPABounds(ATPA);
for i := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
HumanMMouse(x, y, 2, 2);
if WaitUpTextMulti(['Pick', 'Item'], 400) then
if DeBug then Writeln('Found Item');
ClickMouse2(True);
Result := True;
Exit;
end;
end;

Sawyer

2013-06-04 20:25:27

It could just be not finding dots or items during FindDot or FindItem. When you use or, it means if ANY of them are, it stops repeating.

Element17

2013-06-04 20:28:10

Makes sense. Will change that and see if that fixes the problem.

Rich

2013-06-05 07:17:04

Try this:

procedure Blah;
begin
repeat
if (FindItem) and (WaitInvCount(InvCount + 1, 5000, ExactCT)) then
Writeln('Got it');
if (FindDot) then
while (IsMoving) do
Wait(500 + Random(250));
if not(IsMoving) then
if (FindItem) and (WaitInvCount(InvCount + 1, 5000, ExactCT)) then
Writeln('Got it');
until (((not FindDot) and (not FindItem)) or (InvCount = 7));
end;
:)