SRL Archive - Senior Scripts and Snippets

Bank Browsing


pwnaz0r

2007-09-14 18:06:50

Here are a few functions i put together for the bank browsing section. It will find any box in the bank accurately by finding the distance from the scroll up arrow ad the scroll bar, multiplying it by the ratio of bankscreen to scrollbar , and subtracting that from the bank box positions. Anyways post feedback :)

From: Boreas
Slots:
Inv/Bank/Shop/Trade all have slots. They are lined up and in fixed positions. Global arrays for these so coords only need to be updated in one place.



type
boolint = record
bool: boolean;
int: integer;
end;

function GetBarDistance: integer; // Will return -1 if false
var
dist: integer;
begin
if not GetColor(476, 74) = 2436403 then
begin
result:= -1;
exit;
end else
begin
for dist:= 1 to 175 do
begin
if GetColor(477, 74 + dist) = 5531254 then
begin
result:= dist;
exit;
end;
end;
end;
result:= -1;
end;

function CreateDifference: boolint; // return difference ratio
var
dis: integer;
begin
dis:= GetBarDistance;
result.int := Round((dis - 1) * 9.6);
result.bool := Result.int > 0;
end;

function HandleScreenShift(i: integer): integer;
var
tmpx,tmpy,t: integer;
begin
result:= i;
if getcolor(475,75) = 5531254 then
exit;
try
findcolor(tmpx, tmpy, 65535, 73, i-15, 443, i+15);
result:=tmpy;
except
FixBank;
wait(600);
try
findcolor(tmpx, tmpy, 65535, 73, i-15, 443, i+15);
result:=tmpy;
except
Writeln('Error');
exit;
end;
end;
end;

function BankBox(i :Integer): TBox;
var
row, col: Integer;
tmp: boolint;
begin
col := i mod 8; if col = 0 then col:= 8; // Columns are Vertical
row := i / 8; if i mod 8 <> 0 then Inc(row); // Rows are Horizontal
Result.x1 := 32 + (col * 47);
tmp:= CreateDifference;
if tmp.bool then
begin
Result.y1 := 24 + (row * 38) - tmp.int;
Result.y1 := HandleScreenShift(Result.y1);
end else Result.y1 := 24 + (row * 38);
Result.x2 := Result.x1 + 31;
Result.y2 := Result.y1 + 31;
end;

function BoxVisible(i: integer): Boolean;
var
TheBankBox: TBox;
begin
TheBankBox:= BankBox(i);
Writeln(IntToStr(TheBankBox.y1));
if (TheBankBox.y1 >= 62) and (TheBankBox.y1 <= 254) then result:= True;
end;

function ResetForBox(i: integer): boolean;
var
BoxMark, bx, by: integer;
begin
FixBank;
If BoxVisible(i) then
begin
result:= true;
exit;
end;
HoldMouse(475 + random(6) - random(6), 281 + random(6) - random(6), true);
GetMousePos(bx, by);
MarkTime(BoxMark);
repeat
begin
Wait(1);
If TimeFromMark(BoxMark) >= 20000 then
begin
result:= false;
ReleaseMouse(bx, by, true);
exit;
end;
end;
until(BoxVisible(i));
ReleaseMouse(bx, by, true);
result:= true;
end;

function MakeBoxVisible(i: integer): boolean;
var
TheBankBox: TBox;
begin
if not BoxVisible(i) then
begin
// WriteLn('Bank box not visible');
ResetForBox(i);
end;
end;

function MakeMiddlePoint(i: integer): TPoint;
var
TheBankBox: TBox;
begin
TheBankBox:= BankBox(i);
result.x:= ((TheBankBox.x2 - TheBankBox.x1) / 2) + TheBankBox.x1;
result.y:= ((TheBankBox.y2 - TheBankBox.y1) / 2) + TheBankBox.y1;
end;

procedure MMouseSlot(i: integer);
var
Mid: Tpoint;
TheBankBox: TBox;
begin
MakeBoxVisible(i);
TheBankBox:= BankBox(i);
MMouse(TheBankBox.x1 + 2 + random(27), TheBankBox.y1 + 2 + random(27), 0, 0);
end;

procedure MouseSlot(i: integer; left: boolean);
var
bx, by: integer;
begin
MMouseSlot(i);
GetMousePos(bx, by);
Mouse(bx, by, 0, 0, left);
end;

function ChooseOptionSlot(i: integer; s: string): boolean;
begin
MouseSlot(i, false);
wait(400);
result:= ChooseOption(s);
end;

function ItemExistsSlot(i: integer): boolean;
var
rx, ry: integer;
TheBankBox: TBox;
begin
MakeBoxVisible(i);
TheBankBox:= BankBox(i);
result:= FindColor(rx, ry, 65536, TheBankBox.x1, TheBankBox.y1, TheBankBox.x2, TheBankBox.y2);
end;

Special Ed

2007-09-14 18:22:26

Looks interesting I'll try it out when I get a chance but I'm not making a Banking script at the moment so I probably won't "use" it for quite some time.

pwnaz0r

2007-09-14 18:30:03

Ok, anything i could add?

nielsie95

2007-09-15 03:19:36

Very nice :)

EDIT: I did some testing, and it looks like it could use some tweaks:

MMouseSlot is way to random, it may miss the item (no uptext).
Also MMouseSlot(0) doesn't work?
It looks like ItemExistsSlot always returns true here.. (?)
And the scrolling also causes a lot of lag here =\

Other then that, I like your idea very much! :)

pwnaz0r

2007-09-15 03:43:45

From: nielsie95
Very nice :)

EDIT: I did some testing, and it looks like it could use some tweaks:

MMouseSlot is way to random, it may miss the item (no uptext).
Also MMouseSlot(0) doesn't work?
It looks like ItemExistsSlot always returns true here.. (?)
And the scrolling also causes a lot of lag here =\

Other then that, I like your idea very much! :)

yeah, we ironed out all of those bugs but Boreas and I are still trying to work on the ratio finding. Its a bit difficult considering the ratio can vary between 9.6 - 10.4. I think we almost have it though

- Hah, its fixed in update
- Slots start at 1
- same as #1
- scroll doesn't cause lag for me? maybe its just this version lol.

Point being, everything will be ironed out in update ;) If you have any suggestions please post

Dark_Sniper

2007-09-15 12:15:56

From: nielsie95


It looks like ItemExistsSlot always returns true here.. (?)


Yes and you should know for an item to return true the color : 65536 needs to be in the items slot range…
the new update to runescape made it so the pillars (borders of the item bag) contain this color :p


Also MMouseSlot(0) doesn't work?


maybe mmouseslot cannot move the mouse to slot "0" because it does not obtain the correct coords….(maybe a failsafe in the code prevents it form doing that? or the math in the code does not include 0…)

i hope you understood that…

also…
hope that clears things up

pwnaz0r

2007-09-15 16:08:23

From: Dark_Sniper
Yes and you should know for an item to return true the color : 65536 needs to be in the items slot range…
the new update to runescape made it so the pillars (borders of the item bag) contain this color :p



maybe mmouseslot cannot move the mouse to slot "0" because it does not obtain the correct coords….(maybe a failsafe in the code prevents it form doing that? or the math in the code does not include 0…)

i hope you understood that…

also…
hope that clears things up


anyways, i updated again and i think its fairly good. You currenty have to have numbers in that row. will add failsafes(checking multiple rows) when it is 100% stable (i think it is)