SRL Archive - Reflection Development

R_AtBank


**BANNED The Man

2011-02-13 08:28:48

{*******************************************************************************
Function R_AtBank(Bank : String): Boolean;
By: Dynamite
Description: Will result true if at specified bank.
*******************************************************************************}
function R_AtBank(Bank : String) : Boolean;
var
Tiles: TPointArray;
P: TPoint;
Tries: Integer;
begin
case LowerCase(Bank) of
'veb', 'varrock east':
Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb', 'varrock west':
Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444),
Point(3181,3442), Point(3181,3440), Point(3181,3438),
Point(3181,3436)];
'falador west', 'fwb':
Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'falador east', 'feb':
Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lumbridge', 'lb':
Tiles := [Point(3208,3221)];
'draynor', 'db':
Tiles := [Point(3091,3245), Point(3091,3243), Point(3091,3242)];
'al kharid', 'akb':
Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3169), Point(3268,3164)];
'seb', 'seers':
Tiles := [Point(2729,3494), Point(2728,3494), Point(2727,3494),
Point(2724,3494), Point(2722,3494), Point(2721,3494)];

'ctb', 'catherby':
Tiles := [Point(2807,3442), Point(2809,3442), Point(2810,3442),
Point(2811,3442)];

'eb', 'edgeville':
Tiles := [Point(3095,3489), Point(3095,3491), Point(3095,3493),
Point(3097,3495)];
'cb', 'catherby':
Tiles := [Point(2807, 3442), Point(2809, 3442), Point(2810, 3442), Point(2811, 3442)];
'fgb', 'fishing guild':
Tiles := [Point(2584, 3423), Point(2584, 3422)];
'mc', 'moonclan':
Tiles := [Point(2098, 3920), Point(2097, 3920), Point(2098, 3920)];
'yb', 'yanille':
Tiles := [Point(2614, 3094), Point(2614, 3092), Point(2614, 3091)];
'da', 'duel arena': Tiles := [Point(3381, 3269), Point(3382, 3270)];
'asb', 'ardougne south': Tiles := [Point(2656, 3286), Point(2656, 3283)];
'pc', 'pest control':
Tiles := [Point(2667, 2652), Point(2666, 2652), Point(2665, 2652),
Point(2668, 2652)];
else
begin
SRL_Warn('R_AtBank', 'Unsupported bank name.', -1);
Exit;
end;
end;
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 4) or not TileOnMS(Tiles[0], 10) then
begin
if not(TileOnMM(Tiles[0])) then
begin
SRL_Warn('R_AtBank', 'Not At '+Bank, Warn_AllVersions);
Exit;
end;
WalkToTile(Tiles[0], 0, 0);
Wait(50);
R_Flag;
Wait(RandomRange(100, 200));
end;
if not(TileOnMS(Tiles[0], 10)) then
begin
SetAngle(True);
MakeCompass('n');
Wait(RandomRange(200, 400));
if not(TileOnMS(Tiles[0], 10)) then
begin
SRL_Warn('R_AtBank', 'Couldnt get MS Point.', Warn_AllVersions);
Exit;
end;
end;
Result := DistanceFrom(Tiles[0]) =< 4;
end;

If you are within 4 tiles of one of the bank tiles specified it will result true, else false.

-Boom

Sir R. M8gic1an

2011-02-13 08:30:08

Cool function, I like the thinking of it.

Could be used to determine areas… :)

~RM

**BANNED The Man

2011-02-13 08:32:07

From: Sir R. M8gic1an
Cool function, I like the thinking of it.

Could be used to determine areas… :)

~RM


Indeed, I like your thinking :)
I am going to post up another few functions now, I will request a pull from nava2 in a few minutes :)
Please check the others out and feedback ? <3

-Boom

Sir R. M8gic1an

2011-02-13 08:33:55

Sure, I shall sooner or later.

I'd suggest you use bank constants tho. I believe they've already been in SRL for a long time, and they don't break the scripts, but it'd make for a much easier switchover to SRL 5.

~RM

**BANNED The Man

2011-02-13 08:46:19

From: Sir R. M8gic1an
Sure, I shall sooner or later.

I'd suggest you use bank constants tho. I believe they've already been in SRL for a long time, and they don't break the scripts, but it'd make for a much easier switchover to SRL 5.

~RM


I am in the progress of editing reflections Bank.scar to use constants, then I will edit this to work with that :)

-Boom

Craig`

2011-02-13 12:15:18

Result := DistanceFrom(Tiles[0]) =< 4;

shouldn't it be <=?

**BANNED The Man

2011-02-13 12:17:00

Exactly same thing :)
Mine means: Equal to or less than 4
Yours means: Less than or equal to 4.

-Boom

Sir R. M8gic1an

2011-02-13 12:20:42

PointInBox?

~RM

NCDS

2011-02-13 12:29:13

From: Sir R. M8gic1an
Sure, I shall sooner or later.

I'd suggest you use bank constants tho. I believe they've already been in SRL for a long time, and they don't break the scripts, but it'd make for a much easier switchover to SRL 5.

~RM


The constants are Integers in SRL 5 though, not strings like in SRL 4. Just pointing that out.

**BANNED The Man

2011-02-13 12:31:40

From: NCDS
The constants are Integers in SRL 5 though, not strings like in SRL 4. Just pointing that out.


Should I do that then?

-Boom

NCDS

2011-02-13 12:33:07

From: Dynamite
Should I do that then?

-Boom


If you want to comply with SRL 5 when the switch is made, then yeah, it probably wouldn't be a bad idea.

**BANNED The Man

2011-02-13 12:46:20

Ok, just converted Bank.scar to SRL 5 compatible :)
Now uses Bank constants that are integers as well :)

-Boom

Nava2

2011-02-13 12:59:53

You may want to make sure they are the same constants ;)

NCDS

2011-02-13 13:00:07

From: Dynamite
Ok, just converted Bank.scar to SRL 5 compatible :)
Now uses Bank constants that are integers as well :)

-Boom


Function in OP still uses strings?


const
Bank_LB = 1; //'lb'; (Lumbridge Bank)
Bank_FE = 2; //'feb'; (Falador East Bank)
Bank_FW = 3; //'fwb'; (Falador West Bank)
Bank_VE = 4; //'veb'; (Varrock East Bank)
Bank_VW = 5; //'vwb'; (Varrock West Bank)
Bank_GE = 6; //'geb'; (Varrock GE Bank)
Bank_DR = 7; //'db' ; (Draynor Bank)
Bank_AK = 8; //'akb'; (Al-Kharid Bank)
Bank_EV = 9; //'eb' ; (Edgeville Bank)
Bank_CT = 10; //'ctb'; (Catherby bank)
Bank_CM = 11; //'clt'; (Camelot bank)
Bank_NA = 12; //'nab'; (North Ardougne bank)
Bank_SA = 13; //'sab'; (South Ardougne bank)
Bank_YN = 14; //'ynb'; (Yanille bank)
Bank_NG = 15; //'ngb'; (North gnome bank)
Bank_SG = 16; //'sgb'; (South gnome bank)
Bank_WG = 17; //'wgb'; (Warrior guild bank)
Bank_FG = 18; //'fgb'; (Fishing guild bank)
for easy reference.

**BANNED The Man

2011-02-13 13:05:57

From: NCDS
Function in OP still uses strings?


const
Bank_LB = 1; //'lb'; (Lumbridge Bank)
Bank_FE = 2; //'feb'; (Falador East Bank)
Bank_FW = 3; //'fwb'; (Falador West Bank)
Bank_VE = 4; //'veb'; (Varrock East Bank)
Bank_VW = 5; //'vwb'; (Varrock West Bank)
Bank_GE = 6; //'geb'; (Varrock GE Bank)
Bank_DR = 7; //'db' ; (Draynor Bank)
Bank_AK = 8; //'akb'; (Al-Kharid Bank)
Bank_EV = 9; //'eb' ; (Edgeville Bank)
Bank_CT = 10; //'ctb'; (Catherby bank)
Bank_CM = 11; //'clt'; (Camelot bank)
Bank_NA = 12; //'nab'; (North Ardougne bank)
Bank_SA = 13; //'sab'; (South Ardougne bank)
Bank_YN = 14; //'ynb'; (Yanille bank)
Bank_NG = 15; //'ngb'; (North gnome bank)
Bank_SG = 16; //'sgb'; (South gnome bank)
Bank_WG = 17; //'wgb'; (Warrior guild bank)
Bank_FG = 18; //'fgb'; (Fishing guild bank)
for easy reference.


Check: http://villavu.com/forum/showthread.php?t=62333
:)

-Boom

EvilChicken!

2011-02-13 15:25:11

From: Dynamite
Exactly same thing :)
Mine means: Equal to or less than 4
Yours means: Less than or equal to 4.

-Boom


No, he actually has a point; because of precedence, there's only one way to correctly write such a statement.

begin
WriteLn(4 >= 5);
WriteLn(4 => 5);
end.

Try to run the code above; you'll get an error at the second writeLn; I hope you see what I mean then. :)