SRL Archive - First Scripts

Fady's Alcher!! A second, first script?


fady

2015-03-01 01:35:41

Welcome to my other "first" script! This time I did an alcher. I've found that all the available alchers are dependent on time taken between alchs, and lack antiban. I figured there has to be another way that is more accurate and faster, and hopefully safer. This is what I have come up with. I'm currently using Item counts to monitor when an alch has actually started, so the following one can be lined up.

I completely wrote most of it by myself this time, I wanted to receive some feedback, before putting it out in the Magic section.

Features:
1- Not time dependent.
2- Should work well, even with a little lag
3- Proggy.
4- Alchs anything in slots 1..26 (not 27 or 28! those are for runes) in your backpack, as long as the alchemy spell is bound to slot 1 in the action bar.
5- Antiban.
6- Stops when you run out of either items to alch or nature runes.

To-Do list:
1- Have it Alch multiple inventory slots in succession. Which I already have an idea on how to implement. I would just have an integer variable instead of having a slot number, and I'd have it go up by 1, whenever the slot being alched turns empty. I think I might have a problem with stopping the script that way tho. I can just have it stop when it finishes all 28 inventory slots. Done!! Let me know what you think please.
2- Right now the Item count will reset when passing the 6 hours limit. I need to figure that out!
3- Make it take breaks!

Directions:
1- Fill out the top part of the script.
2- Make sure your graphics/interface settings are set to https://villavu.com/forum/showthread.php?t=47714.
3- Have your items in inventory slots 1..26, and your nature runes in slot 27..28. (slot 1 being top left, and 28 being bottom right.
4- Have Alchemy spell (High or Low) bound to action bar slot 1.
5- Let the money and the Magic gains flow start! :D

Any comments or suggestions are encouraged and much appreciated.

Thanks go to The Mayor for getting me started with scripting with his tutorial and for his empty script template, Camel for his Antiban procedure, and KeepBotting from whom I used part of my end detection.

Now to the script!

program Alchemiser;

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

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true; // true or false
isMember := false; // true or false
world := 0; // Pick a world or 0 for random or -1 for just play
end
currentPlayer := 0;
end;

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~//
///////////////// Written by Fady, unless otherwise stated ///////////////////
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~//
////////////////////// DO NOT TOUCH BELOW THIS LINE!! ////////////////////////
////////////////////// DO NOT TOUCH BELOW THIS LINE!! ////////////////////////
///////////////// Only Edit if you know what you're doing!! //////////////////
///////////////// Only Edit if you know what you're doing!! //////////////////
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~//

// Variable Descriptions:
// n: Item count before each alch. Needed to signal following one,
// startCount: Starting total item count in slots 1..26, needed to calculate alchs to go
// a: Number of antibans done for proggy
// slot: Backpack slot to alch
// alchsDone: Current total alchs done
// itemDifference: Difference between initial item count and alchs done
var
n, startCount, a, slot, alchsDone: integer;

function itemDifference(): integer;
begin
result := (startCount - alchsDone);
end;

procedure startCountSetup(); // (+ 27 - tabBackpack.count()) because empty slots return -1 not 0
begin
startCount := (getItemAmount(tabBackpack.getSlotBox(1)) + getItemAmount(tabBackpack.getSlotBox(2)) + getItemAmount(tabBackpack.getSlotBox(3)) + getItemAmount(tabBackpack.getSlotBox(4)) + getItemAmount(tabBackpack.getSlotBox(5)) + getItemAmount(tabBackpack.getSlotBox(6)) + getItemAmount(tabBackpack.getSlotBox(7)) + getItemAmount(tabBackpack.getSlotBox(8)) + getItemAmount(tabBackpack.getSlotBox(9)) + getItemAmount(tabBackpack.getSlotBox(10)) + getItemAmount(tabBackpack.getSlotBox(11)) + getItemAmount(tabBackpack.getSlotBox(12)) + getItemAmount(tabBackpack.getSlotBox(13)) + getItemAmount(tabBackpack.getSlotBox(14)) + getItemAmount(tabBackpack.getSlotBox(15)) + getItemAmount(tabBackpack.getSlotBox(16)) + getItemAmount(tabBackpack.getSlotBox(17)) + getItemAmount(tabBackpack.getSlotBox(18)) + getItemAmount(tabBackpack.getSlotBox(19)) + getItemAmount(tabBackpack.getSlotBox(20)) + getItemAmount(tabBackpack.getSlotBox(21)) + getItemAmount(tabBackpack.getSlotBox(22)) + getItemAmount(tabBackpack.getSlotBox(23)) + getItemAmount(tabBackpack.getSlotBox(24)) + getItemAmount(tabBackpack.getSlotBox(25)) + getItemAmount(tabBackpack.getSlotBox(26)) + 27 - tabBackpack.count());
end;

procedure initiate();
begin
if (tabBackpack.isItemInSlot(slot)) then // Checks if theres an item in that slot before proceeding
begin
typeSend('1', false); // Action bar slot 1 for alchemy spell
wait(gaussRangeInt(100, 400));
tabBackPack.mouseSlot(slot, MOUSE_LEFT); // Backpack slot for item
inc(alchsDone);
wait(gaussRangeInt(100, 200));
typeSend('1', false);
wait (gaussRangeInt(1000, 1300));
end;
end;

procedure antiBan(); // Credit goes to Camel! Slight modification of the antiban in his Aircrafter.
var
i: integer;
begin
i := random(2400);
if i < 60 then
begin
writeLn('Doing antiban');
case i of
1..4: begin
writeLn('Taking Mini-break');
wait(gaussRangeInt(180000,300000));
if not isLoggedIn() then
begin
players[currentPlayer].login();
wait(gaussRangeInt(300,2000));
minimap.setAngle(MM_DIRECTION_NORTH);
mainscreen.setAngle(MS_ANGLE_HIGH);
closePollWindow();
end;
end;
5..18: begin
hoverSkill(SKILL_MAGIC);
wait(gaussRangeInt(1500,5000));
gameTabs.openTab(TAB_BACKPACK);
end;
19..21: mouseMovingObject();
22..34: sleepAndMoveMouse(randomRange(3000,6000));
35..45: begin
mouseOffClient(Random(4));
Wait(gaussRangeInt(10000,15000));
end;
46..53: Wait(gaussRangeInt(2000,3000));
54..60:begin
pickUpMouse();
wait(gaussRangeInt(1500,5000));
end;
end;
writeLn('Antiban Done, Resuming Alching');
inc(a);
initiate();
end;
end;

procedure alch();
var
timer: TTimeMarker; //Timer for each alch
begin
timer.start(); //Starts the timer
tabBackPack.mouseSlot(slot, MOUSE_LEFT);
wait(gaussRangeInt(300, 500)); //Waiting 0.3-0.5 seconds between clicks
typeSend('1', false);
repeat
getItemAmount(tabBackpack.getSlotBox(slot));
until (n - getItemAmount(tabBackpack.getSlotBox(slot)) = 1) or (timer.getTime() >= 7000); //Signals next alch when this one is done or when time >7 seconds
inc(alchsDone);
wait(gaussRangeInt(600, 1000)); // Waiting 0.6-1 second to repeat
end;

procedure proggy();
begin
clearDebug;
writeLn(' Number of items starting with: ' + intToStr(startCount));
writeLn(' Number of Alchs done: ' + intToStr(alchsDone));
writeLn(' Alchs left to go: ' +intToStr(itemDifference()));
writeLn(' XP Gained if High Alch: ' + intToStr(alchsDone*65));
writeLn(' XP Gained if Low Alch: ' + intToStr(alchsDone*31));
writeln(' Time Running: '+timeRunning);
writeLn(' Antibans Done: ' + intToStr(a));
end;

procedure mainLoop();
var
timeRunning: TTimeMarker; // Used to stop the mainLoop at the 6 hour mark to relog in
begin
timeRunning.start();
repeat
inc(slot);
if (tabBackpack.isItemInSlot(slot)) then // Checks if theres an item in that slot before proceeding
begin
initiate(); // First alch due to the lag between the change in number, and the ability to click on the first one.
if (tabBackpack.isItemInSlot(slot)) then // Checks if theres an item in that slot before proceeding
begin
repeat
antiBan();
n := getItemAmount(tabBackpack.getSlotBox(slot)); // Obtains the item count before alching
alch();
proggy();
until (n = 1) or (chatbox.findText(['unes to cast this spe'])) or (timeRunning.getTime() >= 21600000); // Partly taken from Keepbotting's iAlch
end;
end;
until (slot > 25) or (chatbox.findText(['unes to cast this spe'])) or (timeRunning.getTime() >= 21600000); // Partly taken from Keepbotting's iAlch
exit;
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

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

if not(slot > 25) then
begin
startCountSetup();
mainLoop();
end else
terminateScript();
until false;
end..


If you use it, post a proggy! Let me know how its going!!

o0Matthius0o

2015-03-01 07:26:18

Nice script! You should make use of the player manager. Its extremely easy. You can just take the snippet of code from one of the scripts already made. Ill probably give yours a try when i go to train magic again.

Trollcrank

2015-03-01 10:06:23

Looks good. There already are a few alching scripts, last time I checked. I think TheMayor and KeepBotting both have one out. Although I don't see any harm with another one :)

I would add one space between the procedures for readability.

procedure Example;
begin
//code
end;
//There is a gap here now.
procedure ILikeToAlch;
begin
end;
And I would also change the ending of the script from

until n = 2 or chatbox.findAnyText(['unes to cast this spe']); // Taken from Keepbotting's iAlch
terminateScript;
until false;
//to
until n = 2 or chatbox.findAnyText(['unes to cast this spe']); // Taken from Keepbotting's iAlch
writeLn('Out of nature runes, ending script.');
terminateScript;
until false;
I'm going to note that the script right now will run like this:
Log in
setup variables(namely the startAmount := getItemAmount(tabBackpack.getSlotBox(1)); )
Alch until out of runes/six hour limit. Then the backpack failsafe will break the loop and will terminateScript; It will not log back in.
So at best this will run about 6 hours since the client respawn. But who in the right mind would alch for more than 6 hours straight. If I was to release that script I would consider adding in the loggin feature to the mainloop with a possible constant at the top to make it optional.(just a true false thing)

There is also an advance forum setup that look cool, I'm sure you have seen it. It is more user friendly but a little harder to setup for beginners.
https://villavu.com/forum/showthread.php?t=107572

fady

2015-03-01 20:12:52

From: Trollcrank

I'm going to note that the script right now will run like this:
Log in
setup variables(namely the startAmount := getItemAmount(tabBackpack.getSlotBox(1)); )
Alch until out of runes/six hour limit. Then the backpack failsafe will break the loop and will terminateScript; It will not log back in.
So at best this will run about 6 hours since the client respawn. But who in the right mind would alch for more than 6 hours straight. If I was to release that script I would consider adding in the loggin feature to the mainloop with a possible constant at the top to make it optional.(just a true false thing)


Thanks for bringing that to my attention! I rewrote most of the script and added the functionality to alch more than 1 spot, and with that, I think I fixed the 6 hour issue. I added a timer that starts when the mainloop starts and I exit the main loop when the time goes over 6 hours to check for login.

As for the Player Form, I want to learn how to incorporate that! I just haven't gotten around to it yet. It is def next on my list tho!

Any comments on the rewrite are very appreciated

IROC-Z

2015-03-02 16:22:15

I gave this a go and the only thing I found is that it got stuck clicking the bottom left corner of backpack slot one. I would recommend in your alch function checking for the uptext "Cast" or "Alchemy" before it clicks and if it doesn't see that then it should move a couple pixels towards the center of the slot or just have it move to a whole new spot in the slot.

fady

2015-03-02 18:21:20

From: IROC-Z
I gave this a go and the only thing I found is that it got stuck clicking the bottom left corner of backpack slot one. I would recommend in your alch function checking for the uptext "Cast" or "Alchemy" before it clicks and if it doesn't see that then it should move a couple pixels towards the center of the slot or just have it move to a whole new spot in the slot.


Hmmm, thanks for your feedback! I'll look into that and try to figure out a way to prevent it from happening. Does it happen every time you run it? or just that one time?

IROC-Z

2015-03-02 18:48:53

From: fady
Hmmm, thanks for your feedback! I'll look into that and try to figure out a way to prevent it from happening. Does it happen every time you run it? or just that one time?


I only tried it once. I'll fire it up in a bit, gotta study some pharmacology stuff first. I'll definitely let you know. Got about 10k things to alch.

IROC-Z

2015-03-02 21:00:52

I Ran it again and I didn't have a problem. Did about 700 casts to finish off the item in slot 1 and then moved to slot 2 without any issue. As far as I could tell. What I experienced the first time must have been a rare thing, but it wouldn't hurt to incorporate the uptext check.

fady

2015-03-02 22:46:49

From: IROC-Z
I Ran it again and I didn't have a problem. Did about 700 casts to finish off the item in slot 1 and then moved to slot 2 without any issue. As far as I could tell. What I experienced the first time must have been a rare thing, but it wouldn't hurt to incorporate the uptext check.


Yea, I'll try and incorporate that in the script! Thanks for your feedback again! Hope it gets you through your 10k items :D

IROC-Z

2015-03-02 23:34:13

From: fady
Yea, I'll try and incorporate that in the script! Thanks for your feedback again! Hope it gets you through your 10k items :D


This is the proggy I got

Number of items starting with: 5424
Number of Alchs done: 3115
Alchs left to go: 2309
XP Gained if High Alch: 202475
XP Gained if Low Alch: 96565
Time Running: 2 Hours, 59 Minutes and 10 Seconds
Antibans Done: 70
Error: Invalid floating point operation at line 235
Execution failed.

Very nice, thank you for your contribution

fady

2015-03-03 13:38:35

From: IROC-Z
This is the proggy I got

Number of items starting with: 5424
Number of Alchs done: 3115
Alchs left to go: 2309
XP Gained if High Alch: 202475
XP Gained if Low Alch: 96565
Time Running: 2 Hours, 59 Minutes and 10 Seconds
Antibans Done: 70
Error: Invalid floating point operation at line 235
Execution failed.

Very nice, thank you for your contribution


I'm Glad you liked it!