SRL Archive - First Scripts

[First Script] Fire Runecrafter [NEED HELP, broken]


meep152

2015-02-08 20:24:56

This is my first attempted script - it crafts fire runes in Al Kharid and uses the Duel Arena bank.
Currently, the script must be started at Duel Arena bank
This script uses Preset 1 to bank, which is 1 fire tiara (worn) and 28 rune essence in inventory


Some of the things I would like help adding/improving are:
• ([most important) looping all procedures together.
At the moment, the script will only perform one run (if successful at all), then it will stop at Duel Arena Bank. Advice on how to get it to repeat by banking again and continue running, is appreciated.


• failsafes
This script has quite a few infinite loops and I'm wondering how to manage all of them so my character doesn't get stuck doing something?

• walking help
I found SPS to be very unreliable for the walking in Al Kharid, so I ended up using DTMs for all walking procedures. This can also be unreliable at times, especially if a white player dot is on top of the minimap icons used. I wonder if anyone has a better alternative for walking?

• antiban
currently, the script has no antiban and I would like to know how to add it

• anything else
if you know how the script logic or speed can be improved, please do tell! At the moment, the script is a bit slow and appears bot-like at times


Thank you for any help and feedback offered, and a big thanks to The Mayor's tutorial, from which a large portion of the code was based.

jarofhearts

2015-02-09 10:42:46

I'm not an expert by any means, but I'll try to help with what I can.

To loop the procedures together, you need to add a repeat into your main loop. Something like this:
// main loop
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
//SPS.setup('KHARID_MAP2', RUNESCAPE_OTHER); //script tries to use DTMs to walk now

if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
minimap.clickCompass();
end;
repeat
openBank();
withdrawEss();
walkAltar();
enterAltar();
craftRunes();
exitAltar();
walktoBank();
end;
End.

For failsafes: I don't know a lot about this. I would look at some of the scripting guides, as they typically implement lots of failsafes.

For antiban: some scripts create a function called antiban with various features in it, such as move mouse offscreen, change camera angle, check xp, etc. Then the antiban procedure is called at semirandom intervals in the main loop (usually set by a user threshold for frequency). A lot of the popular free scripts have fairly elaborate antiban procedures, I would take a look there for some ideas. You could also add random time intervals between your functions in the main loop.

Hopefully some of that helps!

meep152

2015-02-09 17:33:01

Thank you! That information did help for sure and now Ive added a few timers to break out of "repeat" loops which the character would otherwise get stuck on. I also managed to get all the procedures to loop together thanks to your help.

I've placed my updated script in the original post; I'm still looking for ways to add antiban and I might want to add a teleport failsafe since the script ocassionally gets stuck when banking or entering the altar. Other than that, I got the script to run for 40 minutes without any problems. It's a start, woo!

HKbotz

2015-02-10 12:41:35

A couple things I noticed. First the program name needs to be all one word and you can't use . in it, so it should be something like
program fireRunecrafterV1_1;
or something like that. I couldn't get it to compile until I changed it. Also I've found it really useful to make normal procedures boolean functions, that way if your function messes up, say if you're trying to craft the runes and it fails, it can return false and you can use that as a way to either break out of your main loop, or go do something else to try and fix it.

for example instead of:
repeat
openBank();
withdrawEss();
//etc
until (false);

it could be:
repeat
if (not openBank()) then
break; //breaks you out of your infinite main loop
if (not withdrawEss()) then
break;
//etc
until (false);
All you have to do is change your procedures to boolean functions and have them exit true/false appropriately


As for antiban you can just make a procedure with a case statement and call it in your script.

Example:

procedure antiban(seed: integer);
begin
case random(seed) of
0..9: //change these to whatever you want to change likelihood of calling
//do something
10..19: //change these to whatever you want to change likelihood of calling
//do something else
20..29: //change these to whatever you want to change likelihood of calling
//do something even different
//etc
end;
end;

and to call it you would do:

procedure foo();
begin
//some stuff that does some stuff
antiban(100); //change 100 to whatever number you want
//some more stuff that does some more stuff
end;


Hope that's helpful and not too confusing :p