SRL Archive - OSR Help

Why is the function coming back true...


Roflme

2012-11-04 09:37:42

program RoflmeRimmingtonMine;

{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}

const
WaitForHowLong = 4000; // Milliseconds waited for script to try mining again.
// Increase if your mining is low leveled.
var
x, y, HomeTele, PortSarim, TeleportCheck:Integer;


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;


procedure SetDTMs;
begin
HomeTele := DTMFromString('mbQAAAHicY2VgYGBngAAQzQel2bGI7zvyiaFtzg2GlXufgmkQlgOKo2NGLBgMAIhLC5Q=');
PortSarim := DTMFromString('mggAAAHicY2NgYOAAYi4gZgVidiDmZ4AACSDmhmIQEIRiGWk5OL62hZPBzc0djDmBctgwIw4MAQBP+AT4');
end;


procedure AntiBan;
begin
Case Random(6000) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..5999: Wait(50);
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(50+Random(20));
end;


function ClickCompassNorth:boolean;
var
d: Integer;
begin
Mouse(543, 33, 10, 2, mouse_left);
Wait(200+random(20));
for d := 0 to 5 do
if rs_GetCompassAngleDegrees = d then
begin
Result := True;
Writeln('Successfully changed Compass');
end;
SetAngle(SRL_ANGLE_HIGH);
end;


function OreColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.01, 2.27);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 6730204, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) 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
Exit;
end;


function SnowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.49, 1.84);

if not (FindColorsTolerance(arP, 14473666, MMX1, MMY1, MMX2, MMY2, 35)) 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
Exit;

end;


function GoFindObj(Color, Tol: Integer; ObjText: string): Boolean;
var
CTS, I, N: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.7, 0.2);
For N := 0 to 1 do
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol) then
Exit;
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 3, 3);
FilterTPADist(TPA, 3);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(50+random(10));
If IsUpText(ObjText) then
begin
Result := True
Writeln('Found Object');
Break;
end;
end;
end;


procedure MineClay;
var
MineWait, PlusOne:Integer;
begin
Writeln('Time to start mining!');
MakeCompass('45');
repeat
if InvFull then
Exit;

PlusOne := InvCount + 1

if GoFindObj(OreColor, 1, 'lay') then
begin
ClickMouse2(true);
MarkTime(MineWait);
end;

repeat
Wait(50+random(10));
until (TimeFromMark(MineWait) > WaitForHowLong) or (InvCount = PlusOne);

until(InvFull);
Exit;
end;



function isTeleporting:boolean;
var
Shift:integer;
YourBox: TBox;
begin
YourBox := PointToBox(Point(MSCX-17, MSCY-11),Point(MSCX+10,MSCY+30));
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 300 then
begin
Result := True;
Writeln('Teleporting');
end else
Exit;
Wait(100);
end;
end;


function DaemonheimCheck:integer;
begin
Result := CountColorTolerance(SnowColor, MMCX-40, MMCY-40, MMCX+40, MMCY+40, 35);
Writeln(Result);
end;


function isDaemonheim:boolean;
begin
if DaemonheimCheck > 200 then
begin
Result := True;
Writeln('At Daemonheim');
end;
end;


procedure StartTeleportDaemonheim;
begin
GameTab(tab_Equip);
MouseTBox(GetEquippedItemBounds('ring'), mouse_right);
ChooseOptionMulti(['Teleport',' to Daemonheim', 'Daemonheim', 'Daemon', 'Telepor', 'rt to Dae', 'monheim']);
end;


function CheckTeleportDaemonheim:boolean;
begin

if isDaemonheim then
begin
Result := True;
Exit;
end else

MarkTime(TeleportCheck);
repeat
if isTeleporting then
Break;
Writeln('Checking');
until(TimeFromMark(TeleportCheck) > 4000) or isDaemonheim;

if TimeFromMark(TeleportCheck) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportDaemonheim;
CheckTeleportDaemonheim;
Exit;
end;
end;


function WalkToBank:boolean;
var
myPath:TPointArray;
begin
ClickCompassNorth;

SPS_Setup(RUNESCAPE_SURFACE, ['13_3', '13_4', '14_3', '14_4']);
myPath := [Point(5637, 1819), Point(5637, 1768)]
SPS_WalkPath(myPath);

repeat
Wait(50+random(10));
until not isMoving

if FindSymbol(x, y, 'bank') then
begin
Result := True;
Writeln('At the bank');
end;

if not FindSymbol(x, y, 'bank') then
begin
Writeln('Messed up walking, will try again');
StartTeleportDaemonheim;
CheckTeleportDaemonheim;
WalkToBank;
end;
end;


function FremennikBank:boolean;
begin
repeat
if FindObjTPA(x, y, 6242869, 18, 2, 4, 4, 15, ['Fremen', 'banker', 'ik bank']) then
begin
Mouse(x, y, 1, 1, False);
WaitOption('Bank', 1000);
Wait(1000)
end;

until BankScreen or PinScreen;

if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen
end;

if BankScreen then
Result := True;
repeat
DepositAll;
Wait(300+random(30));
until InvCount=0
CloseBank;

end;


procedure StartTeleportPortSarim;
begin
GameTab(tab_Magic);
if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 3, 3, mouse_left);
Wait(600+random(70));
repeat
if FindDTM(PortSarim, x, y, MSX1, MSY1, MSX2, MSY2) then
Mouse(x, y, 2, 4, mouse_left);
wait(1000+random(100));
until not LodestoneScreen;
end;


function isPortSarim:boolean;
begin
if FindSymbol(x, y, 'lodestone') then
begin
Result := True;
end;
end;


function CheckTeleportPortSarim:boolean;
begin

if isPortSarim then
begin
Result := True;
Exit;
end else

MarkTime(TeleportCheck);
repeat
if isTeleporting then
Break;
Writeln('Checking');
until(TimeFromMark(TeleportCheck) > 4000) or isPortSarim;

if TimeFromMark(TeleportCheck) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportPortSarim;
CheckTeleportPortSarim;
Exit;
end;
end;


function WalkToMine:boolean;
var
myPath:TPointArray;
begin
if IsPortSarim then
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 172), Point(227, 142), Point(204, 97), Point(167, 83), Point(146, 115)];
SPS_WalkPath(myPath);

if FindSymbol(x, y, 'mine') then
begin
Result := True;
end;
end;
end;


begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(40);
LoginPlayer;
ClickCompassNorth;
SetDTMs;
repeat
Writeln('Going to get to mine');
StartTeleportPortSarim;
Writeln('Making sure everything is working');
CheckTeleportPortSarim;
Writeln('Successfully teleported to Port Sarim, going mine');
WalkToMine;
Writeln('Successfully walked to mine, mining some clay');
MineClay;
Writeln('Full invo, banking');
StartTeleportDaemonheim;
Writeln('Making sure teleport to Daemonheim is going as planned');
CheckTeleportDaemonheim;
Writeln('At Daemonhiem successfully, going to bank');
WalkToBank;
Writeln('Found bank, banking');
FremennikBank;
until(false);
end.

Working on this new project starting with getting a working Rimmington miner.

Wherever I start the script, it'll start teleporting but then it'll say

Successfully teleported to Port Sarim, going mine
Successfully walked to mine, mining some clay
Time to start mining!

Which means CheckTeleportPortSarim is coming back true? Even when I start it in the middle of nowhere…

And then WalkToMine is coming back true as well??

Why??? What am I doing wrong…


(Ignore the banking procedures, they're just temporary. I just want it to be able to teleport, walk to mine, and get a full inventory first.)

xtrapsp

2012-11-04 10:35:32

Have you considered adding a waiting failsafe?

also you have an if but no else, that can create and alternative to it ending the function :)

JPHamlett

2012-11-04 11:05:47

It'll return true, if there is a lodestone on the minimap, just a quick glance though

Roflme

2012-11-04 14:08:39

From: xtrapsp
Have you considered adding a waiting failsafe?

also you have an if but no else, that can create and alternative to it ending the function :)


I originally had waiting failsafes, but I wanted to try not to use them as I dislike them greatly. Perhaps I'll incorporate them into the functions though. (Have it wait the time it takes to teleport, THEN check for the symbols, and if it can't find the symbols then just retry the teleport again).

From: JPHamlett
It'll return true, if there is a lodestone on the minimap, just a quick glance though


I was making sure there was nothing else nearby. I stood where there were NO symbols on the minimap :(

J J

2012-11-04 14:22:07

So you are talking about these two
function isPortSarim:boolean;
begin
if FindSymbol(x, y, 'lodestone') then
begin
Result := True;
end;
end;


function CheckTeleportPortSarim:boolean;
begin

if isPortSarim then
begin
Result := True;
Exit;
end else

MarkTime(TeleportCheck);
repeat
if isTeleporting then
Break;
Writeln('Checking');
until(TimeFromMark(TeleportCheck) > 4000) or isPortSarim;

if TimeFromMark(TeleportCheck) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportPortSarim;
CheckTeleportPortSarim;
Exit;
end;
end;


function WalkToMine:boolean;
var
myPath:TPointArray;
begin
if IsPortSarim then
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 172), Point(227, 142), Point(204, 97), Point(167, 83), Point(146, 115)];
SPS_WalkPath(myPath);

if FindSymbol(x, y, 'mine') then
begin
Result := True;
end;
end;
end;

Your logic is off in quite a lot functions so I rewrote them a bit. Also using unnecessary global variables.

function isPortSarim: boolean;
begin
Result := FindSymbol(X, Y, 'lodestone');
end;

function CheckTeleportPortSarim: boolean;
var
T: Integer;

begin
if not(isPortSarim) then
begin
MarkTime(T);
while not(isPortSarim) do
begin
if TimeFromMark(T) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportPortSarim;
CheckTeleportPortSarim;
Exit;
end;

if isTeleporting then
break;
end;
end;

Result := True;
end;

function WalkToMine: boolean;
var
myPath:TPointArray;

begin
if IsPortSarim then
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 172), Point(227, 142), Point(204, 97), Point(167, 83), Point(146, 115)];
SPS_WalkPath(myPath);

if FindSymbol(x, y, 'mine') then
Result := True;
end;
end;


Also this one you can make ClickCompassNorth like this. But I don't really understand what you are doing, you could just use ClickNorth(SRL_ANGLE_HIGH)?
function ClickCompassNorth:boolean;
var
D: Extended;

begin
Mouse(543, 33, 10, 2, mouse_left);
Wait(200+random(20));

d := rs_GetCompassAngleDegrees;
Result := (d > -5) and (d < 5);

Writeln('Changed compass succesfully? ' + BoolToStr(Result));

SetAngle(SRL_ANGLE_HIGH);
end;

Anyways for your main question:
Successfully teleported to Port Sarim, going mine
Successfully walked to mine, mining some clay
Time to start mining!

You aren't using if statements so it is going to print all times. Use if statements to see if you actually performed this.

Some of your logic is messed up, I suggest writing a new script from scratch looking at your current code. Then step by step you can finish the script, starting with the mining. Once that works fine, move on to the walking, etc.

Roflme

2012-11-04 14:33:37

From: J J
So you are talking about these two
function isPortSarim:boolean;
begin
if FindSymbol(x, y, 'lodestone') then
begin
Result := True;
end;
end;


function CheckTeleportPortSarim:boolean;
begin

if isPortSarim then
begin
Result := True;
Exit;
end else

MarkTime(TeleportCheck);
repeat
if isTeleporting then
Break;
Writeln('Checking');
until(TimeFromMark(TeleportCheck) > 4000) or isPortSarim;

if TimeFromMark(TeleportCheck) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportPortSarim;
CheckTeleportPortSarim;
Exit;
end;
end;


function WalkToMine:boolean;
var
myPath:TPointArray;
begin
if IsPortSarim then
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 172), Point(227, 142), Point(204, 97), Point(167, 83), Point(146, 115)];
SPS_WalkPath(myPath);

if FindSymbol(x, y, 'mine') then
begin
Result := True;
end;
end;
end;

Your logic is off in quite a lot functions so I rewrote them a bit. Also using unnecessary global variables.

function isPortSarim: boolean;
begin
Result := FindSymbol(X, Y, 'lodestone');
end;

function CheckTeleportPortSarim: boolean;
var
T: Integer;

begin
if not(isPortSarim) then
begin
MarkTime(T);
while not(isPortSarim) do
begin
if TimeFromMark(T) > 4000 then
begin
Writeln('Time is past 4 seconds');
StartTeleportPortSarim;
CheckTeleportPortSarim;
Exit;
end;

if isTeleporting then
break;
end;
end;

Result := True;
end;

function WalkToMine: boolean;
var
myPath:TPointArray;

begin
if IsPortSarim then
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 172), Point(227, 142), Point(204, 97), Point(167, 83), Point(146, 115)];
SPS_WalkPath(myPath);

if FindSymbol(x, y, 'mine') then
Result := True;
end;
end;


Also this one you can make ClickCompassNorth like this. But I don't really understand what you are doing, you could just use ClickNorth(SRL_ANGLE_HIGH)?
function ClickCompassNorth:boolean;
var
D: Extended;

begin
Mouse(543, 33, 10, 2, mouse_left);
Wait(200+random(20));

d := rs_GetCompassAngleDegrees;
Result := (d > -5) and (d < 5);

Writeln('Changed compass succesfully? ' + BoolToStr(Result));

SetAngle(SRL_ANGLE_HIGH);
end;

Anyways for your main question:
Successfully teleported to Port Sarim, going mine
Successfully walked to mine, mining some clay
Time to start mining!

You aren't using if statements so it is going to print all times. Use if statements to see if you actually performed this.

Some of your logic is messed up, I suggest writing a new script from scratch looking at your current code. Then step by step you can finish the script, starting with the mining. Once that works fine, move on to the walking, etc.


Didn't know ClickNorth existed so that's why I made that :p

I had a feeling some of my logic was off. I've been working on this half asleep and in a rush :(. Your changes look much nicer :p

And I just checked the tutorials and found the global variables. Still trying to understand how they're used :( Like, how would I go about going to the top of the function? I don't like calling the function within itself in case of infinite loops. How would I go to the start of CheckTeleport without calling the function?

Thank you for those changes. I'll use them as references :D

J J

2012-11-04 15:21:52

Just make isDaemonheim a color tolerance 1 color count. Use auto color aid to get the best color/tolerance.

Like this
function AtDaemonheim: boolean;
begin
Result := CountColorTolerance(12345, MMCX-50, MMCY-50, MMCX+50, MMCY+50) > 500;
end;

Writing the function, something like this.
It will break out of the while loop if it is at daemonheim OR if the time has greater than 10 seconds. So you can easily reverse engineer if you are at daemonheim: if the time is < 10 seconds then you must be at daemonheim.

function CheckTeleportDaemonheim: boolean;
var
T: Integer;

begin
if not(AtDaemonheim) then
begin
MarkTime(T);
while ((TimeFromMark(T) < 10000) and not(AtDaemonheim)) do
begin
// Teleport there
// Wait until teleport has finished
end;
Result := TimeFromMark(T) < 10000;
end;
end;

Global variables are only used if you need to keep track of something in multiple procedures. Like counting the ores you have mined and displaying the ores in a paint. You need to inc(ores) when you mined one and need the variable to display the ores in the paint.

Roflme

2012-11-04 16:41:56

Gah, so it will wait until T>10 AND for AtDaemonheim to be true…

So then what if the teleport there doesn't work, after the wait until teleport is finished, because it still is not AtDaemonheim it'll repeat that?


And I'm confused by Result := <10 seconds? What if the mark goes beyond 10 seconds?

J J

2012-11-04 16:46:28

From: Roflme
Gah, so it will wait until T>10 AND for AtDaemonheim to be true…

So then what if the teleport there doesn't work, after the wait until teleport is finished, because it still is not AtDaemonheim it'll repeat that?


And I'm confused by Result := <10 seconds? What if the mark goes beyond 10 seconds?

It's an and statement.
While the statement is true do this

while ((TimeFromMark(T) < 10000) and not(AtDaemonheim)) do
is timefrom mark < 10000? true
are we NOT at daemonheim? true
-> true and true = true -> we go on

is time from mark < 10000? false
are we not at daemonheim? true
false and false -> false -> we stop the loop
time from mark is > 10000 so the result is false

is time from mark < 10000? true
are we not at daemonheim? false
true & false -> false -> we stop the loop
time from mark is < 10000 so the result is true

Roflme

2012-11-04 22:24:33

Inc wall of text.



THANK YOU SO MUCH

That really helped me understand :p

I made some changes… still playing around with it as I make this post but…


function TeleportPortSarim:boolean;
var
TtoP:Integer;
begin
if not isPortSarim then
begin
GameTab(tab_Magic);
if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 2, 2, mouse_left);

Wait(1000+random(100));

if FindDTM(PortSarim, x, y, MSX1, MSY1, MSX2, MSY2) then
Mouse(x, y, 2, 2, mouse_left);

Wait(500+random(100));
MarkTime(TtoP);
while not isPortSarim do
begin
if TimeFromMark(TtoP) > 4000 then
begin
if isTeleporting then
break;
TeleportPortSarim;
end;
end;
end;

Result := True;
end;

function isPortSarim:boolean;
begin
Result := FindSymbol(x, y, 'lodestone');
end;

function isTeleporting:boolean;
var
Shift:integer;
YourBox: TBox;
begin
YourBox := PointToBox(Point(MSCX-17, MSCY-11),Point(MSCX+10,MSCY+30));
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 100 then
begin
Result := True;
Writeln('Teleporting');
end else
Exit;
Wait(100);
end;
end;

What's wrong with my logic now :fiery:

Script as a whole:
program RoflmeRimmingtonMine;

{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}

const
WaitForHowLong = 4000; // Milliseconds waited for script to try mining again.
// Increase if your mining is low leveled.
var
x, y, HomeTele, PortSarim:Integer;


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;

procedure SetDTMs;
begin
HomeTele := DTMFromString('mbQAAAHicY2VgYGBngAAQzQel2bGI7zvyiaFtzg2GlXufgmkQlgOKo2NGLBgMAIhLC5Q=');
PortSarim := DTMFromString('mggAAAHicY2NgYOAAYi4gZgVidiDmZ4AACSDmhmIQEIRiGWk5OL62hZPBzc0djDmBctgwIw4MAQBP+AT4');
end;

procedure FreeDTMZ;
begin
FreeDTM(HomeTele);
FreeDTM(PortSarim);
end;

procedure AntiBan;
begin
Case Random(6000) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..5999: Wait(50);
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(50+Random(20));
end;

function SnowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.49, 1.84);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 14473666, MMX1, MMY1, MMX2, MMY2, 13);
if (Length(arP) = 0) 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
Exit;
end;

function BankerColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.09, 0.70);

if not (FindColorsTolerance(arP, 7359036, MSX1, MSY1, MSX2, MSY2, 15)) 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
Exit;
end;

function OreColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.01, 2.27);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 6730204, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) 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
Exit;
end;

function GoFindObj(Color, Tol: Integer): Boolean;
var
CTS, I, N: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.7, 0.2);
For N := 0 to 1 do
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol) then
Exit;
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 3, 3);
FilterTPADist(TPA, 3);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(50+random(10));
If IsUpTextMultiCustom(['Clay', 'rocks', 'Mine Clay rocks', 'lay roc', 'rocks', 'lay r', 'Mine Cla']) then
begin
Result := True
Writeln('Found Object');
Break;
end;
end;
end;

function WalkToMine:boolean;
var
myPath:TPointArray;
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 165), Point(223, 114), Point(186, 84), Point(141, 119)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

Result := FindSymbol(x, y, 'mine');
end;

procedure MineClay;
var
MineWait, PlusOne:Integer;
begin
Writeln('Time to start mining!');
repeat
if InvFull then
Exit;

PlusOne := InvCount + 1

if GoFindObj(OreColor, 1) then
begin
ClickMouse2(true);
MarkTime(MineWait);
end;

repeat
Wait(50+random(10));
until (TimeFromMark(MineWait) > WaitForHowLong) or (InvCount = PlusOne);

until(InvFull);
Exit;
end;

function isTeleporting:boolean;
var
Shift:integer;
YourBox: TBox;
begin
YourBox := PointToBox(Point(MSCX-17, MSCY-11),Point(MSCX+10,MSCY+30));
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 100 then
begin
Result := True;
Writeln('Teleporting');
end else
Exit;
Wait(100);
end;
end;

function isPortSarim:boolean;
begin
Result := FindSymbol(x, y, 'lodestone');
end;




function TeleportPortSarim:boolean;
var
TtoP:Integer;
begin
if not isPortSarim then
begin
GameTab(tab_Magic);
if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 2, 2, mouse_left);

Wait(1000+random(100));

if FindDTM(PortSarim, x, y, MSX1, MSY1, MSX2, MSY2) then
Mouse(x, y, 2, 2, mouse_left);

Wait(500+random(100));
MarkTime(TtoP);
while not isPortSarim do
begin
if TimeFromMark(TtoP) > 4000 then
begin
if isTeleporting then
break;
TeleportPortSarim;
end;
end;
end;

Result := True;
end;

function isDaemonheim:boolean;
begin
Result := CountColorTolerance(SnowColor, MMX1, MMY1, MMX2, MMY2, 10) > 300;
if Result then
Writeln('At Daemonheim');
end;

function TeleportDaemonheim:boolean;
var
TtoD:Integer;
begin

if not (isDaemonheim) then
begin
Writeln('Teleporting Daemonheim');
GameTab(tab_Equip);
MouseEquippedItem('ring', mouse_right);
ChooseOptionMulti(['Daemonheim', 'aemon', 'Teleport', 'eleport to', 'to Dae', 'port t', 'to Daemon']);
MarkTime(TtoD);
while not (isDaemonheim) do
begin
if TimeFromMark(TtoD) > 4000 then
begin
if not isTeleporting then
begin
if isDaemonheim then
Exit;

TeleportDaemonheim;
Writeln('Not teleporting correct, retrying');
end;
end;
end;
end;

Result := True;

end;

function WalkToBank:boolean;
var
myPath:TPointArray;
begin
Wait(5000+random(1000));

SPS_Setup(RUNESCAPE_SURFACE, ['13_3', '13_4', '14_3', '14_4']);
myPath := [Point(5635, 1807), Point(5634, 1777)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

if not FindSymbol(x, y, 'bank') then
begin
TeleportDaemonheim;
WalkToBank;
Exit;
end;

Result := True;
end;

function FremennikBank:boolean;
begin
repeat
if FindObjTPA(x, y, BankerColor, 4, 3, 5, 5, 15, ['Fremen', 'banker', 'ik bank']) then
begin
Mouse(x, y, 1, 1, False);
WaitOption('Bank', 1000);
Wait(1000)
end;
until BankScreen or PinScreen;

if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen
end;

if BankScreen then
Result := True;
repeat
DepositAll;
Wait(300+random(30));
until InvCount=0
CloseBank;
end;

begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(40);
LoginPlayer;
ClickNorth(SRL_ANGLE_HIGH);
SetDTMs;
repeat
TeleportPortSarim;
WalkToMine;
MineClay;
TeleportDaemonheim;
WalkToBank;
FremennikBank;
until(false);
FreeDTMZ;
end.


It completed one loop, but now it teleported to port sarim, froze up for a few seconds, and then thought it was at the mine.

Where did my logic get messed up?



EDIT: And when I just run TeleportPortSarim and WalkToMine it works fine :(





EDIT2: Trying another loop with a few changes… strange I can get it to keep working… I believe it just messed up that one time.







EDIT3: It's having a problem when it tries to repeat the loop again. It can teleport successfully the first time, but after banking and returning to Port Sarim it messes up.

J J

2012-11-05 02:59:38

Edited TeleportPortSarim and made a new function to make sure we get to Port Sarim
// Switches to the magic tab
function TeleportPortSarim:boolean;
var
TtoP:Integer;
begin
if not isPortSarim then
begin
// If our tab is not the magic tab, then switch to the magic tab
if not GameTab(tab_Magic) then
begin
GameTab(tab_Magic);
Wait(RandomRange(500, 1000));
end;

// Find the home teleport, click on it, wait for lodestone screen
// Then once we are at the lodestone screen click on port sarim
if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 2, 2, mouse_left);
if WaitFunc(@LodestoneScreen, 50, 1500) then
if LodestoneTeleport('port sarim') then
begin
// We are now teleporting to port sarim, waiting until we have arrived
MarkTime(TtoP);
while(TimeFromMark(TtoP) < 20000) do
begin
if isPortSarim then
break;
Wait(RandomRange(200, 600));
end;
// If we find the lodestone DTM before 20 seconds have past we
// must be at Port Sarim due to the loop
Result := TimeFromMark(TtoP) < 20000;
end;
end;
end;
end;

function GetToPortSarim: boolean;
var
T: Integer;

begin
MarkTime(T);

// While we are not at port sarim, try to get there
while not(isPortSarim) do
begin
// iF we have waited for longer than 1 minute break
if TimeFromMark(T) > 60000 then
break;

// If we managed to get at port sarim, break
if TeleportPortSarim then
break;

// We wait a bit to save CPU and see what happens
Wait(RandomRange(500, 1000));
end;

// If we broke out the loop before 1 minute time then we must be at Port Sarim
Result := TimeFromMark(T) < 60000;
end;

Also edited the mainloop as seen in the full script
program RoflmeRimmingtonMine;

{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}

const
WaitForHowLong = 4000; // Milliseconds waited for script to try mining again.
// Increase if your mining is low leveled.
var
x, y, HomeTele, PortSarim:Integer;


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;

procedure SetDTMs;
begin
HomeTele := DTMFromString('mbQAAAHicY2VgYGBngAAQzQel2bGI7zvyiaFtzg2GlXufgmkQlgOKo2NGLBgMAIhLC5Q=');
PortSarim := DTMFromString('mggAAAHicY2NgYOAAYi4gZgVidiDmZ4AACSDmhmIQEIRiGWk5OL62hZPBzc0djDmBctgwIw4MAQBP+AT4');
end;

procedure FreeDTMZ;
begin
FreeDTM(HomeTele);
FreeDTM(PortSarim);
end;

procedure AntiBan;
begin
Case Random(6000) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..5999: Wait(50);
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(50+Random(20));
end;

function SnowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.49, 1.84);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 14473666, MMX1, MMY1, MMX2, MMY2, 13);
if (Length(arP) = 0) 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
Exit;
end;

function BankerColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.09, 0.70);

if not (FindColorsTolerance(arP, 7359036, MSX1, MSY1, MSX2, MSY2, 15)) 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
Exit;
end;

function OreColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.01, 2.27);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 6730204, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) 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
Exit;
end;

function GoFindObj(Color, Tol: Integer): Boolean;
var
CTS, I, N: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.7, 0.2);
For N := 0 to 1 do
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol) then
Exit;
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 3, 3);
FilterTPADist(TPA, 3);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(50+random(10));
If IsUpTextMultiCustom(['Clay', 'rocks', 'Mine Clay rocks', 'lay roc', 'rocks', 'lay r', 'Mine Cla']) then
begin
Result := True
Writeln('Found Object');
Break;
end;
end;
end;

function WalkToMine:boolean;
var
myPath:TPointArray;
begin
SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 165), Point(223, 114), Point(186, 84), Point(141, 119)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

Result := FindSymbol(x, y, 'mine');
end;

procedure MineClay;
var
MineWait, PlusOne:Integer;
begin
Writeln('Time to start mining!');
repeat
if InvFull then
Exit;

PlusOne := InvCount + 1

if GoFindObj(OreColor, 1) then
begin
ClickMouse2(true);
MarkTime(MineWait);
end;

repeat
Wait(50+random(10));
until (TimeFromMark(MineWait) > WaitForHowLong) or (InvCount = PlusOne);

until(InvFull);
Exit;
end;

function isTeleporting:boolean;
var
Shift:integer;
YourBox: TBox;
begin
YourBox := PointToBox(Point(MSCX-17, MSCY-11),Point(MSCX+10,MSCY+30));
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 100 then
begin
Result := True;
Writeln('Teleporting');
end else
Exit;
Wait(100);
end;
end;

function isPortSarim:boolean;
begin
Result := FindSymbol(x, y, 'lodestone');
end;

// Switches to the magic tab
function TeleportPortSarim:boolean;
var
TtoP:Integer;
begin
if not isPortSarim then
begin
// If our tab is not the magic tab, then switch to the magic tab
if not GameTab(tab_Magic) then
begin
GameTab(tab_Magic);
Wait(RandomRange(500, 1000));
end;

// Find the home teleport, click on it, wait for lodestone screen
// Then once we are at the lodestone screen click on port sarim
if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 2, 2, mouse_left);
if WaitFunc(@LodestoneScreen, 50, 1500) then
if LodestoneTeleport('port sarim') then
begin
// We are now teleporting to port sarim, waiting until we have arrived
MarkTime(TtoP);
while(TimeFromMark(TtoP) < 20000) do
begin
if isPortSarim then
break;
Wait(RandomRange(200, 600));
end;
// If we find the lodestone DTM before 20 seconds have past we
// must be at Port Sarim due to the loop
Result := TimeFromMark(TtoP) < 20000;
end;
end;
end;
end;

function GetToPortSarim: boolean;
var
T: Integer;

begin
MarkTime(T);

// While we are not at port sarim, try to get there
while not(isPortSarim) do
begin
// iF we have waited for longer than 1 minute break
if TimeFromMark(T) > 60000 then
break;

// If we managed to get at port sarim, break
if TeleportPortSarim then
break;

// We wait a bit to save CPU and see what happens
Wait(RandomRange(500, 1000));
end;

// If we broke out the loop before 1 minute time then we must be at Port Sarim
Result := TimeFromMark(T) < 60000;
end;

function isDaemonheim:boolean;
begin
Result := CountColorTolerance(SnowColor, MMX1, MMY1, MMX2, MMY2, 10) > 300;
if Result then
Writeln('At Daemonheim');
end;

function TeleportDaemonheim:boolean;
var
TtoD:Integer;
begin

if not (isDaemonheim) then
begin
Writeln('Teleporting Daemonheim');
GameTab(tab_Equip);
MouseEquippedItem('ring', mouse_right);
ChooseOptionMulti(['Daemonheim', 'aemon', 'Teleport', 'eleport to', 'to Dae', 'port t', 'to Daemon']);
MarkTime(TtoD);
while not (isDaemonheim) do
begin
if TimeFromMark(TtoD) > 4000 then
begin
if not isTeleporting then
begin
if isDaemonheim then
Exit;

TeleportDaemonheim;
Writeln('Not teleporting correct, retrying');
end;
end;
end;
end;

Result := True;

end;

function WalkToBank:boolean;
var
myPath:TPointArray;
begin
Wait(5000+random(1000));

SPS_Setup(RUNESCAPE_SURFACE, ['13_3', '13_4', '14_3', '14_4']);
myPath := [Point(5635, 1807), Point(5634, 1777)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

if not FindSymbol(x, y, 'bank') then
begin
TeleportDaemonheim;
WalkToBank;
Exit;
end;

Result := True;
end;

function FremennikBank:boolean;
begin
repeat
if FindObjTPA(x, y, BankerColor, 4, 3, 5, 5, 15, ['Fremen', 'banker', 'ik bank']) then
begin
Mouse(x, y, 1, 1, False);
WaitOption('Bank', 1000);
Wait(1000)
end;
until BankScreen or PinScreen;

if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen
end;

if BankScreen then
Result := True;
repeat
DepositAll;
Wait(300+random(30));
until InvCount=0
CloseBank;
end;

begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(40);
LoginPlayer;
ClickNorth(SRL_ANGLE_HIGH);
SetDTMs;
repeat
if GetToPortSarim then
begin
WalkToMine;
MineClay;
TeleportDaemonheim;
WalkToBank;
FremennikBank;
end;
until(false);
FreeDTMZ;
end.

Roflme

2012-11-05 06:50:17

Thank you so much J J! :D


For some reason LodestoneTeleport never works for me, I'll have to look at that function and see why it never works :(. It'll move to Port Sarim image but never click it.


I think I understand the logic there. The one thing I'm still a little confused about is what if TeleportPortSarim runs while you are at Port Sarim? That problem is solved with GetToPortSarim since you'll have marked the time BEFORE checking if it's in port sarim?




while(TimeFromMark(TtoP) < 20000) do
begin
if isPortSarim then
break;
Wait(RandomRange(200, 600));
end;
The break gets out of the While do loop right?

function GetToPortSarim: boolean;
var
T: Integer;

begin
MarkTime(T);

// While we are not at port sarim, try to get there
while not(isPortSarim) do
begin
// iF we have waited for longer than 1 minute break
if TimeFromMark(T) > 60000 then
break;

// If we managed to get at port sarim, break
if TeleportPortSarim then
break;

// We wait a bit to save CPU and see what happens
Wait(RandomRange(500, 1000));
end;

// If we broke out the loop before 1 minute time then we must be at Port Sarim
Result := TimeFromMark(T) < 60000;
end;
So while you aren't in port sarim it'll check if it's
1) Waited over a minute, if so it'll break which will cause it to run this function again according to the main loop?
2) Teleported to Port Sarim which wouldn't come true unless you actually are in Port Sarim?

And breaking out of the loop = it's true, you did get to Port Sarim = awesome.

Roflme

2012-11-05 09:01:04

program RoflmeRimmingtonMine;

{$DEFINE SMART}
{$i SRL/SRL.simba}
{$i SPS/SPS.simba}
{$i SRL/SRL/Misc/Debug.simba}
{$I SRL/SRL/Misc/Online.simba}

const
WaitForHowLong = 4000; // Milliseconds waited for script to try mining again.
// Increase if your mining is low leveled.
var
x, y, HomeTele, PortSarim:Integer;


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
With Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := true;
end;
end;

procedure SetDTMs;
begin
HomeTele := DTMFromString('mbQAAAHicY2VgYGBngAAQzQel2bGI7zvyiaFtzg2GlXufgmkQlgOKo2NGLBgMAIhLC5Q=');
PortSarim := DTMFromString('mggAAAHicY2NgYOAAYi4gZgVidiDmZ4AACSDmhmIQEIRiGWk5OL62hZPBzc0djDmBctgwIw4MAQBP+AT4');
end;

procedure FreeDTMZ;
begin
FreeDTM(HomeTele);
FreeDTM(PortSarim);
end;

procedure AntiBan;
begin
Case Random(6000) of
1: RandomRClick;
2: RandomMovement;
3..10: BoredHuman;
11..20: PickUpMouse;
21..5999: Wait(50);
end;
SetAngle(SRL_ANGLE_HIGH);
Wait(50+Random(20));
end;

function SnowColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.49, 1.84);

FindColorsSpiralTolerance(MMCX, MMCY, arP, 14473666, MMX1, MMY1, MMX2, MMY2, 13);
if (Length(arP) = 0) 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
Exit;
end;



function BankerColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.09, 0.70);

if not (FindColorsTolerance(arP, 7359036, MSX1, MSY1, MSX2, MSY2, 15)) 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
Exit;
end;



function OreColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.01, 2.27);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 6730204, MSX1, MSY1, MSX2, MSY2, 11);
if (Length(arP) = 0) 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
Exit;
end;



function GoFindObj(Color, Tol: Integer): boolean;
var
CTS, I, N: Integer;
TPA: TPointArray;
ATPA: Array of TPointArray;

begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.7, 0.2);
For N := 0 to 1 do
if not FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, MSX1, MSY1, MSX2, MSY2, Tol) then
Exit;
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(TPA, 2, 2);
FilterTPADist(TPA, 3);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 0, 0);
Wait(50+random(10));
If IsUpTextMultiCustom(['Clay', 'rocks', 'Mine Clay rocks', 'lay roc', 'rocks', 'lay r', 'Mine Cla']) then
begin
Result := True
Break;
end;
end;
end;



function isPortSarim: boolean;
begin
Result := FindSymbol(x, y, 'lodestone');
end;



function WalkToMine: boolean;
var
myPath:TPointArray;
begin
Result := FindSymbol(x, y, 'mine');

if Result then
Exit;

if not isPortSarim then
Exit;

SPS_Setup(RUNESCAPE_OTHER, ['rimmington']);
myPath := [Point(259, 165), Point(223, 114), Point(186, 84), Point(149, 126)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

if Result then
Exit;

end;



procedure MineClay;
var
MineWait, PlusOne:Integer;
begin
Writeln('Time to start mining!');
repeat
if WalkToMine then
begin

if InvFull then
Exit;


PlusOne := InvCount + 1

if GoFindObj(OreColor, 1) then
begin
Mouse(x, y, 2, 2, mouse_left);
MarkTime(MineWait);
end;

repeat
Wait(RandomRange(20,50));
until (TimeFromMark(MineWait) > WaitForHowLong) or (InvCount = PlusOne);

end;
until(InvFull);
Exit;
end;



function isTeleporting: boolean;
var
Shift:integer;
YourBox: TBox;
begin
YourBox := PointToBox(Point(MSCX-17, MSCY-11),Point(MSCX+10,MSCY+30));
begin
Shift := AveragePixelShift(YourBox, 400, 800);
if Shift > 100 then
begin
Result := True;
Writeln('Teleporting');
end else
Exit;
Wait(100);
end;
end;



function LodestonePortSarim: boolean;
begin
if FindDTM(PortSarim, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 2, 2, mouse_left);
Wait(RandomRange(600,800));
Result := not LodestoneScreen;
end;
end;



function TeleportPortSarim: boolean; // Credits to J J for fixing this up
var
TtoP:Integer;
begin
if not isPortSarim then
begin
if not GameTab(tab_Magic) then
begin
GameTab(tab_Magic);
Wait(RandomRange(500,1000));
end;

if FindDTM(HomeTele, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 2, 2, mouse_left);
if WaitFunc(@LodestoneScreen, 50, 1500) then
if LodestonePortSarim then
begin
MarkTime(TtoP);
while(TimeFromMark(TtoP) < 20000) do
begin
if isPortSarim then
break;
Wait(RandomRange(200,600));
end;
Result := TimeFromMark(TtoP) < 20000;
end;
end;
end;
end;



function GetToPortSarim: boolean; // Credits to J J for this function
var
T: Integer;
begin
MarkTime(T);

while not isPortSarim do
begin
if TimeFromMark(T) > 60000 then
break;

if TeleportPortSarim then
break;

Wait(RandomRange(500, 1000));
end;

Result := TimeFromMark(T) < 60000;
end;



function isDaemonheim:boolean;
begin
Result := CountColorTolerance(SnowColor, MMX1, MMY1, MMX2, MMY2, 10) > 300;
if Result then
Writeln('At Daemonheim');
end;



function TeleportDaemonheim:boolean;
var
TtoD:Integer;
begin

if not (isDaemonheim) then
begin
Writeln('Teleporting Daemonheim');
GameTab(tab_Equip);
MouseEquippedItem('ring', mouse_right);
ChooseOptionMulti(['Daemonheim', 'aemon', 'Teleport', 'eleport to', 'to Dae', 'port t', 'to Daemon']);
MarkTime(TtoD);
while not (isDaemonheim) do
begin
if TimeFromMark(TtoD) > 10000 then
begin
if not isTeleporting then
begin
if isDaemonheim then
Exit;

TeleportDaemonheim;
Writeln('Not teleporting correct, retrying');
end;
end;
end;
end;

Result := True;

end;



function WalkToBank:boolean;
var
myPath:TPointArray;
begin
Wait(5000+random(1000));

SPS_Setup(RUNESCAPE_SURFACE, ['13_3', '13_4', '14_3', '14_4']);
myPath := [Point(5635, 1807), Point(5634, 1777)];
SPS_WalkPath(myPath);

repeat
Wait(100+random(10));
until not isMoving;

if not FindSymbol(x, y, 'bank') then
begin
TeleportDaemonheim;
WalkToBank;
Exit;
end;

Result := True;
end;



function FremennikBank:boolean;
begin
repeat
if FindObjTPA(x, y, BankerColor, 4, 3, 5, 5, 15, ['Fremen', 'banker', 'ik bank']) then
begin
Mouse(x, y, 1, 1, False);
WaitOption('Bank', 1000);
Wait(1000)
end;
until BankScreen or PinScreen;

if PinScreen then
begin
repeat
InPin(Players[0].Pin);
until BankScreen
end;

if BankScreen then
Result := True;
repeat
DepositAll;
Wait(300+random(30));
until InvCount=0
CloseBank;
end;



begin
Cleardebug;
DeclarePlayers;
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
SmartSetRefresh(40);
LoginPlayer;
ClickNorth(SRL_ANGLE_HIGH);
SetDTMs;
repeat
if GetToPortSarim then
begin
Wait(RandomRange(4000,6000));
WalkToMine;
MineClay;
TeleportDaemonheim;
WalkToBank;
FremennikBank;
end;
until(false);
FreeDTMZ;
end.

Now with this it will teleport port sarim, walk to the mine, mine a full inventory, bank, teleport back to port sarim, but then it will not walk back to the mine.

Meh, I'm going to just play around with it. Thank you for all of your help :D