SRL Archive - Archive

sparkyownage - SRL Member Application


The Spark

2014-08-05 23:20:42

How Long have You Played Runescape?
8 Year(s)


Are you affilated in anyway with Jagex LTD?
No

Were you Referred to SRL?



What is your general programming knowledge?
Well, I attempted to learn python a few years ago, only learned the basics, but it has really helped me in learning to code with Simba and using SRL.


Are you a member of any other communities?
No


Tell us about yourself…
From: sparkyownage
Well, my name is Thad. I'm 19 years old, I'm a student, I go to college in California. I'm doing my undergrad at Stanford University, and I hope to get into their medical school in a few years. I am currently studying to become a Cardiac Surgeon, which takes an extremely long time. I spend most of my time studying, my education is probably the #1 most important thing for me :D. I don't really play or watch any sports, but I really like coding, it's very fascinating and I love the different scripts you can create to solve the same issue. That's pretty much why I'm here, to learn more :)



Please show us one (or multiple) of your scripts.
program CanifisTanner;
{$DEFINE SMART} // Always have this to load smart
{$I SRL-6/SRL.simba} // To load the SRL include files
{$I SPS/lib/SPS-RS3.Simba} // To load the SPS include files


// Thanks to TheMayor for his amazing tutorials and his help to me in the process of making this script :)
// Thanks to Turpinator and Slacky for taking the time to help me on IRC :D
{

__ __ _ ____
| \/ | | | | _ \
| \ / | __ _ __| | ___ | |_) |_ _
| |\/| |/ _` |/ _` |/ _ \ | _ <| | | |
| | | | (_| | (_| | __/ | |_) | |_| |
|_| |_|\__,_|\__,_|\___| |____/ \__, |
__/ |
|___/

_____ _
/ ____| | |
| (___ _ __ __ _ _ __| | ___ _ _____ ___ __ __ _ __ _ ___
\___ \| '_ \ / _` | '__| |/ / | | |/ _ \ \ /\ / / '_ \ / _` |/ _` |/ _ \
____) | |_) | (_| | | | <| |_| | (_) \ V V /| | | | (_| | (_| | __/
|_____/| .__/ \__,_|_| |_|\_\\__, |\___/ \_/\_/ |_| |_|\__,_|\__, |\___|
| | __/ | __/ |
|_| |___/ |___/

{-----------------------------INSTRUCTIONS: -----------------------------------)
{------------------------------------------------------------------------------)
Have it zoomed all the way out
Start the script with your player in Canifis Bank
Have NOTHING in your inventory
If you want the script to work well, go in a world where your ping is good
Fill out your username and password
Fill out at what percent you want to rest at
Press Play or F9
Have fun :)


Written for SRL Membership Application
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------}



const
VERSION = '1.1';

SBOTT_COLOR = 2040107;
SBOTT_TOL = 6;
SBOTT_HUE = 0.55;
SBOTT_SAT = 1.09;
BANK_COLOUR = 1723228;
BANK_TOL = 5;
BANK_HUE = 0.04;
BANK_SAT = 2.74;
NumberOfLoads = 1000; // How many loads do you want it to complete?
PercentRest = 45; // # at what percent you would like the bot to rest

var
loadscomplete : Integer = 0;
rested : Integer;

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; // Put your username in between the apostraphes
password := ''; // Put your password in between the apostraphes
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)
{--------------------------END OF SCRIPT SETUP---------------------------------)
(--------------------------DO NOT TOUCH BELOW----------------------------------)
(-------------------UNLESS YOU KNOW WHAT YOU'RE DOING--------------------------)
{------------------------------------------------------------------------------)
(------------------------------------------------------------------------------}
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)
{------------------------------------------------------------------------------)






{------------------------------------------------------------------------------)
Procedure: autoUpdateMe
Description: Checks for updated script online, and downloads if avaliable.
Credits: Shuttleu and Ashaman88 and TheMayor (modified by Sparkyownage)
(------------------------------------------------------------------------------}
procedure autoUpdateMe();
var
newFile: integer;
onlineVersion, latestScript, newFileName: string;
begin
writeln('Checking for script updates...');
writeLn('');
onlineVersion := getPage('tannerrs3.googlecode.com/git/version.txt');
writeLn('NOTIFICATION: Current script version: ' + version + ' | Online version: ' + onlineVersion);
if (trim(onlineVersion) > version) then
begin
writeLn('NOTIFICATION: Downloading the newer version from Google Code');
latestScript := GetPage('https://tannerrs3.googlecode.com/git/CanifisTanner.simba');
newFileName := scriptPath+ 'The Mayors Plank Banker v'+OnlineVersion+'.simba';
newFile := rewriteFile(newFileName, true);

if not writeFileString(newFile, latestScript) then
begin
writeLn('NOTIFICATION: Fatal error writing to ' + newFileName);
terminatescript();
end;

closeFile(newFile);
writeLn('NOTIFICATION: New script downloaded to ' + newFileName + ' | Please use this one!');
writeLn('');
terminateScript();
end else
writeLn('NOTIFICATION: You have the latest version.');
end;
{------------------------------------------------------------------------------)
Procedure: scriptTerminate
Description: Logs the player out when something goes wrong)
(------------------------------------------------------------------------------}

procedure scriptTerminate();
begin
writeln('Shutting down: Took a picture, please post the picture in the thread for assistance');
saveScreenshot(scriptPath + timeRunning() + ':' + 'TannerFailure.png');
players[currentPlayer].logout;
terminateScript;
end;

{------------------------------------------------------------------------------)
Procedure: paintStatus
Description: Paints the current script status on SMART, in the chatbox.
Credits: TheMayor (Modified by Sparkyownage)
(------------------------------------------------------------------------------}
procedure paintStatus(status: string);
begin
smartImage.clearArea(intToBox(6, 6, 740, 75));
smartImage.drawText('Status: ' + status, point(6,6), SmallChars, false, ClYellow);
end;


{------------------------------------------------------------------------------)
Procedure: antiban
Description: Does some random (human-like) stuff.
(------------------------------------------------------------------------------}
procedure antiBan();
var
i: integer;

begin
if not isLoggedin() then
exit;

paintStatus('Engaging in antiban');

i := random(500);
case i of
1..12: pickUpMouse();
13..18: randomRClickItem();
19..26: sleepAndMoveMouse(random(2000) + 750);
27..32: smallRandomMouse();
33..50: mouseOffClient(OFF_CLIENT_RANDOM);
51..85: randomCompass(random(300), randomrange(10, 100), false);
86..120: mainScreen.setAngle(MS_ANGLE_HIGH);
121..150: hoverRandomSkill();
end;
end;

{------------------------------------------------------------------------------)
Function: runPercent
Description: Estimates run energy using a polynomial equation of colour counts
Credits: The Mayor and Ashaman88 ( Modified by Sparkyownage)
(------------------------------------------------------------------------------}
function runPercent(): integer;
var
count: integer;

begin
if not isLoggedIn then
exit;

count:= countColorTolerance(1719429, minimap.button[MM_BUTTON_RUN].bounds, 11, colorSetting(2, 0.23, 1.34));

if count >= 280 then
result := 100
else
if count <= 10 then
result := 0
else
result := round((0.0009 * (count * count)) + (0.069 * count) + 3.7717);

print('Our 2nd degree polynomial prediction equation estimates run energy is: ' + toStr(result) + '%');
end;

{------------------------------------------------------------------------------)
Function: needToRest
Description: Determines if the player is low on energy.
Credits: TheMayor (Modified by Sparkyownage)
(------------------------------------------------------------------------------}
function needToRest(): boolean;
begin
result := runPercent <= PercentRest;
end;

{------------------------------------------------------------------------------)
Procedure: Rest
Description: Rests when low on energy.
Credits: TheMayor (Modified by Sparkyownage)
(------------------------------------------------------------------------------}
procedure Rest();
var
energy, x, y: integer;
restTimer : TTimeMarker;

begin
if not isLoggedIn then
exit;

energy := (70 + random(25));

if needToRest() then
begin
if (random(2) = 0) then // 1/3 or 33% chance of actually resting
begin
writeLn('Energy less than ' + toStr(runPercent) +'%, we need to rest');
if not minimap.isResting() then
begin
mouse(point(minimap.button[MM_BUTTON_RUN].center.x+random(4), minimap.button[MM_BUTTON_RUN].center.y+random(4)), MOUSE_MOVE);
fastClick(MOUSE_RIGHT);
wait(gaussRangeInt(100, 350));
if chooseOption.select(['est']) then
begin
paintStatus('Resting to regenerate energy');
restTimer.start();
repeat
if random(1) = 0 then
antiban();
wait(gaussRangeInt(1000, 2000));
until (runPercent() >= energy) or (restTimer.getTime() > 15000);
inc(Rested);
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_NORTH);
end;
end;
end;
end;
end


{------------------------------------------------------------------------------)
Procedure: findBanker
Description: Locates the Banker
(------------------------------------------------------------------------------}
procedure findBanker();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn() then
exit;
paintStatus('We are locating the banker');

findColorsSpiralTolerance(x, y, TPA, BANK_COLOUR, mainScreen.getBounds(), BANK_TOL, colorSetting(2, BANK_HUE, BANK_SAT));

if (Length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['ooth'], 500) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;

end;
{------------------------------------------------------------------------------)
Procedure: takeOutHides
Description: Withdraws 28 Dragonhide using the first preset
(------------------------------------------------------------------------------}

procedure takeOutHides();
begin
if not isLoggedin() then
exit;
wait(randomRange(2000, 2250));
paintStatus('We are withdrawing the dragonhides');
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
end;

{------------------------------------------------------------------------------)
Procedure: WalktoTanner
Description:Uses SPS to walk from the bank to the tanner
(------------------------------------------------------------------------------}
procedure WalktoTanner();
var
pathtoTanner: TPointArray;
p: TPoint;
begin;
if not isLoggedin() then
exit;
if needToRest() then
rest();
wait(randomRange(500, 1000));

if(tabBackpack.count() = 28) then
begin
paintStatus('We are walking to the tanner');

pathtoTanner := [Point(237, 174), Point(213, 167), Point(193, 160), Point(185, 147), Point(175, 133), Point(163, 124), Point(153, 115), Point(147, 98), Point(162, 90)];
if SPS.walkPath(pathtoTanner) then
minimap.waitPlayerMoving()

end;
wait(randomRange(2000, 2500));
if(tabBackpack.count() < 28) then
wait(randomRange(2000, 2500));

if(tabBackpack.count() < 28) then
begin;
WriteLn('We failed to walk to the Tanner for some reason.');
scriptTerminate();
terminateScript();
end;
end;

{------------------------------------------------------------------------------)
Function: findSbott
Description: Locates Sbott(The Tanner) in his shop
(------------------------------------------------------------------------------}

function findSbott(): boolean;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedin() then
exit;
paintStatus('We are locating Sbott');
minimap.setangle(MM_DIRECTION_EAST);
wait(randomRange(100, 250));

findColorsSpiralTolerance(x, y, TPA, SBOTT_COLOR, mainScreen.getBounds(), SBOTT_TOL, colorSetting(2, SBOTT_HUE, SBOTT_SAT));

if length(TPA) < 1 then
begin
writeLn('Didn''t find any pixels that match Sbott''s colour!');
exit;
end;

ATPA := TPA.cluster(10, 10);

ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(MiddleTPA(ATPA[i]), MOUSE_MOVE);

if isMouseOverText(['Sbott'], 500) then
begin
fastClick(MOUSE_RIGHT);
chooseOption.select(['rade']);
smartImage.clearArea(mainscreen.getBounds());
exit(true);
end;
end;

end;
{------------------------------------------------------------------------------)
Procedure: TanHides
Description: Clicks on the tan option to tan the dragonhide into dragon leather
(------------------------------------------------------------------------------}

procedure tanHides();
var
RoyalBox: TBox;
begin;
if not isLoggedin() then
exit;
paintStatus('We are tanning the hides!');
wait(randomRange(2500, 3000));
RoyalBox := intToBox(285, 325, 510, 355);
mouseBox(RoyalBox, MOUSE_MOVE);
fastclick(MOUSE_LEFT);
wait(randomRange(50, 100));
end;
{------------------------------------------------------------------------------)
Procedure: WalktoBank
Description: Uses SPS to walk to the bank in Canifis
(------------------------------------------------------------------------------}

procedure WalktoBank();
var
pathtoBanker: TPointArray;
pathtoTanner: TPointArray;

begin;
if not isLoggedin() then
exit;
if needToRest() then
rest();
paintStatus('We are walking to the bank');
pathtoBanker := [Point(162, 90), Point(147, 98), Point(153, 115), Point(163, 124), Point(175, 133), Point(185, 147), Point(193, 160), Point(213, 167), Point(237, 174)];
if SPS.walkPath(pathtoBanker) then
minimap.waitPlayerMoving()
else
WriteLn('We failed to walk to the Bank');

end;
{------------------------------------------------------------------------------)
Procedure: Report
Description: Displays how many loads have been completed in te debug window
(------------------------------------------------------------------------------}

procedure Report();
var
TannedHides: integer
begin;

TannedHides := loadscomplete * 28
if not isLoggedin() then
exit;
writeLn('{-------------------------------------------------------}');
writeLn('{-------------------------------------------------------}');
writeLn('{-------------------------------------------------------}');
writeLn('{-------------------------------------------------------}');
writeLn('{-------------Canifis Tanner by Sparkyownage------------}');
writeLn(' Script has been running for: ' + timeRunning());
writeLn('{---------------We have completed ' + IntToStr(loadscomplete) + ' loads---------------}');
writeLn('{-----------We have tanned: ' + IntToStr(TannedHides) + ' Hides--------------------}');
writeLn('{-------------------------------------------------------}');
writeLn('{-------------------------------------------------------}');
writeLn('{-------------------------------------------------------}');
end;

{------------------------------------------------------------------------------)
The Main Loop
Description: Puts all of the above procedures and functions together in the
correct order
(------------------------------------------------------------------------------}

// main loop
begin

clearDebug(); // Clear the debug box
autoUpdateMe(); //Automatically updates the script
smartPlugins := ['D3d9.dll', 'opengl32.dll']; // Enables the Direct X plugin
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

SPS.setup('Canifis_Map', RUNESCAPE_OTHER, 5, 775, 0.5);

if not isLoggedIn() then // If player isn't logged in then
begin
players[currentPlayer].login(); // Log them in
exitSquealOfFortune(); // Exit squeal if found
minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

repeat
findBanker();
takeOutHides();
WalktoTanner();
findSbott();
tanHides();
walktoBank();
antiban();
Inc(loadscomplete);
Report();
until (loadscomplete) = NumberOfLoads;
end.

If you ultimately decide to vote no on this poll, please make a post telling me why. I'd love to know what I can improve on :)

rj

2014-08-06 13:24:58

The code looks alright but I don't see much activity from you, but I would like to point out you can get a little bit OOP with code like this:

ATPA := TPA.cluster(10, 10);

ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

Can be changed to:

ATPA := TPA.cluster(10, 10).filterBetween(0, 10).sortFromMidPoint(mainscreen.playerPoint);

The Spark

2014-08-06 15:18:21

From: Robert
The code looks alright but I don't see much activity from you, but I would like to point out you can get a little bit OOP with code like this:

ATPA := TPA.cluster(10, 10);

ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

Can be changed to:

ATPA := TPA.cluster(10, 10).filterBetween(0, 10).sortFromMidPoint(mainscreen.playerPoint);


I see, thanks for the feedback :)

slacky

2014-08-06 21:27:08

From: Robert
The code looks alright but I don't see much activity from you, but I would like to point out you can get a little bit OOP with code like this:

ATPA := TPA.cluster(10, 10);

ATPA.filterBetween(0, 10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

Can be changed to:

ATPA := TPA.cluster(10, 10).filterBetween(0, 10).sortFromMidPoint(mainscreen.playerPoint);


No you can not.
FilterBetween does not return anything, nor does SortFromMindPoint.. Both modifies the ATPA in place / both are procedures.
You can only stack function-calls in such a manner.

Hypothetically speaking: If they where to return something, I would advice against stacking with such lengthy calls, it's rather distracting, and makes it harder to see whats going on. The line found in Simba (Gray vertical line at the right in the editor), it's at about 80 chars out, 80 chars max line-length is a very nice guideline, which is heavily standardized in multiple languages, and should rarely be exceeded, and should generally not be close to it unless there is no better option.

If there where a few short small functions, I would however agree that stacking am like that is nice, to a degree.
IE:

ATPA := TPA.Cluster(2).Sorted(); //sorted does not exist in SRL tho.
// even...
Mid := TPA.Cluster(2).Sorted()[0].Mean();


On topic:
I voted No. Your script is just too simple, and to a degree a collection of function which others have written. I require a bit more then a script then what you show for me to say yes. You did however make a decent script for the simple task you have chosen.
Next time you could go for a bit harder, more complex task to show us what you are good for.

rj

2014-08-06 22:10:07

From: slacky
No you can not.
FilterBetween does not return anything, nor does SortFromMindPoint.. Both modifies the ATPA in place / both are procedures.
You can only stack function-calls in such a manner.

Hypothetically speaking: If they where to return something, I would advice against stacking with such lengthy calls, it's rather distracting, and makes it harder to see whats going on. The line found in Simba (Gray vertical line at the right in the editor), it's at about 80 chars out, 80 chars max line-length is a very nice guideline, which is heavily standardized in multiple languages, and should rarely be exceeded, and should generally not be close to it unless there is no better option.

If there where a few short small functions, I would however agree that stacking am like that is nice, to a degree.
IE:

ATPA := TPA.Cluster(2).Sorted(); //sorted does not exist in SRL tho.
// even...
Mid := TPA.Cluster(2).Sorted()[0].Mean();

oh wait i thought they where functions lmao

The Mayor

2014-08-07 01:47:04

It's great you've put this together :) but it looks like the majority of your code is either straight from the tutorial or that guys planker (you even left all the comments in). The way you have structured your main loop means that the script will most likely break if one of the procedures fails.


repeat
findBanker();
takeOutHides();
WalktoTanner();
findSbott();
tanHides();
walktoBank();
antiban();
Inc(loadscomplete);
Report();
until (loadscomplete) = NumberOfLoads;

For example, if findSbott() fails (it couldn't find him because he was blocked, or your walking failed to get you there, or you lagged, etc.) then you will still try and tan the hides. Your tanHides procedure is actually just clicking a box on the mainScreen, so this could cause big problems if the 'tanning window' isn't even open (which you should probably have a Boolean function for).


procedure tanHides();
var
RoyalBox: TBox;
begin;
if not isLoggedin() then
exit;
paintStatus('We are tanning the hides!');
wait(randomRange(2500, 3000));
RoyalBox := intToBox(285, 325, 510, 355);
mouseBox(RoyalBox, MOUSE_MOVE);
fastclick(MOUSE_LEFT);
wait(randomRange(50, 100));
end;


From the looks of your activity, you returned 2 weeks ago from a 6 month break. If you were an active member of the community I would have voted yes. Maybe you should release (and maintain) your script and get some feedback on it?

The Spark

2014-08-07 02:34:24

From: The Mayor


From the looks of your activity, you returned 2 weeks ago from a 6 month break. If you were an active member of the community I would have voted yes. Maybe you should release (and maintain) your script and get some feedback on it?



Thanks for your feedback, extremely helpful as not everybody made a post when they voted no, which if they don't, then I really don't know what I can do better. Thanks for your advice, I just released the script :)

slacky

2014-08-31 21:26:04

From: sparkyownage
Thanks for your feedback, extremely helpful as not everybody made a post when they voted no, which if they don't, then I really don't know what I can do better. Thanks for your advice, I just released the script :)

Next time (assuming you don't get in) you could go for a bit harder, more complex task to show us what you are good for. The tanner you have made doesn't really show us what you are capable of, it's such a simple task. Also, not needed, but I recommend to avoid the use of other peoples methods (at least for such simple things), we want to see what YOU are good for :P

The Spark

2014-08-31 21:34:00

From: slacky
Next time (assuming you don't get in) you could go for a bit harder, more complex task to show us what you are good for. The tanner you have made doesn't really show us what you are capable of, it's such a simple task. Also, not needed, but I recommend to avoid the use of other peoples methods, we want to see what YOU are good for :P


Can you tell me what your idea of a "complex task" is/what a complex script should use? Thanks for the feedback though :)

slacky

2014-08-31 21:57:05

From: sparkyownage
Can you tell me what your idea of a "complex task" is/what a complex script should use? Thanks for the feedback though :)

I don't play RS, not have I played it in many many years, so I don't recall anything cool.
But like your script does four very simple steps:
-> Extract items from bank
-> Walk From Bank to some close by building
-> Locate a NPC and select an option
-> Walk back to bank

Clearly there must be some more involved task out there.

Justin

2014-08-31 22:00:59

Hi @sparkyownage;.

Unfortunately, it doesn't look like you will get in this time Heed the advice the members that have posted in this thread have given, and you may very well get in the next time! You may apply again in one month.

Cheers,
Justin.