babablksheep
12-08-2012, 06:09 PM
So I've modified Nebbula's monkfisher to suit my needs, added a break system and real-time paint.
The problem I'm having is the memory leak, it increases in mem usage significantly and crashes by the 7th or 8th load. Disabling the paint seems to get rid of it and getting rid of counting items seems to reduce it.
So my question is, is it the counting of the items that is causing the leak? If so, is there a solution or am I stuck with disabling the paint entirely?
program NebulaMonkFisher;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/Misc/SmartGraphics.Simba}
///////////////////////////// Instructions: ////////////////////////////////////
///////////////////// Start in the Piscatoris Bank /////////////////////////////
////////////////// Have a small net in your Toolbelt ///////////////////////////
/////////// Enter how many Loads of monkfish you want to fish //////////////////
///////////////////Enter what world you want to fish in ////////////////////////
//////////////////// Enter your username + password ////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Var
f, k, g, count:integer; // Failsafes
lpu, startbreaktime, breakwhen, ebreakwhen, endbreaktime, x, y, DiffInCount, Mffi, Mffb, XpGained, monkfish: integer; //other
MiddleWalk, spot1, spot2, spot3, EastWalk, WestWalk:TPointArray;
PBox: TBox;
Status, BStatus: String;
const
Loads = 999999; // Amount of loads to do
Procedure DeclarePlayers;
begin
HowManyPlayers := 1; // Don't touch this
NumberOfPlayers(HowManyPlayers);// Don't touch this
CurrentPlayer := 0; // Don't touch this
Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Active := True; // Don't touch this
Players[0].Pin := ' '; // Bank Pin, Leave blank if you don't have one
end;
{---------------------Don't touch anything past this line---------------------}
//Procedure Loadmonkfish;
//begin
// monkfish := DTMFromString('mggAAAHicY2NgYBBmZmCQB2JJIOYDYi4gVg ficEYGBj8gjgVifyCOguJsD2ugLiYMzM+AHTDiwBAAAFOTA7s= ');
//end;
//Procedure Freemonkfish;
//begin
// FreeDTM(monkfish);
//end;
Function CountMonks: integer;
var
Count: integer;
begin
if GetCurrentTab() <> 25 then
begin
Gametab(Tab_Inv);
end;
//Count := CountItems('dtm', monkfish, []);
Count := CountItems('color',4346998, []);
result := Count;
end;
Procedure PaintProggy(TP: TStringArray; Placement: TPoint; Colour: integer);
var
I, H: Integer;
begin
if TimeFromMark(lpu) >= 1000 then
begin
Smart_ClearCanvas;
For I := 0 To High(TP) Do
begin
LoadTextTPA(TP[I], UpChars, H);
Placement.Y := Placement.Y + (H);
Smart_DrawTextEx(False, Placement.X, Placement.Y, 'UpChars', TP[I], Colour);
MarkTime(lpu);
end;
end;
end;
Function CalculateNextBreakTime: string;
var
Clock, Clock2: TIntegerArray;
begin
Clock := [0,0,0];
Clock2 := [0,0,0];
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
ConvertTime(breakwhen - (TimeFromMark(endbreaktime)),Clock2[0],Clock2[1],Clock2[2]);
result := 'Next break in ' + tostr(Clock2[0])+':'+tostr(Clock2[1])+':'+tostr(Clock2[2])+' for ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]);
end;
Function gSmartLines(onbreak: boolean): TStringArray;
Var
SmartLines: TStringArray;
Clock: TIntegerArray;
XPPH, FishPerHour : integer;
begin
if (not onbreak or not LoggedIn) then
begin
DiffInCount := CountMonks - Mffi;
if DiffInCount <> 0 then
begin
IncEx(XpGained, DiffInCount*120);
IncEx(Mffi, DiffInCount);
end;
end;
Clock := [0,0,0];
XPPH := Round((XpGained * 3600) / (GetTimeRunning / 1000));
FishPerHour := Round(((Mffi+Mffb) * 3600) / (GetTimeRunning / 1000));
ConvertTime(GetTimeRunning,Clock[0],Clock[1],Clock[2]);
SetArrayLength(SmartLines, 7);
SmartLines[0] := ('Time Ran:' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
SmartLines[1] := ('Exp Gained:' + IntToStr(XpGained));
SmartLines[2] := ('Exp Per hour:' + IntToStr(XPPH));
SmartLines[3] := ('Monkfish Fished:' + IntToStr(Mffb + Mffi));
SmartLines[4] := ('Monkfish per hour:' + IntToStr(FishPerHour));
SmartLines[5] := ('Status: '+Status);
if not onbreak then
begin
BStatus := CalculateNextBreakTime;
end;
SmartLines[6] := (BStatus);
result := SmartLines;
end;
Procedure doChecks;
begin
if (ExitSquealOfFortune()) then
begin
writeln('Closing squeal of fortune pop-up');
end;
if (FindSpinTicket()) then
begin
writeln('Found spin ticket, claiming.');
end;
if (not LoggedIn()) then
begin
WriteLn('Error: Not Logged In! Fixing - Thanks API!');
LoginPlayer();
wait(3500);
end;
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
end;
Procedure CalculateNextBreak;
var
Clock2, Clock: TIntegerArray;
begin
MarkTime(endbreaktime);
breakwhen := randomrange(600000, 6000000)//Break every 10 to 100 minutes
ebreakwhen := randomrange(10000, 3000000)//Break for 10 seconds to 50 minutes
Clock := [0,0,0];
Clock2 := [0,0,0];
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
ConvertTime(breakwhen,Clock2[0],Clock2[1],Clock2[2]);
writeln('*zzz*Next break in ' + tostr(Clock2[0])+':'+tostr(Clock2[1])+':'+tostr(Clock2[2])+' for ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
end;
Procedure CheckForEBreak;
var
bml: integer;
Clock: TIntegerArray;
begin
Status := 'On Break';
repeat
inc(bml);
Clock := [0,0,0];
ConvertTime((ebreakwhen - TimeFromMark(startbreaktime)),Clock[0],Clock[1],Clock[2]);
if(TimeFromMark(lpu) > 950) then
begin
MarkTime(lpu);
BStatus := 'Resuming in: ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]);
PaintProggy(gSmartLines(true),Point(10,30),clWhite );
end;
if (bml > 5000000) then
begin
bml := 0;
writeln('*zzz* Currently on a coffee break resuming in: ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
end;
until (TimeFromMark(startbreaktime) >= ebreakwhen);
begin
//onbreak := 0;
writeln('*zzz* Resuming Fishing now.');
marktime(endbreaktime);
CalculateNextBreak;
end;
end;
Function CheckForBreak: Boolean;
var
Clock: TIntegerArray;
begin
if (TimeFromMark(endbreaktime) >= breakwhen) then
begin
Clock := [0,0,0];
marktime(startbreaktime);
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
writeln('*zzz*Going on a coffee break resuming in:' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
result := true;
if(ebreakwhen >= 300000) then//Check if break is greater than idle logout
begin
if(randomrange(1, 100) > 50) then//If so, have a chance of logging out manually (as if you knew you were going to be gone for a while)
begin
writeln('*zzz*Decided to logout, we know we''re going to be gone a while.')
Logout();
end;
end;
//onbreak := 1;
end else
begin
result := false;
end;
end;
Procedure Antiban;
var
randomanti: Integer;
begin
randomanti := random(375);
if randomanti < 23 then
begin
Wait(RandomRange(400,600));
end;
Case randomanti of
1: Mouse(531, 62, 11, 11, true);
2: begin
HoverSkill('Fishing', false);
Wait(RandomRange(2000, 3000));
Gametab(Tab_Inv);
end;
3: begin
Gametab(Tab_Stats);
Wait(randomrange(750, 2400));
Gametab(Tab_Inv);
end;
4: begin
Gametab(Tab_Friends);
Wait(randomrange(750, 2400));
Gametab(Tab_Inv);
end;
5: MakeCompass(RandomRange(0,20));
//6: MouseBox(0, 0, 753, 492, 0);
7: MakeCompass(RandomRange(340, 360));
8: SetAngle(RandomRange(0,30));
//10: MouseBox(5, 482, 454, 500, 1);
11: PickUpMouse;
12: PickUpMouse;
13: MouseBox(0, 0, 753, 492, 0);
14: MMouse(333, 225, 300, 215);
15: MMouse(333, 225, 300, 215);
16: MMouse(333, 225, 300, 215);
17: SetAngle(RandomRange(0,30));
18: MakeCompass(RandomRange(0,20));
19: MakeCompass(RandomRange(340, 360));
20: MakeCompass('N');
21: MakeCompass('N');
22: MouseSpeed := RandomRange(10,20);
23: MouseSpeed := RandomRange(10,20);
end;
end;
Procedure Beginning;
begin
// Loadmonkfish;
// Addonterminate('Freemonkfish');
MakeCompass('N');
SetAngle(0);
CalculateNextBreak;
// Writeln('done with beginning');
GameTab(Tab_Inv);
end;
Procedure WalkBankFromMiddle;
begin
MiddleWalk := [Point(1185, 1858), Point(1180, 1870), Point(1176, 1883), Point(1158, 1882)];
SPS_WalkPath(MiddleWalk);
end;
Procedure WalkFishingSpot1;
begin
spot1 := [Point(1180+randomrange(-2, 2), 1835+randomrange(-2, 2))];
SPS_WalkPath(spot1);
end;
Procedure WalkFishingSpot2;
begin
spot2 := [Point(1220+randomrange(-2, 2), 1838+randomrange(-2, 2))];
SPS_WalkPath(spot2);
end;
Procedure WalkFishingSpot3;
begin
spot3 := [Point(1145+randomrange(-2, 2), 1841+randomrange(-2, 2))];
SPS_WalkPath(spot3);
end;
Procedure WalkBankFromEast;
begin
EastWalk := [Point(1242, 1844), Point(1229, 1852), Point(1216, 1860), Point(1204, 1866), Point(1188, 1873), Point(1178, 1883), Point(1156, 1885)];
SPS_WalkPath(EastWalk);
end;
Procedure WalkBankFromWest;
begin
WestWalk := [Point(1096, 1842), Point(1110, 1846), Point(1125, 1849), Point(1142, 1851), Point(1158, 1853), Point(1174, 1857), Point(1176, 1885), Point(1158, 1883)];
SPS_WalkPath(WestWalk);
end;
Procedure PrintProggy();
Var
wc: integer;
SmartLines: TStringArray;
begin
SmartLines := gSmartLines(false);
repeat
writeln('***'+SmartLines[WC]);
inc(WC);
until (WC >= 4);
end;
Function StartFishing: Boolean;
begin
Status := 'Finding a fishing spot'
doChecks()
if not CheckForBreak then
begin
count := 1
f := 0
repeat
// MakeProggy(false);
inc(count);
x := MSCX;
y := MSCY;
// Writeln('Searching');
Wait(randomrange(300,700));
MouseSpeed := RandomRange(7,14);
If (FindObjTPA(x, y, 11379098, 10, 1, 20, 20, 2,['Harpoon'])) then
begin
// writeln('Found possible spot');
Mouse(x, y, 4, 4, False);
Wait(randomrange(300, 900));
If (WaitOption('Net F', 3000)) then
begin
if (randomrange(0, 25) < 10) then
begin
wait(randomrange(300, 900));
x := MSCX;
y := MSCY;
MMouse(randomrange(0, x), randomrange(0, y), 0, 0);
end;
//writeln('found spot');
result := true
Break;
end;
end;
until((count>4) or (true) or (not LoggedIn()));
If (count>4) then
begin
result := false
end;
end else
begin
CheckForEBreak;
end;
end;
Procedure WhileFishing;
begin
if not CheckForBreak then
begin
doChecks()
wait(randomrange(2000,2500));
repeat
PBox := IntToBox(245, 130, 285, 195);
repeat
Status := 'Fishing';
doChecks()
if CheckForBreak then
begin
CheckForEBreak;
end;
//MakeProggy(false);
if (AveragePixelShift(PBox, 50, 500)>=79) then
AntiBan;
until ((AveragePixelShift(PBox, 50, 500)<78) or (InvFull) or (not LoggedIn()));
// Writeln('pixelshift A done');
if (InvFull) then
begin
// writeln('Inv is full');
break;
end else
begin
if (AveragePixelShift(PBox, 250, 2500)<550) then
begin
// Writeln('PixelShift B done');
wait(randomrange(10,150));
if not startfishing then
break;
end;
end;
until((InvFull) or (not LoggedIn()));
end else
begin
CheckForEBreak;
end;
end;
Procedure WalkToBank;
var
P : TPoint;
Begin
SPS_GetMyPos;
Writeln(ToStr(SPS_GetMyPos));
P := SPS_GetMyPos;
if (P.x>1200) then
begin
writeln('Walking East Path');
WalkBankFromEast;
end else
if (P.x<1166) then
begin
writeln('Walking Wast Path');
WalkBankFromWest;
end else
begin
writeln('Walking Middle Path');
WalkBankFromMiddle;
end;
end;
Procedure Banking;
var
failattempts: integer;
begin
if not CheckForBreak then
begin
repeat
writeln('Detected as still walking, waiting to try for banker...');
until(AveragePixelShift(PBox, 1, 1800)<3)
MouseSpeed := RandomRange(100,110);
writeln('done walking to bank2;');
//PaintProggy(gSmartLines,Point(10,30),clWhite);
Writeln('Banking');
f := 0;
Wait(randomrange(400,800));
repeat
Wait(randomrange(250, 600));
//Inc(f); //gets rid of old failure check, it counts a fail even if it succeeds, which may not be a big deal, but let's just be smarter about it and keep it local.
x := MSCX;
y := MSCY;
if (FindObjTPA(x, y, 2846095, 15, 1, 4, 5, 4, ['rnold', 'Arnold'])) then
begin
Mouse(x, y, 0, 0, false);
if (WaitOption('Bank ', 800)) then
begin
g := 0
repeat
Inc(g);
Wait(RandomRange(45, 55))
until((BankScreen) or (g>60) or (PinScreen) or (not LoggedIn()));
If PinScreen then
InPin(Players[CurrentPlayer].Pin);
end;
end else
begin
inc(failattempts);
if(failattempts > 3) then
begin
SetAngle(0);
failattempts := 0;
MakeCompass(RandomRange(90,270));
end;
end;
until((BankScreen) or (not LoggedIn()));
if (not LoggedIn()) then
begin
writeln('Looking for the banker when we are not even logged in...');
end else
begin
IncEx(Mffb, Mffi);
Mffi := 0;
DepositAll;
Wait(randomRange(400, 800));
CloseBank;
end;
end else
begin
CheckForEBreak;
end;
end;
begin
MouseSpeed := RandomRange(10,20);
SRL_SixHourFix := True;
SMART_FixSpeed := True;
ClearDebug;
SetupSRL;
DeclarePlayers;
if (not LoggedIn()) then
begin
LoginPlayer();
wait(3500);
end;
Beginning;
writeln('Starting');
// MakeProggy;
SPS_Setup(RUNESCAPE_SURFACE,['2_4']);
repeat
// if onbreak = 1 then
// repeat
// until(onbreak = 0);
Status := 'Checking Position';
doChecks();
repeat
repeat
SPS_GetMyPos;
if (invfull) then
break
else
if not Startfishing then
begin
Status := 'Walking to fish spot'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
MouseSpeed := RandomRange(10,20);
WalkFishingSpot1;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot2;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot1;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot3;
wait(RandomRange(600,1200));
if not Startfishing then
begin
end;
end;
end;
end;
end;
until((true) or (not LoggedIn()));
WhileFishing;
until((InvFull) or (not LoggedIn()));
if (InvFull) then
begin
Wait(Randomrange(1300,4000));
Status := 'Walking to bank'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
WalkToBank;
// LoadDTMS;
Status := 'Banking'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
Banking;
PrintProggy();
inc(k);
Writeln('###Finished with load #'+IntToStr(k));
// FreeDTMMs;
MouseSpeed := RandomRange(10,20);
end;
until(k=loads);
end.
The problem I'm having is the memory leak, it increases in mem usage significantly and crashes by the 7th or 8th load. Disabling the paint seems to get rid of it and getting rid of counting items seems to reduce it.
So my question is, is it the counting of the items that is causing the leak? If so, is there a solution or am I stuck with disabling the paint entirely?
program NebulaMonkFisher;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/Misc/SmartGraphics.Simba}
///////////////////////////// Instructions: ////////////////////////////////////
///////////////////// Start in the Piscatoris Bank /////////////////////////////
////////////////// Have a small net in your Toolbelt ///////////////////////////
/////////// Enter how many Loads of monkfish you want to fish //////////////////
///////////////////Enter what world you want to fish in ////////////////////////
//////////////////// Enter your username + password ////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Var
f, k, g, count:integer; // Failsafes
lpu, startbreaktime, breakwhen, ebreakwhen, endbreaktime, x, y, DiffInCount, Mffi, Mffb, XpGained, monkfish: integer; //other
MiddleWalk, spot1, spot2, spot3, EastWalk, WestWalk:TPointArray;
PBox: TBox;
Status, BStatus: String;
const
Loads = 999999; // Amount of loads to do
Procedure DeclarePlayers;
begin
HowManyPlayers := 1; // Don't touch this
NumberOfPlayers(HowManyPlayers);// Don't touch this
CurrentPlayer := 0; // Don't touch this
Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Active := True; // Don't touch this
Players[0].Pin := ' '; // Bank Pin, Leave blank if you don't have one
end;
{---------------------Don't touch anything past this line---------------------}
//Procedure Loadmonkfish;
//begin
// monkfish := DTMFromString('mggAAAHicY2NgYBBmZmCQB2JJIOYDYi4gVg ficEYGBj8gjgVifyCOguJsD2ugLiYMzM+AHTDiwBAAAFOTA7s= ');
//end;
//Procedure Freemonkfish;
//begin
// FreeDTM(monkfish);
//end;
Function CountMonks: integer;
var
Count: integer;
begin
if GetCurrentTab() <> 25 then
begin
Gametab(Tab_Inv);
end;
//Count := CountItems('dtm', monkfish, []);
Count := CountItems('color',4346998, []);
result := Count;
end;
Procedure PaintProggy(TP: TStringArray; Placement: TPoint; Colour: integer);
var
I, H: Integer;
begin
if TimeFromMark(lpu) >= 1000 then
begin
Smart_ClearCanvas;
For I := 0 To High(TP) Do
begin
LoadTextTPA(TP[I], UpChars, H);
Placement.Y := Placement.Y + (H);
Smart_DrawTextEx(False, Placement.X, Placement.Y, 'UpChars', TP[I], Colour);
MarkTime(lpu);
end;
end;
end;
Function CalculateNextBreakTime: string;
var
Clock, Clock2: TIntegerArray;
begin
Clock := [0,0,0];
Clock2 := [0,0,0];
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
ConvertTime(breakwhen - (TimeFromMark(endbreaktime)),Clock2[0],Clock2[1],Clock2[2]);
result := 'Next break in ' + tostr(Clock2[0])+':'+tostr(Clock2[1])+':'+tostr(Clock2[2])+' for ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]);
end;
Function gSmartLines(onbreak: boolean): TStringArray;
Var
SmartLines: TStringArray;
Clock: TIntegerArray;
XPPH, FishPerHour : integer;
begin
if (not onbreak or not LoggedIn) then
begin
DiffInCount := CountMonks - Mffi;
if DiffInCount <> 0 then
begin
IncEx(XpGained, DiffInCount*120);
IncEx(Mffi, DiffInCount);
end;
end;
Clock := [0,0,0];
XPPH := Round((XpGained * 3600) / (GetTimeRunning / 1000));
FishPerHour := Round(((Mffi+Mffb) * 3600) / (GetTimeRunning / 1000));
ConvertTime(GetTimeRunning,Clock[0],Clock[1],Clock[2]);
SetArrayLength(SmartLines, 7);
SmartLines[0] := ('Time Ran:' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
SmartLines[1] := ('Exp Gained:' + IntToStr(XpGained));
SmartLines[2] := ('Exp Per hour:' + IntToStr(XPPH));
SmartLines[3] := ('Monkfish Fished:' + IntToStr(Mffb + Mffi));
SmartLines[4] := ('Monkfish per hour:' + IntToStr(FishPerHour));
SmartLines[5] := ('Status: '+Status);
if not onbreak then
begin
BStatus := CalculateNextBreakTime;
end;
SmartLines[6] := (BStatus);
result := SmartLines;
end;
Procedure doChecks;
begin
if (ExitSquealOfFortune()) then
begin
writeln('Closing squeal of fortune pop-up');
end;
if (FindSpinTicket()) then
begin
writeln('Found spin ticket, claiming.');
end;
if (not LoggedIn()) then
begin
WriteLn('Error: Not Logged In! Fixing - Thanks API!');
LoginPlayer();
wait(3500);
end;
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
end;
Procedure CalculateNextBreak;
var
Clock2, Clock: TIntegerArray;
begin
MarkTime(endbreaktime);
breakwhen := randomrange(600000, 6000000)//Break every 10 to 100 minutes
ebreakwhen := randomrange(10000, 3000000)//Break for 10 seconds to 50 minutes
Clock := [0,0,0];
Clock2 := [0,0,0];
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
ConvertTime(breakwhen,Clock2[0],Clock2[1],Clock2[2]);
writeln('*zzz*Next break in ' + tostr(Clock2[0])+':'+tostr(Clock2[1])+':'+tostr(Clock2[2])+' for ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
end;
Procedure CheckForEBreak;
var
bml: integer;
Clock: TIntegerArray;
begin
Status := 'On Break';
repeat
inc(bml);
Clock := [0,0,0];
ConvertTime((ebreakwhen - TimeFromMark(startbreaktime)),Clock[0],Clock[1],Clock[2]);
if(TimeFromMark(lpu) > 950) then
begin
MarkTime(lpu);
BStatus := 'Resuming in: ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]);
PaintProggy(gSmartLines(true),Point(10,30),clWhite );
end;
if (bml > 5000000) then
begin
bml := 0;
writeln('*zzz* Currently on a coffee break resuming in: ' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
end;
until (TimeFromMark(startbreaktime) >= ebreakwhen);
begin
//onbreak := 0;
writeln('*zzz* Resuming Fishing now.');
marktime(endbreaktime);
CalculateNextBreak;
end;
end;
Function CheckForBreak: Boolean;
var
Clock: TIntegerArray;
begin
if (TimeFromMark(endbreaktime) >= breakwhen) then
begin
Clock := [0,0,0];
marktime(startbreaktime);
ConvertTime(ebreakwhen,Clock[0],Clock[1],Clock[2]);
writeln('*zzz*Going on a coffee break resuming in:' + tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
result := true;
if(ebreakwhen >= 300000) then//Check if break is greater than idle logout
begin
if(randomrange(1, 100) > 50) then//If so, have a chance of logging out manually (as if you knew you were going to be gone for a while)
begin
writeln('*zzz*Decided to logout, we know we''re going to be gone a while.')
Logout();
end;
end;
//onbreak := 1;
end else
begin
result := false;
end;
end;
Procedure Antiban;
var
randomanti: Integer;
begin
randomanti := random(375);
if randomanti < 23 then
begin
Wait(RandomRange(400,600));
end;
Case randomanti of
1: Mouse(531, 62, 11, 11, true);
2: begin
HoverSkill('Fishing', false);
Wait(RandomRange(2000, 3000));
Gametab(Tab_Inv);
end;
3: begin
Gametab(Tab_Stats);
Wait(randomrange(750, 2400));
Gametab(Tab_Inv);
end;
4: begin
Gametab(Tab_Friends);
Wait(randomrange(750, 2400));
Gametab(Tab_Inv);
end;
5: MakeCompass(RandomRange(0,20));
//6: MouseBox(0, 0, 753, 492, 0);
7: MakeCompass(RandomRange(340, 360));
8: SetAngle(RandomRange(0,30));
//10: MouseBox(5, 482, 454, 500, 1);
11: PickUpMouse;
12: PickUpMouse;
13: MouseBox(0, 0, 753, 492, 0);
14: MMouse(333, 225, 300, 215);
15: MMouse(333, 225, 300, 215);
16: MMouse(333, 225, 300, 215);
17: SetAngle(RandomRange(0,30));
18: MakeCompass(RandomRange(0,20));
19: MakeCompass(RandomRange(340, 360));
20: MakeCompass('N');
21: MakeCompass('N');
22: MouseSpeed := RandomRange(10,20);
23: MouseSpeed := RandomRange(10,20);
end;
end;
Procedure Beginning;
begin
// Loadmonkfish;
// Addonterminate('Freemonkfish');
MakeCompass('N');
SetAngle(0);
CalculateNextBreak;
// Writeln('done with beginning');
GameTab(Tab_Inv);
end;
Procedure WalkBankFromMiddle;
begin
MiddleWalk := [Point(1185, 1858), Point(1180, 1870), Point(1176, 1883), Point(1158, 1882)];
SPS_WalkPath(MiddleWalk);
end;
Procedure WalkFishingSpot1;
begin
spot1 := [Point(1180+randomrange(-2, 2), 1835+randomrange(-2, 2))];
SPS_WalkPath(spot1);
end;
Procedure WalkFishingSpot2;
begin
spot2 := [Point(1220+randomrange(-2, 2), 1838+randomrange(-2, 2))];
SPS_WalkPath(spot2);
end;
Procedure WalkFishingSpot3;
begin
spot3 := [Point(1145+randomrange(-2, 2), 1841+randomrange(-2, 2))];
SPS_WalkPath(spot3);
end;
Procedure WalkBankFromEast;
begin
EastWalk := [Point(1242, 1844), Point(1229, 1852), Point(1216, 1860), Point(1204, 1866), Point(1188, 1873), Point(1178, 1883), Point(1156, 1885)];
SPS_WalkPath(EastWalk);
end;
Procedure WalkBankFromWest;
begin
WestWalk := [Point(1096, 1842), Point(1110, 1846), Point(1125, 1849), Point(1142, 1851), Point(1158, 1853), Point(1174, 1857), Point(1176, 1885), Point(1158, 1883)];
SPS_WalkPath(WestWalk);
end;
Procedure PrintProggy();
Var
wc: integer;
SmartLines: TStringArray;
begin
SmartLines := gSmartLines(false);
repeat
writeln('***'+SmartLines[WC]);
inc(WC);
until (WC >= 4);
end;
Function StartFishing: Boolean;
begin
Status := 'Finding a fishing spot'
doChecks()
if not CheckForBreak then
begin
count := 1
f := 0
repeat
// MakeProggy(false);
inc(count);
x := MSCX;
y := MSCY;
// Writeln('Searching');
Wait(randomrange(300,700));
MouseSpeed := RandomRange(7,14);
If (FindObjTPA(x, y, 11379098, 10, 1, 20, 20, 2,['Harpoon'])) then
begin
// writeln('Found possible spot');
Mouse(x, y, 4, 4, False);
Wait(randomrange(300, 900));
If (WaitOption('Net F', 3000)) then
begin
if (randomrange(0, 25) < 10) then
begin
wait(randomrange(300, 900));
x := MSCX;
y := MSCY;
MMouse(randomrange(0, x), randomrange(0, y), 0, 0);
end;
//writeln('found spot');
result := true
Break;
end;
end;
until((count>4) or (true) or (not LoggedIn()));
If (count>4) then
begin
result := false
end;
end else
begin
CheckForEBreak;
end;
end;
Procedure WhileFishing;
begin
if not CheckForBreak then
begin
doChecks()
wait(randomrange(2000,2500));
repeat
PBox := IntToBox(245, 130, 285, 195);
repeat
Status := 'Fishing';
doChecks()
if CheckForBreak then
begin
CheckForEBreak;
end;
//MakeProggy(false);
if (AveragePixelShift(PBox, 50, 500)>=79) then
AntiBan;
until ((AveragePixelShift(PBox, 50, 500)<78) or (InvFull) or (not LoggedIn()));
// Writeln('pixelshift A done');
if (InvFull) then
begin
// writeln('Inv is full');
break;
end else
begin
if (AveragePixelShift(PBox, 250, 2500)<550) then
begin
// Writeln('PixelShift B done');
wait(randomrange(10,150));
if not startfishing then
break;
end;
end;
until((InvFull) or (not LoggedIn()));
end else
begin
CheckForEBreak;
end;
end;
Procedure WalkToBank;
var
P : TPoint;
Begin
SPS_GetMyPos;
Writeln(ToStr(SPS_GetMyPos));
P := SPS_GetMyPos;
if (P.x>1200) then
begin
writeln('Walking East Path');
WalkBankFromEast;
end else
if (P.x<1166) then
begin
writeln('Walking Wast Path');
WalkBankFromWest;
end else
begin
writeln('Walking Middle Path');
WalkBankFromMiddle;
end;
end;
Procedure Banking;
var
failattempts: integer;
begin
if not CheckForBreak then
begin
repeat
writeln('Detected as still walking, waiting to try for banker...');
until(AveragePixelShift(PBox, 1, 1800)<3)
MouseSpeed := RandomRange(100,110);
writeln('done walking to bank2;');
//PaintProggy(gSmartLines,Point(10,30),clWhite);
Writeln('Banking');
f := 0;
Wait(randomrange(400,800));
repeat
Wait(randomrange(250, 600));
//Inc(f); //gets rid of old failure check, it counts a fail even if it succeeds, which may not be a big deal, but let's just be smarter about it and keep it local.
x := MSCX;
y := MSCY;
if (FindObjTPA(x, y, 2846095, 15, 1, 4, 5, 4, ['rnold', 'Arnold'])) then
begin
Mouse(x, y, 0, 0, false);
if (WaitOption('Bank ', 800)) then
begin
g := 0
repeat
Inc(g);
Wait(RandomRange(45, 55))
until((BankScreen) or (g>60) or (PinScreen) or (not LoggedIn()));
If PinScreen then
InPin(Players[CurrentPlayer].Pin);
end;
end else
begin
inc(failattempts);
if(failattempts > 3) then
begin
SetAngle(0);
failattempts := 0;
MakeCompass(RandomRange(90,270));
end;
end;
until((BankScreen) or (not LoggedIn()));
if (not LoggedIn()) then
begin
writeln('Looking for the banker when we are not even logged in...');
end else
begin
IncEx(Mffb, Mffi);
Mffi := 0;
DepositAll;
Wait(randomRange(400, 800));
CloseBank;
end;
end else
begin
CheckForEBreak;
end;
end;
begin
MouseSpeed := RandomRange(10,20);
SRL_SixHourFix := True;
SMART_FixSpeed := True;
ClearDebug;
SetupSRL;
DeclarePlayers;
if (not LoggedIn()) then
begin
LoginPlayer();
wait(3500);
end;
Beginning;
writeln('Starting');
// MakeProggy;
SPS_Setup(RUNESCAPE_SURFACE,['2_4']);
repeat
// if onbreak = 1 then
// repeat
// until(onbreak = 0);
Status := 'Checking Position';
doChecks();
repeat
repeat
SPS_GetMyPos;
if (invfull) then
break
else
if not Startfishing then
begin
Status := 'Walking to fish spot'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
MouseSpeed := RandomRange(10,20);
WalkFishingSpot1;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot2;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot1;
wait(RandomRange(600,1200));
if not Startfishing then
begin
MouseSpeed := RandomRange(10,20);
WalkFishingSpot3;
wait(RandomRange(600,1200));
if not Startfishing then
begin
end;
end;
end;
end;
end;
until((true) or (not LoggedIn()));
WhileFishing;
until((InvFull) or (not LoggedIn()));
if (InvFull) then
begin
Wait(Randomrange(1300,4000));
Status := 'Walking to bank'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
WalkToBank;
// LoadDTMS;
Status := 'Banking'
PaintProggy(gSmartLines(false),Point(10,30),clWhit e);
Banking;
PrintProggy();
inc(k);
Writeln('###Finished with load #'+IntToStr(k));
// FreeDTMMs;
MouseSpeed := RandomRange(10,20);
end;
until(k=loads);
end.