SRL Archive - First Scripts

CosmicRunner


Werttit

2014-03-05 10:17:11

Hello everyone, I just finished my first script! It makes cosmic runes in Zanaris, and currently requires 66 agility.
It has no pouch support (yet) and it's overall a pretty messy script. After all, I have never really scripted before. :p
Currently it doesn't even login itself, so you have to start it already logged in. (has problems choosing the world)

I don't recommend running it for long periods, as it is still very bot-like!

1. Download COSMIC_MAP.png and place in …SPS/img/runescape_other
2. Start in Zanaris bank and have your pure essence in the 10th slot of bank (first row, last column).
3. Report bugs!

If you notice any code in the script that could be written shorter or could be more reliable, please leave some feedback! :)
program CosmicRunner;

{$DEFINE SMART}
{$I srl-6/srl.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
TripsDone: integer;

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true;
isMember := true;
world := 105; // change this world to your default one
end
currentPlayer := 0;
end;
/////////////////////////////////////////// Don't touch below unless you know what you're doing

procedure runToCosmicRuins();
var
pathBankToCut, pathInsideShortcut, pathCutToRuins: TPointArray;
x, y: integer;
begin
if not isLoggedIn() then
exit;

minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

pathBankToCut := [Point(61, 44), Point(75, 44), Point(88, 71), Point(133, 79),
Point(168, 94), Point(178, 119), Point(195, 138), Point(204, 176),
Point(203, 214), Point(190, 240), Point(184, 267)]

if SPS.walkPath(pathBankToCut) then
minimap.waitPlayerMoving()
else
writeLn('Something went wrong when walking to the shortcut!');

mainscreen.findObject(x, y, 13301244, 4, colorSetting(2, 0.59, 2.68), mainscreen.playerPoint, 30, 30, 60, ['utting', 'wall']);
if (random(9) < 4) then
smallRandomMouse();

Wait(randomRange(4998, 5996));

pathInsideShortcut := [Point(184, 271), Point(154, 296)]

if SPS.walkPath(pathInsideShortcut) then
minimap.waitPlayerMoving()
else
writeLn('Something went wrong inside the shortcut!');

mainscreen.findObject(x, y, 13301244, 4, colorSetting(2, 0.59, 2.68), mainscreen.playerPoint, 30, 30, 60, ['utting', 'wall']);
Wait(randomRange(4698, 5996));

pathCutToRuins := [Point(155, 301), Point(138, 333), Point(154, 362)]

if SPS.walkPath(pathCutToRuins) then
minimap.waitPlayerMoving()
else
writeLn('Something went wrong when walking to the ruins!');

if not mainscreen.findObject(x, y, 12019609, 20, colorSetting(2, 0.05, 1.63), mainscreen.playerPoint, 30, 10, 40, ['ysterious', 'ruins']) then
begin
minimap.setAngle(MM_DIRECTION_EAST);
mainScreen.setAngle(MS_ANGLE_HIGH);
if not mainscreen.findObject(x, y, 12019609, 20, colorSetting(2, 0.05, 1.63), mainscreen.playerPoint, 30, 10, 40, ['ysterious', 'ruins']) then
begin
WriteLn('Failed to find Mysterious Ruins!');
players[currentPlayer].logout();
end;
Wait(randomRange(259, 567));
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
Wait(randomRange(1355, 2109));
end;
end;

procedure craftRunes();
var
minimapAltar: TBoxArray;
x, y, i, r: integer;
T, P: TPoint;
AltarMM: TBoxArray = [[680, 20, 704, 33], [758, 100, 779, 120],
[680, 179, 695, 191], [597, 91, 615, 115]];
begin
if not isLoggedIn() then
exit;

minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

r := randomRange(1, 3);

for i to high(AltarMM) do
if findColorSpiralTolerance(x, y, 4473406, AltarMM[i], 19) then
begin
P := [x+r, y+r];
writeLn('Color found in minimap!');
mouse(P, MOUSE_LEFT);
end;
Wait(randomRange(8595, 9654));

if not mainScreen.findObject(x, y, 6642529, 9, colorSetting(2, 0.84, 0.20), mainscreen.playerPoint, 30, 10, 40, ['ltar']) then
begin
minimap.setAngle(MM_DIRECTION_EAST);
mainScreen.setAngle(MS_ANGLE_HIGH);
if not mainScreen.findObject(x, y, 6642529, 9, colorSetting(2, 0.84, 0.20), mainscreen.playerPoint, 30, 10, 40, ['ltar']) then
begin
WriteLn('Failed to find Cosmic Altar!');
players[currentPlayer].logout();
end;
Wait(randomRange(259, 567));
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

if (random(10) < 4) then
hoverSkill(SKILL_RUNECRAFTING);

end;

inc(TripsDone);

Wait(randomRange(3540, 4120));
minimap.findSymbol(T, MM_SYMBOL_ARROW, minimap.getBounds());
Wait(randomRange(140, 220));
mouse(T, MOUSE_LEFT);

Wait(randomRange(9134, 9859));
if not mainScreen.findObject(x, y, 9606557, 7, colorSetting(2, 0.44, 0.23), mainscreen.playerPoint, 10, 10, 5, ['ortal']) then
begin
Wait(randomRange(320, 450));
if not mainScreen.findObject(x, y, 9606557, 7, colorSetting(2, 0.44, 0.23), mainscreen.playerPoint, 10, 10, 5, ['ortal']) then
begin
WriteLn('Failed to find Portal to Zanaris!');
players[currentPlayer].logout();
end;
Wait(randomRange(1355, 2109));
end;

end;

procedure runToBank();
var
pathRuinsToCut, pathShortcut, pathCutToBank: TPointArray;
x, y: integer;
P, T: TPoint;
begin

if not isLoggedIn() then
exit;

minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

FindColorSpiralTolerance(x, y, 4177682, 689, 34, 713, 58, 7);

T := [x, y];
mouse(T, MOUSE_LEFT);
Wait(randomRange(5876, 6344));

mainscreen.findObject(x, y, 13301244, 4, colorSetting(2, 0.59, 2.68), mainscreen.playerPoint, 30, 30, 40, ['utting', 'wall']);
Wait(randomRange(5198, 6196));

pathShortcut := [Point(154, 296), Point(184, 271)]

if SPS.walkPath(pathShortcut) then
minimap.waitPlayerMoving()
else
writeLn('Something went wrong inside the shortcut!');

mainscreen.findObject(x, y, 13301244, 4, colorSetting(2, 0.59, 2.68), mainscreen.playerPoint, 30, 30, 40, ['utting', 'wall']);
Wait(randomRange(4498, 5996));

pathCutToBank := [Point(183, 266), Point(191, 241), Point(203, 214),
Point(206, 187), Point(201, 162), Point(192, 139),
Point(179, 121), Point(166, 100), Point(157, 82),
Point(128, 75), Point(94, 73), Point(76, 52)]
if SPS.walkPath(pathCutToBank) then
minimap.waitPlayerMoving()
else
writeLn('Something went wrong when walking to the bank!');

minimap.findSymbol(P, MM_SYMBOL_BANK, minimap.getBounds());
mouse(P, MOUSE_LEFT);
Wait(randomRange(800, 1104));

end;

procedure bankEverything();
var
x, y: integer;
begin
if not isLoggedIn() then
exit;

minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

if not mainscreen.findObject(x, y, 9696761, 4, colorSetting(2, 0.17, 2.64), mainscreen.playerPoint, 5, 5, 5, ['ank', 'booth']) then
begin
WriteLn('Failed to find a bank booth!');
players[currentPlayer].logout();
end;
Wait(randomRange(2356, 2891));

if (bankScreen.isOpen()) then
begin
writeLn('Found open bankscreen!');
Wait(randomRange(273, 360));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);

if (random(32) > 13) then
mouseOffClient(OFF_CLIENT_RANDOM);

Wait(randomRange(353, 500));
bankScreen.Withdraw(10, WITHDRAW_AMOUNT_ALL, ['']);
Wait(randomRange(253, 410));
bankScreen.close;
end;
end;

procedure progressReport();
var
runesCrafted, runesPerHour: integer;
begin
runesCrafted := TripsDone * 56;
runesPerHour := round((runesCrafted * 60 ) / (getTimeRunning() / 60000));

clearDebug();
writeLn('****************************************');
writeLn('* CosmicRunner v1.01 by Werttit');
writeLn('* Runtime: ' + timeRunning);
writeLn('* Cosmic runes crafted: ' + intToStr(runesCrafted));
writeLn('* Cosmic runes per hour: ' + intToStr(runesPerHour));
writeLn('****************************************');
writeLn(intToStr(TripsDone));
end;


begin
clearDebug();
setupSRL();
declarePlayers();

SPS.setup('COSMIC_MAP', RUNESCAPE_OTHER);

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

progressReport();

bankEverything();
runToCosmicRuins();
Wait(randomRange(2209, 3186));
craftRunes();
Wait(randomRange(2900, 3980));
runToBank();
Wait(randomRange(1000, 1980));
until(false);
end.

sdf

2014-03-05 10:37:25

Just curious, doesn't MoveMouse make the mouse pointer jump rather than move over a path like Mouse()? It's just the whole HoldMouse/ReleaseMouse thing is odd to see.

Also, the 4 'or' conditions for findColorSpiralTolerance you have under craftRunes() could be made to go through a TBoxArray to make it look neater.

Clarity

2014-03-05 10:53:59

Grats on the release! Nice to see another RS3 RC script. But you're definitely going to want to use the SRL mouse functions for human-like mouse movement rather than the bare basic ones, which are very botlike. It also makes things easier on yourself since you don't have to hardcode holding down the mouse, etc.

e.g.


mouse(somePoint, MOUSE_MOVE, MOUSE_HUMAN);
wait(gaussRangeInt(someX, someY)); //optional wait
fastClick(MOUSE_LEFT);

Foundry

2014-03-05 11:01:03

Good job on your first script! As sdf said, it would be much more humanlike (and easier) to use SRL 6 mouse functions.

For example you could replace what you use to click:

HoldMouse(x, y, mouse_Left);
Wait(randomRange(104, 201));
ReleaseMouse(x, y, mouse_Left);

with this:

fastClick(MOUSE_LEFT)

There is also a function to move the mouse and click that can replace this:

MoveMouse(T.x, T.y);
HoldMouse(T.x, T.y, mouse_Left);
Wait(randomRange(104, 201));
ReleaseMouse(x, y, mouse_Left);

with this nice mouse function:

mouse(T, MOUSE_LEFT);

:( ninja'd

Clarity

2014-03-05 11:04:39

From: Foundry
:( ninja'd

ninja'd only because your post was more thorough and helpful tbh

Werttit

2014-03-05 12:57:46

From: sdf

Also, the 4 'or' conditions for findColorSpiralTolerance you have under craftRunes() could be made to go through a TBoxArray to make it look neater.


How would I go on about doing it like this?

Also, I'll make sure to change the better mouse functions.

Foundry

2014-03-05 13:46:56

From: Werttit
How would I go on about doing it like this?

Also, I'll make sure to change the better mouse functions.


Just make a TBoxArray with the boxes in it and then use a for loop to iterate through it. Example below:

var
i, x, y: Integer;
MMColors: TBoxArray = [[626, 16, 749, 59], [742, 75, 784, 130],
[675, 176, 709, 192], [600, 85, 609, 111]];
begin
for i to high(MMColors) do
if findColorSpiralTolerance(x, y, 4473406, MMColors[i], 25) then
begin
writeLn('color found in minimap!');
fast_click(MOUSE_LEFT);
end;
end;

Also @Clarity; It was because it takes me a century to post something from my phone lol

Werttit

2014-03-07 17:09:49

Alright, I have made some changes to the script. No more jumping mouse, also tried to add in some antibans. Still feels very bot-like in my opinion :unsure: .
I tried to add the playerform, but couldn't wrap my head around it just yet.

Going to add pouch support in later, when I get the spells to repair pouches.

How do I get the script to select a world when logging in? If the world written to the script is not the default world, it just freezes in the world lobby.

Falixus

2014-07-18 21:28:01

I like it very much, best of luck. :)