SRL Archive - Reflection Development

Smart Reflection Relocation - r_Relocate


Rich

2011-06-26 18:19:26

This isn't a thread suggesting one needs to be made, or how to do one, but instead showing one which I've made. It's fairly simple actually.

{*******************************************************************************
function r_Relocate(Where : string; ResultDist : Integer; Rest, Lumb : Boolean) : Boolean;
By: Rich
Description: Walks to user specified locations
'akb' : Al Kharid bank
'veb' : Varrock East bank
'vwb' : Varrock West bank
'feb' : Falador East bank
'fwb' : Falador West bank
'eb' : Edgeville bank
'db' : Draynor bank
'ge' : Grand Exchange
'ps' : Port Sarim (next to jewellery and axe store)
'lc' : Lumbridge Castle
'rim' : Rimmington (next to the fountain)
ResultDist is the distance to be from the desired location for the function to
result as True.
Rest is whether to rest or not when running along.
Lumb is whether or not to teleport back to Lumbridge if, for some reason, the
function fails to relocate your character.
Start where ever you want to. If you're on the path to your location, it will
detect that and carry on. If not, it'll teleport to Lumbridge and follow the
complete path.
*******************************************************************************}
function r_Relocate(Where : string; ResultDist : Integer; Rest, Lumb : Boolean) : Boolean;
var
I, T, PN, PC, X, Y : Integer;
FinalPoints, Path : TPointArray;
Tele : Boolean;

begin
FinalPoints:= [Point(3270, 3164), Point(3254, 3421), Point(3187, 3439),
Point(3012, 3356), Point(2945, 3369), Point(3093, 3494),
Point(3094, 3242), Point(3165, 3488), Point(3019, 3241),
Point(3224, 3217), Point(2955, 3213)];
case Where of
'akb' : PN:= 0;
'veb' : PN:= 1;
'vwb' : PN:= 2;
'feb' : PN:= 3;
'fwb' : PN:= 4;
'eb' : PN:= 5;
'db' : PN:= 6;
'ge' : PN:= 7;
'ps' : PN:= 8;
'lc' : PN:= 9;
'rim' : PN:= 10;
end;
Result:= (DistanceFrom(FinalPoints[PN]) <= ResultDist);
if Result then
Exit;
case Where of
'akb' : Path:= [Point(3231, 3217), Point(3236, 3207), Point(3244, 3193),
Point(3243, 3178), Point(3242, 3166), Point(3255, 3166),
Point(3263, 3173), Point(3275, 3171), Point(3270, 3164)];

'veb', 'eb',
'vwb', 'ge' : begin
Path:= [Point(3230, 3217), Point(3242, 3224), Point(3257, 3226),
Point(3260, 3238), Point(3254, 3250), Point(3251, 3263),
Point(3242, 3275), Point(3239, 3290), Point(3241, 3306),
Point(3251, 3317), Point(3264, 3324), Point(3278, 3332),
Point(3287, 3345), Point(3296, 3356), Point(3296, 3369),
Point(3294, 3382), Point(3292, 3396), Point(3290, 3409),
Point(3285, 3422), Point(3277, 3429), Point(3263, 3429)];

if (Where <> 'veb') then
begin
Path:= CombineTPA(Path, [Point(3252, 3429), Point(3238, 3430),
Point(3224, 3429), Point(3208, 3429), Point(3194, 3430)]);
if (Where = 'ge') then
Path:= CombineTPA(Path, [Point(3185, 3438), Point(3187, 3447),
Point(3179, 3450), Point(3168, 3459), Point(3165, 3471),
Point(3167, 3480)]);
if (Where = 'eb') then
Path:= CombineTPA(Path, [Point(3176, 3428), Point(3164, 3423),
Point(3150, 3417), Point(3137, 3417), Point(3123, 3417),
Point(3112, 3422), Point(3099, 3420), Point(3092, 3430),
Point(3092, 3441), Point(3096, 3453), Point(3099, 3465),
Point(3097, 3478), Point(3088, 3485), Point(3089, 3492)]);
end;
end;

'ps', 'rim',
'feb', 'db',
'fwb' : begin
Path:= [Point(3228, 3216), Point(3228, 3230), Point(3221, 3242),
Point(3218, 3256), Point(3216, 3270), Point(3204, 3278),
Point(3189, 3280), Point(3175, 3284), Point(3162, 3289),
Point(3147, 3293), Point(3133, 3294), Point(3118, 3293),
Point(3110, 3293)];

if (Where = 'db') then
Path:= CombineTPA(Path, [Point(3109, 3286), Point(3105, 3273),
Point(3105, 3258), Point(3105, 3249), Point(3095, 3247)])
else
Path:= CombineTPA(Path, [Point(3101, 3294), Point(3090, 3288),
Point(3076, 3282), Point(3061, 3276), Point(3046, 3275),
Point(3033, 3276)]);
if (Where = 'ps') then
Path:= CombineTPA(Path, [Point(3029, 3270), Point(3020, 3262),
Point(3018, 3249)]);
if (Where = 'rim') then
Path:= CombineTPA(Path, [Point(3094, 3192), Point(3025, 3276),
Point(3012, 3271), Point(2997, 3266), Point(2985, 3262),
Point(2971, 3255), Point(2960, 3247), Point(2956, 3233),
Point(2956, 3222)]);
if ((Where = 'feb') or (Where = 'fwb')) then
begin
Path:= CombineTPA(Path, [Point(3022, 3277), Point(3012, 3280),
Point(3008, 3293), Point(3006, 3307), Point(3007, 3321),
Point(3007, 3334), Point(3007, 3348), Point(3007, 3362)]);
if (Where = 'fwb') then
Path:= CombineTPA(Path, [Point(2999, 3364), Point(2989, 3372),
Point(2977, 3379), Point(2962, 3381), Point(2951, 3378),
Point(2945, 3375)]);
end;
end;
end;
Path:= CombineTPA(Path, [FinalPoints[PN]]);
ClickNorth(True);
Tele:= True;
for I:= 0 to High(Path) do
begin
if (DistanceFrom(Point(Path[I].x, Path[I].y)) < 15) then
begin
if (DistanceFrom(Point(Path[I + 1].x, Path[I + 1].y)) < 15) then
Inc(I);
if r_WebWalk(Path[I]) then
begin
I:= I;
Tele:= False;
Break;
end else
I:= 0;
end;
end;
if Tele then
begin
GameTab(tab_Magic);
SetupSpells;
Cast('lumbridge home teleport', False);
while (DistanceFrom(Point(3224, 3217)) > 15) do
begin
Wait(100);
IncEx(T, 100);
if (T > 15000) then
Break;
end;
Wait(2500 + Random(2000));
end;
SetAngle(True);
for I:= I to High(Path) do
begin
case r_GetMMLevels('run') of
0..30 : if Rest then
begin
RestUntil(75);
SetRun(True);
end;
40..100 : SetRun(True);
end;
if (Rest and FindSymbolIn(X, Y, 'rest', MMCX - 45, MMCY - 45, MMCX + 45, MMCY + 45)
and (r_GetMMLevels('run') < 70)) then
begin
Mouse(X, Y, 1, 1, True);
R_Flag;
RestUntil(100);
SetRun(True);
end;
if not r_WebWalk(Path[I]) then
begin
for PC:= 0 to High(Path) do
begin
if (DistanceFrom(Path[PC]) < 15) then
begin
r_WebWalk(Path[PC]);
I:= PC;
Break;
end;
I:= -1;
end;
if (I = -1) then
begin
WriteLn('Could not walk to ' + Where + ' using r_WebWalk method - attempting WalkPath');
Break;
end;
end;
Wait(500 + Random(500));
end;
Result:= (DistanceFrom(FinalPoints[PN]) <= ResultDist);
if Result then
Exit;
Result:= WalkPath(Path);
if ((not Result) and Lumb) then
begin
Cast('lumbridge home teleport', False);
WriteLn('Could not walk to ' + Where + ' using either method');
WriteLn('May or may not be at Lumbridge Castle depending on ''Lumb''');
end;
end;

The user can call the function no matter where they are in the RS world. If they are somewhere along the path to their location when the function is called, it will detect that and carry on from there. If not, it will teleport to Lumbridge and follow the complete path. Since it uses a twist on r_WebWalk as the primary walking method, no path will be same. If, for some reason that fails, it will try to detect the characters location. If that fails too, it will teleport back to Lumbridge and use WalkPath. Resting can be used in the form a var. ResultDist is the distance needed to be from the desired location for the function to result as true. In the unlikely event of both walking methods failing to get the character where the user wants it, they can choose whether or not to teleport to Lumbridge at the end by declaring Lumb as either true or false.

I've tested it a fair amount and it works fantastically. I've checked that the smart path detection works, and it does. I said that I wanted to go to VWB, and was stood in VEB. It detected I was on the path and carried on walking. This could be really useful if you want to relocate an entire army.

More paths to other locations could easily be added if needed.

Thoughts?

Flight

2011-06-26 21:14:19

Well I for one think it's pretty smart. I was considering, earlier, a WalkPath that would detect if you're a certain distance from the next tile or if it wasn't on the map, and simply "blindwalk" to that tile if the tile wasn't a long, long distance away. If it was then obviously something went way wrong and a home teleport (depending on what spell book you have) to start over and go from there.

Rich

2011-06-27 03:23:49

That was pretty much what I wanted to make; a reliable and easy way of walking. I guess if this doesn't get included into Reflection it could be turned into a script, or maybe implemented into MSI if the MSI Devs want to.

Rich

2011-06-27 06:44:40

Currently in the middle of making it quite a bit shorter by combining similar paths. Eg: VEB, VWB, GE, and EB. I'm going out in a minute, so will finish up when I'm back.

Flight

2011-06-27 07:07:01

From: Rich
Currently in the middle of making it quite a bit shorter by combining similar paths. Eg: VEB, VWB, GE, and EB. I'm going out in a minute, so will finish up when I'm back.


Ah good idea, I didn't think about that either.

As far as making it into a script, what idea could you suggest that would use all of your relocater to it's full potential? Maybe a world-walker or quest script, otherwise I can't think of many instances in which such long walks are needed.

Rich

2011-06-27 09:06:48

From: Flight
Ah good idea, I didn't think about that either.

As far as making it into a script, what idea could you suggest that would use all of your relocater to it's full potential? Maybe a world-walker or quest script, otherwise I can't think of many instances in which such long walks are needed.
I can think of a few just off the top of my head.
The two that you said (world walking and questing)
Army relocating
Could be used in HLR.
Death walks
Any script which might need to walk those paths.
An example could be if you are chopping yews south of Falador, all you'd need to do to get to the bank is get back near the path, then call this. Just an idea.

Drakan

2011-06-27 09:44:35

It probably wouldn't be implemented due simply to the fact that we plan on adding a web walker to reflection 2. But it looks nice :)

Rich

2011-06-27 09:48:21

Combined the paths, improved the path detection, and added so that if a rest point is spotted and Rest is True, it will rest there. Tested it all again and it works like a charm. Edited first post.
From: drags111
It probably wouldn't be implemented due simply to the fact that we plan on adding a web walker to reflection 2. But it looks nice :)
Is that already under development? If not, couldn't this be used a base? Well…It's more complete than a base. And thanks :)

Dgby714

2011-06-27 10:01:50

From: Rich
Combined the paths, improved the path detection, and added so that if a rest point is spotted and Rest is True, it will rest there. Tested it all again and it works like a charm. Edited first post.Is that already under development? If not, couldn't this be used a base? Well…It's more complete than a base. And thanks :)


Web <> Path

I like the web idea =)

Home

2011-06-27 12:34:53

Remember that r_WebWalk bugs your ass off if you are too near of your destination tile when you call r_WebWalk Function.

Simple fix is.

Pseudo code:

[PHP]If TileOnMM(FinalTile) Then WalkPath(FinalTile…) else r_WebWalk(FinalTile);[/PHP]

Otherwise looks great :)!


EDIT:

Btw is this possible :P

This:
[PHP] case Where of
'akb' : PN:= 0;
'veb' : PN:= 1;
'vwb' : PN:= 2;
'feb' : PN:= 3;
'fwb' : PN:= 4;
'eb' : PN:= 5;
'db' : PN:= 6;
'ge' : PN:= 7;
'ps' : PN:= 8;
'lc' : PN:= 9;
'rim' : PN:= 10;
end; [/PHP]

To this:

[PHP] LocInt := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim'];
for I := 0 to High(LocInt) do
if (Where = LocString) then
PN := LocInt; [/PHP]

Just asking :)

~Home

Rich

2011-06-27 12:43:26

From: Home
Remember that r_WebWalk bugs your ass off if you are too near of your destination tile when you call r_WebWalk Function.

Simple fix is.

Pseudo code:

[PHP]If TileOnMM(FinalTile) Then WalkPath(FinalTile…) else r_WebWalk(FinalTile);[/PHP]

Otherwise looks great :)!

~Home
Thanks. Will change that. I've decided I'm going to make it into a proper script, except it will be a fair amount more complicated with 'regions' as such.

Drakan

2011-06-27 13:50:26

What you have there is not web walking. That is great for certain scripts but it's definitely not the same thing ;) And yes it's been under development for a while, but won't be finished till after the initial release of Reflection 2.

Rich

2011-06-27 15:24:00

From: Home
Btw is this possible :P

This:
[PHP] case Where of
'akb' : PN:= 0;
'veb' : PN:= 1;
'vwb' : PN:= 2;
'feb' : PN:= 3;
'fwb' : PN:= 4;
'eb' : PN:= 5;
'db' : PN:= 6;
'ge' : PN:= 7;
'ps' : PN:= 8;
'lc' : PN:= 9;
'rim' : PN:= 10;
end; [/PHP]

To this:

[PHP] LocInt := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim'];
for I := 0 to High(LocInt) do
if (Where = LocString) then
PN := LocInt; [/PHP]

Just asking :)

~Home
You genius!

From: drags111
What you have there is not web walking. That is great for certain scripts but it's definitely not the same thing ;) And yes it's been under development for a while, but won't be finished till after the initial release of Reflection 2.
OK no worries :)

Gu3st...

2011-06-27 17:21:13

LocInt := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 
LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim'];
for I := 0 to High(LocInt) do
if (Where = LocString[I]) then
PN := LocInt[I];

There's no need for the int array actually…

LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim']; 
for I := High(LocString) downto 0 do
if (Where = LocString[I]) then
begin
PN := I;
Break;
end;

Home

2011-06-27 17:27:41

From: Zyt3x
LocInt := [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 
LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim'];
for I := 0 to High(LocInt) do
if (Where = LocString[I]) then
PN := LocInt[I];

There's no need for the int array actually…

LocString := ['akb', 'veb', 'vwb', 'feb', 'fwb', 'eb', 'db', 'ge', 'ps', 'lc', 'rim']; 
for I := High(LocString) downto 0 do
if (Where = LocString[I]) then
begin
PN := I;
Break;
end;


Ohh yeah. Because there is just number what increase by one :)

~Home