SRL Archive - RS3 Help

Reading the XP counter or part of SRL-6 include in ogLib


Krzysztof

2015-06-13 06:52:12

Greetings

I am trying to produce a simple Ivy chopping script. Since it has a weird model and I wasn't able to get ogLib to click it properly I turned to SRL-6. And now I don't know how to determine when the script should click another ivy after the first had been chopped.

PixelShift I don't want, as I've seen it's pretty unreliable.
Can't use ItemShift, due to obvious lack of items in ivy chopping.

Therefore I had concluded that best would be to make the script get the XP from XP counter, and do the math, and if it hadn't changed then click an ivy. A XPShift, if you will.
I browsed a bit of SRL, and a function of xp getting from IvyChopperUltra in RS3 public script, however I have no idea how to make such a function or how to use an existing one in SRL-6.

Alternatively, I could use the wonderful method from oglib that simply looks for my choppingModel and if it's not present it carries on as the script knows exactly when I'm not chopping. However, as afaik Clarity hadn't finished SRL compatibility yet, I would have to manually include some SRL-6 scripts into oglib setup, and in that I failed.
I tried to include lib/utilities/color, math, types and some others, but the same error present i.e. not knowing what maxint is.

If anybody could help me get any of these two methods to work I'd appreciate it. I do not understand much, so I look for simplest ways possible, and that shortcutting I hope you would forgive me.

This is the current base of the script, obviously far from finished. It's to tell what I'm using and what I would have to potentially include into ogLib setup to make it work.
[spoiler=click me]
program AutoIvy;
{$DEFINE SMART}
{$i srl-6/srl.simba}

procedure chopIvy();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
findColorsSpiralTolerance(x, y, TPA, 2509624, mainScreen.getBounds(), 6, colorSetting(2, 0.05, 0.23));

if length(TPA) < 1 then
exit;

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

//smartImage.debugATPA(ATPA);
//smartImage.debugTPA(TPA, true);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['hop Ivy'], 500) then
begin
getMousePos(x, y);
holdMouse(x, y, MOUSE_LEFT);
wait(gaussRangeInt(46,78));
releaseMouse(x, y, MOUaSE_LEFT);
wait(gaussRangeInt(2184,2721));
break;
end;
end;
end;

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

chopIvy;
// repeat
// chopIvy;
// until false;
end.
[/spoiler]

edit:
I found Ashaman's post on chatbox.getxp. As opposed to the piece of the function I copypasted from Ivy Chopper Ultra this one didn't give compile errors. I'll test it later, and hopefully it will work.

The Mayor

2015-06-13 08:58:49

Yeah, chatBox.getXPBar() is included in SRL-6.

KeepBotting

2015-06-13 11:31:41

From: The Mayor
Yeah, chatBox.getXPBar() is included in SRL-6.


This. Put it on a timer, like so:

function isStillChopping():boolean;
var
xp1, xp2:integer;
t:TTimeMarker;
begin
t.start();

result := false;

while (t.getTime() < 5000) do //However long you want to spend checking
begin
xp1 := chatBox.getXp();
wait(1000); //or however much time it should take to gain xp normally
xp2 := chatBox.getXp();

if (xp1 <> xp2) then
result := true;
end;
end;

Maybe I screwed that up a bit (crazy night last night – still recovering) but there's the general idea.

Ross

2015-06-13 11:48:20

From: Krzysztof
Greetings

I am trying to produce a simple Ivy chopping script. Since it has a weird model and I wasn't able to get ogLib to click it properly I turned to SRL-6. And now I don't know how to determine when the script should click another ivy after the first had been chopped.

PixelShift I don't want, as I've seen it's pretty unreliable.
Can't use ItemShift, due to obvious lack of items in ivy chopping.

Therefore I had concluded that best would be to make the script get the XP from XP counter, and do the math, and if it hadn't changed then click an ivy. A XPShift, if you will.
I browsed a bit of SRL, and a function of xp getting from IvyChopperUltra in RS3 public script, however I have no idea how to make such a function or how to use an existing one in SRL-6.

Alternatively, I could use the wonderful method from oglib that simply looks for my choppingModel and if it's not present it carries on as the script knows exactly when I'm not chopping. However, as afaik Clarity hadn't finished SRL compatibility yet, I would have to manually include some SRL-6 scripts into oglib setup, and in that I failed.
I tried to include lib/utilities/color, math, types and some others, but the same error present i.e. not knowing what maxint is.

If anybody could help me get any of these two methods to work I'd appreciate it. I do not understand much, so I look for simplest ways possible, and that shortcutting I hope you would forgive me.

This is the current base of the script, obviously far from finished. It's to tell what I'm using and what I would have to potentially include into ogLib setup to make it work.
[spoiler=click me]
program AutoIvy;
{$DEFINE SMART}
{$i srl-6/srl.simba}

procedure chopIvy();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
findColorsSpiralTolerance(x, y, TPA, 2509624, mainScreen.getBounds(), 6, colorSetting(2, 0.05, 0.23));

if length(TPA) < 1 then
exit;

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

//smartImage.debugATPA(ATPA);
//smartImage.debugTPA(TPA, true);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['hop Ivy'], 500) then
begin
getMousePos(x, y);
holdMouse(x, y, MOUSE_LEFT);
wait(gaussRangeInt(46,78));
releaseMouse(x, y, MOUaSE_LEFT);
wait(gaussRangeInt(2184,2721));
break;
end;
end;
end;

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

chopIvy;
// repeat
// chopIvy;
// until false;
end.
[/spoiler]

edit:
I found Ashaman's post on chatbox.getxp. As opposed to the piece of the function I copypasted from Ivy Chopper Ultra this one didn't give compile errors. I'll test it later, and hopefully it will work.


If you need help with ogLib feel free to ask around the forum.

Clarity

2015-06-13 11:49:07

You can read the XP tracker with 100% accuracy (getXPBar can fail) using char detection within a TBox. Then you should parse the received string to get rid of any commas or spaces.


function getCurrentXP(): integer;
var
receivedXP: string;
begin
receivedXP := ogl.getChars(IntToBox(X1, Y1, X2, Y2)).toString();
result := strToIntDef(replace(replace(receivedXP, ',', '', [rfReplaceAll]), ' ', '', [rfReplaceAll]), 0);
end;

If you want it to be more dynamic, you can look for the texture next to the XP tracker, and create a TBox based on that.


function getCurrentXP(): integer;
var
receivedXP: string;
statBar: glTextureArray;
searchBox: TBox;
begin
statBar := ogl.getTextures(statBarTextureID, statBarColourID);
if length(statBar) then
begin
searchBox := statBar[0].bounds();
searchBox := IntToBox(searchBox.X1, searchBox.Y1 - 10, searchBox.X2 + 100, searchBox.Y2 + 10);
end;
receivedXP := ogl.getChars(searchBox).toString();
result := strToIntDef(replace(replace(receivedXP, ',', '', [rfReplaceAll]), ' ', '', [rfReplaceAll]), 0);
end;

Krzysztof

2015-06-13 12:26:35

Wow! I am tremendously surprised from the amount of responses.

I did manage to get it to work, and I thank you all a lot. I am however quite embarrassed that I receive such help and I lack any real-er motivation to learn all of this.

Seeing as there are sometimes 15-30 seconds delays in XPBar updating (chopping ivy takes time and therefore using XPShift can reduce script efficiency by 20-40% if I don't want the script to switch ivy's in the middle of chopping one), I'd like to ask what do I need to include into this:
[spoiler=(my default oglib script setup)]
program ogLib;
{$i ogLib\lib\core\core.simba}

procedure mainLoop;
var
begin
end;

begin
ogl.setup();
repeat
mainLoop;
until false;
end.
[/spoiler]

To make the chopIvy; procedure from opening post work? Without including anything I got the "Unknown declaration colorSettings" error, and then
I tried including math+color+wrappers, but then got the "Unknown declaration maxInt" error.

edit: Btw, I had noticed sometimes Ivy would last for so long that my character would log out while still chopping :D

EDIT: Well, nevermind. I managed to successfully arrange a pixelshift function, therefore no need for ogLib based isChopping one. And I worked around the logouts from long choping by clicking once 2 minutes passed. Topic closed, I guess.