SRL Archive - OSR Help

Wont stop when InvFull? or am I just dumb?


rotchy1

2013-06-05 14:24:54

So this script will pick potatos at below varrok, bank, and repeat however It will not stop picking potatos when the Inv is full? I used the same procedure that I used in my Chicken Collecting script (which seems to work fine) however it does not in this script?

heres the code

program RotchysPotatoPicker;

{$DEFINE SMART}
{$I SRL/SRL.simba}
{$I SPS/SPS.simba}

var
PotatosPicked, PotatosPerHour, TimeGone: Integer;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Active := True;
WorldInfo := [true, 7];
end;
end;

procedure Setup;
begin
Smart_FixSpeed := True;
ClearDebug;
SetupSRL;
DeclarePlayers;
LogInPlayer;
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);
CloseAllScreens;
FindNormalRandoms;
ToggleActionBar(False);
Wait(RandomRange(200, 500));
ToggleMoneyPouch(False);
Wait(RandomRange(200, 500));
ToggleXPBar(False);
Wait(RandomRange(200, 500));
Retaliate(True);
Wait(RandomRange(200, 500));
end;

procedure ProgressReport;

begin
ClearDebug;
TimeGone := (GetTimeRunning / 1000);
PotatosPerHour :=(3600*(PotatosPicked)) / ((TimeGone));
begin
Writeln('|------------------- Rotchy1' + 's ' + 'Potato Looter -------------------');
Writeln('|###############################################################');
Writeln('|' + ' We have looted ' + IntToStr(PotatosPicked) + ' Raw Potatos so far ');
Writeln('|' + ' ' + IntToStr(PotatosPerHour) + ' Raw Potatos per hour ')
Writeln('|' + ' We have been collecting Raw Potatos for ' + TimeRunning + ' ');
Writeln('|' + ' Simple, yet effective. ' + '');
Writeln('|###############################################################');
end;
end;

procedure AntiBan;
begin
case Random(40) of
0: begin BoredHuman; end;
10: begin RandomRClick; end;
20: begin RandomMovement; end;
30: begin HoverMovingObject; end;
39: begin ExamineInv; end;
end;
end;

procedure TeleVarrock;

var T: Integer;

begin
MarkTime(T);
ProgressReport;
AntiBan;
FindNormalRandoms;
OpenLodeStoneScreen;
Lodestoneteleport('Varrock');
Wait(RandomRange(15000, 16000));
if TimeFRomMark(T) > 30000 then
begin
TeleVarrock;
end
else
if TimeFromMark(T) > 60000 then
begin
Writeln('error 1');
Logout;
TerminateScript;
end
else
end;

procedure WalkToPotatos;

var status: string;
ToPotatos: TPointArray;

begin
FindNormalRandoms;
SPS_Setup(RUNESCAPE_SURFACE,['11_7','12_7','12_8']);

ToPotatos:= [Point(4655, 3101), Point(4668, 3111), Point(4690, 3126), Point(4708, 3136), Point(4730, 3149), Point(4752, 3157), Point(4771, 3160), Point(4792, 3169), Point(4800, 3189), Point(4802, 3209), Point(4807, 3233), Point(4823, 3243), Point(4838, 3254), Point(4854, 3271), Point(4859, 3287), Point(4850, 3300), Point(4843, 3310)];
if SPS_WalkPath(ToPotatos) then
begin
Status := 'ToPotatos'
WaitNotMoving(True);
end else
begin
Status :='ToPotatos';
WaitNotMoving(True);
end;
AntiBan;
end;

Function FindPotato : Boolean; //Credits to Kasi for showing me how to split
//TPAs to reduce the amount of total points
//and find the point closest to player first.
//This makes the script look much more human
//like and increased the speed a good bit. I
//really appreciate it!
var
I, T, TimesFailed : integer;
PotatoTPA : TPointArray;
Potato2DTPA : T2DPointArray;
TB : TBox;
begin
FindNormalRandoms;
InvCount;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.05, 0.14);
FindColorsTolerance(PotatoTPA, 3828053, MSX1, MSY1, MSX2, MSY2, 5);
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
SplitTPAExWrap(PotatoTPA, 15, 15, Potato2DTPA);
SetLength(PotatoTPA, 0);
for I := 0 to High(Potato2DTPA) do
begin
TB := GetTPABounds(Potato2DTPA[I]);
if ((iAbs(TB.X1 - TB.X2) > 8) and (iAbs(TB.Y1 - TB.Y2) > 8) and
(iAbs(TB.X1 - TB.X2) < 40) and (iAbs(TB.Y1 - TB.Y2) < 40))
then
CombineTPAWrap(PotatoTPA, [MiddleTPA(Potato2DTPA[I])], PotatoTPA);
end;
SortTPAFrom(PotatoTPA, Point(MSCx, MSCy));
MarkTime(T);
for i := 0 to High(PotatoTPA) do
begin
MMouse(PotatoTPA[I].x, PotatoTPA[I].y, 1, 1);
if waituptext('Pick', 100) then
begin
ClickMouse2(mouse_Left);
if (DidRedClick) then
begin
Inc(PotatosPicked);
Result := True;
WaitNotMoving(True);
Wait(RandomRange(200,300));
ProgressReport;
end else
if (DidYellowClick) then
begin
WaitNotMoving(True);
ProgressReport;
end;
end else
begin
if TimeFromMark(T) > 3000 then
begin
Inc(TimesFailed);
FindPotato;
if TimesFailed >= 3 then
begin
WalkToPotatos;
AntiBan;
TimesFailed := 0;
end;
end;
if TimeFromMark(T) > 30000 then
begin
WalkToPotatos;
end;
end;
end;
end;

function FindColorsSpiralMulti(Sx, Sy: Integer; Colors, Tolerance: TIntegerArray; X1, Y1, X2, Y2: Integer): TPointArray;
var
i: Integer;
ATPA: T2DPointArray;
CombTPA: TPointArray;
begin
if (High(Colors) <> High(Tolerance)) then
begin
Writeln('Invalid number of parameters');
TerminateScript;
end;
for i := 0 to High(Colors) do
begin
SetLength(ATPA, i + 1);
FindColorsSpiralTolerance(Sx, Sy, ATPA[i], Colors[i], x1, y1, x2, y2, Tolerance[i]);
end;
CombTPA := MergeATPA(ATPA);
SortTPAFrom(CombTPA, Point(sx, sy));
Result := CombTPA;
end;

function OpenGateIfClosed: Boolean;
var
MMx, MMy, T, i: Integer;
MSPC: TPoint;
TPA: TPointArray;
begin
MarkTime(T);
while True do
begin
FFlag(0);
TPA := FindColorsSpiralMulti(MMCX + 10, MMCY + 10, [197874, 3951706], [10, 10], MMX1, MMY1, MMX2, MMY2);
MSPC := MMToMS(TPA[0]);
if FindObj(MMx, MMy, 'ate', 3951706, 7) then //FindOBj automatically moves the mouse to the point when checking for uptext
begin
if WaitUptext('pen', RandomRange(400, 650)) then
begin
ClickMouse2(True);
FFlag(0);
Break;
end else
FindPotato;
end;
Inc(i);
if (i = 5) or (TimeFromMark(T) > 30000) then
Exit;
end;
AntiBan;
Result := True;
end;

procedure Main;
begin
if not OpenGateIfClosed then
WalkToPotatos;
end;

procedure BankTheLootFailsafe;

var T, x, y: Integer;

begin
MarkTime(T);
begin
FindNormalRandoms;
GameTab(26);
if WearingItem(11) then
MouseEquippedItem('ring', MOUSE_RIGHT);
ChooseOption('aemon');
Wait(RandomRange(9000,11000));
end;
Writeln('RadialBankWalk');
repeat
RadialWalkTolerance(15985378, 356, 359, 45, -1, 0, 15);
wait(RandomRange(2000,2500));
until (FindObj (x, y, 'remennik', 8673603, 25)) or (TimeFromMark(T) > 30000)
begin
Mouse(x, y, 2, 2, false);
ChooseOption('Bank');
wait(Randomrange(1500,2000));
if BankScreen then
DepositAll;
wait(RandomRange(500,1000));
CloseBank;
end;
If (TimeFromMark(T) > 35000) or (InvFull) then
begin
BankTheLootFailsafe;
end
else
if TimeFromMark(T) > 60000 then
begin
Writeln('error 18');
Logout;
TerminateScript;
end
else
end;

procedure BankTheLoot;

var
T, x, y: Integer;
status: string;
ToBank: TPointArray;

begin
MarkTime(T);
begin
FindNormalRandoms;
GameTab(26);
if WearingItem(11) then
begin
MouseEquippedItem('ring', MOUSE_RIGHT);
ChooseOption('aemon');
Wait(RandomRange(9000,11000));
end;
end;
begin
SPS_Setup(RUNESCAPE_SURFACE,['13_4']);

ToBank:=[Point(5576, 1811), Point(5587, 1802), Point(5590, 1792), Point(5591, 1777), Point(5592, 1763), Point(5591, 1748), Point(5590, 1735), Point(5589, 1723)];
if SPS_WalkPath(ToBank) then
Status := 'ToBank'
else
begin
Status :='BankTheLoot';
BankTheLoot;
end;
end;
begin
AntiBan;
WaitNotMoving(true);
if FindObj (x, y, 'remennik', 8276535, 40) then
begin
Mouse(x, y, 2, 2, false);
ChooseOption('Bank');
wait(Randomrange(1500,2000));
if BankScreen then
DepositAll;
wait(RandomRange(500,1000));
CloseBank;
end;
If (TimeFromMark(T) > 35000) or (InvFull = True) then
begin
BankTheLoot;
end
else
end;
end;

procedure MainLoop;
begin
if (InvFull = True) then
begin
BankTheLoot;
ProgressReport;
end;
repeat
TeleVarrock;
WalkToPotatos;
Main;
repeat
FindPotato;
until (InvFull = True)
BankTheLoot;
ProgressReport;
until (LoggedIn = False)
end;

Begin
Setup;
MainLoop;
End.

JuKKa

2013-06-05 14:40:05



Function FindPotato : Boolean; //Credits to Kasi for showing me how to split
//TPAs to reduce the amount of total points
//and find the point closest to player first.
//This makes the script look much more human
//like and increased the speed a good bit. I
//really appreciate it!
var
I, T, TimesFailed : integer;
PotatoTPA : TPointArray;
Potato2DTPA : T2DPointArray;
TB : TBox;
begin
FindNormalRandoms;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.05, 0.14);
FindColorsTolerance(PotatoTPA, 3828053, MSX1, MSY1, MSX2, MSY2, 5);
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
SplitTPAExWrap(PotatoTPA, 15, 15, Potato2DTPA);
SetLength(PotatoTPA, 0);
for I := 0 to High(Potato2DTPA) do
begin
TB := GetTPABounds(Potato2DTPA[I]);
if ((iAbs(TB.X1 - TB.X2) > 8) and (iAbs(TB.Y1 - TB.Y2) > 8) and
(iAbs(TB.X1 - TB.X2) < 40) and (iAbs(TB.Y1 - TB.Y2) < 40))
then
CombineTPAWrap(PotatoTPA, [MiddleTPA(Potato2DTPA[I])], PotatoTPA);
end;
SortTPAFrom(PotatoTPA, Point(MSCx, MSCy));
MarkTime(T);
for i := 0 to High(PotatoTPA) do
begin
MMouse(PotatoTPA[I].x, PotatoTPA[I].y, 1, 1);
if waituptext('Pick', 100) then
begin
ClickMouse2(mouse_Left);
if (DidRedClick) then
begin
Inc(PotatosPicked);
Result := True;
WaitNotMoving(True);
Wait(RandomRange(200,300));
ProgressReport;
end else
if (DidYellowClick) then
begin
WaitNotMoving(True);
ProgressReport;
end;
end else
begin
if TimeFromMark(T) > 3000 then //<-- might want to add a bit more time here, idk
begin
Inc(TimesFailed);
if TimesFailed >= 3 then
begin
WalkToPotatos;
AntiBan;
TimesFailed := 0;
end;
end;
if TimeFromMark(T) > 30000 then
begin
WalkToPotatos;
end;
end;
end;
end;
i didnt actually test i just noticed u had a potential endless loop there. I removed it. Hope it works.
i saw some more endless loops in the script ill help more if u need try that first see how it goes.

rotchy1

2013-06-05 14:59:08

From: JuKKa


Function FindPotato : Boolean; //Credits to Kasi for showing me how to split
//TPAs to reduce the amount of total points
//and find the point closest to player first.
//This makes the script look much more human
//like and increased the speed a good bit. I
//really appreciate it!
var
I, T, TimesFailed : integer;
PotatoTPA : TPointArray;
Potato2DTPA : T2DPointArray;
TB : TBox;
begin
FindNormalRandoms;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.05, 0.14);
FindColorsTolerance(PotatoTPA, 3828053, MSX1, MSY1, MSX2, MSY2, 5);
SetColorToleranceSpeed(1);
SetToleranceSpeed2Modifiers(0.02, 0.02);
SplitTPAExWrap(PotatoTPA, 15, 15, Potato2DTPA);
SetLength(PotatoTPA, 0);
for I := 0 to High(Potato2DTPA) do
begin
TB := GetTPABounds(Potato2DTPA[I]);
if ((iAbs(TB.X1 - TB.X2) > 8) and (iAbs(TB.Y1 - TB.Y2) > 8) and
(iAbs(TB.X1 - TB.X2) < 40) and (iAbs(TB.Y1 - TB.Y2) < 40))
then
CombineTPAWrap(PotatoTPA, [MiddleTPA(Potato2DTPA[I])], PotatoTPA);
end;
SortTPAFrom(PotatoTPA, Point(MSCx, MSCy));
MarkTime(T);
for i := 0 to High(PotatoTPA) do
begin
MMouse(PotatoTPA[I].x, PotatoTPA[I].y, 1, 1);
if waituptext('Pick', 100) then
begin
ClickMouse2(mouse_Left);
if (DidRedClick) then
begin
Inc(PotatosPicked);
Result := True;
WaitNotMoving(True);
Wait(RandomRange(200,300));
ProgressReport;
end else
if (DidYellowClick) then
begin
WaitNotMoving(True);
ProgressReport;
end;
end else
begin
if TimeFromMark(T) > 3000 then //<-- might want to add a bit more time here, idk
begin
Inc(TimesFailed);
if TimesFailed >= 3 then
begin
WalkToPotatos;
AntiBan;
TimesFailed := 0;
end;
end;
if TimeFromMark(T) > 30000 then
begin
WalkToPotatos;
end;
end;
end;
end;
i didnt actually test i just noticed u had a potential endless loop there. I removed it. Hope it works.
i saw some more endless loops in the script ill help more if u need try that first see how it goes.


Will try soon as I get another free minute! Thanks!

EDIT: Seems to be working ok now, Thanks! I went through and tried to fix all the infinite loops, they must have been causing the error.