SRL Archive - OSR Help

DiscoverArea


DeSnob

2010-12-01 11:17:13

Since I want to make a large script I need a procedure that will work globally. This function is supposed to see if your character is around the walking path to the selected area. It also has a banking parameter to invert the path. The problem is that even after it checks the minimap it never actually completes what it's supposed to do.
function LoadPath(Which: string): TPointArray;
begin
case (Which) of
'lumby swamps','noob mine':
begin
SetLength(Result, 23);

Result[0] := Point(3973, 2572);
Result[1] := Point(3978, 2576);
Result[2] := Point(3977, 2581);
Result[3] := Point(3984, 2581);
Result[4] := Point(3990, 2581);
Result[5] := Point(3995, 2581);
Result[6] := Point(3997, 2577);
Result[7] := Point(3998, 2572);
Result[8] := Point(3999, 2567);
Result[9] := Point(4002, 2563);
Result[10] := Point(4004, 2558);
Result[11] := Point(4007, 2554);
Result[12] := Point(4005, 2548);
Result[13] := Point(4005, 2544);
Result[14] := Point(4002, 2540);
Result[15] := Point(4001, 2536);
Result[16] := Point(3999, 2531);
Result[17] := Point(3998, 2525);
Result[18] := Point(3996, 2521);
Result[19] := Point(3994, 2517);
Result[20] := Point(3993, 2513);
Result[21] := Point(3989, 2512);
Result[22] := Point(3989, 2509);
end;
end;
end;
procedure InvertTpPath(var Path: TPointArray);
var
Temp: TPointArray;
i: integer;
begin
for i := High(Path) downto 0 do
begin
SetLength(Temp, Length(Temp)+1);
Temp[High(Temp)] := Path[i];
end;
Path := Temp;
end;

function DiscoverArea(Where: String; Bank: Boolean): Boolean;
var
i, Location: Integer;
Path: TPointArray;
begin
Writeln('Testing..');
Path := LoadPath(Where);
if Length(Path) = 0 then
begin
Writeln('INVALID PATH!');
TerminateScript;
end;
for i:= 0 to High(Path) do
begin
if (TileOnMM(Tile(Path[i].x, Path[i].y))) then
Location := i;
Writeln(IntToStr(i));
end;
if (Bank) then
InvertTpPath(Path);
for i:= (Location) to High(Path) do
begin
Result := WalkToTile(Tile(Path[i].x, Path[i].y), 5, 2+random(5));
if (Result) then
Writeln('Successfully Walked to tile [ '+ IntToStr(Path[i].x) + ', '
+ IntToStr(Path[i].y) + ' ]');
end;
end;

*Most of the begins are just to debug. *

It goes through each tile but even though the player is on the path it does not do anything. Location is always 0. :(

It returns this:
Testing..
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0//location variable

Cstrike

2010-12-01 11:25:38

These are my quick recommendations:

procedure InvertTpPath(var Path: TPointArray);
var
Temp: TPointArray;
i: integer;
begin
for i := High(Path) downto 0 do
begin
SetLength(Temp, Length(Temp)+1);
Temp[High(Temp)] := Path[i];
end;
Path := Temp;
end;

For this function, WizzyPlugin has a faster function called InvertTPA (…) which you can use. Since it's a plugin, runs faster ;) (nothing noticeable though, but good job at creating your own code).

For walking, don't use WalkToTile, try WalkPath (TTileArrayHere);
Plug int the TPA anyways, try this:

 Result := WalkPath (LoadPath);
//or
Result := WalkPath(InvertTPA(LoadPath));
Havent tested them, but should work!
I <3 WalkPath.

DeSnob

2010-12-01 11:33:15

From: cstrike
These are my quick recommendations:

procedure InvertTpPath(var Path: TPointArray);
var
Temp: TPointArray;
i: integer;
begin
for i := High(Path) downto 0 do
begin
SetLength(Temp, Length(Temp)+1);
Temp[High(Temp)] := Path[i];
end;
Path := Temp;
end;

For this function, WizzyPlugin has a faster function called InvertTPA (…) which you can use. Since it's a plugin, runs faster ;) (nothing noticeable though, but good job at creating your own code).

For walking, don't use WalkToTile, try WalkPath (TTileArrayHere);
Plug int the TPA anyways, try this:

 Result := WalkPath (LoadPath);
//or
Result := WalkPath(InvertTPA(LoadPath));
Havent tested them, but should work!
I <3 WalkPath.


But I need it to walk from a certain point. I don't want to tell the user to just go to the bank or mining area. I want them to have a wide array of locations. :)

E: How would I remove the un-needed tiles, so that it just walks from its current spot?

HyperSecret

2010-12-01 12:39:24

I would do something like…


for (tiles in array)
if (me within a certain distance to tile[i]) then
Location = i

for (location to end of path)
if TileOnMM() then
WalkToTile

or something of the sort

Cstrike

2010-12-01 12:48:47

From: DeSnob
But I need it to walk from a certain point. I don't want to tell the user to just go to the bank or mining area. I want them to have a wide array of locations. :)

E: How would I remove the un-needed tiles, so that it just walks from its current spot?


If I have this right, lets say you're at Path # 5 of 12, WalkPath will start at 5 or 6 of 12 (if 6 is the most visible one) and walk that path. It won't start at the beginning for you.

DeSnob

2010-12-01 13:52:16

From: cstrike
If I have this right, lets say you're at Path # 5 of 12, WalkPath will start at 5 or 6 of 12 (if 6 is the most visible one) and walk that path. It won't start at the beginning for you.


:duh::duh::duh::duh::duh: