Simba Code:
Procedure IsFishing;
var
OutTime, ETime, STime: Integer;
Mov: Boolean;
Box: TBox;
begin
//This checks if inv is full. Because you don't want to continue looking
//if we are fishing, if you inv is full
if InvFull then
begin
Writeln('Can''t fit anymore, going to bank or dropping');
Exit;// This exits the procedure without doing anything else
end;
//Sets a Tbox into a small square at the center of the rs main screen
Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
//This is the out side loop. It times out after 4 mins
repeat
Mov := False;// False because if the below loop don't find movement,
// this false reading will kick it out of loop
STime := GetSystemTime;//Gets the start time
//Inside loop. This loop looks for movement for 3000 ms(3sec)
repeat
// Below baicly takes a picture of the box specified and 100ms later
// takes another picture to compare to. If at least 9 pixels change in
// the second pic, then it returns true as it found movement
if Animating(Box, 100, 9) then Mov := True; //mov is true if found
ETime := GetSystemTime - STime;// this gets the time the inner loop has been repeated for
until (ETime > 3000) or (Mov = True) or InvFull
// If the above loop finds movement then the outside loop is repeated
// until it doesn't find movement for at least 3 sec or 4 mins has passed.
// Once again check for full inv to kick out of loop if needed
if InvFull then
begin
WriteLn('Can''t fit anymore, going to bank or dropping');
Exit;
end;
// Gets the time the outer loop has been repeated for
OutTime := (GetSystemTime - InTime);
until (Mov = False) or (OutTime > 240000) or InvFull
// If 4 mins has passed or the inner loop didn't find movement for 3 sec then
// the outer loop ends and we are not fishing or not fishing anymore.
end;
Simba Code:
program new;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$IFDEF SIMBAMAJOR980}
{$I SRL/SRL/Misc/PaintSmart.Simba}
{$ELSE}
{$I SRL/SRL/Misc/SmartGraphics.Simba}
{$ENDIF}
var
FishText: TStringArray;
const
Debug = true;
procedure LoadText;
begin
FishText := ['Cage', 'age']; // the uptext for the fishing spot you are looking for
end;
Procedure PaintCross(x,y,col: Integer);
var
CTPA ,HighTPA, i, c: Integer;
TP: Tpoint;
TPA, NewTPA: TPointArray;
begin
SetLength(TPA, 104);
SetLength(NewTPA, Length(TPA));
//Draw right
TP := Point(x, y);
for CTPA:= 0 to 9 do
begin
TPA[CTPA] := TP;
TP := point(TP.x + 1, TP.y);
end;
TP := Point(x, y - 1);
for CTPA := 10 to 17 do
begin
TPA[CTPA] := TP;
TP := point(TP.x + 1, TP.y);
end;
TP := Point(x,y+1);
for CTPA:= 18 to 25 do
begin
TPA[CTPA] := TP;
TP := point(TP.x + 1, TP.y);
end;
//Draw down
TP := Point(x, y);
for CTPA := 26 to 35 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y + 1);
end;
TP := Point(x + 1, y);
for CTPA := 36 to 43 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y + 1);
end;
TP := Point(x - 1, y);
for CTPA := 44 to 51 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y + 1);
end;
//Draw left
TP := Point(x, y);
for CTPA := 52 to 61 do
begin
TPA[CTPA] := TP;
TP := point(TP.x - 1, TP.y);
end;
TP := Point(x, y + 1);
for CTPA := 62 to 69 do
begin
TPA[CTPA] := TP;
TP := point(TP.x - 1, TP.y);
end;
TP := Point(x, y - 1);
for CTPA := 70 to 77 do
begin
TPA[CTPA] := TP;
TP := point(TP.x - 1, TP.y);
end;
//Draw up
TP := Point(x, y);
for CTPA:= 78 to 87 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y - 1);
end;
TP := Point(x + 1, y);
for CTPA := 88 to 95 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y - 1);
end;
TP := Point(x - 1, y);
for CTPA:= 96 to 103 do
begin
TPA[CTPA] := TP;
TP := point(TP.x, TP.y - 1);
end;
c := 0;
HighTPA := High(TPA)
for i := 0 to HighTPA do
begin
if not (TPA[i].x < MSX1 + 1) and
not (TPA[i].x > MSX2 - 1) and
not (TPA[i].y < MSY1 + 1) and
not (TPA[i].y > MSY2 - 1) then
begin
NewTPA[c] := TPA[i];
inc(c);
end;
end;
SetLength(NewTPA, c)
SMART_DrawDotsEx(False, NewTPA, col);
end;
Procedure WriteDebug(txt: string);
begin
if(Debug)then
WriteLn(txt);
end;
Function CheckLogin: Boolean;
begin
Result := False;
if not loggedin then
begin
if not loginplayer then
begin
//restart := True;
Result := True;
end;
end;
end;
Function IsUpTextAdv(Text: TStringArray): Boolean;
var
TP : TPoint;
begin
Result := FindTextEx(TP.x,TP.y,Text,['UpChars'],MSX1,MSY1,MSX1+300,MSY1+30) or
FindTextEx(TP.x,TP.y,Text,['UpChars_s'],MSX1,MSY1,MSX1+300,MSY1+30) or
FindTextEx(TP.x,TP.y,Text,['UpCharsEx'],MSX1,MSY1,MSX1+300,MSY1+30) or
IsUpTextMultiCustom(Text);
end;
Function FindTextAdv(Text: TStringArray): Boolean;
var
x, y: Integer;
begin
Result := False;
if IsUpTextAdv(Text) then
begin
Result := True;
end else
begin
if FindTextEx(x, y, Text, ['UpCharsEx'], MSX1, MSY1, MIX2, MIY2) then
begin
Result := True;
end else
begin
WriteDebug('Did not Find ' + Text[0] + ' UpText');
end;
end;
end;
Procedure IsFishing;
var
InTime, OutTime, ETime, STime: Integer;
Mov: Boolean;
Box, Box2 : TBox;
begin
if CheckLogin then Exit;
if (debug = True) then SMART_ClearCanvas;
if InvFull then
begin
WriteDebug('Can''t fit anymore, going to bank or dropping');
Exit;
end;
Box := IntToBox(MSCX - 2, MSCY - 4, MSCX + 4, MSCY + 6);
Box2 := IntToBox(MSCX - 13, MSCY, MSCX + 13, MSCY + 24);
InTime := (GetSystemTime);
Mov := False;
STime := GetSystemTime;
repeat
if Animating(Box, 100, 9) then Mov := True;
ETime := GetSystemTime - STime;
until (ETime > 3500) or (Mov = True)
if (Mov = True) then
begin
WriteDebug('We are fishing');
repeat
if CheckLogin then Exit;
if (debug = True) then SMART_DrawBox(Box);
//if (debug = True) then SMART_DrawBoxEX(False, False, Box2, clGreen);
Mov := False;
STime := GetSystemTime;
repeat
if Animating(Box, 100, 9) then Mov := True;
ETime := GetSystemTime - STime;
until (ETime > 3000) or (Mov = True) or InvFull
if InvFull then
begin
WriteDebug('Can''t fit anymore, going to bank or dropping');
Exit;
end;
if (Mov = True) then
begin
if (debug = True) then PaintCross(MSCX, MSCY, clYellow);
wait(RandomRange(10,11));
status('We are fishing');
//WriteDebug('Still Fishing');
//AntiBan;
if not FindTextAdv(FishText) then
begin
WriteDebug('Add you fishing spot finder here to look for next fishing spot');
// Here you can add you fishing spot finding method to
// look for next fishing spot b4 finished fishing
{if FindFishingSpot(False, 30) then
WriteDebug('Nexted Fishing Spot Found'); }
end;
end else WriteDebug('Stopped Fishing');
if (debug = True) then SMART_ClearCanvas;
//LookForFullChatTxt;
OutTime := (GetSystemTime - InTime);
until (Mov = False) or (OutTime > 240000) or InvFull
if (OutTime > 120000) then
begin
WriteDebug('''Is Fishing'' timed out');
writeln('Timed out after ' + ToStr(OutTime));
end;
end else
begin
WriteDebug('Didn''t detect that we are fishing');
Exit;
end;
if (debug = True) then SMART_ClearCanvas;
end;
begin
SetupSRL;
LoadText;
IsFishing
end.