SRL Archive - First Scripts

[RS3] Edgeville Jeweler


Nexus Crux

2014-06-05 22:11:14

While I'm certain this already exists in a hidden section of the forum, I needed a bracelet script for my own purposes. To set up, do directX, zoomed all the way out and follow script setup instructions below.


program cruxJewelrySmelter;

{$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

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//////////// ////////////
//////////// Nexus Crux's Jewelry Maker v0.3 ////////////
//////////// ////////////
//////////// ////////////
//////////// ////////////
//////////// 1. Input BANK_PIN, loginName, and password ////////////
//////////// 2. Load your crafting stuff into bank Preset 2 ////////////
//////////// 3. Input a JEWELRY_CHOICE from the following table: ////////////
//////////// ////////////
//////////// ////////////
//////////// Ring Neck Brace Ammy ////////////
//////////// ////////////
//////////// Gold: 1 2 3 4 ////////////
//////////// Sapphire: 5 6 7 8 ////////////
//////////// Emerald: 9 10 11 12 ////////////
//////////// Ruby: 13 14 15 16 ////////////
//////////// Diamond: 17 18 19 20 ////////////
//////////// Dragon: 21 22 23 24 ////////////
//////////// Onyx: 25 26 27 28 ////////////
//////////// ////////////
//////////// ////////////
//////////// 4. Start inside Edgeville Bank (for now) ////////////
//////////// ////////////
//////////// ////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////


const
BANK_PIN = '1234';
JEWELRY_CHOICE = 7;

var
numberTrips: integer;


procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'Zezima';
password := 'ABC123';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;


procedure openBank(); //clicks banker, defeats pin screen, bypasses all that if the bank screen is already open, and lastly clicks the preset 2
var
x, y, i: integer;
begin
if not isLoggedIn() then
exit;

repeat
bankScreen.open(BANK_NPC_BLUE);
inc(i);
until bankScreen.isOpen() or pinScreen.isOpen() or (i >= 15);

if pinScreen.isOpen() then
pinScreen.enter(BANK_PIN);

if bankScreen.isOpen() then
bankScreen.clickButton(BANK_BUTTON_PRESET_2);

end;

procedure walkFurnace(); //walks to the furnace

var
myPath: TPointArray;

begin
tabBackpack.waitWhileLocked();
wait(randomRange(500, 1000));

myPath := [Point(189, 178), Point(239, 167)];
SPS.walkPath(myPath);
end;

procedure walkBank(); //walks to the bank to start all over
var
myPath: TPointArray;

begin
myPath := [Point(239, 167), Point(189, 178)];
SPS.walkPath(myPath);
end;

procedure makeBracelets(); //finds the furnace, clicks make, waits, and uses key tokens
var
x, y, i: integer;
begin

//ClickingFurnace and Production
repeat
mainscreen.findObject(x, y, 1121980, 5, colorSetting(2, 0.32, 1.71), mainscreen.playerPoint, 23, 30, 8, ['melt', 'urnace'], MOUSE_LEFT);
wait(randomRange(1000, 2000));
inc(i);
writeln('Try');
until productionScreen.isOpen() or (i >= 10);

if (productionScreen.isOpen()) then
begin

if (numberTrips=0) then
begin
if not (productionScreen._getSelectedBox(JEWELRY_CHOICE)) then
begin
productionScreen.selectBox(JEWELRY_CHOICE);
productionScreen.clickStart();
end;
end else begin
productionScreen.clickStart();
end;
end;

wait(randomRange(25500, 27000));
claimTicket();

end;




// main loop
begin
smartPlugins := ['d3d9.dll'];
clearDebug(); // Clear the debug box
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

SPS.setup('crux_edgevilleMap', RUNESCAPE_SURFACE); //map setup

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

openBank();
walkFurnace();
makeBracelets();
walkBank();
inc(numberTrips);
writeln(numberTrips);
until false;

end.

To-Do List:

Make Login/Password into Constants for cohesion, BONUS: learn how to use player form*
Add a progress report
Add material failsafe for running out of resources*
Add antiban features to wait time*
Add "inBank()" and "inFurnace()" boolean checks as failsafes
Fix false positive color in furnace (tries to pick up on little pool next to furnace, using orange color)*
Randomize map click points*
Somehow reduce wait times from waitPlayerMoving in SPS*

*: Things I could use suggestions on


I just want to thank The Mayor for his excellent tutorial that has helped to get me started here. I would love any feedback that you guys might have! I could definitely use tips on increasing efficiency and decreasing bottyness.

Currently the script is running at about ~60k/hr xp from me doing sapphire bracelets. This is about 15-20k shy of my target xp/hr rate that I've been getting with other methods.

The Mayor

2014-06-06 00:46:52

Probably some of the best formatting I've seen for a first script, especially since you've been here less than 1 month! A working crafter doesn't actually exist in the higher boards, but I do know at least 2 people with private ones.

I would add some sort of progress report. Also, because you only tell your player to login at the top of your main loop, make sure you have 'if not isLoggedIn() then exit' at the top of each procedure where it could get stuck. E.g., if your player lags out after walkFurnace() it will search for the furnace 11 times even if it's logged out (isn't that much of a big deal but small things make some difference).

Nexus Crux

2014-06-06 11:18:44

Thanks, Mayor! I'll fix it up a bit with the logged in checks.

catsrback321

2014-06-07 15:59:25

Hey, just wondering if you got my pm, not sure if you
can reply with under 10 posts so just reply to this to hit 10 :)

Nexus Crux

2014-06-07 22:25:00

Yep, I got it. Was locked out of replying though. Incoming shortly!

Nexus Crux

2014-06-11 13:42:16

I'm not sure if this is an issue with SPS or my script, but the map clicking sometimes fails when trying to go to the furnace or bank. It'll click way farther north, near the wilderness wall and stall. Is this a known issue with SPS map clicking, or have I done something wrong? I used the SPS coordinate tool to pick the walkpath.

The Mayor

2014-06-12 06:37:49

From: Nexus Crux
I'm not sure if this is an issue with SPS or my script, but the map clicking sometimes fails when trying to go to the furnace or bank. It'll click way farther north, near the wilderness wall and stall. Is this a known issue with SPS map clicking, or have I done something wrong? I used the SPS coordinate tool to pick the walkpath.


SPS can sometimes be really buggy. I heard Olly is working on a new walking method.

Clarity

2014-06-12 07:16:04

Nice first release! Looking forward to any future work ;)

Nexus Crux

2014-06-12 20:55:55

Thanks, Clarity! I wouldn't call it a release quite yet. Still a lot to be ironed out. I have a lot of script ideas in mind that I'd really love to try, after I get at least one working. :)

[XoL]

2014-06-18 10:19:58

Nice job! Looks great for a first script :)

KeepBotting

2014-06-18 10:57:46

This is a really, really good first script. I'd use this myself if I didn't have a private Al-Karahid crafter :D keep it up!

Add material failsafe for running out of resources*
Try checking for mouseovertext of resources when withdrawing them form the bank
Add antiban features to wait time*
what do you measn by this? I see that you already use randomRange, do you mean running antiban while you're waiting? if so, you have to repeatedly check for a condition (in the case, inventory shift or production box dialog not existing) and if it returns true/false, run an antiban, otherwise exit the function.
Add "inBank()" and "inFurnace()" boolean checks as failsafes
SPS positioning would work for this.
Fix false positive color in furnace (tries to pick up on little pool next to furnace, using orange color)*
findObject() can only do so much, it allows you to set CTS2 values, but you should read up on TPA/ATPA/T2DPA colorfinding if you really want to find objects accurately and reliably, @The Mayor; has a great section on it in his AIO tutorial
Randomize map click points*
I believe srl's mouse() takes ranomization values, in for form of parameter randRange, like so:
randRange(-3, 3)
however i'm unsure how to use it outside of TPA/ATPA
Somehow reduce wait times from waitPlayerMoving in SPS*
try using Flag; (FFlag, waitFlag, whatever it's called now)

Nexus Crux

2014-06-19 22:56:14

Awesome, Botting. Thanks for the advice! I'll give your suggestions a try.

As for the antiban thing, I'd like to add some features which do random things while waiting for the bracelets to finish. Also, the 25.5-27 second random wait isn't necessarily accurate if someone is making gold jewelry, where it'll be a longer wait due to not using gems. I think I'll need to do an inventory check and a Case block that does a few antiban things during the wait. I think there is a lot of existing scripting that I can learn from in that regard, however.

Nexus Crux

2014-06-22 15:35:04

I attempted to add a "tabBackpack.countDTM" for gold bars but the function seems to keep trying to open/close the backpack tab. Is this a known bug? Is there a workaround? I'm trying to determine if the gold bars withdrawn from the preset are less than 14, in which case the player has run out of materials.

KeepBotting

2014-06-22 15:49:38

From: Nexus Crux
I attempted to add a "tabBackpack.countDTM" for gold bars but the function seems to keep trying to open/close the backpack tab. Is this a known bug? Is there a workaround? I'm trying to determine if the gold bars withdrawn from the preset are less than 14, in which case the player has run out of materials.
Stick this in your script somewhere and see what it returns:

 i := tabBackpack.countDtm(goldBarDtm);
writeDebug('Counted ' + toStr(i) + ' gold bars.');

skillers

2014-07-11 09:10:01

i will deffinately be using this in the near future!