SRL Archive - Jr. Member RS3 Scripts

Function Release: FindSideBarSlot


ogustuce

2019-08-02 06:31:42

hello everyone,here is a little function i've been working on the past few days and i thougth i'd share it.

What it does:
finds additionnal bars on your screen so you can use their slots. It finds them anywhere on the screen.

for example, in a combat script, i use it to find out if im out of food, since the food is on an extra action bar.

something like:

procedure heal;
var
x,y:integer;
SharkBox:Tbox;
begin

SharkBox:=FindsidebarSlot(7,4); // shark is on action bar 7 in slot 4

if actionbar.getHPpercent<50 then
begin
if findcolortolerancein(sharkColor,x,y,Sharkbox,25) then
presskey(VK_V); //sharkfood keybind
end

end

this way the bot wont stupidly mash the food button when your out of sharks.

This has other potential uses like finding if stuff on the sidebars are on cooldown or used for switching gear around via keybinds for more complex pvm stuff.

anyway, here's the function


function FindSidebarSlot(barNumber,slot:integer):Tbox;
var
i,j,l,k,h,x,d1,d2,y,halfgear,f:integer;
p:tpoint;
Circle,circle2:Tpointarray;
HboxShort,HboxLong,Vboxshort,VboxLong,box,box2,box3:Tbox;
circles:t2dpointarray;
Longbar:Boolean;
barslots:TboxArray;
Bars:Array of Tboxarray;
begin
setlength(bars,10);

Halfgear:= BitmapFromString(7, 14, 'meJxTlBZRkBKRFOFXlhOXFhMQlVd' +
'If/xXQoRPUpRf3ztc2caZj5vDuH1l9p//MuKCsq5h6U/+Ff/5F7Hn' +
'JZCR/OcfUKOcrVvQo39hn/8DUfib/0C2uBAvPy+nw4YX3s/++V34C' +
'2QY1s0XEBc3qJ4N5Hrc/me367OAopoQH5fdzk9ANUAR+/P/dOvXCf' +
'NziwnxqM+/qbHrn/6hv0BBhY59ArycitIifGJi8pHF6vNvGZ75a3P' +
'gj4C6oagQn5yEENB5Cj0XgIqBgkBkNnGfjIQgt46N6obfQEMgJBAB' +
'Hc+nawtUCUR8eUuApMyWf0CPA23k1bHhUTXg4WLn9MyXWfheT0MB6' +
'H1RQW55SWE5SSFBIQG+vMUAOdhwww==');


findcolorsspiraltolerance(x,y,circle,1343945,Getclientbounds,15);
circles:=SplitTPAex(circle,8,8);
h:=high(circles);

for i:=h downto 0 do
begin
box:=circles[i].getbounds;
filterpointspie(circles[i],0,360,6,8,middlebox(box).x,middlebox(box).y);
box:=circles[i].getBounds;
//etl_drawbox(Box,clred,true);
box:=circles[i].getBounds;
f:= strToIntdef(getTextAtEx(intToBox(box.x1, box.y1, box.x2,box.y2), 0, 0, 0, 3111603, 0, 'UpChars'), -1);

if (f>0) then
begin


p:=middlebox(circles[i].getBounds);
writeln(inttostr(p.x)+'/'+inttostr(p.y));

HboxLong:=[p.x-8,p.y+8,p.x+10,p.y+27];
HboxShort:=[p.x-8,p.y+40,p.x+10,p.y+64];
VboxLong:= [p.x+14,p.y-8,p.x+25,p.y+11];
VboxShort:= [p.x+40,p.y-8,p.x+60,p.y+11]

if middlebox(HboxLong).isInBox(getclientbounds) then
if findbitmaptolerancein(halfgear,x,y,HboxLong,35) then
begin
writeln('bar:'+inttostr(f)+' is horizontal Long');
//etl_drawbox(HboxLong,clgreen,true);
barslots:=grid(14,1,33,33,36,0,[p.x-493,p.y+10]);
bars[f]:=barslots;
end



if middlebox(VboxLong).isInBox(getclientbounds) then
if findbitmaptolerancein(halfgear,x,y,vboxLong,35) then
begin
writeln('bar:'+inttostr(f)+' is Vertical long');
// etl_drawbox(VboxLong,clgreen,true);
Barslots:=grid(1,14,33,33,0,36,[p.x+10,p.y-494]);
bars[f]:=barslots;
end

if middlebox(HboxShort).isInBox(getclientbounds) then
if findbitmaptolerancein(halfgear,x,y,HboxShort,35) then
begin
if not findbitmaptolerancein(halfgear,x,y,HboxLong,35) then
begin
writeln('bar:'+inttostr(f)+' is horizontal short');
// etl_drawbox(Hboxshort,clgreen,true);
barslots:=grid(7,2,33,33,35,35,[p.x-232,p.y+10]);
bars[f]:=barslots;
end
end

if middlebox(VboxShort).isInBox(getclientbounds) then
if findbitmaptolerancein(halfgear,x,y,vboxShort,35) then
begin
if not findbitmaptolerancein(halfgear,x,y,vboxLong,35) then
begin
writeln('bar:'+inttostr(f)+' is Vertical short');
// etl_drawbox(Vboxshort,clgreen,true);
barslots:=grid(2,7,33,33,36,35,[p.x+12,p.y-235]);
bars[f]:=barslots;
end
end
end

end
freebitmap(halfgear);
result:=bars[barNumber,Slot-1];
//etl_drawbox(result,clyellow,true);

end

you can delete all the ETL_ stuff, i used it to see what the function finds while building it.

it works with the modern font (the black-ish one) and of course no tranparancy. If you want it to work with other fonts, you'll have to change the bitmap.

also, if you call for a barnumber that is not on the screen you will get access violation error. IIrc members can have up to 10 bars (with unlocked extras) and if you just copy/paste this function you have to call slots from 0 to 13 ( so if you put findactionbarslot(3,0); it will find slot1 on bar 3).

klamor

2019-08-04 19:22:01

Looks great, but i'm wondering why you don't just make keybinds for the secondary actionbars and use globals to assign the keys? Maybe i'm just lazy, but that's the way I do it :D I unassigned the keys on the main actionbar and use them specifically for my secondary, so I can have lots of extra buttons for items and skills. I define all the keys in my player setup.

Sounds like you're using a lot of secondary action bars though, High lvl-PVM?

ogustuce

2019-08-08 21:02:55

From: klamor
Looks great, but i'm wondering why you don't just make keybinds for the secondary actionbars and use globals to assign the keys? Maybe i'm just lazy, but that's the way I do it :D I unassigned the keys on the main actionbar and use them specifically for my secondary, so I can have lots of extra buttons for items and skills. I define all the keys in my player setup.

Sounds like you're using a lot of secondary action bars though, High lvl-PVM?


sorry for the late reply, been busy with finals. Yeah i use it for high pvm. For instance, i have a script i use to help me when doing aod. The script will basically eat and restore prayer while i play normally. The reason i make it find tboxes on action bar is so it detects if im out of food/prayer pot by looking for a color in that actionbar slot. if i have them, the box is lit, it finds the color. if im out, the box is dark and it doesnt find the color. this way i can avoid similar color conflict from looking for those colors in the inventory. Also, this function finds the bars/boxes no matter where they are on the screen and no matter their orientation. So i can change layout preset at will.
i tried using it at telos, but the issue is it will interrupt onslaught, which is mandatory to do on p3. i tried having it stop is onslaught is on cooldown and stuff like that but its tricky and i havent really tried tbh.

I guess it could also be used to automatically find the keybinds on the actionbars -> look for white text in action bars slots,store them as strings, then call them later after VK_' '


also thinking of making a telos bot some day. This would be very useful for more human-like play. like switches,prayer flick,looking for surge cooldown, limitless sigil cooldown,eating, pray pot, etc,etc.