SRL Archive - Reflection Development

function R_AtBank(WhichBank: string): boolean;


All that is man

2009-07-06 23:51:09

Bored out of my mind so I made this, didn't add any P2P banks cause I don't have a member atm, just an idea.

{*******************************************************************************
function R_atBank(WhichBank: string): boolean;
By: All that is man
Description: Returns true if at the given bank.
*******************************************************************************}
function R_atBank(WhichBank: string): boolean;
begin
case lowerCase(WhichBank) of
'ge' : result := (tileOnMM(Point(3164, 3487)));
'veb': result := (tileOnMM(Point(3186, 3439)));
'vwb': result := (tileOnMM(Point(3253, 3420)));
'eb' : result := (tileOnMM(Point(3093, 3490)));
'feb': result := (tileOnMM(Point(2945, 3368)));
'fwb': result := (tileOnMM(Point(3012, 3356)));
'akb': result := (tileOnMM(Point(3270, 3167)));
'lb' : result := (tileOnMM(Point(3208, 3217)));
'db': result := (tileOnMM(Point(3093, 3243)));
end;
end;

marpis

2009-07-07 08:26:47

you should make it like

function R_InBank(WhichBank: string): boolean;
var
P: TPoint;
begin
P := GetMyPos; // is this a proper function?
case lowercase(WhichBank) of
'veb': result := InRange(P.x, VEBx1, VEBx2) and InRange(P.y, VEBy1, VEBy2);
'vwb': result := InRange(P.x, VWBx1, VWBx2) and InRange(P.y, VWBy1, VWBy2);
...
end;
end;

but that's a very useful function mate!

All that is man

2009-07-07 21:02:50

Eh how does inrange work i couldn't figure it out

Phran6

2009-07-07 21:42:55

if between the 2 number
so its like if you make a box and check if your in

All that is man

2009-07-07 22:36:54

From: francishelie
if between the 2 number
so its like if you make a box and check if your in


yeah i tried it out but i couldn't figure it out cause it said that we weren't in the bank with my writeln procedure

is it

InRange(p.x, top left hand corner x, bottom right hand corner x) and InRange(p.y, top left hand corner y, bottom right hand corner y);

??

The Little

2009-07-08 15:07:31

This worked for me:

{ **************************************************************************** )
CharInBox(UpperLeft, BottomRight);
Returns True when in box
( **************************************************************************** }
function CharInBox(P1, P2 : TPoint) : boolean;
var
Char : TPoint;
begin
Char := GetMyPos;
Result := InRange(Char.x, P1.x, P2.x) and InRange(Char.y, P1.y, P2.y);
end;

Gu3st...

2009-07-08 15:13:08

From: marpis
you should make it like
Code:
[LEFT]function R_InBank(WhichBank: string): boolean;
var
P: TPoint;
begin
P := GetMyPos; // is this a proper function?
case lowercase(WhichBank) of
'veb': result := InRange(P.x, VEBx1, VEBx2) and InRange(P.y, VEBy1, VEBy2);
'vwb': result := InRange(P.x, VWBx1, VWBx2) and InRange(P.y, VWBy1, VWBy2);
…
end;
end;
[/LEFT]


but that's a very useful function mate!

But it would not be faster :)

The Little

2009-07-08 16:25:08

it wouldn't be faster, but it would me more precise (in the bank, instead of close to it). but that could be a different function all together, AtBank and InBank.

marpis

2009-07-08 17:26:31

From: All that is man
yeah i tried it out but i couldn't figure it out cause it said that we weren't in the bank with my writeln procedure

is it

InRange(p.x, top left hand corner x, bottom right hand corner x) and InRange(p.y, top left hand corner y, bottom right hand corner y);

??

Banks are recantgles, which means that

top right corner X = bottom right corner X
top left corner X = bottom left corner X

top left corner Y = top right corner Y
bottom left corner Y = bottom right corner Y


So yes, you're doing it right :)


From: Zyt3x
But it would not be faster :)

Precision is worth a millisecond :|
EDIT: Actually my way is faster.
TileOnMM uses TileToMM, GetMyPos, GetMinimapAngleRad (which uses a few functions) and rs_OnMinimap, which all have plenty of calculations.
Mine only uses GetMyPos and InRange.

There can be many many lines behind a very short procedure. Besides, shorter is not always faster ;)

Don't post

Gu3st...

2009-07-08 21:21:44

From: marpis
EDIT: Actually my way is faster.
TileOnMM uses TileToMM, GetMyPos, GetMinimapAngleRad (which uses a few functions) and rs_OnMinimap, which all have plenty of calculations.
Mine only uses GetMyPos and InRange.

There can be many many lines behind a very short procedure. Besides, shorter is not always faster ;)

Don't post

But your procedure uses more memory :p
P : TPoint and all those WEBx1 stuff…
Anyway: I don't care :P It is a nice function, both of you ;)

All that is man

2009-07-08 23:25:49

Ok guys I just tried to make it and guess what, jagex updated runescape…. just my luck. So i'll make it when the hooks are updated thanks for all of the ideas =D

marpis

2009-07-09 00:15:33

From: Zyt3x
But your procedure uses more memory :p
P : TPoint and all those WEBx1 stuff…
Anyway: I don't care :P It is a nice function, both of you ;)


It's only 2 variables:
P: TPoint;
BankBoxes: Array [0..?] of TBox;

;)

Blumblebee

2009-07-09 01:00:03

why not use distancefrom() ?

The Little

2009-07-09 23:38:52

That would probably be the best Blumblebee, although not as precise as the box method, it is probably faster. I couldn't find the function in the reflection dirs so I have no idea what's hiding behind it though.

mormonman

2009-07-10 01:31:18

From: The Little
That would probably be the best Blumblebee, although not as precise as the box method, it is probably faster. I couldn't find the function in the reflection dirs so I have no idea what's hiding behind it though.


I think it would be great because if the bank is that distance(like 14-16 tiles) from it you can always walk to it on the minimap

marpis

2009-07-10 14:56:23

From: The Little
That would probably be the best Blumblebee, although not as precise as the box method, it is probably faster. I couldn't find the function in the reflection dirs so I have no idea what's hiding behind it though.


Why do everyone think that the box method would be slow?
It's matter of microseconds here -_-'

Making faster functions is essential when they are called often, like

function DoSomething(P: TPoint): boolean;
var
a, b: integer;
begin
a := P.x;
b := P.y;
if (a*2*4*8) > (3*5*7) then
result := (b*6*5*3) < (8 div 4 div 2);
end;

begin
FindColorsTolerance(TPA, 123123, MSX1, MSY1, MSX2, MSY2, 100);
for i := 0 to high(TPA) do
if DoSomething(TPA[i]) then
break;
end.

When we have a huge array we have to go through. In this case
DoSomething is called very many times, that's why we must make it as efficient as possible. Let's take a look at the function DoSomething: As we can see, it has many multiplying calculations and computers are pretty bad in multiplying and division. Let's make it faster:

function DoSomething(P: TPoint): boolean;
begin
if (P.x shl 6) > (105) then
result := (P.y*90) < (1);
end;

These are the cases where faster functions really matter.
When you check If R_AtBank('feb') every 10 minutes, it doesn't matter a crap if it takes 0.01 ms or 0.02 ms.

No more "this is faster way"- posts please

Here's my function with made-up cords:

function R_AtBank(WhichBank: string): boolean;
var
i: integer;
s: string;
P: TPoint;
SBanks: Array [0..8] of String;
BankPoints: Array [0..35] of Integer;
begin
P := GetMyPos;
s := lowercase(WhichBank);
SBanks := ['ge', 'veb', 'vwb' 'eb', 'feb', 'fwb', 'akb', 'lb', 'db'];
BankPoints := [3340, 3888, 3345, 3882, // ge x1, y1, x2, y2
3145, 2999, 3140, 3005, // veb x1, y1, x2, y2
3215, 3145, 2989, 3455, // vwb x1, y1, x2, y2
3456, 2997, 3654, 2897, // eb x1, y1, x2, y2
2698, 2687, 3487, 2459, // feb x1, y1, x2, y2
3887, 3998, 3456, 3657, // fwb x1, y1, x2, y2
2897, 3568, 2989, 3656, // akb x1, y1, x2, y2
3597, 2996, 3458, 2969, // lb x1, y1, x2, y2
2929, 3487, 3837, 3624]; // db x1, y1, x2, y2
for i := 0 to 8 do
if s = SBanks[i] then
begin
result := InRange(P.x, BankPoints[i shl 2], BankPoints[(i shl 2)+2]) and
InRange(P.y, BankPoints[(i shl 2)+1], BankPoints[(i shl 2)+3];
exit;
end;
end;
Cords are made up, they don't work!!

mormonman

2009-07-10 15:23:21

Marpis use an array of an array or a TBoxArray. What you have right now won't work, plus would if you are within like 2 tiles or so from being inside the bank… I think you can still open it. DistanceFrom() is your best bet for this function(not just for speed).

If you want to do a function like that name it R_InBank; or something.

marpis

2009-07-10 15:46:35

From: mormonman
Marpis… What you have right now won't work,…


Yes it does.

Lets assume you call
R_AtBank('db');


// 'db' = SBanks[8]

for i := 0 to 8 do
if s = SBanks[i] then
begin
result := InRange(P.x, BankPoints[i shl 2], BankPoints[(i shl 2)+2]) and
InRange(P.y, BankPoints[(i shl 2)+1], BankPoints[(i shl 2)+3];
exit;
end;
{
i = 8
~ x ~
8 shl 2 = 32
i shl 2 + 2 = 34
InRange(P.x, BankPoints[32], BankPoints[34])
Lets see the cords array
InRange(P.x, 2929, 3837) these are db x1 and x2

~ y ~
8 shl 2 + 1 = 33
8 shl 2 +3 = 35

InRange(P.y, BankPoints[33], BankPoints[35])
Lets see the cords array
InRange(P.y, 3487, 3624) these are db y1 and y2

You've been proven wrong.

mormonman

2009-07-11 00:57:33

From: marpis
Yes it does.

Lets assume you call
R_AtBank('db');


// 'db' = SBanks[8]

for i := 0 to 8 do
if s = SBanks[i] then
begin
result := InRange(P.x, BankPoints[i shl 2], BankPoints[(i shl 2)+2]) and
InRange(P.y, BankPoints[(i shl 2)+1], BankPoints[(i shl 2)+3];
exit;
end;
{
i = 8
~ x ~
8 shl 2 = 32
i shl 2 + 2 = 34
InRange(P.x, BankPoints[32], BankPoints[34])
Lets see the cords array
InRange(P.x, 2929, 3837) these are db x1 and x2

~ y ~
8 shl 2 + 1 = 33
8 shl 2 +3 = 35

InRange(P.y, BankPoints[33], BankPoints[35])
Lets see the cords array
InRange(P.y, 3487, 3624) these are db y1 and y2

You've been proven wrong.


Wow, I hope you think you are cool after you changed that code. It did not have shl when I read it, just i.

Edit: and your other one would work, but it would cycle through unneeded numbers, wasting time.

marpis

2009-07-11 14:53:32

From: mormonman
Wow, I hope you think you are cool after you changed that code. It did not have shl when I read it, just i.

Edit: and your other one would work, but it would cycle through unneeded numbers, wasting time.


well i changed the code immediately when i had posted the 1st one, cause i noticed i had forgotten the i*4 ^^

and to the timewasting: read my former reply.