From: Footy
Put the marktime before the loop. And also, you probably don't want your script to continue normally if it times out, you would want to print an error line to debug and attempt to recover. To do that, do this
marktime(counter);
Repeat
Blahblahblaj
if timefrommark(counter) > 10000 then
begin
writeln('Error!');
Recoveryprocedure;
end;
until(invfull);
At the moment I've got it so after 10 seconds it's going to be moving up/down the stairs. Didn't add that portion into the code there.
program RoflmeCookGuild;
{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}
var
x, y:Integer;
procedure DeclarePlayers; // Declares your player.
begin // Multi Players will be added
HowManyPlayers := 1; // later.
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;
procedure AntiBan; // Performs AntiBan..
begin
Case Random(800) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..700: Wait(300);
end;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Wait(350+Random(200));
end;
Function WhichFloor: Integer; // If finds the right symbol(s)
var // then it knows what floor it's
TPA: TPointArray; // on. If it doesn't find symbols
begin // it'll know that it's on other floor
if FindSymbolsMulti(TPA, ['cook', 'churn']) then
begin
Result := 2;
Writeln('On floor 2');
Exit;
end else
Result := 3;
Writeln('On floor 3');
Exit;
end;
function StairImageColor: Integer; // Credits to ACA
var // (AutoColor Aid)
arP: TPointArray; // Gets stair color on Minimap (the image that looks like a ladder).
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.51, 3.87);
if not (FindColorsTolerance(arP, 601945, MMX1, MMY1, MMX2, MMY2, 2)) then
begin
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC[i];
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
end;
Function Stairs: Boolean; // Credits to CephaXz
var // for the main function (made a few
S, MP: TPoint; // edits for this script).
TPA: TPointArray; // Will take the StairImageColor found and use it to
ATPA: T2DPointArray; // find the stairs on the Main Screen.
begin
FindMMColorsSpiralTolerance(TPA, StairImageColor, 15);
ATPA := TPAtoATPAEx(TPA, 10, 10);
if Length(ATPA) < 1 then
begin
Writeln('Failed to find Stair Image');
TerminateScript;
end else
begin
MP := MiddleTPA(ATPA[0])
S := MMtoMSEx(5, 20, Point(MP.x, MP.y));
MMouse(S.x, S.y, 1, 1)
if IsUpText('limb') then
begin
Result := true
Writeln('Found Stairs');
ClickMouse2(mouse_right);
Writeln('Right clicked stairs');
end;
end;
end;
Function GoDownStairs: Boolean; // Will go downstairs until it confirms
begin // it's on the bottom floor. If "On floor"
AntiBan; // is bothering you just comment it out with two backslashes infront of it
if Stairs then // //WriteLn('On floor ' + IntToStr(WhichFloor));
repeat
WaitOption('limb-do', 4000);
Writeln('On floor ' + IntToStr(WhichFloor));
until FindSymbol(x, y, 'bank');
if FindSymbol(x, y, 'bank') then
begin
Result := true
Writeln('On bottom floor');
Exit;
end else
Result := false;
end;
function GrapeColor: Integer; // Credit to ACA again.
var // Finds the best color to use for Grape.
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.21, 0.99);
if not (FindColorsTolerance(arP, 7150462, MSX1, MSY1, MSX2, MSY2, 13)) then
begin
//Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
//Writeln('AutoColor failed in finding the color.');
end;
function AppleColor: Integer; // Same as above but for Apple this time.
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.25, 1.51);
if not (FindColorsTolerance(arP, 2867819, MSX1, MSY1, MSX2, MSY2, 8)) then
begin
//Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
Result := arC[i];
//Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
//Writeln('AutoColor failed in finding the color.');
end;
Function FindApple: Boolean; // Uses the color result to confirm that object is apple.
var
CTS, I, H: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
For H := 0 to 1 do
FindColorsSpiralTolerance(MSCX, MSCY, TPA, AppleColor, MSX1, MSY1, MSX2, MSY2, 0);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 5, 5);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y+1, 0, 0);
Wait(150+random(10));
If IsUpText('ake') then
begin
Result := True
Break;
end;
end;
end;
Function FindGrape: Boolean; // Same as above, with grape this time.
var
CTS, I: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, GrapeColor, MSX1, MSY1, MSX2, MSY2, 0)
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 5, 5);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y+1, 0, 0);
Wait(150+random(10));
If IsUpText('ake') then
begin
Result := True
Break;
end;
end;
end;
Procedure TakeApple; // Actually takes the apple.
var
PlusOne: Integer;
begin
PlusOne := InvCount + 1
if FindApple then
repeat
Wait(70+random(20));
ClickMouse2(true);
AntiBan;
repeat
Wait(80+random(50));
until not IsMoving;
until (PlusOne=InvCount) or (FindApple=false);
end;
Procedure TakeGrape; // Actually takes the grape.
var
PlusOne: Integer;
begin
PlusOne := InvCount + 1
if FindGrape then
repeat
Wait(30+random(20));
ClickMouse2(true);
AntiBan;
repeat
Wait(600+random(50));
until not IsMoving;
until (PlusOne=InvCount) or (FindGrape=false);
end;
Procedure Loop; // The main loop...
var // This is what the script will actually do.
Waiting: Integer;
begin
MarkTime(Waiting);
repeat
TakeApple;
TakeGrape;
Wait(100+random(80));
AntiBan;
until InvFull or (TimeFromMark(Waiting) > 5000);
if TimeFromMark(Waiting) > 5000 then
if InvFull then
begin
GoDownstairs;
end else
if FindApple or FindGrape then
begin
Loop;
end else
begin
Writeln('Time to check other floors...');
if Stairs then
Case WhichFloor of
2:
begin
WaitOption('limb-u',5000);
end;
3:
begin
WaitOption('limb-do', 5000);
end;
end;
end;
if InvFull then
GoDownStairs;
end;
begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(70);
LoginPlayer;
SetAngle(SRL_ANGLE_HIGH);
MakeCompass('N');
Repeat
Loop;
until InvFull;
end.
The ONLY problem I'm having at the moment is using the stairs.
It will sometimes have to run through the loop twice (sometimes even more). But eventually it will get up and down the stairs.
EDIT: Now it's having problems finding the stair image on the second floor..[
Now my challenge is getting a function working for the door. Since the whole bottom floor has brown everywhere color isn't doing so well :pDoor has finally been conquered :p
Function FindDoor: Boolean;
var
CTS, I, H, x, y: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
SetAngle(SRL_ANGLE_LOW);
MakeCompass('N');
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.23, 1.02);
For H := 0 to 1 do
FindColorsSpiralTolerance(MSCX, MSCY, TPA, DoorColor, MSX1, MSY1, MSX2, MSY2, 0);
ColorToleranceSpeed(CTS);
ATPA := TPAtoATPAEx(TPA, 10, 15);
SortATPASize(ATPA, true);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(150+random(10));
If IsUpText('oor') then
begin
Result := True
Break;
end;
end;
end;
From what I've tested this found the door :D from SRL_Angle_Low in one of the southern spots of inside cooking guild.
If anyone has suggestions on any methods for detecting stairs I'd appreciate it. I have a function that only works sometimes :(