SRL Archive - MSI Suggestions

Walk+retrieve anywhere reflection walker [addition to Location] - project


Cstrike

2010-08-30 10:33:03

Completion list thus far:
[green = done —- orange = working on —- red = not done yet]
    Define nodes
    [*]Travel to any node
    [*]Can travel to any point with BlindWalk unless utterly lost (aka: outside of map at bottom)
    [*]Test with TPA subpoints from an ATPA
    [*]Ensure program can be retrieved to any bank
    [*]Create all the paths for MSI
    [*]Ability to walk to any point you input

    Additional cool pieces that should be added through time
    [*]Create ALL possible F2P paths
    [*]Al Kharid support and Karamja support
    [*]>60 total level support
    [*]Failsafe works on second floors for common teleport fail places (ex: wiz tower)



Hi there,

I've been interested in making world walking scripts. So far it has been successful.
NOTE: This is a simba script so far only
NOTE 2: This was inspired by Zyt3x's walker

Update:

The purpose of the world walker I've made is to
A) Retrieve you from *wherever*
B) Walk to wherever
C) It is NOT meant to be a walking script in general though. You should not use it to go from Position A to B, and then B to A multiple times. For back and forth trips, your own reflection walking script should be made ;), this is specifically for moving your account or army to whatever position.
How this helps MSI is that it would allow all the scripts to be carried out. You could code it like this

case random(5) of
0: DoCombat;
1: DoWoodcutting;
2: DoMining;
3: DoFishing;
4: DoFiremaking;
5: DoCrafting;
end;

//... down the line...

// When running procedure DoWhatever
WalkTo (RELEVANT_POINT);
MainScriptHere;

The WalkTo (TP: TPoint); command is designed to take you to wherever you desire. Just plug in a coordinate and you are retrieved. I would like to let you know for now though, if you're in some obscure location like al kharid, karamja, crandor…etc, the script will not work too well. Same for the wilderness. Same for places that don't have many points (ex: lumber yard, but it will be supported later).

If you're within a reasonable distance from a path that is attached below, and can walk to it in a relatively straight line, then you will be retrieved. Otherwise you wont for now. Ideally when completed you will be able to be anywhere on RS. This will actually be pretty useful for doing quests.

What I need to add in
MSI support, it'd be cool if I could call something like
WalkToLoc (LOC_DB_WILLOWS)
And it takes you there.
Actually, it could easily do that if you define LOC_DB_WILLOWS as a TPoint near the willows. One line of code :)

I need to add in all the paths (sorry) and karamja support + al kharid. That won't be hard

I will not be doing P2P for a while, if ever. Does not mean I will never do it, but making the paths sort of sucks. Though now I'm better at it!

Below the script is attached for you to test out!
Any questions are welcome in this huge thread.

NOTE: The code is very messy, and it is unoptimized. I reduced some of the debug output but still expect your debug box to get somewhat… owned…

Here is the [most up to date] code if you hate downloading:
NEWEST VERSION UPLOADED: 0.01
Remember, it's in its alpha or pre-alpha. Next phase is for me to add all the subpaths. I fixed the falador bug btw ;)

Sir R. M8gic1an

2010-08-30 10:44:57

Can we see some code? :D Sounds great.

~RM

Cstrike

2010-08-30 10:48:34

How could I forget the code :p stupid me:

NOTE: This is what I have so far. I took out some random procedure by accident that was for debugging only, so some of these may not totally work

Also, my ReflectionWalker needs to be updated to include angles, I sort of screwed up there. In addition, the code SUCKS for that section

EDIT: I know the code may not be up to MSI standards, I expect if it does become useful that I will re-work it and make the procedures much more succinct/less messy

program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

{
To add a new node,
1) Define it in the constants below
2) Add it to "ListNodePoints" procedure
3) Add it to SetupNodePoints (important)
4) Add it to AssignNodeLocation (important)
}

const
ox = 0; // X axis offset
oy = 0; // Y axis offset

// Node points
varrockWestBank_x = 3186 + ox;
varrockWestBank_y = 3439 + oy;
faladorEastBank_x = 3013 + ox;
faladorEastBank_y = 3356 + oy;
lumbridgeNE_x = 3217 + ox;
lumbridgeNE_y = 3251 + oy;
draynorBank_x = 3094 + ox;
draynorBank_y = 3242 + oy;
barbVillageC_x = 3081 + ox;
barbVillageC_y = 3416 + oy;

// General variables needed across multiple functions
var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
currentLocString : String; // String of current location, used for
highwayTPA : TPointArray;

// Highway variables
VWB_LNE, VWB_BBC,
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC,
EntireHighwayArray : TPointArray;

// Street variables

// Finds the minimum number of a TIntArray and returns the lowest integer
function FindMin (TIntArray : TIntegerArray) : Integer;
var i, j : Integer;
minFound : Boolean;
begin
minFound := false;
for i:=0 to high(TIntArray)do // This finds the mode and returns it's value
begin
for j:=0 to high(TIntArray) do
begin
if TIntArray[j] < TIntArray[i] then
begin
Break;
end;
if (j = high(TIntArray)) and not minFound then
begin
minFound := true;
result := TIntArray[i];
end;
end;
if minFound then break;
end;
end;

function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

// Attempts to walk (blindly) towards a tile
// X increases as you go east, y as you go north
// Needs some SERIOUS code fixing...
// NOTE: For walkRadius, use '8' as default if you want to travel about
// 1/2 the way to the edge of the minimap (ex: radius 8 means if found
// south of you only, will probably travel between MMCY, and MMY2/2
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, opp, hyp, increments, cx, cy, xincI, yincI : Integer;
xinc, yinc : Extended;
walkPoint : TPoint;
begin
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

// This procedure will add a TPA to a TTileArray (and convert it properly)
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

// This procedure sets up node points (major points, usually banks)
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (varrockWestBank_x, varrockWestBank_y), // 0 Varrock west bank
Tile (faladorEastBank_x, faladorEastBank_y), // 1 Fally east bank
Tile (lumbridgeNE_x, lumbridgeNE_y), // 2 Lumby NE
Tile (draynorBank_x, draynorBank_y), // 3 Draynor bank
Tile (barbVillageC_x, barbVillageC_y) // 4 Barb village center (S of dungeon)
];
// Highways
VWB_LNE := [Point(varrockWestBank_x, varrockWestBank_y), Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(lumbridgeNE_x, lumbridgeNE_y)];
VWB_BBC := [Point(varrockWestBank_x, varrockWestBank_y), Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(barbVillageC_x, barbVillageC_y)];

BBC_VWB := [Point(barbVillageC_x, barbVillageC_y), Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(varrockWestBank_x, varrockWestBank_y)];
BBC_FEB := [Point(barbVillageC_x, barbVillageC_y), Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (faladorEastBank_x, faladorEastBank_y)];

DRB_LNE := [Point(draynorBank_x, draynorBank_y), Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(lumbridgeNE_x, lumbridgeNE_y)];
DRB_FEB := [Point(draynorBank_x, draynorBank_y), Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (faladorEastBank_x, faladorEastBank_y)];

LNE_DRB := [Point(lumbridgeNE_x, lumbridgeNE_x), Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(draynorBank_x, draynorBank_y)];
LNE_VWB := [Point(lumbridgeNE_x, lumbridgeNE_y), Point(3223, 3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (varrockWestBank_x, varrockWestBank_y)];

FEB_DRB := [Point (faladorEastBank_x, faladorEastBank_y), Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (draynorBank_x, draynorBank_y)];
FEB_BBC := [Point (faladorEastBank_x, faladorEastBank_y), Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(barbVillageC_x, barbVillageC_y)];

EntireHighwayArray := [Point(varrockWestBank_x, varrockWestBank_y), Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247), //22 (last TP is #22)
Point(lumbridgeNE_x, lumbridgeNE_x), Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), //41
Point(draynorBank_x, draynorBank_y), Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), //59
Point (faladorEastBank_x, faladorEastBank_y), Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(barbVillageC_x, barbVillageC_y) //78
];

//Streets
end;

// This is used to find the closest node point
// This procedure is mainly for if you're lost
{
procedure DetermineClosestNode;
var distanceArray : TIntegerArray;
i, closestDistance : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
SetArrayLength (distanceArray, (high(NodeArray)+1));
for i:=0 to high(NodeArray) do // Find all distances
begin
distanceArray[i] := Distance(currentTile.x, currentTile.y, NodeArray[i].x, NodeArray[i].y); //Sqrt((Sqr(currentTile.x-NodeArray[i].x))+(Sqr(currentTile.y-NodeArray[i].y)))
ListNodePoints (i);
writeln (IntToStr(distanceArray[i]));
end;
closestDistance := FindMin (distanceArray); // Return closest distance from all distances from nodepoints
for i:=0 to high(NodeArray) do
begin
if closestDistance = distanceArray[i] then
begin
writeln ('');
writeln ('Closest node point:');
ListNodePoints (i);
end;
end;
end;
}

// If you're near a node, this will assign currentLocString to it
procedure AssignNodeLocation (var location : string; maxTileRadius : integer);
var i : Integer;
currentTile : TTile;
begin
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'varrockwestbank';
1: location := 'faladoreastbank';
2: location := 'lumbridgenortheast';
3: location := 'draynorbank';
4: location := 'barbarianvillagecenter';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
//writeln ('In node range = ('+location+')');
end;


{ Travels from node to node
VWB = varrock west bank
FEB = falador east bank
BBC = barbarian village center (south of dungeon entrance)
DRB = draynor bank
LNE = Lumbridge, northeast a bit of the castle
}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk, path2 : TPointArray;
pathToWalkTTA : TTileArray;
begin
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB':
begin
pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
end;
'LNE':
begin
pathToWalk := VWB_LNE;
end;
'DRB':
begin
pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
end;
'BBC':
begin
pathToWalk := VWB_BBC;
end;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB':
begin
pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
end;
'LNE':
begin
pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
end;
'DRB':
begin
pathToWalk := FEB_DRB;
end;
'BBC':
begin
pathToWalk := FEB_BBC;
end;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB':
begin
pathToWalk := LNE_VWB;
end;
'FEB':
begin
pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
end;
'DRB':
begin
pathToWalk := LNE_DRB;
end;
'BBC':
begin
pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB':
begin
pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
end;
'FEB':
begin
pathToWalk := DRB_FEB;
end;
'LNE':
begin
pathToWalk := DRB_LNE;
end;
'BBC':
begin
pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB':
begin
pathToWalk := BBC_VWB;
end;
'FEB':
begin
pathToWalk := BBC_FEB;
end;
'LNE':
begin
pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
end;
'DRB':
begin
pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

// Creates an array of 'distance' from specific highway points
// It then returns the T point which is closest
function ClosestNodePath (var TP : Tpoint; TPA : TPointArray) : TPoint;
var currentPosition : TTile;
currentPosTP : TPoint;
i : Integer;
tempdistArray, distArray : TIntegerArray;
begin
currentPosition := GetMyPos;
writeln ('Tile: '+inttostr(currentPosition.x)+','+inttostr(currentPosition.y)); // Nice debug anyways :)
TileToPoint (currentPosition);
SetArrayLength (distArray, high(TPA)+1);
SetArrayLength (tempdistArray, high(TPA)+1);
for i:=0 to high(TPA) do
begin
distArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
tempdistArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
end;
QuickSort (tempdistArray); // Don't want to screw up our actual distance array order!
for i:=0 to high (distArray) do
begin
if (tempdistArray[0] = distArray[i]) then //If we find the value i for which the lowest distance was found, so we can use 'i' to identify the TPoint which the distance returned as the shortest...
begin
TP := TPA[i];
writeln ('Distance = '+inttostr(distArray[i]));
end;
end;
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := 'hihi'; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

var TP : TPoint;
begin
SetUpScript;
SetupNodesAndPaths;
ClosestNodePath (TP, EntireHighwayArray);
FindPathToTile (TP, 8);
{
repeat
ClearDebug;
TP := ClosestNodePath(EntireHighwayArray);
writeln (inttostr(TP.x)+','+inttostr(TP.y));
wait (100);
until (false)
}
end.

So far the script code I have for the main loop finds the closest TPoint and attempts to travel to it. If anyone wants to try the node to node, you can try for example
TravelToNode ('BBC','LNE');

Rich

2010-08-30 11:49:19

All of the cases inside the case don't need to have begin and end, because you're only calling one function inside them.

Shuttleu

2010-08-30 12:10:28

now i dont want anyone to think im lying about this but i was thinking about exactly the same thing the otherday

here is the way i thought of it

there would be subpoints (lumby, fally, varrock, draynor)
there would be be a path between each path
then for things like fally to lumby it would do fally to varrock, then run the varrock to lumby path

i was going to start on it in a couple of days but it looks like you have beaten me to it

i would love to work with you on this, or i can create my own version and then whichever works better we can further develop

~shut

EDIT: this is the map which i came up with a couple of days ago
each point is a sub point (and will have a name) the lines are the connections between the points, if you can see any points that i have forgotton then let me know

JPHamlett

2010-08-30 12:36:59

there already is one of them in POMS that Timer made

mormonman

2010-08-30 15:25:13

One problem I see with your theory about being on a different level of the world is that the tiles are the same(for example lumbridge castle first floor, second floor, and third floor all have the same tile values). There is another variable in the client that contains what plane you are on.

Shuttleu

2010-08-30 15:55:01

From: mormonman
One problem I see with your theory about being on a different level of the world is that the tiles are the same(for example lumbridge castle first floor, second floor, and third floor all have the same tile values). There is another variable in the client that contains what plane you are on.

well that wont be hard to fix, if it is in certain tiles then check what plane it is on, simples ;)

~shut

Cstrike

2010-08-30 16:01:02

Shuttleu I like that idea :)

How would you go about the syntax though of travelling from point to point? Ex: if user wanted to go from Fally west bnak to draynor manor…

Thats one of the problems I ran into. I figured if I worked in node points and sub nodes that always returned to a highway path (which can be detected), and going from a highway to a subnode path as well… I could always determine location since the start of the TPA for the subnode path would always be i=0, and would always be a point on the path
Sorry that might not have made too much sense, but if you have any ideas or know of anything you'd like to do I'd be more than willing to collaborate on trying something. Unfortunately I didn't start out making mine too code friendly :p

Shuttleu

2010-08-30 16:52:37

well im starting on mine now, i will let you know how i get along, i was thinking of something like adding loads of sub points (nodes)

~shut

EDIT: i have started, but i havent really started :/ *yawn!*

nickrules

2010-09-01 18:41:34

Shut, I had the exact same thought the other day :O Its somewhere in the SVN core board if im not mistaken.

Anyway, I like this plan, and would love to see it go far.
Ima test this in a few mins…

edit: Tried it, worked like a charm! Well done. With some work, this project can go far. Also, If you're not using it, sumillions pathmaker, with the right map/offset, works great.

If I can find it, I'll attach it…

Cstrike

2010-09-01 19:44:50

Woot :D

Ok what I'm going try try over the next few days is to make code that will take subpoints [to and from] highways, and then to a place of choice.
My plan first is to focus on making it so it can retrieve from anywhere first, and then seeing if the subpaths can be reverse walked.


Is there a "Find TPoint in [TPA and/or ATPA] function"? If not I'll have to make one… though there may be one in the wizzyplugin that I missed due to still being in awe over all the awesome TPA stuff.


BTW I tried sumillions path maker, works great. I'm going to have to make paths mainly with it now since the subpaths are where it gets messy.

nickrules

2010-09-02 16:47:41

Great. just make sure you have the correct map and such. the one from the original thread is outdated.

Shuttleu

2010-09-02 16:55:17

From: nickrules
Great. just make sure you have the correct map and such. the one from the original thread is outdated.

if you look in the reflection svn then you will find one with the new map, if its not there then you can download it from here
http://villavu.com/forum/showthread.php?t=57826
remember to set the offsets

~shut

Shuttleu

2010-09-02 19:16:54

ok done with the paths for now

what i have done is made a individual path for each line, then when you want to walk from say falador to varrock it will walk along the paths (the rest point, wp3, barbarian village, wp4, wp6, wp44, wp45, varrock)
that is what i have, and adding a path is really easy

(any black lines can be ignored and dont really exist ;))

~shut

Cstrike

2010-09-03 14:07:38

Nice :D

Btw one thing I was trying was to make it find the closest TPoint in a TPA (or even ATPA, but I'll have to make all the ATPA's first).

So far in a TPA, it can find it:

Warning, shitty quick code ahead
program WalkTPA;
{$i SRL/SRL.scar}

var walkingTPA : TPointArray;
myPoint, closestTP : TPoint;
distArr, tempdistArr : TIntegerArray;
i : Integer;

begin
cleardebug;
// Bottom left
walkingTPA := [Point(3343,3223), Point(3346,3227), Point(3351,3231),
Point(3343,3240), Point(3349,3241), Point(3355,3245)]; // Top right [highway]
myPoint := Point(3349, 3242);
SetArrayLength (distArr, (high(walkingTPA)+1));
SetArrayLength (tempdistArr, (high(walkingTPA)+1));
for i:=0 to high (walkingTPA) do
begin
distArr[i] := Distance (myPoint.x, myPoint.y, walkingTPA[i].x, walkingTPA[i].y);
tempdistArr[i] := Distance (myPoint.x, myPoint.y, walkingTPA[i].x, walkingTPA[i].y);
writeln ('dist of ['+inttostr(i)+'] = ' +inttostr(distArr[i]));
end;
// tempdistArr := distArr; //WHY THE FUCK DO YOU KEEP CHANGING distArr TO YOURSELF AFTER QUICKSORT :@
Quicksort (tempdistArr);
writeln ('tempdistArr [0] = '+inttostr(tempdistArr[0]));
writeln ('debug: distArr [0] = '+inttostr(distArr[0]));
for i:=0 to high (distArr) do
begin
if tempdistArr[0] = distArr[i] then
begin
closestTP := walkingTPA[i];
writeln (i);
writeln ('Found closestTP = '+inttostr(walkingTPA[i].x) +','+inttostr(walkingTPA[i].y));
Break;
end;
end;
end.


My next plan would be for it to return the TPoint, then see if's on the minimap.
If it's on minimap, walk to it, if not… do random guess walk to it
Once there, find the number slot that TP is in the TPA, then from there walk up to a highway point and return to a node.

Hopefully I can continue on the core, and then all that is left is to make the A/TPA's

Sir R. M8gic1an

2010-09-03 14:21:52

SortTPAFrom, SortATPAfromFirstPoint, etc in wizzypluggin?

~RM

Shuttleu

2010-09-03 14:24:33

well this is my thought
(quick bit of paint to help me here)

it finds the closest sub point, checks the point that would be before and after that point, if the one after that point is closer than the one before then it will make a path from the point is as closest to, if it is the other way round then it will create a path from the point before

you may not understand what i just said :p

~shut

nickrules

2010-09-04 10:48:11

I <3 this script. makes moving an army easy, lol.

Any way I can help; by making more paths perhaps?

Cstrike

2010-09-04 12:58:49

From: nickrules
I <3 this script. makes moving an army easy, lol.

Any way I can help; by making more paths perhaps?


So far the cool thing about some code I'm working on is that you can make and include your own paths (!!). All you have to do is start your path [preferably] on one of the TPoints of the 'highway' points (or even nodes themselves), and then just draw your path to wherever you would like accounts to either walk in the future or be retrieved from.

Ex: If you want to retrieve from the lumby swamp, you could draw a path that would go up to the path between draynor village and lumbridge, and connect with one of the TPoints that connect LNE to DRB.

Best thing to do is test it and make sure you can walk the path, post it here and I'll load it into the script [with your name cited of course], and it will be part of the walker for probably eternity unless RS gets a massive update. Over the next month I'll be making and testing various paths, and then finalizing code that will ensure characters walk each path properly.

NOTE: Make sure that you start your TPoint path near (ideally on) one of the highway points, or at least make it so you could get to the final point and then walk to one of the highway points by the minimap radius

Bigger note: I need to include a DTM that finds the stupid "Do you really want to leave the safe area" thing which gets annoying when you're moving a lvl 3 army


============================================================


EDIT:
I set it up like this


I ensure the top point is on one of the highway paths, and then end up writing it like this:
**NOTE, I declare an ATPA with SubStreets:
  //Streets
SetArrayLength (SubStreet, 1); // for now
SubStreet[0] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];

All that is left is for some big ass code which I'm going to attempt to write now

i luffs yeww

2010-09-04 14:43:40

Someone should recreate a color version of this. :) LordGregGreg did it a couple years ago. Got members with it. I'm sure it's somewhere around here.

Cstrike

2010-09-04 16:00:14

From: i luffs yeww
Someone should recreate a color version of this. :) LordGregGreg did it a couple years ago. Got members with it. I'm sure it's somewhere around here.

If someone could do that, it would blow my mind :p … I can't even begin to think how it'd function! Though that would probably be better in some ways than this because this is reflection… which needs to be usually constantly updated.


The newest code erased all my fears. I was always worried that the program would chew through too much resources when finding all the distances between TPAs and stuff.

// Finds all the distances from subpoints only (defined as streets in SetupNodes/Paths
// distArrLowest [i] would = shortest distance in ATPA[i]
// Returns the closest TPoint from the ATPA, which you further should use the 'walktowardsTP' procedure
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z, time : Integer;
begin
if not LoggedIn then exit;
MarkTime (time);
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
// Debug output to get a nice chart :)
for z:=0 to high(ATPA) do
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
writeln (TimeFromMark(time));
end;


Now the output:
ATPA is basically the entire array of all the TPA walking subpoints

SubPointDist: Current tile = (3211,3213)
high(ATPA) = 5
ATPA[0][0] distance = 256 (3004,3363)
ATPA[0][1] distance = 267 (2993,3368)
ATPA[0][2] distance = 280 (2983,3376)
ATPA[0][3] distance = 293 (2969,3379)
ATPA[0][4] distance = 302 (2965,3389)
ATPA[0][5] distance = 305 (2971,3402)
ATPA[0][6] distance = 306 (2978,3412)
ATPA[0][7] distance = 305 (2986,3419)
ATPA[0][8] distance = 310 (2989,3429)
ATPA[0][9] distance = 302 (3002,3431)
ATPA[0][10] distance = 297 (3010,3431)
ATPA[0][11] distance = 288 (3020,3428)
ATPA[0][12] distance = 278 (3032,3426)
ATPA[0][13] distance = 265 (3044,3419)
ATPA[0][14] distance = 256 (3054,3415)
ATPA[0][15] distance = 251 (3064,3417)
ATPA[0][16] distance = 247 (3075,3419)
ATPA[0][17] distance = 241 (3081,3416)
Minimum distance (tempdistTPAInt[0])= 241
ATPA[1][0] distance = 239 (3089,3419)
ATPA[1][1] distance = 235 (3099,3420)
ATPA[1][2] distance = 230 (3111,3420)
ATPA[1][3] distance = 224 (3120,3418)
ATPA[1][4] distance = 219 (3129,3416)
ATPA[1][5] distance = 216 (3140,3417)
ATPA[1][6] distance = 213 (3151,3417)
ATPA[1][7] distance = 213 (3163,3421)
ATPA[1][8] distance = 219 (3169,3428)
ATPA[1][9] distance = 218 (3180,3429)
ATPA[1][10] distance = 227 (3186,3439)
Minimum distance (tempdistTPAInt[0])= 213
ATPA[2][0] distance = 227 (3186,3439)
ATPA[2][1] distance = 217 (3194,3429)
ATPA[2][2] distance = 215 (3207,3428)
ATPA[2][3] distance = 202 (3211,3415)
ATPA[2][4] distance = 187 (3211,3400)
ATPA[2][5] distance = 173 (3211,3386)
ATPA[2][6] distance = 159 (3213,3372)
ATPA[2][7] distance = 146 (3218,3359)
ATPA[2][8] distance = 135 (3226,3347)
ATPA[2][9] distance = 125 (3228,3337)
ATPA[2][10] distance = 126 (3240,3336)
ATPA[2][11] distance = 117 (3240,3326)
ATPA[2][12] distance = 103 (3240,3312)
ATPA[2][13] distance = 93 (3239,3302)
ATPA[2][14] distance = 86 (3239,3294)
ATPA[2][15] distance = 74 (3239,3282)
ATPA[2][16] distance = 69 (3241,3275)
ATPA[2][17] distance = 59 (3241,3264)
ATPA[2][18] distance = 51 (3227,3261)
ATPA[2][19] distance = 44 (3217,3257)
ATPA[2][20] distance = 35 (3219,3247)
ATPA[2][21] distance = 38 (3217,3251)
Minimum distance (tempdistTPAInt[0])= 35
ATPA[3][0] distance = 33 (3214,3246)
ATPA[3][1] distance = 33 (3208,3246)
ATPA[3][2] distance = 36 (3200,3247)
ATPA[3][3] distance = 38 (3193,3246)
ATPA[3][4] distance = 41 (3185,3245)
ATPA[3][5] distance = 46 (3180,3247)
ATPA[3][6] distance = 47 (3176,3245)
ATPA[3][7] distance = 48 (3171,3239)
ATPA[3][8] distance = 52 (3165,3238)
ATPA[3][9] distance = 58 (3157,3235)
ATPA[3][10] distance = 68 (3147,3235)
ATPA[3][11] distance = 72 (3141,3229)
ATPA[3][12] distance = 79 (3133,3227)
ATPA[3][13] distance = 87 (3125,3225)
ATPA[3][14] distance = 93 (3119,3228)
ATPA[3][15] distance = 102 (3110,3229)
ATPA[3][16] distance = 112 (3100,3230)
ATPA[3][17] distance = 115 (3098,3235)
ATPA[3][18] distance = 121 (3094,3242)
Minimum distance (tempdistTPAInt[0])= 33
ATPA[4][0] distance = 130 (3086,3249)
ATPA[4][1] distance = 138 (3080,3256)
ATPA[4][2] distance = 148 (3073,3266)
ATPA[4][3] distance = 153 (3072,3276)
ATPA[4][4] distance = 160 (3064,3277)
ATPA[4][5] distance = 173 (3050,3275)
ATPA[4][6] distance = 183 (3039,3276)
ATPA[4][7] distance = 191 (3031,3278)
ATPA[4][8] distance = 200 (3021,3276)
ATPA[4][9] distance = 211 (3010,3278)
ATPA[4][10] distance = 219 (3005,3287)
ATPA[4][11] distance = 222 (3006,3298)
ATPA[4][12] distance = 227 (3006,3311)
ATPA[4][13] distance = 231 (3006,3320)
ATPA[4][14] distance = 236 (3007,3331)
ATPA[4][15] distance = 242 (3008,3345)
ATPA[4][16] distance = 250 (3006,3356)
ATPA[4][17] distance = 244 (3013,3356)
Minimum distance (tempdistTPAInt[0])= 130
ATPA[5][0] distance = 102 (3110,3229)
ATPA[5][1] distance = 97 (3114,3220)
ATPA[5][2] distance = 94 (3117,3212)
ATPA[5][3] distance = 97 (3114,3205)
ATPA[5][4] distance = 99 (3113,3196)
ATPA[5][5] distance = 101 (3113,3187)
ATPA[5][6] distance = 103 (3113,3181)
ATPA[5][7] distance = 107 (3113,3171)
ATPA[5][8] distance = 111 (3110,3167)
ATPA[5][9] distance = 119 (3102,3165)
ATPA[5][10] distance = 124 (3101,3155)
ATPA[5][11] distance = 123 (3105,3150)
Minimum distance (tempdistTPAInt[0])= 94
distArrLowest[0] = 241 @ distArrLowestTP[0] (3081,3416)
distArrLowest[1] = 213 @ distArrLowestTP[1] (3163,3421)
distArrLowest[2] = 35 @ distArrLowestTP[2] (3219,3247)
distArrLowest[3] = 33 @ distArrLowestTP[3] (3208,3246)
distArrLowest[4] = 130 @ distArrLowestTP[4] (3086,3249)
distArrLowest[5] = 94 @ distArrLowestTP[5] (3117,3212)
453
Successfully executed.

Woot :D
Compiled in 453 milliseconds (or whatever unit TimeFromMark outputs)… though I've managed to get it compiling as fast as 250 ms.
EDIT2: Note, these paths were only for the highways AND test from the wizards tower. This test was designed to see if it could handle subpaths. It worked!!


EDIT: I just realized as stated above that if youre on a second floor it won't tell you. Therefore, IIRC… was there not some reflection code that could determine your height or what floor you're on? If so that'd be invaluable here.

Gu3st...

2010-09-04 16:29:36

Oh wow, you've came a long way!
This is really cool, cstrike :)
Glad to have inspired you ^^,

Cstrike

2010-09-04 18:15:21

Thank you :)


Update:

The script can now retrieve itself from any subpoint you enter!
So far I tested it with wizards tower, and it takes you back to draynor.

Now the code for once at a highway is not actually complete, I just tell the program to walk every path in one way (which will take you back to the bank) which has no real failsafes, but here it is. I'm done with it for today, I'll probably work on it more tomorrow.

Heres the code if youre interested

program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
ox = 0; // X axis offset
oy = 0; // Y axis offset

// Node points
varrockWestBank_x = 3186 + ox;
varrockWestBank_y = 3439 + oy;
faladorEastBank_x = 3013 + ox;
faladorEastBank_y = 3356 + oy;
lumbridgeNE_x = 3217 + ox;
lumbridgeNE_y = 3251 + oy;
draynorBank_x = 3094 + ox;
draynorBank_y = 3242 + oy;
barbVillageC_x = 3081 + ox;
barbVillageC_y = 3416 + oy;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
currentLocString : String; // String of current location, used for
highwayTPA : TPointArray;

VWB_LNE, VWB_BBC,
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray; // Highway variables

Highway, SubStreet : T2DPointArray; // Street variables

procedure SetupNodesAndPaths; // This procedure sets up node points (major points, usually banks)
begin
NodeArray := [Tile (varrockWestBank_x, varrockWestBank_y), // 0 Varrock west bank
Tile (faladorEastBank_x, faladorEastBank_y), // 1 Fally east bank
Tile (lumbridgeNE_x, lumbridgeNE_y), // 2 Lumby NE
Tile (draynorBank_x, draynorBank_y), // 3 Draynor bank
Tile (barbVillageC_x, barbVillageC_y)]; // 4 Barb village center (S of dungeon)

// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(lumbridgeNE_x, lumbridgeNE_y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(barbVillageC_x, barbVillageC_y)];

BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(varrockWestBank_x, varrockWestBank_y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (faladorEastBank_x, faladorEastBank_y)];

DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(lumbridgeNE_x, lumbridgeNE_y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (faladorEastBank_x, faladorEastBank_y)];

LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(draynorBank_x, draynorBank_y)];
LNE_VWB := [Point(3223, 3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (varrockWestBank_x, varrockWestBank_y)];

FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (draynorBank_x, draynorBank_y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(barbVillageC_x, barbVillageC_y)];

SetArrayLength (Highway, 5);
//Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(varrockWestBank_x, varrockWestBank_y)];
Highway[1] :=[Point(3223, 3237), // Lumby northeast to varrock west bank
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (varrockWestBank_x, varrockWestBank_y)];
Highway[2] :=[Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (faladorEastBank_x, faladorEastBank_y)];
Highway[3] :=[Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (faladorEastBank_x, faladorEastBank_y)];
Highway[4] :=[Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(draynorBank_x, draynorBank_y)];

//Streets
SetArrayLength (SubStreet, 1);
// These are all highways, i'll remove them later [GOES CLOCKWISE STARTING FROM FALLY]
SubStreet[0] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
end;

// This procedure will add a TPA to a TTileArray (and convert it properly)
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

// Takes a position and creates a path from i down to 0
// Useful for being retrieved
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

// Takes a position and creates a path from 0 up to i
// Useful for being retrieved
procedure AddTPAFromUpToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=0 to TPAPos do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
end;

{
// Finds the minimum number of a TIntArray and returns the lowest integer
function FindMin (TIntArray : TIntegerArray) : Integer;
var i, j : Integer;
minFound : Boolean;
begin
minFound := false;
for i:=0 to high(TIntArray)do // This finds the mode and returns it's value
begin
for j:=0 to high(TIntArray) do
begin
if TIntArray[j] < TIntArray[i] then
begin
Break;
end;
if (j = high(TIntArray)) and not minFound then
begin
minFound := true;
result := TIntArray[i];
end;
end;
if minFound then break;
end;
end; }

function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

// Returns the TPA that the TPoint is in (or ATPA[number here])
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

// Attempts to walk (blindly) towards a tile
// X increases as you go east, y as you go north
// Needs some SERIOUS code fixing...
// NOTE: For walkRadius, use '8' as default if you want to travel about
// 1/2 the way to the edge of the minimap (ex: radius 8 means if found
// south of you only, will probably travel between MMCY, and MMY2/2
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
// opp : Integer;
xinc, yinc : Extended;
//walkPoint : TPoint;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

// This procedure will add a TPA to a TTileArray (and convert it properly)


// This is used to find the closest node point
// This procedure is mainly for if you're lost
{
procedure DetermineClosestNode;
var distanceArray : TIntegerArray;
i, closestDistance : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
SetArrayLength (distanceArray, (high(NodeArray)+1));
for i:=0 to high(NodeArray) do // Find all distances
begin
distanceArray[i] := Distance(currentTile.x, currentTile.y, NodeArray[i].x, NodeArray[i].y); //Sqrt((Sqr(currentTile.x-NodeArray[i].x))+(Sqr(currentTile.y-NodeArray[i].y)))
ListNodePoints (i);
writeln (IntToStr(distanceArray[i]));
end;
closestDistance := FindMin (distanceArray); // Return closest distance from all distances from nodepoints
for i:=0 to high(NodeArray) do
begin
if closestDistance = distanceArray[i] then
begin
writeln ('');
writeln ('Closest node point:');
ListNodePoints (i);
end;
end;
end;
}



// Finds all the distances from subpoints only (defined as streets in SetupNodes/Paths
// distArrLowest [i] would = shortest distance in ATPA[i]
// Returns the closest TPoint from the ATPA, which you further should use the 'walktowardsTP' procedure
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z, time : Integer;
begin
if not LoggedIn then exit;
MarkTime (time);
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
// Debug output to get a nice chart :)
for z:=0 to high(ATPA) do
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
writeln (TimeFromMark(time));
end;

// If you're near a node, this will assign currentLocString to it
procedure AssignNodeLocation (var location : string; maxTileRadius : integer);
var i : Integer;
currentTile : TTile;
begin
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'varrockwestbank';
1: location := 'faladoreastbank';
2: location := 'lumbridgenortheast';
3: location := 'draynorbank';
4: location := 'barbarianvillagecenter';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
//writeln ('In node range = ('+location+')');
end;

{ Travels from node to node
VWB = varrock west bank
FEB = falador east bank
BBC = barbarian village center (south of dungeon entrance)
DRB = draynor bank
LNE = Lumbridge, northeast a bit of the castle
}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk, path2 : TPointArray;
pathToWalkTTA : TTileArray;
begin
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB':
begin
pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
end;
'LNE':
begin
pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
end;
'DRB':
begin
pathToWalk := FEB_DRB;
end;
'BBC':
begin
pathToWalk := FEB_BBC;
end;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB':
begin
pathToWalk := LNE_VWB;
end;
'FEB':
begin
pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
end;
'DRB':
begin
pathToWalk := LNE_DRB;
end;
'BBC':
begin
pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB':
begin
pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
end;
'FEB':
begin
pathToWalk := DRB_FEB;
end;
'LNE':
begin
pathToWalk := DRB_LNE;
end;
'BBC':
begin
pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB':
begin
pathToWalk := BBC_VWB;
end;
'FEB':
begin
pathToWalk := BBC_FEB;
end;
'LNE':
begin
pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
end;
'DRB':
begin
pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

// Creates an array of 'distance' from specific highway points
// It then returns the T point which is closest
function ClosestNodePath (var TP : Tpoint; TPA : TPointArray) : TPoint;
var currentPosition : TTile;
currentPosTP : TPoint;
i : Integer;
tempdistArray, distArray : TIntegerArray;
begin
currentPosition := GetMyPos;
writeln ('Tile: '+inttostr(currentPosition.x)+','+inttostr(currentPosition.y)); // Nice debug anyways :)
TileToPoint (currentPosition);
SetArrayLength (distArray, high(TPA)+1);
SetArrayLength (tempdistArray, high(TPA)+1);
for i:=0 to high(TPA) do
begin
distArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
tempdistArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
end;
QuickSort (tempdistArray); // Don't want to screw up our actual distance array order!
for i:=0 to high (distArray) do
begin
if (tempdistArray[0] = distArray[i]) then //If we find the value i for which the lowest distance was found, so we can use 'i' to identify the TPoint which the distance returned as the shortest...
begin
TP := TPA[i];
writeln ('Distance = '+inttostr(distArray[i]));
end;
end;
end;

function BlindWalkToAnyNode : Boolean;
begin
TravelToNode ('DRB','FEB');
TravelToNode ('BBC','FEB');
TravelToNode ('LNE','DRB');
TravelToNode ('LNE','VWB');
TravelToNode ('BBC','VWB');
result := true;
end;

function RetrieveToClosestNode : Boolean;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, numby : Integer;
TTA : TTileArray;
//currentTile : TTile;
begin
TP := SubPointDistances (SubStreet);
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA);
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA);
{ for numby:=0 to high(TPA) do
begin
writeln ('['+inttostr(numby)+'] = ('+inttostr(TPA[numby].x)+','+inttostr(TPA[numby].y)+')');
end; }
AddTPAToTTA (TPA, TTA);
WalkPath (TTA); // Walk us to the point in the Highway[?]

currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');

FFlag(0);
writeln ('Now trying to get to nearest node');
wait (3000);

BlindWalkToAnyNode;
result := true;
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := 'lol'; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
//SetRun (true);
end;

begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
RetrieveToClosestNode;
//TravelToNode ('LNE', 'DRB');
end.

NOTE: It will only retrieve from wizards tower so far, or walk to any node

Sir R. M8gic1an

2010-09-05 01:02:18

Btw, if at the end this could work as

WalkTo(TP: TPoint); it would be perfect. It would mean the character could be anywhere and we'd just tell it where we want it to end up and it would go there.

If we managed this, it could replace MSI's current walking system and it would allow us to finally run several (different) MSI scripts on one char.

~RM

Shuttleu

2010-09-05 10:44:24

From: Sir R. Magician
Btw, if at the end this could work as

WalkTo(TP: TPoint); it would be perfect. It would mean the character could be anywhere and we'd just tell it where we want it to end up and it would go there.

If we managed this, it could replace MSI's current walking system and it would allow us to finally run several (different) MSI scripts on one char.

~RM


my one will have this, also i thought we could run multiple scripts on one char?

~shut

Heavenguard

2010-09-05 10:59:57

The Color version of this walking could be easily integrated if the reflection version works out. Not trying to say I would know the perfect way of doing it, but with enough effort im sure we will find a way to make it sync with the reflection style.

Once the Reflection version is pretty much finished with its Point system, im sure we can find a good style of Organization and failsafe all of the points with color, and keep this script alive for a much longer time.

Great job on all of you guys though, really beautiful things. Well done ^^

Shuttleu

2010-09-05 11:12:51

From: Heavenguard
The Color version of this walking could be easily integrated if the reflection version works out. Not trying to say I would know the perfect way of doing it, but with enough effort im sure we will find a way to make it sync with the reflection style.

Once the Reflection version is pretty much finished with its Point system, im sure we can find a good style of Organization and failsafe all of the points with color, and keep this script alive for a much longer time.

Great job on all of you guys though, really beautiful things. Well done ^^


you say beautiful, but i havent even posted any code yet XD
the advantage of my code over cstrike's is that i use lots of sub points, which means you can easily make a new path with one line, whereas with cstrike's you need to add a whole path

~shut

nickrules

2010-09-05 11:29:12

[Point(3121, 3067), Point(3136, 3066), Point(3151, 3065),
Point(3165, 3066), Point(3178, 3066), Point(3186, 3058)];
Just though this path was particularly needed….

Probably will make a bunch more later…

@Shut, Looking forward to seeing this code ;)

Cstrike

2010-09-05 11:30:32

From: Sir R. Magician
Btw, if at the end this could work as

WalkTo(TP: TPoint); it would be perfect. It would mean the character could be anywhere and we'd just tell it where we want it to end up and it would go there.

If we managed this, it could replace MSI's current walking system and it would allow us to finally run several (different) MSI scripts on one char.

~RM


Sorry but I'm confused at what you mean by using at the end :(

Do you mean like

//code...
WalkTo ('VWB');
or
WalkTo (Point(VWBx, VWBy)); // Where point(x,y) would be probably some variable

I just want to get down what you mean and I'll try integrating it :P


From: Shuttleu
you say beautiful, but i havent even posted any code yet XD
the advantage of my code over cstrike's is that i use lots of sub points, which means you can easily make a new path with one line, whereas with cstrike's you need to add a whole path

~shut


Awesome :D
How does that work? I'm just curious on how you'd run that code :)
EDIT: Sorry I sort of duplicated this in the PM i sent you


From: nickrules
[Point(3121, 3067), Point(3136, 3066), Point(3151, 3065),
Point(3165, 3066), Point(3178, 3066), Point(3186, 3058)];
Just though this path was particularly needed….

Probably will make a bunch more later…


I'm going to try this today and hopefully see how it works!

Shuttleu

2010-09-05 11:55:50

well im feeling good today, so i will post what i currently have, i havent done anything for the last few days so it doesnt look impressive, at the moment it will only load the path from one point to the next (you can see which point is connected to which with the image i posted earlier)

program new;
{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}
{$i reflection/reflection.simba}
{
const
GOBLIN_VILLAGE
DWARVEN_MINE
BLACK_KNIGHT_FORTRESS
EDGEVILLE
EDGEVILLE_MONESTARY
EDGEVILLE_YEWS
EDGEVILLE_BANK
GRAND_EXCHANGE
VARROCK_CENTRAL
VARROCK_PALACE
VARROCK_WEST_BANK
VARROCK_EAST_BANK
VARROCK_WEST_MINE
VARROCK_EAST_MINE
CHAMPIONS_GUILD
LUMBRIDGE_EAST_CHICKENS
LUMBRIDGE_CASTLE
DRAYNOR_BANK
DRAYNOR_MANOR
DRAYNOR_MANOR_FENCE
PORT_SARIM_DBOX
WIZARDS_TOWER
LUMBRIDGE_WEST_SWAMP_MINE
LUMBRIDGE_EAST_SWAMP_MINE
RIMMINGTON_MINE
RIMMINGTON
MELZARS_MAZE
CRAFTING_GUILD
FALADOR_EAST_BANK
FALADOR_WEST_BANK
FALADOR_NORTH_REST
FALADOR_CENTRAL
FALADOR_MINING_GUILD
FALADOR_FOUNTAIN
FALADOR_DWARVEN_MINE
FALADOR_SOUTH_FARM
COOKING_GUILD
BARBARIAN_VILLAGE
ALKHARID_BANK
ALKHARID_PALACE
ALKHARID_MINE

WP1
WP2
WP3
WP4
WP5
WP6
WP7
WP8
WP9
WP10
WP11
WP12
WP13
WP14
WP15
WP16
WP17
WP18
WP19
WP20
WP21
WP22
WP23
WP24
WP25
WP26
WP27
WP28
WP29
WP30
WP31
WP32
WP33
WP34
WP35
WP36
WP37
WP38
WP39
WP40
WP41
WP42
WP43
WP44
WP45
WP46
WP47
WP48
WP49}

function MirrorTPA(TPA: TPointArray): TPointArray;
var
i, h: integer;
begin
h := 0;
SetLength(Result, Length(TPA));
for i:= High(TPA) DownTo 0 do
begin
Result[h] := TPA[i];
Inc(h);
end;
end;

function CombineTPAs(TheTPAs: array of TPointArray): TPointArray;
var
i: Integer;
begin
i:= 0 to High(TheTPAs) do
CompineTPA(Result, TheTPAs[i]);
end;

function LoadPath(StartLoc, EndLoc: string): TPointArray;
begin
case (StartLoc+'_'+EndLoc) of
'GOBLIN_VILLAGE_FALADOR_NORTH_REST' : Result:= [Point(2955, 3501), Point(2955, 3488), Point(2953, 3476),
Point(2948, 3466), Point(2946, 3456), Point(2946, 3446),
Point(2947, 3435), Point(2949, 3425), Point(2955, 3420),
Point(2966, 3413)];
'FALADOR_NORTH_REST_WP3' : Result:= [Point(2966, 3413), Point(2976, 3416), Point(2986, 3421),
Point(2991, 3428), Point(3002, 3432), Point(3012, 3431),
Point(3022, 3429), Point(3034, 3429)];
'WP2_WP3' : Result:= [Point(3051, 3469), Point(3047, 3459), Point(3041, 3449),
Point(3039, 3439), Point(3037, 3429)];
'WP1_WP2' : Result:= [Point(3032, 3473), Point(3041, 3472), Point(3051, 3468)];
'BLACK_KNIGHT_FORTRESS_WP1' : Result:= [Point(3026, 3503), Point(3023, 3497), Point(3019, 3490),
Point(3022, 3483), Point(3029, 3480), Point(3032, 3473)];
'DWARVEN_MINE_WP1' : Result:= [Point(3015, 3450), Point(3015, 3458), Point(3024, 3462),
Point(3032, 3473)];
'WP2_EDGEVILLE_MONESTARY' : Result:= [Point(3051, 3468), Point(3051, 3478), Point(3051, 3491)];
'WP2_BARBARIAN_VILLIAGE' : Result:= [Point(3051, 3468), Point(3051, 3457), Point(3061, 3451),
Point(3066, 3445), Point(3068, 3434), Point(3069, 3424),
Point(3079, 3421)];
'WP3_BARBARIAN_VILLIAGE' : Result:= [Point(3036, 3429), Point(3044, 3423), Point(3055, 3422),
Point(3065, 3421), Point(3078, 3421)];
'EDGEVILLE_MONESTARY_WP43' : Result:= [Point(3051, 3492), Point(3051, 3500), Point(3051, 3510),
Point(3057, 3519), Point(3065, 3522), Point(3076, 3521),
Point(3085, 3518), Point(3088, 3510), Point(3089, 3503)];
'WP43_EDGEVILLE_BANK' : Result:= [Point(3089, 3502), Point(3093, 3497)];
'EDGEVILLE_WP43' : Result:= [Point(3087, 3492), Point(3089, 3502)];
'EDGEVILLE_EDGEVILLE_BANK' : Result:= [Point(3087, 3493), Point(3093, 3495)];
'EDGEVILLE_YEWS_EDGEVILLE' : Result:= [Point(3086, 3477), Point(3093, 3472), Point(3094, 3480),
Point(3087, 3492)];
'EDGEVILLE_BARBARIAN_VILLIAGE' : Result:= [Point(3087, 3492), Point(3081, 3485), Point(3081, 3474),
Point(3087, 3466), Point(3090, 3456), Point(3091, 3444),
Point(3091, 3433), Point(3090, 3421)];
'BARBARIAN_VILLIAGE_WP4' : Result:= [Point(3086, 3422), Point(3097, 3421), Point(3108, 3421),
Point(3118, 3420)];
'WP4_VARROCK_WEST_MINE' : Result:= [Point(3117, 3420), Point(3128, 3415), Point(3136, 3407),
Point(3145, 3400), Point(3154, 3393), Point(3161, 3386),
Point(3169, 3378), Point(3177, 3370)];
'BARBARIAN_VILLIAGE_WP38' : Result:= [Point(3079, 3421), Point(3081, 3411), Point(3085, 3402),
Point(3083, 3392), Point(3076, 3385), Point(3072, 3376),
Point(3070, 3366), Point(3071, 3354), Point(3071, 3342)];
'WP4_WP6' : Result:= [Point(3117, 3420), Point(3127, 3415), Point(3141, 3417),
Point(3152, 3418)];
'COOKING_GUILD_WP4' : Result:= [Point(3143, 3439), Point(3134, 3434), Point(3124, 3428),
Point(3116, 3421)];
'COOKING_GUILD_WP6' : Result:= [Point(3145, 3439), Point(3144, 3431), Point(3147, 3424),
Point(3152, 3417)];
'GOOKING_CUILD_WP5' : Result:= [Point(3145, 3439), Point(3152, 3446), Point(3159, 3452),
Point(3166, 3456)];
'WP5_VARROCK_WEST_BANK' : Result:= [Point(3166, 3456), Point(3173, 3455), Point(3180, 3451),
Point(3187, 3448), Point(3187, 3439)];
'WP5_GRAND_EXCHANGE' : Result:= [Point(3166, 3457), Point(3165, 3465), Point(3164, 3476),
Point(3167, 3488)];
'GRAND_EXCHANGE_WP7' : Result:= [Point(3168, 3487), Point(3176, 3488), Point(3186, 3488),
Point(3196, 3488)];
'WP7_WP8' : Result:= [Point(3195, 3488), Point(3197, 3478), Point(3197, 3466),
Point(3200, 3456), Point(3212, 3450)];
'WP8_VARROCK_PALACE' : Result:= [Point(3212, 3450), Point(3213, 3457), Point(3213, 3466)];
'WP8_VARROCK_CENTRAL' : Result:= [Point(3212, 3449), Point(3213, 3439), Point(3213, 3429)];
'WP45_VARROCK_CENTRAL' : Result:= [Point(3188, 3430), Point(3202, 3430), Point(3213, 3429)];
'WP44_WP45' : Result:= [Point(3170, 3428), Point(3178, 3429), Point(3187, 3431)];
'VARROCK_WEST_BANK_WP45' : Result:= [Point(3188, 3439), Point(3187, 3431)];
'WP6_WP44' : Result:= [Point(3153, 3419), Point(3162, 3421), Point(3171, 3429)];
'WP10_VARROCK_CENTRAL' : Result:= [Point(3254, 3430), Point(3244, 3429), Point(3234, 3430),
Point(3225, 3430), Point(3213, 3429)];
'VARROCK_CENTRAL_WP9' : Result:= [Point(3212, 3377), Point(3212, 3387), Point(3211, 3398),
Point(3211, 3411), Point(3210, 3422), Point(3213, 3429)];
'WP10_VARROCK_EAST_BANK' : Result:= [Point(3254, 3429), Point(3254, 3421)];
'WP10_WP12' : Result:= [Point(3254, 3430), Point(3262, 3429), Point(3270, 3429),
Point(3281, 3429), Point(3288, 3420), Point(3290, 3410),
Point(3291, 3398), Point(3293, 3386), Point(3294, 3377)];
'WP44_VARROCK_WEST_MINE' : Result:= [Point(3171, 3430), Point(3171, 3421), Point(3172, 3411),
Point(3170, 3401), Point(3171, 3390), Point(3175, 3380),
Point(3177, 3370)];
'WP46_VARROCK_WEST_MINE' : Result:= [Point(3183, 3368), Point(3177, 3370)];
'WP46_CHAMPIONS_GUILD' : Result:= [Point(3183, 3367), Point(3192, 3365)];
'WP9_CHAMPIONS_GUILD' : Result:= [Point(3211, 3378), Point(3205, 3371), Point(3197, 3367),
Point(3191, 3366)];
'WP9_WP11' : Result:= [Point(3211, 3378), Point(3222, 3378), Point(3234, 3377),
Point(3245, 3374), Point(3257, 3371), Point(3269, 3371),
Point(3279, 3374)];
'WP11_WP12' : Result:= [Point(3278, 3373), Point(3291, 3374)];
'WP11_VARROCK_EAST_MINE' : Result:= [Point(3279, 3373), Point(3286, 3366)];
'WP12_VARROCK_EAST_MINE' : Result:= [Point(3292, 3375), Point(3287, 3366)];
'WP12_WP13' : Result:= [Point(3293, 3377), Point(3297, 3367), Point(3300, 3356),
Point(3297, 3345), Point(3289, 3339), Point(3278, 3333)];
'WP9_WP14' : Result:= [Point(3212, 3380), Point(3215, 3370), Point(3220, 3359),
Point(3226, 3349), Point(3231, 3337), Point(3241, 3336)];
'WP46_WP22' : Result:= [Point(3182, 3365), Point(3176, 3356), Point(3177, 3345),
Point(3176, 3332), Point(3177, 3319), Point(3176, 3307),
Point(3167, 3300), Point(3167, 3288)];
'WP13_WP14' : Result:= [Point(3281, 3333), Point(3267, 3333), Point(3255, 3335),
Point(3243, 3337)];
'WP14_WP15' : Result:= [Point(3240, 3336), Point(3240, 3326), Point(3240, 3316),
Point(3240, 3305)];
'WP13_WP15' : Result:= [Point(3276, 3332), Point(3270, 3328), Point(3260, 3324),
Point(3251, 3318), Point(3246, 3312), Point(3240, 3306)];
'WP13_WP17' : Result:= [Point(3277, 3332), Point(3280, 3322), Point(3279, 3309),
Point(3279, 3298), Point(3281, 3287), Point(3284, 3277),
Point(3293, 3270)];
'ALKHARID_MINE_WP17' : Result:= [Point(3300, 3306), Point(3299, 3297), Point(3301, 3288),
Point(3301, 3279), Point(3295, 3271)];
'WP15_WP47' : Result:= [Point(3240, 3307), Point(3239, 3295)];
'WP47_LUMBRIDGE_EAST_CHICKENS' : Result:= [Point(3239, 3295), Point(3231, 3296)];
'WP47_WP21' : Result:= [Point(3239, 3295), Point(3239, 3286), Point(3240, 3276),
Point(3243, 3265), Point(3236, 3261), Point(3225, 3259),
Point(3216, 3258)];
'WP17_WP18' : Result:= [Point(3292, 3270), Point(3293, 3261), Point(3292, 3250),
Point(3290, 3239), Point(3284, 3230), Point(3281, 3220),
Point(3281, 3209), Point(3283, 3195), Point(3283, 3183)];
'FALADOR_NORTH_REST_FALADOR_CENTRAL' : Result:= [Point(2966, 3412), Point(2965, 3401), Point(2966, 3390),
Point(2965, 3381)];
'FALADOR_CENTRAL_FALADOR_WEST_BANK' : Result:= [Point(2965, 3381), Point(2956, 3381), Point(2951, 3378),
Point(2946, 3369)];
'FALADOR_CENTRAL_WP40' : Result:= [Point(2964, 3381), Point(2975, 3379), Point(2987, 3373),
Point(2997, 3366), Point(3006, 3364)];
'WP40_WP39' : Result:= [Point(3005, 3363), Point(3013, 3363)];
'WP39_FALADOR_EAST_BANK' : Result:= [Point(3012, 3363), Point(3012, 3357)];
'WP39_FALADOR_FOUNTAIN' : Result:= [Point(3012, 3363), Point(3021, 3361), Point(3030, 3357),
Point(3036, 3354)];
'FALADOR_FOUNTAIN_FALADOR_DWARVEN_MINE' : Result:= [Point(3037, 3355), Point(3042, 3360), Point(3043, 3367),
Point(3051, 3369), Point(3061, 3375)];
'FALADOR_FOUNTAIN_FALADOR_MINING_GUILD' : Result:= [Point(3036, 3354), Point(3031, 3347), Point(3026, 3336),
Point(3019, 3339)];
'WP40_WP36' : Result:= [Point(3005, 3363), Point(3006, 3352), Point(3007, 3339),
Point(3006, 3330), Point(3007, 3318)];
'WP36_WP35' : Result:= [Point(3007, 3317), Point(2999, 3313), Point(2991, 3305),
Point(2980, 3301), Point(2969, 3297), Point(2954, 3297)];
'WP35_CRAFTING_GUILD' : Result:= [Point(2953, 3296), Point(2941, 3296), Point(2933, 3292)];
'WP35_WP33' : Result:= [Point(2953, 3296), Point(2958, 3287), Point(2968, 3284),
Point(2975, 3279), Point(2982, 3276)];
'WP33_WP48' : Result:= [Point(2981, 3276), Point(2975, 3265)];
'WP48_WP34' : Result:= [Point(2975, 3264), Point(2970, 3257), Point(2962, 3250),
Point(2954, 3241)];
'WP48_RIMMINGTON_MINE' : Result:= [Point(2975, 3263), Point(2976, 3253), Point(2978, 3239)];
'RIMMINGTON_MINE_WP47' : Result:= [Point(2978, 3238), Point(2969, 3227)];
'WP34_WP47' : Result:= [Point(2953, 3241), Point(2961, 3235), Point(2969, 3226)];
'WP47_RIMMINGTON' : Result:= [Point(2969, 3227), Point(2960, 3221), Point(2956, 3213)];
'WP34_RIMMINGTON' : Result:= [Point(2954, 3240), Point(2956, 3232), Point(2956, 3221),
Point(2956, 3214)];
'WP34_MELZARS_MAZE' : Result:= [Point(2953, 3240), Point(2942, 3245)];
'WP33_WP32' : Result:= [Point(2981, 3275), Point(2993, 3281), Point(3006, 3276)];
'WP36_WP32' : Result:= [Point(3006, 3317), Point(3005, 3308), Point(3005, 3297),
Point(3004, 3286), Point(3008, 3278)];
'WP32_WP31' : Result:= [Point(3007, 3278), Point(3016, 3276), Point(3025, 3276),
Point(3033, 3276)];
'WP31_WP42' : Result:= [Point(3033, 3276), Point(3038, 3265), Point(3039, 3256),
Point(3041, 3246)];
'WP42_PORT_SARIM_DBOX' : Result:= [Point(3041, 3246), Point(3045, 3235)];
'WP30_WP42' : Result:= [Point(3042, 3275), Point(3042, 3266), Point(3041, 3256),
Point(3042, 3246)];
'WP31_WP30' : Result:= [Point(3034, 3277), Point(3042, 3275)];
'WP31_FALADOR_SOUTH_FARM' : Result:= [Point(3033, 3277), Point(3033, 3285)];
'WP30_WP29' : Result:= [Point(3042, 3274), Point(3052, 3275), Point(3061, 3276),
Point(3069, 3276)];
'WP42_WP29' : Result:= [Point(3042, 3246), Point(3054, 3246), Point(3061, 3253),
Point(3065, 3262), Point(3069, 3275)];
'WP36_WP38' : Result:= [Point(3007, 3317), Point(3017, 3321), Point(3028, 3325),
Point(3041, 3326), Point(3054, 3326), Point(3065, 3325),
Point(3069, 3334), Point(3075, 3337)];
'WP38_WP37' : Result:= [Point(3075, 3337), Point(3079, 3328)];
'WP37_DRANOR_MANOR_FENCE' : Result:= [Point(3079, 3327), Point(3090, 3325), Point(3100, 3324),
Point(3109, 3328)];
'DRANOR_MANOR_DRANOR_MANOR_FENCE' : Result:= [Point(3109, 3352), Point(3109, 3342), Point(3110, 3329)];
'WP37_WP28' : Result:= [Point(3081, 3326), Point(3084, 3317), Point(3087, 3308),
Point(3088, 3298), Point(3086, 3289)];
'WP27_WP28' : Result:= [Point(3109, 3294), Point(3099, 3294), Point(3088, 3290)];
'WP27_DRANOR_MANOR_FENCE' : Result:= [Point(3109, 3294), Point(3113, 3304), Point(3112, 3314),
Point(3110, 3327)];
'WP28_WP29' : Result:= [Point(3086, 3289), Point(3076, 3283), Point(3070, 3276)];
'WP26_WP29' : Result:= [Point(3092, 3247), Point(3081, 3251), Point(3073, 3259),
Point(3071, 3268), Point(3069, 3276)];
'WP25_WP26' : Result:= [Point(3104, 3249), Point(3093, 3247)];
'WP26_DRANOR_BANK' : Result:= [Point(3093, 3247), Point(3093, 3242)];
'WP25_WP27' : Result:= [Point(3104, 3248), Point(3104, 3260), Point(3105, 3273),
Point(3109, 3284), Point(3109, 3294)];
'WP28_WP25' : Result:= [Point(3087, 3289), Point(3098, 3286), Point(3105, 3279),
Point(3105, 3270), Point(3104, 3259), Point(3104, 3249)];
'WP22_WP27' : Result:= [Point(3166, 3288), Point(3159, 3289), Point(3148, 3295),
Point(3136, 3294), Point(3125, 3297), Point(3117, 3295),
Point(3109, 3293)];
'WP25_WP49' : Result:= [Point(3104, 3248), Point(3112, 3257), Point(3124, 3261),
Point(3135, 3259), Point(3147, 3257), Point(3160, 3255),
Point(3172, 3251), Point(3185, 3248)];
'WP24_WP25' : Result:= [Point(3116, 3211), Point(3114, 3220), Point(3109, 3230),
Point(3105, 3238), Point(3104, 3248)];
'WP24_WIZARDS_TOWER' : Result:= [Point(3118, 3212), Point(3114, 3201), Point(3113, 3188),
Point(3114, 3176), Point(3110, 3166)];
'WP23_WP24' : Result:= [Point(3140, 3204), Point(3132, 3213), Point(3120, 3213)];
'WP24_WP49' : Result:= [Point(3119, 3213), Point(3127, 3223), Point(3138, 3228),
Point(3151, 3232), Point(3163, 3236), Point(3174, 3242),
Point(3186, 3247)];
'WP22_WP21' : Result:= [Point(3167, 3288), Point(3179, 3286), Point(3189, 3282),
Point(3200, 3278), Point(3213, 3277), Point(3216, 3267),
Point(3216, 3259)];
'WP20_WP21' : Result:= [Point(3218, 3247), Point(3216, 3258)];
'WP20_WP49' : Result:= [Point(3219, 3246), Point(3208, 3246), Point(3197, 3244),
Point(3186, 3247)];
'WP20_WP19' : Result:= [Point(3220, 3246), Point(3224, 3236), Point(3231, 3228),
Point(3236, 3218)];
'WP19_LUMBRIDGE_CASTLE' : Result:= [Point(3237, 3217), Point(3223, 3217)];
'WP19_LUMBRIDGE_EAST_SWAMP_MINE' : Result:= [Point(3237, 3217), Point(3236, 3205), Point(3244, 3195),
Point(3244, 3184), Point(3240, 3173), Point(3238, 3161),
Point(3236, 3151), Point(3227, 3143)];
'LUMBRIDGE_EAST_SWAMP_MINE_WP41' : Result:= [Point(3227, 3144), Point(3218, 3151), Point(3205, 3154),
Point(3191, 3152), Point(3182, 3151)];
'WP41_LUMBRIDGE_WEST_SWAMP_MINE' : Result:= [Point(3182, 3151), Point(3170, 3149), Point(3157, 3147),
Point(3148, 3147)];
'WP23_LUMBRIDGE_WEST_SWAMP_MINE' : Result:= [Point(3141, 3203), Point(3143, 3193), Point(3145, 3182),
Point(3149, 3171), Point(3150, 3160), Point(3149, 3147)];
'WP23_WP41' : Result:= [Point(3142, 3203), Point(3148, 3197), Point(3153, 3186),
Point(3158, 3175), Point(3163, 3163), Point(3170, 3156),
Point(3180, 3152)];
'WP18_ALKHARID_BANK' : Result:= [Point(3284, 3182), Point(3278, 3174), Point(3271, 3165)];
'WP18_ALKHARID_PALACE' : Result:= [Point(3283, 3182), Point(3293, 3180), Point(3293, 3169)];
'FALADOR_NORTH_REST_GOBLIN_VILLAGE', 'WP3_FALADOR_NORTH_REST', 'WP3_WP2',
'WP2_WP1', 'WP2_WP1', 'WP1_BLACK_KNIGHT_FORTRESS', 'WP1_DWARVEN_MINE',
'EDGEVILLE_MONESTARY_WP2', 'BARBARIAN_VILLIAGE_WP2', 'BARBARIAN_VILLIAGE_WP3',
'WP43_EDGEVILLE_MONESTARY', 'EDGEVILLE_BANK_WP43', 'WP43_EDGEVILLE',
'EDGEVILLE_BANK_EDGEVILLE', 'EDGEVILLE_EDGEVILLE_YEWS',
'BARBARIAN_VILLIAGE_EDGEVILLE', 'WP4_BARBARIAN_VILLIAGE', 'VARROCK_WEST_MINE_WP4',
'WP38_BARBARIAN_VILLIAGE', 'WP6_WP4', 'WP4_CG', 'WP6_CG', 'WP5_CG', 'WP25_WP28',
'VARROCK_WEST_BANK_WP5', 'GRAND_EXCHANGE_WP5', 'WP7_GRAND_EXCHANGE', 'WP8_WP7',
'VARROCK_PALACE_WP8', 'VARROCK_CENTRAL_WP8', 'VARROCK_CENTRAL_WP45', 'WP45_WP44',
'WP45_VARROCK_WEST_BANK', 'WP44_WP6', 'VARROCK_CENTRAL_WP10', 'WP9_VARROCK_CENTRAL',
'VARROCK_EAST_BANK_WP10', 'WP12_WP10', 'VARROCK_WEST_MINE_WP44',
'VARROCK_WEST_MINE_WP46', 'CG_WP9', 'CG_WP46', 'WP11_WP9', 'WP12_WP11',
'VARROCK_EAST_MINE_WP11', 'VARROCK_EAST_MINE_WP12', 'WP13_WP12', 'WP14_WP9',
'WP22_WP46', 'WP14_WP13', 'WP15_WP14', 'WP15_WP13', 'WP17_WP13', 'WP17_ALKHARID_MINE',
'WP47_WP15', 'LUMBRIDGE_EAST_CHICKENS_WP47', 'WP21_WP47', 'WP18_WP17',
'FALADOR_CENTRAL_FALADOR_NORTH_REST', 'FALADOR_WEST_BANK_FALADOR_CENTRAL',
'WP40_FALADOR_CENTRAL', 'WP39_WP40', 'FALADOR_EAST_BANK_WP39', 'FALADOR_FOUNTAIN_WP39',
'FALADOR_DWARVEN_MINE_FALADOR_FOUNTAIN', 'FALADOR_MINING_GUILD_FALADOR_FOUNTAIN',
'WP35_WP36', 'WP36_WP40', 'CG_WP35', 'WP33_WP35', 'WP48_WP33', 'WP34_WP48',
'RIMMINGTON_MINE_WP48', 'WP47_RIMMINGTON_MINE', 'WP47_WP34', 'RIMMINGTON_WP47',
'RIMMINGTON_WP34', 'MELZARS_MAZE_WP34', 'WP32_WP33', 'WP32_WP36', 'WP31_WP32',
'WP42_WP31', 'PORT_SARIM_DBOX_WP42', 'WP42_WP30', 'WP30_WP31',
'FALADOR_SOUTH_FARM_WP31', 'WP29_WP30', 'WP29_WP42', 'WP38_WP36', 'WP37_WP38',
'DRANOR_MANOR_FENCE_WP37', 'DRANOR_MANOR_FENCE_DRANOR_MANOR', 'WP28_WP37',
'WP28_WP27', 'DRANOR_MANOR_FENCE_WP27', 'WP29_WP28', 'WP29_WP26', 'WP26_WP25',
'DRANOR_BANK_WP26', 'WP27_WP25', 'WP27_WP22', 'WP49_WP25', 'WP25_WP24',
'WIZARDS_TOWER_WP24', 'WP24_WP23', 'WP49_WP24', 'WP21_WP22', 'WP21_WP20',
'WP49_WP20', 'WP19_WP20', 'LUMBRIDGE_CASTLE_WP19', 'LUMBRIDGE_EAST_SWAMP_MINE_WP19',
'WP41_LUMBRIDGE_EAST_SWAMP_MINE', 'LUMBRIDGE_WEST_SWAMP_MINE_WP41',
'LUMBRIDGE_WEST_SWAMP_MINE_WP23', 'WP41_WP23', 'ALKHARID_BANK_WP18',
'ALKHARID_PALACE_WP18' : Result:= MirrorTPA(LoadPath(EndLoc, StartLoc));
end;
end;

begin
end.

now to add a path from say fally central to varrock central you would do this
FALADOR_CENTRAL_VARROCK_CENTRAL := [CombineTPAs([LoadPath('FALADOR_CENTRAL', 'FALADOR_NORTH_REST'), LoadPath('FALADOR_NORTH_REST', 'WP3'), LoadPath('WP3', 'BARBARIAN_VILLAGE'), LoadPath('BARBARIAN_VILLAGE', 'WP4'), LoadPath('WP4', 'WP6'), LoadPath('WP6', 'WP44'), LoadPath('WP44', 'WP45'), LoadPath('WP45', 'VARROCK_CENTRAL')])];
and this would be added to the end of the function
VARROCK_CENTRAL_FALADOR_CENTRAL

~shut

EDIT: actually addding a path is longer winded than i thought, so im going to add a new function that will make adding a new path much easier

Cstrike

2010-09-05 12:12:11

Ah I see now

I think both of ours have advantages. Yours [from what I've seen] is designed to move by smaller paths, which will allow for more failsafes, plus yours is easier to add things to.

For mine, my goal is to design it in such a way that its easy for users to call certain functions… such as they could literally in one line of code call
WalkTo ('crafting guild');
Upon that one line of code, it will take them from anywhere in RS and follow the proper paths to the crafting guild.
The basis of my code was to create small paths that connect to the main highway, and upon finding the closest path, it will find the first Point from the walking path, then find that Point on the highway, and walk to that point, transfer over and walk the path until the desired integer of tiles.

Hopefully all the best in both our scripts can come together :)

Shuttleu

2010-09-05 12:23:33

updated with a better way to add long paths
program new;
{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}
{$i reflection/reflection.simba}
{
const
GOBLIN_VILLAGE
DWARVEN_MINE
BLACK_KNIGHT_FORTRESS
EDGEVILLE
EDGEVILLE_MONESTARY
EDGEVILLE_YEWS
EDGEVILLE_BANK
GRAND_EXCHANGE
VARROCK_CENTRAL
VARROCK_PALACE
VARROCK_WEST_BANK
VARROCK_EAST_BANK
VARROCK_WEST_MINE
VARROCK_EAST_MINE
CHAMPIONS_GUILD
LUMBRIDGE_EAST_CHICKENS
LUMBRIDGE_CASTLE
DRAYNOR_BANK
DRAYNOR_MANOR
DRAYNOR_MANOR_FENCE
PORT_SARIM_DBOX
WIZARDS_TOWER
LUMBRIDGE_WEST_SWAMP_MINE
LUMBRIDGE_EAST_SWAMP_MINE
RIMMINGTON_MINE
RIMMINGTON
MELZARS_MAZE
CRAFTING_GUILD
FALADOR_EAST_BANK
FALADOR_WEST_BANK
FALADOR_NORTH_REST
FALADOR_CENTRAL
FALADOR_MINING_GUILD
FALADOR_FOUNTAIN
FALADOR_DWARVEN_MINE
FALADOR_SOUTH_FARM
COOKING_GUILD
BARBARIAN_VILLAGE
ALKHARID_BANK
ALKHARID_PALACE
ALKHARID_MINE

WP1
WP2
WP3
WP4
WP5
WP6
WP7
WP8
WP9
WP10
WP11
WP12
WP13
WP14
WP15
WP16
WP17
WP18
WP19
WP20
WP21
WP22
WP23
WP24
WP25
WP26
WP27
WP28
WP29
WP30
WP31
WP32
WP33
WP34
WP35
WP36
WP37
WP38
WP39
WP40
WP41
WP42
WP43
WP44
WP45
WP46
WP47
WP48
WP49}

function MirrorTPA(TPA: TPointArray): TPointArray;
var
i, h: integer;
begin
h := 0;
SetLength(Result, Length(TPA));
for i:= High(TPA) DownTo 0 do
begin
Result[h] := TPA[i];
Inc(h);
end;
end;

function CombineTPAs(TheTPAs: array of TPointArray): TPointArray;
var
i: Integer;
begin
for i:= 0 to High(TheTPAs) do
CombineTPA(Result, TheTPAs[i]);
end;

function CreatePath(ThePoints: TStringArray): TPointArray; forward;

function LoadPath(StartLoc, EndLoc: string): TPointArray;
begin
case (StartLoc+'_'+EndLoc) of
'GOBLIN_VILLAGE_FALADOR_NORTH_REST' : Result:= [Point(2955, 3501), Point(2955, 3488), Point(2953, 3476),
Point(2948, 3466), Point(2946, 3456), Point(2946, 3446),
Point(2947, 3435), Point(2949, 3425), Point(2955, 3420),
Point(2966, 3413)];
'FALADOR_NORTH_REST_WP3' : Result:= [Point(2966, 3413), Point(2976, 3416), Point(2986, 3421),
Point(2991, 3428), Point(3002, 3432), Point(3012, 3431),
Point(3022, 3429), Point(3034, 3429)];
'WP2_WP3' : Result:= [Point(3051, 3469), Point(3047, 3459), Point(3041, 3449),
Point(3039, 3439), Point(3037, 3429)];
'WP1_WP2' : Result:= [Point(3032, 3473), Point(3041, 3472), Point(3051, 3468)];
'BLACK_KNIGHT_FORTRESS_WP1' : Result:= [Point(3026, 3503), Point(3023, 3497), Point(3019, 3490),
Point(3022, 3483), Point(3029, 3480), Point(3032, 3473)];
'DWARVEN_MINE_WP1' : Result:= [Point(3015, 3450), Point(3015, 3458), Point(3024, 3462),
Point(3032, 3473)];
'WP2_EDGEVILLE_MONESTARY' : Result:= [Point(3051, 3468), Point(3051, 3478), Point(3051, 3491)];
'WP2_BARBARIAN_VILLIAGE' : Result:= [Point(3051, 3468), Point(3051, 3457), Point(3061, 3451),
Point(3066, 3445), Point(3068, 3434), Point(3069, 3424),
Point(3079, 3421)];
'WP3_BARBARIAN_VILLIAGE' : Result:= [Point(3036, 3429), Point(3044, 3423), Point(3055, 3422),
Point(3065, 3421), Point(3078, 3421)];
'EDGEVILLE_MONESTARY_WP43' : Result:= [Point(3051, 3492), Point(3051, 3500), Point(3051, 3510),
Point(3057, 3519), Point(3065, 3522), Point(3076, 3521),
Point(3085, 3518), Point(3088, 3510), Point(3089, 3503)];
'WP43_EDGEVILLE_BANK' : Result:= [Point(3089, 3502), Point(3093, 3497)];
'EDGEVILLE_WP43' : Result:= [Point(3087, 3492), Point(3089, 3502)];
'EDGEVILLE_EDGEVILLE_BANK' : Result:= [Point(3087, 3493), Point(3093, 3495)];
'EDGEVILLE_YEWS_EDGEVILLE' : Result:= [Point(3086, 3477), Point(3093, 3472), Point(3094, 3480),
Point(3087, 3492)];
'EDGEVILLE_BARBARIAN_VILLIAGE' : Result:= [Point(3087, 3492), Point(3081, 3485), Point(3081, 3474),
Point(3087, 3466), Point(3090, 3456), Point(3091, 3444),
Point(3091, 3433), Point(3090, 3421)];
'BARBARIAN_VILLIAGE_WP4' : Result:= [Point(3086, 3422), Point(3097, 3421), Point(3108, 3421),
Point(3118, 3420)];
'WP4_VARROCK_WEST_MINE' : Result:= [Point(3117, 3420), Point(3128, 3415), Point(3136, 3407),
Point(3145, 3400), Point(3154, 3393), Point(3161, 3386),
Point(3169, 3378), Point(3177, 3370)];
'BARBARIAN_VILLIAGE_WP38' : Result:= [Point(3079, 3421), Point(3081, 3411), Point(3085, 3402),
Point(3083, 3392), Point(3076, 3385), Point(3072, 3376),
Point(3070, 3366), Point(3071, 3354), Point(3071, 3342)];
'WP4_WP6' : Result:= [Point(3117, 3420), Point(3127, 3415), Point(3141, 3417),
Point(3152, 3418)];
'COOKING_GUILD_WP4' : Result:= [Point(3143, 3439), Point(3134, 3434), Point(3124, 3428),
Point(3116, 3421)];
'COOKING_GUILD_WP6' : Result:= [Point(3145, 3439), Point(3144, 3431), Point(3147, 3424),
Point(3152, 3417)];
'GOOKING_CUILD_WP5' : Result:= [Point(3145, 3439), Point(3152, 3446), Point(3159, 3452),
Point(3166, 3456)];
'WP5_VARROCK_WEST_BANK' : Result:= [Point(3166, 3456), Point(3173, 3455), Point(3180, 3451),
Point(3187, 3448), Point(3187, 3439)];
'WP5_GRAND_EXCHANGE' : Result:= [Point(3166, 3457), Point(3165, 3465), Point(3164, 3476),
Point(3167, 3488)];
'GRAND_EXCHANGE_WP7' : Result:= [Point(3168, 3487), Point(3176, 3488), Point(3186, 3488),
Point(3196, 3488)];
'WP7_WP8' : Result:= [Point(3195, 3488), Point(3197, 3478), Point(3197, 3466),
Point(3200, 3456), Point(3212, 3450)];
'WP8_VARROCK_PALACE' : Result:= [Point(3212, 3450), Point(3213, 3457), Point(3213, 3466)];
'WP8_VARROCK_CENTRAL' : Result:= [Point(3212, 3449), Point(3213, 3439), Point(3213, 3429)];
'WP45_VARROCK_CENTRAL' : Result:= [Point(3188, 3430), Point(3202, 3430), Point(3213, 3429)];
'WP44_WP45' : Result:= [Point(3170, 3428), Point(3178, 3429), Point(3187, 3431)];
'VARROCK_WEST_BANK_WP45' : Result:= [Point(3188, 3439), Point(3187, 3431)];
'WP6_WP44' : Result:= [Point(3153, 3419), Point(3162, 3421), Point(3171, 3429)];
'WP10_VARROCK_CENTRAL' : Result:= [Point(3254, 3430), Point(3244, 3429), Point(3234, 3430),
Point(3225, 3430), Point(3213, 3429)];
'VARROCK_CENTRAL_WP9' : Result:= [Point(3212, 3377), Point(3212, 3387), Point(3211, 3398),
Point(3211, 3411), Point(3210, 3422), Point(3213, 3429)];
'WP10_VARROCK_EAST_BANK' : Result:= [Point(3254, 3429), Point(3254, 3421)];
'WP10_WP12' : Result:= [Point(3254, 3430), Point(3262, 3429), Point(3270, 3429),
Point(3281, 3429), Point(3288, 3420), Point(3290, 3410),
Point(3291, 3398), Point(3293, 3386), Point(3294, 3377)];
'WP44_VARROCK_WEST_MINE' : Result:= [Point(3171, 3430), Point(3171, 3421), Point(3172, 3411),
Point(3170, 3401), Point(3171, 3390), Point(3175, 3380),
Point(3177, 3370)];
'WP46_VARROCK_WEST_MINE' : Result:= [Point(3183, 3368), Point(3177, 3370)];
'WP46_CHAMPIONS_GUILD' : Result:= [Point(3183, 3367), Point(3192, 3365)];
'WP9_CHAMPIONS_GUILD' : Result:= [Point(3211, 3378), Point(3205, 3371), Point(3197, 3367),
Point(3191, 3366)];
'WP9_WP11' : Result:= [Point(3211, 3378), Point(3222, 3378), Point(3234, 3377),
Point(3245, 3374), Point(3257, 3371), Point(3269, 3371),
Point(3279, 3374)];
'WP11_WP12' : Result:= [Point(3278, 3373), Point(3291, 3374)];
'WP11_VARROCK_EAST_MINE' : Result:= [Point(3279, 3373), Point(3286, 3366)];
'WP12_VARROCK_EAST_MINE' : Result:= [Point(3292, 3375), Point(3287, 3366)];
'WP12_WP13' : Result:= [Point(3293, 3377), Point(3297, 3367), Point(3300, 3356),
Point(3297, 3345), Point(3289, 3339), Point(3278, 3333)];
'WP9_WP14' : Result:= [Point(3212, 3380), Point(3215, 3370), Point(3220, 3359),
Point(3226, 3349), Point(3231, 3337), Point(3241, 3336)];
'WP46_WP22' : Result:= [Point(3182, 3365), Point(3176, 3356), Point(3177, 3345),
Point(3176, 3332), Point(3177, 3319), Point(3176, 3307),
Point(3167, 3300), Point(3167, 3288)];
'WP13_WP14' : Result:= [Point(3281, 3333), Point(3267, 3333), Point(3255, 3335),
Point(3243, 3337)];
'WP14_WP15' : Result:= [Point(3240, 3336), Point(3240, 3326), Point(3240, 3316),
Point(3240, 3305)];
'WP13_WP15' : Result:= [Point(3276, 3332), Point(3270, 3328), Point(3260, 3324),
Point(3251, 3318), Point(3246, 3312), Point(3240, 3306)];
'WP13_WP17' : Result:= [Point(3277, 3332), Point(3280, 3322), Point(3279, 3309),
Point(3279, 3298), Point(3281, 3287), Point(3284, 3277),
Point(3293, 3270)];
'ALKHARID_MINE_WP17' : Result:= [Point(3300, 3306), Point(3299, 3297), Point(3301, 3288),
Point(3301, 3279), Point(3295, 3271)];
'WP15_WP47' : Result:= [Point(3240, 3307), Point(3239, 3295)];
'WP47_LUMBRIDGE_EAST_CHICKENS' : Result:= [Point(3239, 3295), Point(3231, 3296)];
'WP47_WP21' : Result:= [Point(3239, 3295), Point(3239, 3286), Point(3240, 3276),
Point(3243, 3265), Point(3236, 3261), Point(3225, 3259),
Point(3216, 3258)];
'WP17_WP18' : Result:= [Point(3292, 3270), Point(3293, 3261), Point(3292, 3250),
Point(3290, 3239), Point(3284, 3230), Point(3281, 3220),
Point(3281, 3209), Point(3283, 3195), Point(3283, 3183)];
'FALADOR_NORTH_REST_FALADOR_CENTRAL' : Result:= [Point(2966, 3412), Point(2965, 3401), Point(2966, 3390),
Point(2965, 3381)];
'FALADOR_CENTRAL_FALADOR_WEST_BANK' : Result:= [Point(2965, 3381), Point(2956, 3381), Point(2951, 3378),
Point(2946, 3369)];
'FALADOR_CENTRAL_WP40' : Result:= [Point(2964, 3381), Point(2975, 3379), Point(2987, 3373),
Point(2997, 3366), Point(3006, 3364)];
'WP40_WP39' : Result:= [Point(3005, 3363), Point(3013, 3363)];
'WP39_FALADOR_EAST_BANK' : Result:= [Point(3012, 3363), Point(3012, 3357)];
'WP39_FALADOR_FOUNTAIN' : Result:= [Point(3012, 3363), Point(3021, 3361), Point(3030, 3357),
Point(3036, 3354)];
'FALADOR_FOUNTAIN_FALADOR_DWARVEN_MINE' : Result:= [Point(3037, 3355), Point(3042, 3360), Point(3043, 3367),
Point(3051, 3369), Point(3061, 3375)];
'FALADOR_FOUNTAIN_FALADOR_MINING_GUILD' : Result:= [Point(3036, 3354), Point(3031, 3347), Point(3026, 3336),
Point(3019, 3339)];
'WP40_WP36' : Result:= [Point(3005, 3363), Point(3006, 3352), Point(3007, 3339),
Point(3006, 3330), Point(3007, 3318)];
'WP36_WP35' : Result:= [Point(3007, 3317), Point(2999, 3313), Point(2991, 3305),
Point(2980, 3301), Point(2969, 3297), Point(2954, 3297)];
'WP35_CRAFTING_GUILD' : Result:= [Point(2953, 3296), Point(2941, 3296), Point(2933, 3292)];
'WP35_WP33' : Result:= [Point(2953, 3296), Point(2958, 3287), Point(2968, 3284),
Point(2975, 3279), Point(2982, 3276)];
'WP33_WP48' : Result:= [Point(2981, 3276), Point(2975, 3265)];
'WP48_WP34' : Result:= [Point(2975, 3264), Point(2970, 3257), Point(2962, 3250),
Point(2954, 3241)];
'WP48_RIMMINGTON_MINE' : Result:= [Point(2975, 3263), Point(2976, 3253), Point(2978, 3239)];
'RIMMINGTON_MINE_WP47' : Result:= [Point(2978, 3238), Point(2969, 3227)];
'WP34_WP47' : Result:= [Point(2953, 3241), Point(2961, 3235), Point(2969, 3226)];
'WP47_RIMMINGTON' : Result:= [Point(2969, 3227), Point(2960, 3221), Point(2956, 3213)];
'WP34_RIMMINGTON' : Result:= [Point(2954, 3240), Point(2956, 3232), Point(2956, 3221),
Point(2956, 3214)];
'WP34_MELZARS_MAZE' : Result:= [Point(2953, 3240), Point(2942, 3245)];
'WP33_WP32' : Result:= [Point(2981, 3275), Point(2993, 3281), Point(3006, 3276)];
'WP36_WP32' : Result:= [Point(3006, 3317), Point(3005, 3308), Point(3005, 3297),
Point(3004, 3286), Point(3008, 3278)];
'WP32_WP31' : Result:= [Point(3007, 3278), Point(3016, 3276), Point(3025, 3276),
Point(3033, 3276)];
'WP31_WP42' : Result:= [Point(3033, 3276), Point(3038, 3265), Point(3039, 3256),
Point(3041, 3246)];
'WP42_PORT_SARIM_DBOX' : Result:= [Point(3041, 3246), Point(3045, 3235)];
'WP30_WP42' : Result:= [Point(3042, 3275), Point(3042, 3266), Point(3041, 3256),
Point(3042, 3246)];
'WP31_WP30' : Result:= [Point(3034, 3277), Point(3042, 3275)];
'WP31_FALADOR_SOUTH_FARM' : Result:= [Point(3033, 3277), Point(3033, 3285)];
'WP30_WP29' : Result:= [Point(3042, 3274), Point(3052, 3275), Point(3061, 3276),
Point(3069, 3276)];
'WP42_WP29' : Result:= [Point(3042, 3246), Point(3054, 3246), Point(3061, 3253),
Point(3065, 3262), Point(3069, 3275)];
'WP36_WP38' : Result:= [Point(3007, 3317), Point(3017, 3321), Point(3028, 3325),
Point(3041, 3326), Point(3054, 3326), Point(3065, 3325),
Point(3069, 3334), Point(3075, 3337)];
'WP38_WP37' : Result:= [Point(3075, 3337), Point(3079, 3328)];
'WP37_DRANOR_MANOR_FENCE' : Result:= [Point(3079, 3327), Point(3090, 3325), Point(3100, 3324),
Point(3109, 3328)];
'DRANOR_MANOR_DRANOR_MANOR_FENCE' : Result:= [Point(3109, 3352), Point(3109, 3342), Point(3110, 3329)];
'WP37_WP28' : Result:= [Point(3081, 3326), Point(3084, 3317), Point(3087, 3308),
Point(3088, 3298), Point(3086, 3289)];
'WP27_WP28' : Result:= [Point(3109, 3294), Point(3099, 3294), Point(3088, 3290)];
'WP27_DRANOR_MANOR_FENCE' : Result:= [Point(3109, 3294), Point(3113, 3304), Point(3112, 3314),
Point(3110, 3327)];
'WP28_WP29' : Result:= [Point(3086, 3289), Point(3076, 3283), Point(3070, 3276)];
'WP26_WP29' : Result:= [Point(3092, 3247), Point(3081, 3251), Point(3073, 3259),
Point(3071, 3268), Point(3069, 3276)];
'WP25_WP26' : Result:= [Point(3104, 3249), Point(3093, 3247)];
'WP26_DRANOR_BANK' : Result:= [Point(3093, 3247), Point(3093, 3242)];
'WP25_WP27' : Result:= [Point(3104, 3248), Point(3104, 3260), Point(3105, 3273),
Point(3109, 3284), Point(3109, 3294)];
'WP28_WP25' : Result:= [Point(3087, 3289), Point(3098, 3286), Point(3105, 3279),
Point(3105, 3270), Point(3104, 3259), Point(3104, 3249)];
'WP22_WP27' : Result:= [Point(3166, 3288), Point(3159, 3289), Point(3148, 3295),
Point(3136, 3294), Point(3125, 3297), Point(3117, 3295),
Point(3109, 3293)];
'WP25_WP49' : Result:= [Point(3104, 3248), Point(3112, 3257), Point(3124, 3261),
Point(3135, 3259), Point(3147, 3257), Point(3160, 3255),
Point(3172, 3251), Point(3185, 3248)];
'WP24_WP25' : Result:= [Point(3116, 3211), Point(3114, 3220), Point(3109, 3230),
Point(3105, 3238), Point(3104, 3248)];
'WP24_WIZARDS_TOWER' : Result:= [Point(3118, 3212), Point(3114, 3201), Point(3113, 3188),
Point(3114, 3176), Point(3110, 3166)];
'WP23_WP24' : Result:= [Point(3140, 3204), Point(3132, 3213), Point(3120, 3213)];
'WP24_WP49' : Result:= [Point(3119, 3213), Point(3127, 3223), Point(3138, 3228),
Point(3151, 3232), Point(3163, 3236), Point(3174, 3242),
Point(3186, 3247)];
'WP22_WP21' : Result:= [Point(3167, 3288), Point(3179, 3286), Point(3189, 3282),
Point(3200, 3278), Point(3213, 3277), Point(3216, 3267),
Point(3216, 3259)];
'WP20_WP21' : Result:= [Point(3218, 3247), Point(3216, 3258)];
'WP20_WP49' : Result:= [Point(3219, 3246), Point(3208, 3246), Point(3197, 3244),
Point(3186, 3247)];
'WP20_WP19' : Result:= [Point(3220, 3246), Point(3224, 3236), Point(3231, 3228),
Point(3236, 3218)];
'WP19_LUMBRIDGE_CASTLE' : Result:= [Point(3237, 3217), Point(3223, 3217)];
'WP19_LUMBRIDGE_EAST_SWAMP_MINE' : Result:= [Point(3237, 3217), Point(3236, 3205), Point(3244, 3195),
Point(3244, 3184), Point(3240, 3173), Point(3238, 3161),
Point(3236, 3151), Point(3227, 3143)];
'LUMBRIDGE_EAST_SWAMP_MINE_WP41' : Result:= [Point(3227, 3144), Point(3218, 3151), Point(3205, 3154),
Point(3191, 3152), Point(3182, 3151)];
'WP41_LUMBRIDGE_WEST_SWAMP_MINE' : Result:= [Point(3182, 3151), Point(3170, 3149), Point(3157, 3147),
Point(3148, 3147)];
'WP23_LUMBRIDGE_WEST_SWAMP_MINE' : Result:= [Point(3141, 3203), Point(3143, 3193), Point(3145, 3182),
Point(3149, 3171), Point(3150, 3160), Point(3149, 3147)];
'WP23_WP41' : Result:= [Point(3142, 3203), Point(3148, 3197), Point(3153, 3186),
Point(3158, 3175), Point(3163, 3163), Point(3170, 3156),
Point(3180, 3152)];
'WP18_ALKHARID_BANK' : Result:= [Point(3284, 3182), Point(3278, 3174), Point(3271, 3165)];
'WP18_ALKHARID_PALACE' : Result:= [Point(3283, 3182), Point(3293, 3180), Point(3293, 3169)];
'FALADOR_NORTH_REST_GOBLIN_VILLAGE', 'WP3_FALADOR_NORTH_REST', 'WP3_WP2',
'WP2_WP1', 'WP2_WP1', 'WP1_BLACK_KNIGHT_FORTRESS', 'WP1_DWARVEN_MINE',
'EDGEVILLE_MONESTARY_WP2', 'BARBARIAN_VILLIAGE_WP2', 'BARBARIAN_VILLIAGE_WP3',
'WP43_EDGEVILLE_MONESTARY', 'EDGEVILLE_BANK_WP43', 'WP43_EDGEVILLE',
'EDGEVILLE_BANK_EDGEVILLE', 'EDGEVILLE_EDGEVILLE_YEWS',
'BARBARIAN_VILLIAGE_EDGEVILLE', 'WP4_BARBARIAN_VILLIAGE', 'VARROCK_WEST_MINE_WP4',
'WP38_BARBARIAN_VILLIAGE', 'WP6_WP4', 'WP4_CG', 'WP6_CG', 'WP5_CG', 'WP25_WP28',
'VARROCK_WEST_BANK_WP5', 'GRAND_EXCHANGE_WP5', 'WP7_GRAND_EXCHANGE', 'WP8_WP7',
'VARROCK_PALACE_WP8', 'VARROCK_CENTRAL_WP8', 'VARROCK_CENTRAL_WP45', 'WP45_WP44',
'WP45_VARROCK_WEST_BANK', 'WP44_WP6', 'VARROCK_CENTRAL_WP10', 'WP9_VARROCK_CENTRAL',
'VARROCK_EAST_BANK_WP10', 'WP12_WP10', 'VARROCK_WEST_MINE_WP44',
'VARROCK_WEST_MINE_WP46', 'CG_WP9', 'CG_WP46', 'WP11_WP9', 'WP12_WP11',
'VARROCK_EAST_MINE_WP11', 'VARROCK_EAST_MINE_WP12', 'WP13_WP12', 'WP14_WP9',
'WP22_WP46', 'WP14_WP13', 'WP15_WP14', 'WP15_WP13', 'WP17_WP13', 'WP17_ALKHARID_MINE',
'WP47_WP15', 'LUMBRIDGE_EAST_CHICKENS_WP47', 'WP21_WP47', 'WP18_WP17',
'FALADOR_CENTRAL_FALADOR_NORTH_REST', 'FALADOR_WEST_BANK_FALADOR_CENTRAL',
'WP40_FALADOR_CENTRAL', 'WP39_WP40', 'FALADOR_EAST_BANK_WP39', 'FALADOR_FOUNTAIN_WP39',
'FALADOR_DWARVEN_MINE_FALADOR_FOUNTAIN', 'FALADOR_MINING_GUILD_FALADOR_FOUNTAIN',
'WP35_WP36', 'WP36_WP40', 'CG_WP35', 'WP33_WP35', 'WP48_WP33', 'WP34_WP48',
'RIMMINGTON_MINE_WP48', 'WP47_RIMMINGTON_MINE', 'WP47_WP34', 'RIMMINGTON_WP47',
'RIMMINGTON_WP34', 'MELZARS_MAZE_WP34', 'WP32_WP33', 'WP32_WP36', 'WP31_WP32',
'WP42_WP31', 'PORT_SARIM_DBOX_WP42', 'WP42_WP30', 'WP30_WP31',
'FALADOR_SOUTH_FARM_WP31', 'WP29_WP30', 'WP29_WP42', 'WP38_WP36', 'WP37_WP38',
'DRANOR_MANOR_FENCE_WP37', 'DRANOR_MANOR_FENCE_DRANOR_MANOR', 'WP28_WP37',
'WP28_WP27', 'DRANOR_MANOR_FENCE_WP27', 'WP29_WP28', 'WP29_WP26', 'WP26_WP25',
'DRANOR_BANK_WP26', 'WP27_WP25', 'WP27_WP22', 'WP49_WP25', 'WP25_WP24',
'WIZARDS_TOWER_WP24', 'WP24_WP23', 'WP49_WP24', 'WP21_WP22', 'WP21_WP20',
'WP49_WP20', 'WP19_WP20', 'LUMBRIDGE_CASTLE_WP19', 'LUMBRIDGE_EAST_SWAMP_MINE_WP19',
'WP41_LUMBRIDGE_EAST_SWAMP_MINE', 'LUMBRIDGE_WEST_SWAMP_MINE_WP41',
'LUMBRIDGE_WEST_SWAMP_MINE_WP23', 'WP41_WP23', 'ALKHARID_BANK_WP18',
'ALKHARID_PALACE_WP18' : Result:= MirrorTPA(LoadPath(EndLoc, StartLoc));
end;
end;

function CreatePath(ThePoints: TStringArray): TPointArray;
var
i: Integer;
begin
for i:=0 to High(ThePoints)-1 do
CombineTPA(Result, LoadPath(ThePoints[i], ThePoints[i+1]));
end;

begin
end.

to add a path you just do
FALADOR_CENTRAL_VARROCK_CENTRAL := CreatePath('FALADOR_CENTRAL', 'FALADOR_NORTH_REST', 'WP3', 'BARBARIAN_VILLAGE', 'WP4', 'WP6', 'WP44', 'WP45', 'VARROCK_CENTRAL');

~shut

EDIT: i was also thinking of a way to get past the lvl 3 noob warning thing, which would also hep with gate and doors
if there is a gate for example you can sete the tiles to 1, 0 then while its walking, if the next tile is 1, 0 then it will search for a closed gate, and if there is then it will open it, this can then be used for things like doors, stiles and the lvl 3 noob warning you get when you leave a safe area

Cstrike

2010-09-05 12:59:52

Are you using the WalkPath in reflection?
If so I was wondering if it could be modified to add some procedure where it says "have not walked anywhere in 10 seconds" which checks for a DTM or BMP of the error message and solves it?

nickrules

2010-09-05 13:16:19

Heres a DDTM, DTM, and the bitmap image of the >60 total level warning:

function SetDDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 251;
dtmMainPoint.y := 61;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 0;
dtmMainPoint.Tolerance := 10;

dtmSubPoints[0].x := 251;
dtmSubPoints[0].y := 61;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 0;
dtmSubPoints[0].Tolerance := 10;

dtmSubPoints[1].x := 89;
dtmSubPoints[1].y := 36;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 0;
dtmSubPoints[1].Tolerance := 10;

dtmSubPoints[2].x := 421;
dtmSubPoints[2].y := 36;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := 0;
dtmSubPoints[2].Tolerance := 10;

dtmSubPoints[3].x := 253;
dtmSubPoints[3].y := 82;
dtmSubPoints[3].AreaSize := 0;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := 0;
dtmSubPoints[3].Tolerance := 10;

dtmSubPoints[4].x := 240;
dtmSubPoints[4].y := 82;
dtmSubPoints[4].AreaSize := 0;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := 0;
dtmSubPoints[4].Tolerance := 10;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;


DTM := DTMFromString('78DA63FCCDC0C060CB8001B8809811CA668C0' +
'4122A04D42C6524ACE62F900822A0E6036135000D99054D');


ImageShack changed my bmp to a png for some reason :S
Sorry, lol.

From: cstrike
Are you using the WalkPath in reflection?
If so I was wondering if it could be modified to add some procedure where it says "have not walked anywhere in 10 seconds" which checks for a DTM or BMP of the error message and solves it?


That would work. It could also check if you're stuck for some reason (random, fence/wall, etc).

Shuttleu

2010-09-05 14:00:11

From: cstrike
Are you using the WalkPath in reflection?
If so I was wondering if it could be modified to add some procedure where it says "have not walked anywhere in 10 seconds" which checks for a DTM or BMP of the error message and solves it?

well i was thinking of using WalkPath and modifying it to do what i posted above, it will also check for the tile after the next one to see if it is there, if it is then it will walk on that one, if not then it will walk to the next one
From: nickrules
Heres a DDTM, DTM, and the bitmap image of the >60 total level warning:
thank you for the DTM, i am grateful

~shut

Coh3n

2010-09-05 19:53:33

From: cstrike
Sorry but I'm confused at what you mean by using at the end :(

Do you mean like

//code...
WalkTo ('VWB');
or
WalkTo (Point(VWBx, VWBy)); // Where point(x,y) would be probably some variable

I just want to get down what you mean and I'll try integrating it :P

I think he means the point would be a tile, and the script would walk from the current players position to that point (no matter where it is on the map).

Cstrike

2010-09-05 19:53:53

So the core is now almost complete

Note: If you're going to test this, it only works for the wiz tower for retrieving, or traveling between nodes
program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
ox = 0;
oy = 0;
// Node points
varrockWestBank_x = 3186 + ox;
varrockWestBank_y = 3439 + oy;
faladorEastBank_x = 3013 + ox;
faladorEastBank_y = 3356 + oy;
lumbridgeNE_x = 3217 + ox;
lumbridgeNE_y = 3251 + oy;
draynorBank_x = 3094 + ox;
draynorBank_y = 3242 + oy;
barbVillageC_x = 3081 + ox;
barbVillageC_y = 3416 + oy;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
currentLocString : String; // String of current location, used for
highwayTPA : TPointArray;
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

// This procedure sets up node points (major points, usually banks)
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (varrockWestBank_x, varrockWestBank_y), // 0 Varrock west bank
Tile (faladorEastBank_x, faladorEastBank_y), // 1 Fally east bank
Tile (lumbridgeNE_x, lumbridgeNE_y), // 2 Lumby NE
Tile (draynorBank_x, draynorBank_y), // 3 Draynor bank
Tile (barbVillageC_x, barbVillageC_y)]; // 4 Barb village center (S of dungeon)

// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(lumbridgeNE_x, lumbridgeNE_y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(barbVillageC_x, barbVillageC_y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(varrockWestBank_x, varrockWestBank_y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (faladorEastBank_x, faladorEastBank_y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(lumbridgeNE_x, lumbridgeNE_y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (faladorEastBank_x, faladorEastBank_y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(draynorBank_x, draynorBank_y)];
LNE_VWB := [Point(3223, 3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (varrockWestBank_x, varrockWestBank_y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (draynorBank_x, draynorBank_y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(barbVillageC_x, barbVillageC_y)];

SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(barbVillageC_x, barbVillageC_y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(varrockWestBank_x, varrockWestBank_y)];
Highway[1] :=[Point(lumbridgeNE_x, lumbridgeNE_y), Point(3223, 3237), // Lumby northeast to varrock west bank
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (varrockWestBank_x, varrockWestBank_y)];
Highway[2] :=[Point(barbVillageC_x, barbVillageC_y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (faladorEastBank_x, faladorEastBank_y)];
Highway[3] :=[Point (draynorBank_x, draynorBank_y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (faladorEastBank_x, faladorEastBank_y)];
Highway[4] :=[Point(lumbridgeNE_x, lumbridgeNE_y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(draynorBank_x, draynorBank_y)];
//Streets
SetArrayLength (SubStreet, 1);
SubStreet[0] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
end;

procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;
// This procedure will add a TPA to a TTileArray (and convert it properly)
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

// Takes a position and creates a path from i down to 0
// Useful for being retrieved
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

// Takes a position and creates a path from 0 up to i | Useful for being retrieved
procedure AddTPAFromUpToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=0 to TPAPos do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
end;

// If you have a TPA from 0 to 20, and want to create TPA#2 from TPA position 16 to 20, use this
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPADifference downto 0 do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

// If you have a TPA from 0 to 20, and want to create TPA#2 from TPA position TPA[7] to TPA[0], use this
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

// Sets TIA[0] as the lowest number
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

// Returns the TPA that the TPoint is in (or ATPA[number here])
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

// Attempts to walk (blindly) towards a tile | X increases as you go east, y as you go north | Needs some SERIOUS code fixing... | NOTE: For walkRadius, use '8' as default if you want to travel about | 1/2 the way to the edge of the minimap (ex: radius 8 means if found) | south of you only, will probably travel between MMCY, and MMY2/2
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
// opp : Integer;
xinc, yinc : Extended;
//walkPoint : TPoint;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

// Finds all the distances from subpoints only (defined as streets in SetupNodes/Paths) | distArrLowest [i] would = shortest distance in ATPA[i] | Returns the closest TPoint from the ATPA, which you further should use the 'walktowardsTP' procedure
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z, time : Integer;
begin
if not LoggedIn then exit;
MarkTime (time);
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
// Debug output to get a nice chart :)
for z:=0 to high(ATPA) do
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
writeln (TimeFromMark(time));
end;

// If you're near a node, this will assign currentLocString to it
procedure AssignNodeLocation (var location : string; maxTileRadius : integer);
var i : Integer;
currentTile : TTile;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'varrockwestbank';
1: location := 'faladoreastbank';
2: location := 'lumbridgenortheast';
3: location := 'draynorbank';
4: location := 'barbarianvillagecenter';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
//writeln ('In node range = ('+location+')');
end;

//Travels from node to node | VWB = varrock west bank FEB = falador east bank BBC = barbarian village center (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast a bit of the castle
procedure TravelToNode (startNode, endNode : string);
var pathToWalk, path2 : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

// Creates an array of 'distance' from specific highway points | It then returns the T point which is closest
function ClosestNodePath (var TP : Tpoint; TPA : TPointArray) : TPoint;
var currentPosition : TTile;
currentPosTP : TPoint;
i : Integer;
tempdistArray, distArray : TIntegerArray;
begin
if not LoggedIn then exit;
currentPosition := GetMyPos;
writeln ('Tile: '+inttostr(currentPosition.x)+','+inttostr(currentPosition.y)); // Nice debug anyways :)
TileToPoint (currentPosition);
SetArrayLength (distArray, high(TPA)+1);
SetArrayLength (tempdistArray, high(TPA)+1);
for i:=0 to high(TPA) do
begin
distArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
tempdistArray[i] := Distance (currentPosition.x, currentPosition.y, TPA[i].x, TPA[i].y);
end;
QuickSort (tempdistArray); // Don't want to screw up our actual distance array order!
for i:=0 to high (distArray) do
begin
if (tempdistArray[0] = distArray[i]) then //If we find the value i for which the lowest distance was found, so we can use 'i' to identify the TPoint which the distance returned as the shortest...
begin
TP := TPA[i];
writeln ('Distance = '+inttostr(distArray[i]));
end;
end;
end;

// Will blindly attempt to walk to any node (if any paths are on the screen, it'll take it)
procedure BlindWalkToAnyNode;
begin
if not LoggedIn then exit;
TravelToNode ('DRB','FEB');
TravelToNode ('BBC','FEB');
TravelToNode ('LNE','DRB');
TravelToNode ('LNE','VWB');
TravelToNode ('BBC','VWB');
end;

// Takes you from your location through a substreet to SubStreet[i][0], which is a highway point (or should be). This returns the TPoint which should be in the highway
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, numby, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

// This procedure walks the closest street to a highway, then walks the highway to a node, then returns the node name for use in other functions
procedure RetrieveToClosestNode;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := 'hiya'; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
RetrieveToClosestNode;
end.

The program can now
A) Use the closest subpath to walk to a highway
B) Determine which node is closer based on its TPoint in the TPA path between two nodes
C) Walks to the closest node

To do:
- Add all the points now
- Test them (oh god this will suck)
- Find bugs
- Return a value when you're at a node
And the big one:
- Make it go in reverse!!


From: Coh3n
I think he means the point would be a tile, and the script would walk from the current players position to that point (no matter where it is on the map).

Ah now I get it. I will incorporate that… plus it'll be a neat challenge

Shuttleu

2010-09-05 20:12:20

i might start mine again… and try to make an aryans web

~shut

Cstrike

2010-09-06 13:02:02

This is the newest version designed to fit into MSI by meeting all the standards. All I have left to do is make all the nodes and test them out. Once it retrieves from mostly anywhere, then I completed my original task. The final task will be to make it walk to any TPoint given.

This is storage for my code in case my computer gets fried:
Note: If you run it, it won't do anything unless you add the code to the main loop. If you want to try it out from the wizards tower or lumby swamp (it does NOT blindwalk yet, so if it can't see the path it will probably fail), try RW_GoTo ('VWB');
program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
X_OFFSET = 0;
Y_OFFSET = 0;
// Node points
VARROCKWESTBANK_X = 3186 + X_OFFSET;
VARROCKWESTBANK_Y = 3439 + Y_OFFSET;
FALADOREASTBANK_X = 3013 + X_OFFSET;
FALADOREASTBANK_Y = 3356 + Y_OFFSET;
LUMBRIDGENE_X = 3217 + X_OFFSET;
LUMBRIDGENE_Y = 3251 + Y_OFFSET;
DRAYNORBANK_X = 3094 + X_OFFSET;
DRAYNORBANK_Y = 3242 + Y_OFFSET;
BARBVILLAGEC_X = 3081 + X_OFFSET;
BARBVILLAGEC_Y = 3416 + Y_OFFSET;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

{******************************************************************************}
{ procedure SetupNodesAndPaths; }
{ By: Cstrike }
{ Description: Sets up node points and all arrays for program to function. }
{******************************************************************************}
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (VARROCKWESTBANK_X, VARROCKWESTBANK_Y), // 0 Varrock west bank
Tile (FALADOREASTBANK_X, FALADOREASTBANK_Y), // 1 Fally east bank
Tile (LUMBRIDGENE_X, LUMBRIDGENE_Y), // 2 Lumby NE
Tile (DRAYNORBANK_X, DRAYNORBANK_Y), // 3 Draynor bank
Tile (BARBVILLAGEC_X, BARBVILLAGEC_Y)]; // 4 Barb village center (S of dungeon)

// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
LNE_VWB := [Point(3223, 3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (DRAYNORBANK_X, DRAYNORBANK_Y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];

// Highway
SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[1] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3223, 3237), // Lumby northeast to varrock west bank
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[2] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[3] :=[Point (DRAYNORBANK_X, DRAYNORBANK_Y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[4] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
//Streets
SetArrayLength (SubStreet, 3);
SubStreet[0] :=[Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
SubStreet[1] :=[Point(3133, 3227), Point(3136, 3218), Point(3138, 3208), // Follows western sea that arcs around the two lumby mines, and ends at the lumby mine with addy/mith at the SE corner [south of lumby]
Point(3141, 3203), Point(3141, 3193), Point(3144, 3184),
Point(3143, 3177), Point(3146, 3167), Point(3148, 3158),
Point(3151, 3149), Point(3159, 3147), Point(3168, 3150),
Point(3177, 3150), Point(3186, 3148), Point(3196, 3148),
Point(3202, 3152), Point(3212, 3151), Point(3222, 3150),
Point(3234, 3150)];
SubStreet[2] :=[Point(3133, 3227), Point(3137, 3218), Point(3143, 3213), // Goes from south of jail, to hook around the north of the swamp below lumbridge
Point(3148, 3206), Point(3154, 3202), Point(3161, 3197),
Point(3174, 3197), Point(3185, 3195), Point(3197, 3190),
Point(3202, 3185), Point(3212, 3184), Point(3219, 3176)];
end;

procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

{******************************************************************************}
{ procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray); }
{ By: Cstrike }
{ Description: Create TTileArray from TPA }
{******************************************************************************}
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

{******************************************************************************}
{ procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: A shofrter version of CreateTPADownFromFragment (below), may }
{ screw up occasionally, don't know why. Must debug this. }
{******************************************************************************}
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 16. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]) }
{******************************************************************************}
// If you have a TPA from 0 to 20, and want to create TPA#2 from TPA position TPA[7] to TPA[0], use this
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ function TMin (TIA : TIntegerArray) : Integer; }
{ By: Cstrike }
{ Description: Sets TIA[0] as the lowest number }
{******************************************************************************}
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

{******************************************************************************}
{ procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer); }
{ By: Cstrike }
{ Description: Searches an ATPA for a TPoint. Returns the ATPA index and the }
{ TPA index of where the TPoint is located }
{******************************************************************************}
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

{******************************************************************************}
{ function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean; }
{ By: Cstrike }
{ Description: Attemps to walk (blindly) towards the TPoint (or TTile, since }
{ the TPoint is converted). X increases as you go east, Y as you go north. }
{ Needs serious code fixing, but it works. WalkRadius is how many tiles it }
{ will walk in each increment. Shouldn't use a radius that is larger than }
{ the minimap. Should not use zero, try and keep it between 2 and 12. }
{******************************************************************************}
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
// opp : Integer;
xinc, yinc : Extended;
//walkPoint : TPoint;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

{******************************************************************************}
{ function SubPointDistances (ATPA : T2DPointArray) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to current position }
{******************************************************************************}
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos; // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
// Debug output to get a nice chart :)
for z:=0 to high(ATPA) do
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function AssignNodeLocation (maxTileRadius : integer) : String; }
{ By: Cstrike }
{ Description: Using reflection tiles, it will assess your current position }
{ and based on how large of a tile radius you input, it will return the three }
{ letter node you are at. If it doesn't work, it returns as an empty string }
{******************************************************************************}
function AssignNodeLocation (maxTileRadius : integer) : String;
var i : Integer;
currentTile : TTile;
location : String;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'VWB';
1: location := 'FEB';
2: location := 'LNE';
3: location := 'DRB';
4: location := 'BBC';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
writeln ('In node range = ('+location+')');
result := location;
end;

{******************************************************************************}
{ procedure procedure TravelToNode (startNode, endNode : string); }
{ By: Cstrike }
{ Description: Travels between nodes. Must use node names. Current names are: }
{ VWB = varrock west bank FEB = falador east bank BBC = barb village center }
{ (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast of }
{ the lumby castle. Use upper case for now }
{******************************************************************************}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

{******************************************************************************}
{ function RetrieveToClosestHighwayPoint : TPoint; }
{ By: Cstrike }
{ Description: Using the SubStreet ATPA, it will search for the closest TPoint }
{ and then it will walk that path until the last TPoint in the path. Returns }
{ the last TPoint in the path. This SHOULD be a TPoint on a highway or later }
{ parts of the script probably wont work unless you re-code it }
{ Ex: Takes you from your location through a substreet to SubStreet[i][0], }
{ which is a highway point (or should be). The A next to TPAPosA/ATPAPosA }
{ has no actual meaning, just a placeholder to be 'different'. Sorry. }
{******************************************************************************}
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

{******************************************************************************}
{ function RetrieveToClosestNode : String; }
{ By: Cstrike }
{ Description: Returns a string of the node you went to. It will return three }
{ lettered node in capitals. }
{ Ex: This procedure walks the closest street to a highway, then walks the }
{ highway to a node, then returns the node name for use in other functions }
{******************************************************************************}
function RetrieveToClosestNode : String;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
result := AssignNodeLocation (8);
writeln ('Result: '+result);
end;

{******************************************************************************}
{ procedure RW_GoTo (Location : string); }
{ By: Cstrike }
{ Description: Takes you from anywhere, to the location you want. Location you }
{ input should be 3 capital letters like VWB. Should only use defined nodes, }
{ don't try entering something like VEB unless in the future it is defined as }
{ a node to actually go to. Use FEB/VWB/BBC/LNE/DRB for now }
{******************************************************************************}
procedure RW_GoTo (Location : string);
var startNode : String;
begin
startNode := RetrieveToClosestNode;
TravelToNode (startNode, Location);
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := 'loli'; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
end.

HyperSecret

2010-09-06 13:12:57

From: cstrike
was there not some reflection code that could determine your height or what floor you're on? If so that'd be invaluable here.


I don't know if this was answered or not. But reflection has a GetPlane or something of the sort. Which will give you the level/floor you are on in a building.

Also isn't there a possible way to just walk like RSBot or iBot does?

WalkTo(Tile.x, Tile.y); and have it just create the path at runtime? I know there was the whole issue of making sure that the subpoints created were walkable. But I think making something of the such would be a lot more efficient.

Cstrike

2010-09-06 13:16:00

From: HyperSecret
I don't know if this was answered or not. But reflection has a GetPlane or something of the sort. Which will give you the level/floor you are on in a building.

Ah yes, I stumbled across it yesterday :D
http://villavu.com/forum/showthread.php?p=735169

Also isn't there a possible way to just walk like RSBot or iBot does?

WalkTo(Tile.x, Tile.y); and have it just create the path at runtime? I know there was the whole issue of making sure that the subpoints created were walkable. But I think making something of the such would be a lot more efficient.

Was the script actually able to make a path, or did it just walk in a straight line with increments? With the designed paths I've created, it should never fail with walking. I don't know how RSBot or iBot would be able to generate such efficient code allowing them to traverse from lumby swamps to the gem store in falador [for example] without running into some kind of problem.

Shuttleu

2010-09-06 13:44:14

From: HyperSecret
Also isn't there a possible way to just walk like RSBot or iBot does?

your talking about iBot, and that is Aryans web, which as i said, im going to try and make it sometime

~shut

HyperSecret

2010-09-06 14:31:17

From: Shuttleu
your talking about iBot, and that is Aryans web, which as i said, im going to try and make it sometime

~shut


Is there any source to that floating around anywhere?

Sir R. M8gic1an

2010-09-17 04:29:00

So how's this coming along? :)

~RM

Cstrike

2010-09-23 12:13:06

From: sir r. Magician
so how's this coming along? :)

~rm

I had the utter crap scared out of me. Since univ started I had to hand in my laptop and I've been using this second hand one for a while. I thought I lost all my additional work on the script! :O
Luckily I didn't, this is how far I've gotten.

Sadly this was a backup since stupid me copied only the backup, but there has been some progress. Not too much since univ. slapped me in the face with all the work (as you may have noticed between the time you posted and the time I last posted ;), but that stuff is out of the way and it's smooth sailing for me with lots of time on my hands.
I apologize for the delay, my plan is to finish

1) WalkTo (TP : TPoint)
Finish this today or tomorrow
2) Finish all the retrieve paths (or walking paths) by making them with Sumillions world map thing
This sucks and takes tons of time, plus is tedious :(

Heres the most updated code

program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
X_OFFSET = 0;
Y_OFFSET = 0;
// Node points
VARROCKWESTBANK_X = 3186 + X_OFFSET;
VARROCKWESTBANK_Y = 3439 + Y_OFFSET;
FALADOREASTBANK_X = 3013 + X_OFFSET;
FALADOREASTBANK_Y = 3356 + Y_OFFSET;
LUMBRIDGENE_X = 3217 + X_OFFSET;
LUMBRIDGENE_Y = 3251 + Y_OFFSET;
DRAYNORBANK_X = 3094 + X_OFFSET;
DRAYNORBANK_Y = 3242 + Y_OFFSET;
BARBVILLAGEC_X = 3081 + X_OFFSET;
BARBVILLAGEC_Y = 3416 + Y_OFFSET;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

{******************************************************************************}
{ procedure SetupNodesAndPaths; }
{ By: Cstrike }
{ Description: Sets up node points and all arrays for program to function. }
{******************************************************************************}
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (VARROCKWESTBANK_X, VARROCKWESTBANK_Y), // 0 Varrock west bank
Tile (FALADOREASTBANK_X, FALADOREASTBANK_Y), // 1 Fally east bank
Tile (LUMBRIDGENE_X, LUMBRIDGENE_Y), // 2 Lumby NE
Tile (DRAYNORBANK_X, DRAYNORBANK_Y), // 3 Draynor bank
Tile (BARBVILLAGEC_X, BARBVILLAGEC_Y)]; // 4 Barb village center (S of dungeon)
// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
LNE_VWB := [Point (3223,3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (DRAYNORBANK_X, DRAYNORBANK_Y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
// Highway
SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[1] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), // Lumby northeast to varrock west bank (tiles[1..2] (note, not tiles[0]) were fucked up, check them)
Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[2] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[3] :=[Point (DRAYNORBANK_X, DRAYNORBANK_Y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[4] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
//Streets
SetArrayLength (SubStreet, 16);
// These paths are between the >60 west of draynor guarded gate, and lumbyNE node
SubStreet[0] := [Point(3094, 3242), Point(3100, 3244), Point(3105, 3247), // &#8730; Inside draynor village to draynor bank
Point(3104, 3257), Point(3102, 3262), Point(3092, 3259)];
SubStreet[1] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // &#8730; Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
SubStreet[2] := [Point(3133, 3227), Point(3136, 3218), Point(3138, 3208), // &#8730; Follows western sea that arcs around the two lumby mines, and ends at the lumby mine with addy/mith at the SE corner [south of lumby]
Point(3141, 3203), Point(3141, 3193), Point(3144, 3184),
Point(3143, 3177), Point(3146, 3167), Point(3148, 3158),
Point(3151, 3149), Point(3159, 3147), Point(3168, 3150),
Point(3177, 3150), Point(3186, 3148), Point(3196, 3148),
Point(3202, 3152), Point(3212, 3151), Point(3222, 3150),
Point(3234, 3150)];
SubStreet[3] := [Point(3133, 3227), Point(3137, 3218), Point(3143, 3213), // &#8730; Goes from south of jail, to hook around the north of the swamp below lumbridge
Point(3148, 3206), Point(3154, 3202), Point(3161, 3197),
Point(3174, 3197), Point(3185, 3195), Point(3197, 3190),
Point(3202, 3185), Point(3212, 3184), Point(3219, 3176)];
SubStreet[4] := [Point(3098, 3235), Point(3092, 3228), Point(3091, 3217), // South of draynor bank
Point(3101, 3211)];
SubStreet[5] := [Point(3072, 3276), Point(3074, 3287), Point(3072, 3297), // &#8730; Hooks north of the draynor market, and goes up to the west of draynor manor (without passing over the walls, and then hooks southeast slightly into the forest
Point(3072, 3307), Point(3076, 3314), Point(3078, 3323),
Point(3088, 3322), Point(3092, 3312)];
SubStreet[6] := [Point(3072, 3276), Point(3077, 3281), Point(3086, 3289), // &#8730; Goes east of the draynor/south fally gate >60 total guys, follows the path to the 4 way cross, goes up to draynor manor and hooks around the right side, ending on the bottom left of the draynor manor near some grey patch
Point(3094, 3291), Point(3102, 3294), Point(3109, 3297),
Point(3113, 3303), Point(3113, 3310), Point(3111, 3318),
Point(3111, 3327), Point(3110, 3339), Point(3109, 3346),
Point(3115, 3351), Point(3123, 3351), Point(3128, 3356),
Point(3128, 3364), Point(3125, 3373), Point(3116, 3376),
Point(3109, 3376), Point(3096, 3376), Point(3091, 3374),
Point(3087, 3365), Point(3087, 3357), Point(3086, 3348),
Point(3090, 3338)];
SubStreet[7] := [Point(3157, 3235), Point(3157, 3227), Point(3160, 3221), // South of ham in lumby-west, between two trees, really close to the water symbol
Point(3167, 3212), Point(3175, 3210)];
SubStreet[8] := [Point(3157, 3235), Point(3152, 3243), Point(3143, 3253), // Runs east of the jail up by the grains and continues up to the right of draynor mansion, stopping before this hole in the white wall east of the manor
Point(3135, 3262), Point(3134, 3275), Point(3134, 3288),
Point(3134, 3300), Point(3136, 3311), Point(3141, 3320),
Point(3145, 3329), Point(3147, 3333)];
SubStreet[9] := [Point(3176, 3245), Point(3172, 3252), Point(3164, 3257), //East around ham building, north in front of windmill/grain thing, and then a tile west of that as the last additional added tile
Point(3163, 3263), Point(3161, 3271), Point(3162, 3278),
Point(3163, 3287), Point(3166, 3293), Point(3167, 3301),
Point(3159, 3310)];
SubStreet[10] :=[Point(3176, 3245), Point(3180, 3232), Point(3182, 3226), // south past the right set of rare trees (west of farming patch) so the southwest side of the lumby castle (outside the walls), does not go under the castle
Point(3185, 3218), Point(3186, 3210), Point(3194, 3204),
Point(3198, 3200)];
SubStreet[11] :=[Point(3176, 3245), Point(3179, 3251), Point(3180, 3258), // east of HAM to the west side of the sheep shearer's farm place
Point(3181, 3267)];
SubStreet[12] :=[Point(3133, 3227), Point(3130, 3235), Point(3132, 3242), // runs up through the bottom of the jail and hooks around the north from the east, to the west
Point(3130, 3248), Point(3119, 3251)];
SubStreet[13] :=[Point(3133, 3227), Point(3139, 3223), Point(3143, 3217), // Walks south of that irritating wall that seperates lumby forest from lumby swamps, remember... walks south of the wall and retrieves to the brown path
Point(3146, 3211), Point(3153, 3209), Point(3160, 3203),
Point(3172, 3203), Point(3184, 3202), Point(3191, 3197),
Point(3199, 3194), Point(3208, 3194)];
SubStreet[14] :=[Point(3217, 3251), Point(3222, 3242), Point(3225, 3235), // Walk from lumbyNE node down the path through graveyard to just east of the mining spot with addy
Point(3231, 3230), Point(3236, 3225), Point(3237, 3216),
Point(3237, 3202), Point(3243, 3199), Point(3245, 3190),
Point(3243, 3180), Point(3239, 3169), Point(3241, 3159),
Point(3237, 3147)];
SubStreet[15] :=[Point(3217, 3251), Point(3221, 3243), Point(3224, 3235), // Goes from LNE node into lumby castle, and inside right to outside the cooks door/near south spiral ladder
Point(3232, 3227), Point(3234, 3218), Point(3225, 3216),
Point(3215, 3217), Point(3214, 3209), Point(3207, 3208)];
SubStreet[16] :=[Point(3217, 3257), Point(3217, 3265), Point(3215, 3274), // takes the first tile in the path that goes from LNE->VWB
Point(3210, 3278), Point(3197, 3278), Point(3190, 3285),
Point(3189, 3294), Point(3188, 3302), Point(3185, 3308),
Point(3177, 3313)];
// These paths are between 'east of lumby bridge(s) and varrock west bank

// These paths are between BBC and varrock west bank

// These paths are between falador east bank and BBC

// These paths are between fally and draynor >60 level guards
end;

// Output's the TPA for debug purposes
procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

{******************************************************************************}
{ procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray); }
{ By: Cstrike }
{ Description: Create TTileArray from TPA }
{******************************************************************************}
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

{******************************************************************************}
{ procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: A shofrter version of CreateTPADownFromFragment (below), may }
{ screw up occasionally, don't know why. Must debug this. }
{******************************************************************************}
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ function TMin (TIA : TIntegerArray) : Integer; }
{ By: Cstrike }
{ Description: Sets TIA[0] as the lowest number }
{******************************************************************************}
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

{******************************************************************************}
{ procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer); }
{ By: Cstrike }
{ Description: Searches an ATPA for a TPoint. Returns the ATPA index and the }
{ TPA index of where the TPoint is located. Only returns one position, which }
{ is the last one it will find }
{******************************************************************************}
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

{******************************************************************************}
{ function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean; }
{ By: Cstrike }
{ Description: Attemps to walk (blindly) towards the TPoint (or TTile, since }
{ the TPoint is converted). X increases as you go east, Y as you go north. }
{ Needs serious code fixing, but it works. WalkRadius is how many tiles it }
{ will walk in each increment. Shouldn't use a radius that is larger than }
{ the minimap. Should not use zero, try and keep it between 2 and 12. }
{******************************************************************************}
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
xinc, yinc : Extended;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

{******************************************************************************}
{ function SubPointDistances (ATPA : T2DPointArray) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to current position }
{******************************************************************************}
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos; // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function SubPointDistancesTP (ATPA : T2DPointArray, TP : TPoint) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to a TP you input }
{******************************************************************************}
function SubPointDistancesTP (ATPA : T2DPointArray; TP : TPoint) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := PointToTile(TP); // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function AssignNodeLocation (maxTileRadius : integer) : String; }
{ By: Cstrike }
{ Description: Using reflection tiles, it will assess your current position }
{ and based on how large of a tile radius you input, it will return the three }
{ letter node you are at. If it doesn't work, it returns as an empty string }
{******************************************************************************}
function AssignNodeLocation (maxTileRadius : integer) : String;
var i : Integer;
currentTile : TTile;
location : String;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'VWB';
1: location := 'FEB';
2: location := 'LNE';
3: location := 'DRB';
4: location := 'BBC';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
writeln ('In node range = ('+location+')');
result := location;
end;

{******************************************************************************}
{ procedure procedure TravelToNode (startNode, endNode : string); }
{ By: Cstrike }
{ Description: Travels between nodes. Must use node names. Current names are: }
{ VWB = varrock west bank FEB = falador east bank BBC = barb village center }
{ (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast of }
{ the lumby castle. Use upper case for now }
{******************************************************************************}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

{******************************************************************************}
{ function RetrieveToClosestHighwayPoint : TPoint; }
{ By: Cstrike }
{ Description: Using the SubStreet ATPA, it will search for the closest TPoint }
{ and then it will walk that path until the last TPoint in the path. Returns }
{ the last TPoint in the path. This SHOULD be a TPoint on a highway or later }
{ parts of the script probably wont work unless you re-code it }
{ Ex: Takes you from your location through a substreet to SubStreet[i][0], }
{ which is a highway point (or should be). The A next to TPAPosA/ATPAPosA }
{ has no actual meaning, just a placeholder to be 'different'. Sorry. }
{******************************************************************************}
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

{******************************************************************************}
{ function RetrieveToClosestNode : String; }
{ By: Cstrike }
{ Description: Returns a string of the node you went to. It will return three }
{ lettered node in capitals. }
{ Ex: This procedure walks the closest street to a highway, then walks the }
{ highway to a node, then returns the node name for use in other functions }
{******************************************************************************}
function RetrieveToClosestNode : String;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
result := AssignNodeLocation (8);
writeln ('Result: '+result);
end;

{******************************************************************************}
{ procedure RW_GoTo (Location : string); }
{ By: Cstrike }
{ Description: Takes you from anywhere, to the location you want. Location you }
{ input should be 3 capital letters like VWB. Should only use defined nodes, }
{ don't try entering something like VEB unless in the future it is defined as }
{ a node to actually go to. Use FEB/VWB/BBC/LNE/DRB for now }
{******************************************************************************}
procedure RW_GoTo (Location : string);
var startNode : String;
begin
if not LoggedIn then exit;
startNode := RetrieveToClosestNode;
if (startNode = Location) then writeln ('Already at '+Location) // This prevents TravelToNode from attempting to walk with 0 TTiles (which crashes the script)
else TravelToNode (startNode, Location);
end;

{******************************************************************************}
{ procedure function WalkTo (TP : TPoint) : Boolean; }
{ By: Cstrike }
{ Description: Will take you from your location to Tile(TP.x,TP.y). Probably }
{ will not work if you're somewhere far away with no node path [ex: wildy] }
{******************************************************************************}
function WalkTo (TP : TPoint) : Boolean;
var highwayTP : TPoint;
ATPAPosH, TPAPosH, highTPA : Integer;
TPA : TPointArray;
TTA : TTileArray;
begin
if not LoggedIn then exit;
highwayTP := SubPointDistancesTP (Highway, TP);
if (Distance(TP.x, TP.y, highwayTP.x, highwayTP.y)<10) then // If distance less than 10 (aka, it's safely on the minimap), then lets just walk from the highway point to our TPoint, instead of trying to follow some SubStreet that will just take longer
begin
writeln ('TP is at least 9 distance tiles from the highway');
FindTPInATPA (highwayTP, Highway, ATPAPosH, TPAPosH); // Find where our highway TP is in the Highway ATPA
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA); // Debug output
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
// WalkToTile (TP) here
end;
{
Else,
Find closest point in ATPA.TPA
Find root number to determine what highway# it is
Determine path to closest node
Return closest node NAME
Generate path to Highway[i], then substreet[j]
Walk to node NAME
walk generated path
if tile TP not on MM then blindwalk
}
end;

// Forget me for now
procedure DeclarePlayers;
begin
end;


procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
//RW_GoTo ('DRB');
end.

Here are the working paths :D (~15-20% completed)



Making the paths for varrock will TRULY suck balls. That will be hours and hours and oodles of hours of work :(
But what must be done, shall be done!!!

nickrules

2010-09-24 19:17:37

Nice work. Yes, everytime MSI updated using this updater timer made, it cleared my magic.scar
Luckly for me, it seems any time i make a change worth noting, i post the entire include in the first post. extremely helpful.

Overtime

2010-09-24 22:12:55

WOW Cstrike.
That is Amazing work! I can't wait to see this completely finished.
It looks absolutely beautiful :D

Cstrike

2010-09-24 22:14:04

From: squancy
WOW Cstrike.
That is Amazing work! I can't wait to see this completely finished.
It looks absolutely beautiful :D


I'm almost there! Just finishing the last parts and its done (MINUS the paths :()
The paths will take a considerable amount of time, the last bit of code to make it fully operational without the paths is almost complete :)


EDIT: UPDATE
Code ALMOST complete. The pre-alpha is about 90% done.
program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
X_OFFSET = 0;
Y_OFFSET = 0;
// Node points
VARROCKWESTBANK_X = 3186 + X_OFFSET;
VARROCKWESTBANK_Y = 3439 + Y_OFFSET;
FALADOREASTBANK_X = 3013 + X_OFFSET;
FALADOREASTBANK_Y = 3356 + Y_OFFSET;
LUMBRIDGENE_X = 3217 + X_OFFSET;
LUMBRIDGENE_Y = 3251 + Y_OFFSET;
DRAYNORBANK_X = 3094 + X_OFFSET;
DRAYNORBANK_Y = 3242 + Y_OFFSET;
BARBVILLAGEC_X = 3081 + X_OFFSET;
BARBVILLAGEC_Y = 3416 + Y_OFFSET;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

{******************************************************************************}
{ procedure SetupNodesAndPaths; }
{ By: Cstrike }
{ Description: Sets up node points and all arrays for program to function. }
{******************************************************************************}
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (VARROCKWESTBANK_X, VARROCKWESTBANK_Y), // 0 Varrock west bank
Tile (FALADOREASTBANK_X, FALADOREASTBANK_Y), // 1 Fally east bank
Tile (LUMBRIDGENE_X, LUMBRIDGENE_Y), // 2 Lumby NE
Tile (DRAYNORBANK_X, DRAYNORBANK_Y), // 3 Draynor bank
Tile (BARBVILLAGEC_X, BARBVILLAGEC_Y)]; // 4 Barb village center (S of dungeon)
// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
LNE_VWB := [Point (3223,3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (DRAYNORBANK_X, DRAYNORBANK_Y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
// Highway
SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[1] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), // Lumby northeast to varrock west bank (tiles[1..2] (note, not tiles[0]) were fucked up, check them)
Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[2] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[3] :=[Point (DRAYNORBANK_X, DRAYNORBANK_Y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[4] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
//Streets
SetArrayLength (SubStreet, 17);
// These paths are between the >60 west of draynor guarded gate, and lumbyNE node
SubStreet[0] := [Point(3094, 3242), Point(3100, 3244), Point(3105, 3247), // &#8730; Inside draynor village to draynor bank
Point(3104, 3257), Point(3102, 3262), Point(3092, 3259)];
SubStreet[1] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // &#8730; Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
SubStreet[2] := [Point(3133, 3227), Point(3136, 3218), Point(3138, 3208), // &#8730; Follows western sea that arcs around the two lumby mines, and ends at the lumby mine with addy/mith at the SE corner [south of lumby]
Point(3141, 3203), Point(3141, 3193), Point(3144, 3184),
Point(3143, 3177), Point(3146, 3167), Point(3148, 3158),
Point(3151, 3149), Point(3159, 3147), Point(3168, 3150),
Point(3177, 3150), Point(3186, 3148), Point(3196, 3148),
Point(3202, 3152), Point(3212, 3151), Point(3222, 3150),
Point(3234, 3150)];
SubStreet[3] := [Point(3133, 3227), Point(3137, 3218), Point(3143, 3213), // &#8730; Goes from south of jail, to hook around the north of the swamp below lumbridge
Point(3148, 3206), Point(3154, 3202), Point(3161, 3197),
Point(3174, 3197), Point(3185, 3195), Point(3197, 3190),
Point(3202, 3185), Point(3212, 3184), Point(3219, 3176)];
SubStreet[4] := [Point(3098, 3235), Point(3092, 3228), Point(3091, 3217), // South of draynor bank
Point(3101, 3211)];
SubStreet[5] := [Point(3072, 3276), Point(3074, 3287), Point(3072, 3297), // &#8730; Hooks north of the draynor market, and goes up to the west of draynor manor (without passing over the walls, and then hooks southeast slightly into the forest
Point(3072, 3307), Point(3076, 3314), Point(3078, 3323),
Point(3088, 3322), Point(3092, 3312)];
SubStreet[6] := [Point(3072, 3276), Point(3077, 3281), Point(3086, 3289), // &#8730; Goes east of the draynor/south fally gate >60 total guys, follows the path to the 4 way cross, goes up to draynor manor and hooks around the right side, ending on the bottom left of the draynor manor near some grey patch
Point(3094, 3291), Point(3102, 3294), Point(3109, 3297),
Point(3113, 3303), Point(3113, 3310), Point(3111, 3318),
Point(3111, 3327), Point(3110, 3339), Point(3109, 3346),
Point(3115, 3351), Point(3123, 3351), Point(3128, 3356),
Point(3128, 3364), Point(3125, 3373), Point(3116, 3376),
Point(3109, 3376), Point(3096, 3376), Point(3091, 3374),
Point(3087, 3365), Point(3087, 3357), Point(3086, 3348),
Point(3090, 3338)];
SubStreet[7] := [Point(3157, 3235), Point(3157, 3227), Point(3160, 3221), // South of ham in lumby-west, between two trees, really close to the water symbol
Point(3167, 3212), Point(3175, 3210)];
SubStreet[8] := [Point(3157, 3235), Point(3152, 3243), Point(3143, 3253), // Runs east of the jail up by the grains and continues up to the right of draynor mansion, stopping before this hole in the white wall east of the manor
Point(3135, 3262), Point(3134, 3275), Point(3134, 3288),
Point(3134, 3300), Point(3136, 3311), Point(3141, 3320),
Point(3145, 3329), Point(3147, 3333)];
SubStreet[9] := [Point(3176, 3245), Point(3172, 3252), Point(3164, 3257), //East around ham building, north in front of windmill/grain thing, and then a tile west of that as the last additional added tile
Point(3163, 3263), Point(3161, 3271), Point(3162, 3278),
Point(3163, 3287), Point(3166, 3293), Point(3167, 3301),
Point(3159, 3310)];
SubStreet[10] :=[Point(3176, 3245), Point(3180, 3232), Point(3182, 3226), // south past the right set of rare trees (west of farming patch) so the southwest side of the lumby castle (outside the walls), does not go under the castle
Point(3185, 3218), Point(3186, 3210), Point(3194, 3204),
Point(3198, 3200)];
SubStreet[11] :=[Point(3176, 3245), Point(3179, 3251), Point(3180, 3258), // east of HAM to the west side of the sheep shearer's farm place
Point(3181, 3267)];
SubStreet[12] :=[Point(3133, 3227), Point(3130, 3235), Point(3132, 3242), // runs up through the bottom of the jail and hooks around the north from the east, to the west
Point(3130, 3248), Point(3119, 3251)];
SubStreet[13] :=[Point(3133, 3227), Point(3139, 3223), Point(3143, 3217), // Walks south of that irritating wall that seperates lumby forest from lumby swamps, remember... walks south of the wall and retrieves to the brown path
Point(3146, 3211), Point(3153, 3209), Point(3160, 3203),
Point(3172, 3203), Point(3184, 3202), Point(3191, 3197),
Point(3199, 3194), Point(3208, 3194)];
SubStreet[14] :=[Point(3217, 3251), Point(3222, 3242), Point(3225, 3235), // Walk from lumbyNE node down the path through graveyard to just east of the mining spot with addy
Point(3231, 3230), Point(3236, 3225), Point(3237, 3216),
Point(3237, 3202), Point(3243, 3199), Point(3245, 3190),
Point(3243, 3180), Point(3239, 3169), Point(3241, 3159),
Point(3237, 3147)];
SubStreet[15] :=[Point(3217, 3251), Point(3221, 3243), Point(3224, 3235), // Goes from LNE node into lumby castle, and inside right to outside the cooks door/near south spiral ladder
Point(3232, 3227), Point(3234, 3218), Point(3225, 3216),
Point(3215, 3217), Point(3214, 3209), Point(3207, 3208)];
SubStreet[16] :=[Point(3217, 3257), Point(3217, 3265), Point(3215, 3274), // takes the first tile in the path that goes from LNE->VWB
Point(3210, 3278), Point(3197, 3278), Point(3190, 3285),
Point(3189, 3294), Point(3188, 3302), Point(3185, 3308),
Point(3177, 3313)];
// These paths are between 'east of lumby bridge(s) and varrock west bank

// These paths are between BBC and varrock west bank

// These paths are between falador east bank and BBC

// These paths are between fally and draynor >60 level guards
end;

// Output's the TPA for debug purposes
procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;

// Output's the TTA for debug purposes
procedure DebugTheTTA (TTA : TTileArray);
var i : Integer;
begin
writeln ('TTA debug:');
for i:=0 to high(TTA) do
begin
writeln ('['+inttostr(i)+']: Tile ('+inttostr(TTA[i].x)+','+inttostr(TTA[i].y)+')');
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

{******************************************************************************}
{ procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray); }
{ By: Cstrike }
{ Description: Create TTileArray from TPA }
{******************************************************************************}
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

{******************************************************************************}
{ procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: A shofrter version of CreateTPADownFromFragment (below), may }
{ screw up occasionally, don't know why. Must debug this. }
{******************************************************************************}
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{ It is considered "Invert" because at the end it inverts the TPA fragment }
{ which is useful for when you are using WalkTo. When you are retrieving }
{ to a bank, you don't need to invert because it will always have the end }
{ tile as being the bank node, but if you try and use this while walking }
{ to a branch point (to branch off on a subpath to get near your TPoint), }
{ the other function will make it so that it will always make you return }
{ to a node point. Thus, invert makes you walk in the opposite direction }
{ from a node point to your branch-off-from-the-highway-point }
{******************************************************************************}
procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]). Inverts at the end (see CTPAUFFInvert for details) }
{******************************************************************************}
procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ function TMin (TIA : TIntegerArray) : Integer; }
{ By: Cstrike }
{ Description: Sets TIA[0] as the lowest number }
{******************************************************************************}
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

{******************************************************************************}
{ procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer); }
{ By: Cstrike }
{ Description: Searches an ATPA for a TPoint. Returns the ATPA index and the }
{ TPA index of where the TPoint is located. Only returns one position, which }
{ is the last one it will find }
{******************************************************************************}
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

{******************************************************************************}
{ function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean; }
{ By: Cstrike }
{ Description: Attemps to walk (blindly) towards the TPoint (or TTile, since }
{ the TPoint is converted). X increases as you go east, Y as you go north. }
{ Needs serious code fixing, but it works. WalkRadius is how many tiles it }
{ will walk in each increment. Shouldn't use a radius that is larger than }
{ the minimap. Should not use zero, try and keep it between 2 and 12. }
{******************************************************************************}
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
xinc, yinc : Extended;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

{******************************************************************************}
{ function SubPointDistances (ATPA : T2DPointArray) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to current position }
{******************************************************************************}
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos; // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function SubPointDistancesTP (ATPA : T2DPointArray, TP : TPoint) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to a TP you input }
{******************************************************************************}
function SubPointDistancesTP (ATPA : T2DPointArray; TP : TPoint) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := PointToTile(TP); // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
writeln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function AssignNodeLocation (maxTileRadius : integer) : String; }
{ By: Cstrike }
{ Description: Using reflection tiles, it will assess your current position }
{ and based on how large of a tile radius you input, it will return the three }
{ letter node you are at. If it doesn't work, it returns as an empty string }
{******************************************************************************}
function AssignNodeLocation (maxTileRadius : integer) : String;
var i : Integer;
currentTile : TTile;
location : String;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'VWB';
1: location := 'FEB';
2: location := 'LNE';
3: location := 'DRB';
4: location := 'BBC';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
writeln ('In node range = ('+location+')');
result := location;
end;

{******************************************************************************}
{ procedure procedure TravelToNode (startNode, endNode : string); }
{ By: Cstrike }
{ Description: Travels between nodes. Must use node names. Current names are: }
{ VWB = varrock west bank FEB = falador east bank BBC = barb village center }
{ (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast of }
{ the lumby castle. Use upper case for now }
{******************************************************************************}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

{******************************************************************************}
{ function RetrieveToClosestHighwayPoint : TPoint; }
{ By: Cstrike }
{ Description: Using the SubStreet ATPA, it will search for the closest TPoint }
{ and then it will walk that path until the last TPoint in the path. Returns }
{ the last TPoint in the path. This SHOULD be a TPoint on a highway or later }
{ parts of the script probably wont work unless you re-code it }
{ Ex: Takes you from your location through a substreet to SubStreet[i][0], }
{ which is a highway point (or should be). The A next to TPAPosA/ATPAPosA }
{ has no actual meaning, just a placeholder to be 'different'. Sorry. }
{******************************************************************************}
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

{******************************************************************************}
{ function RetrieveToClosestNode : String; }
{ By: Cstrike }
{ Description: Returns a string of the node you went to. It will return three }
{ lettered node in capitals. }
{ Ex: This procedure walks the closest street to a highway, then walks the }
{ highway to a node, then returns the node name for use in other functions }
{******************************************************************************}
function RetrieveToClosestNode : String;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
result := AssignNodeLocation (8);
writeln ('Result: '+result);
end;

{******************************************************************************}
{ function DetermineNodeName (TP : TPoint) : String }
{ By: Cstrike }
{ Description: Checks node TP's with inputted TP and returns node name. If no }
{ node is found, returns ''. }
{******************************************************************************}
function DetermineNodeName (TP : TPoint) : String;
begin
if not LoggedIn then exit;
writeln ('DetermineNodeNameFunction: Point("'+inttostr(TP.x)+ '" to "'+inttostr(TP.y)+'")');
result := '';
case TP of
Point((3186 + X_OFFSET),(3439 + Y_OFFSET)): result := 'VWB';
Point((3013 + X_OFFSET),(3356 + Y_OFFSET)): result := 'FEB';
Point((3217 + X_OFFSET),(3251 + Y_OFFSET)): result := 'LNE';
Point((3094 + X_OFFSET),(3242 + Y_OFFSET)): result := 'DRB';
Point((3081 + X_OFFSET),(3416 + Y_OFFSET)): result := 'BBC';
end;
end;

procedure KEY_FUNCTIONS_BELOW (); //Placeholder, ignore me
begin
end;

{******************************************************************************}
{ procedure GoToNodeFromAnywhere (Location : string); }
{ By: Cstrike }
{ Description: Takes you from anywhere, to the location you want. Location you }
{ input should be 3 capital letters like VWB. Should only use defined nodes, }
{ don't try entering something like VEB unless in the future it is defined as }
{ a node to actually go to. Use FEB/VWB/BBC/LNE/DRB for now }
{******************************************************************************}
procedure GoToNodeFromAnywhere (Location : string);
var startNode : String;
begin
if not LoggedIn then exit;
startNode := RetrieveToClosestNode;
if (startNode = Location) then writeln ('Already at '+Location) // This prevents TravelToNode from attempting to walk with 0 TTiles (which crashes the script)
else TravelToNode (startNode, Location);
end;

{******************************************************************************}
{ procedure function WalkTo (TP : TPoint) : Boolean; }
{ By: Cstrike }
{ Description: Will take you from your location to Tile(TP.x,TP.y). Probably }
{ will not work if you're somewhere far away with no node path [ex: wildy]. }
{ Returns true if you reach TP. }
{******************************************************************************}
function WalkTo (TP : TPoint) : Boolean;
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPos, TPAPos, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
if not LoggedIn then exit;
highwayTP := SubPointDistancesTP (Highway, TP);
substreetTP := SubPointDistancesTP (SubStreet, TP);
if (Distance(TP.x, TP.y, highwayTP.x, highwayTP.y)<10) then // If distance less than 10 (aka, it's safely on the minimap), then lets just walk from the highway point to our TPoint, instead of trying to follow some SubStreet that will just take longer
begin
writeln ('TP is at least 9 distance tiles from the highway');
FindTPInATPA (highwayTP, Highway, ATPAPos, TPAPos); // Find where our highway TP is in the Highway ATPA
highTPA := high(Highway[ATPAPos]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPos >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end;
DebugTheTPA (TPA); // Debug output
AddTPAToTTA (TPA, TTA);
DebugTheTTA (TTA); // Debug
WalkPath (TTA);
TileToWalkTo := PointToTile (TP); // WalkToTile (TP) here
if TileOnMM (TileToWalkTo) then
begin
writeln ('Desired tile on minimap, attempting to walk to it');
WalkToTile (TileToWalkTo, 1, 0);
end else
begin
writeln ('Desired tile NOT on minimap, attempting to blindwalk to it');
FindPathToTile (TP, 9); // Change walk radius of 9 if you think its too much
end;
CurrentTile := GetMyPos;
result := true;
if ((currentTile.x - TP.x) < 4) or ((currentTile.x - TP.x) > -4) or ((currentTile.y - TP.y) < 4) or ((currentTile.y - TP.y) > -4) then
begin
writeln ('We are greater than 4 tiles away from desired point('+inttostr(TP.x)+','+inttostr(TP.y)+')');
result := false;
end;
end else // If the point is not within ~9 tile radius of a highway (meaning were going to have to do some travelling...) do this:
begin
//Determine which path to use (highway is closer? or are one of the substreets closer?)
useSubstreet := true; // Will be changed by next line of code
if (Distance(TP.x, TP.y, highwayTP.x, highwayTP.y)) <= (Distance(TP.x, TP.y, substreetTP.x, substreetTP.y)) then useSubstreet := false;
if useSubstreet then
begin
writeln ('DEBUG of USESUBSTREET');
//Find closest point in ATPA.TPA
closestTP := SubPointDistancesTP(SubStreet, TP);
//Determine what index it is
FindTPInATPA (closestTP, SubStreet, ATPAPos, TPAPos);
writeln ('ATPAPos = '+inttostr(ATPAPos));
writeln ('TPAPos = '+inttostr(TPAPos));
//Find what highway it connects to
rootSubstreetTP := SubStreet[ATPAPos][0];
FindTPInATPA (rootSubstreetTP, Highway, ATPAPosH, TPAPosH); // Finds what highway index were looking for, and what point to walk from
//Determine closest node and return 3 letter node name
highTPAHighway := high(Highway[ATPAPos]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPos >= (highTPAHighway/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, search highest TPA point for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+']['+inttostr(highTPAHighway)+']');
nodeName := DetermineNodeName (Highway[ATPAPosH][highTPAHighway]);
writeln ('Node name determined that is closest: '+nodeName);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, search TPA[0] for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+'][0]');
nodeName := DetermineNodeName (Highway[ATPAPosH][0]);
writeln ('Node name determined that is closest: '+nodeName);
end;
//Generate path to Highway[i], then substreet[j]

//Retrieve to node
if nodeName = '' then
begin
writeln ('Warning, node name blank, exiting procedure');
result := false;
Exit;
end else GoToNodeFromAnywhere (nodeName); // This is what it SHOULD do if there is no error
//walk generated path

//if tile TP not on MM then blindwalk
FindPathToTile (TP, 6);
end else
begin
//Find closest point in ATPA.TPA
closestTP := SubPointDistancesTP(Highway, TP);
//Find root number to determine what highway# it is

//Determine path to closest node

//Return closest node NAME

//Generate path to Highway[i], then substreet[j]

//Walk to node NAME

//walk generated path

end;

end;
end;

procedure SCRIPT_RUNNING_STUFF (); //Placeholder, ignore me
begin
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := 'asdi'; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

var myCTile : TTile;
begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
//TravelToNode ('VWB','DRB');
//WalkTo (Point(3097,3226));
repeat
myCTile := GetMyPos;
wait (1000);
writeln ('('+inttostr(myCTile.x)+','+inttostr(myCTile.y)+')');
until (false)
end.

Note, the WalkTo procedure needs to still be completed, I'm just taking a rest after almost completing the final part. I will complete everything tomorrow.

nickrules

2010-09-26 08:54:24

So I was sitting here, reading through the MSI boards, and it occured to me, that this could be a great army mover, if start and end locations are in the DeclarePlayers. It would take minimal effort to implement, and would allow multi-player.
Also, if this were to be added to msi, it would need to be setup like that anyways….

Sir R. M8gic1an

2010-09-26 09:48:02

From: nickrules
So I was sitting here, reading through the MSI boards, and it occured to me, that this could be a great army mover, if start and end locations are in the DeclarePlayers. It would take minimal effort to implement, and would allow multi-player.
Also, if this were to be added to msi, it would need to be setup like that anyways….


Agreed!

~RM

Cstrike

2010-09-26 10:17:50

I'm going to finish the script for MSI today (but not all the paths), since I want to get MSI army moving/testing multiple scripts going

In addition… I was wondering about a new option.

It would go like this
WalkToLumbTele (TP : TPoint) : Boolean
This would (if lost, lets say WalkTo returned false) log out for 10 minutes to ensure it can lumbridge teleport, then teleport and walk to wherever. Good for randoms?
 if not WalkTo(TP) then
begin
writeln ('Had trouble walking');
if not WalkToLumbTele(TP, true) then
begin
result := false; // For whatever
NextPlayer(false)
writeln ('Failed being found');
end;
end;

Sir R. M8gic1an

2010-09-26 10:54:47

You can click the spell how much time there is left.

We can even add to the player record when they can next teleport to lumby, meaning we can do something like this:


if Players.Loc = LOC_LOST then
if Players.NextTele > GetSystemTime then
NextPlayer(true)
else
Teleport(Loc_Lumby);

~RM

Cstrike

2010-09-28 23:03:11

Good news:
My script can now go both ways (to and from any point!) :D

Bad news:
For some reason, it keeps retrieving to the wrong node now which means the minimap WalkPath isn't on the map.

I'm trying to fix this ASAP. As soon as it is working, I will post the final pre-pre-alpha code :)
Shouldn't be too long of a fix, but I am going to tidy up the code. I accidentally let it get a bit messy…

Update:
On top of not feeling well (coming down with something) real life just dumped more work on me which will have to wait. God damn real life keeps postponing my release D:!!

Update 2: ALMOST FINISHED :D
The core is working!!!!!
All that is left is for me to add the sub paths and it should be fully operational. I've attached paths, try it out. I warn you, it may screw up. So far it's worked for all the paths that are near the yellow ones. Expect massive debug output.
REMEMBER: The code is very rough!!! It has not been totally optimized. I will get to that one it is fully operational.

program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
X_OFFSET = 0;
Y_OFFSET = 0;
// Node points
VARROCKWESTBANK_X = 3186 + X_OFFSET;
VARROCKWESTBANK_Y = 3439 + Y_OFFSET;
FALADOREASTBANK_X = 3013 + X_OFFSET;
FALADOREASTBANK_Y = 3356 + Y_OFFSET;
LUMBRIDGENE_X = 3217 + X_OFFSET;
LUMBRIDGENE_Y = 3251 + Y_OFFSET;
DRAYNORBANK_X = 3094 + X_OFFSET;
DRAYNORBANK_Y = 3242 + Y_OFFSET;
BARBVILLAGEC_X = 3081 + X_OFFSET;
BARBVILLAGEC_Y = 3416 + Y_OFFSET;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

{******************************************************************************}
{ procedure SetupNodesAndPaths; }
{ By: Cstrike }
{ Description: Sets up node points and all arrays for program to function. }
{******************************************************************************}
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (VARROCKWESTBANK_X, VARROCKWESTBANK_Y), // 0 Varrock west bank
Tile (FALADOREASTBANK_X, FALADOREASTBANK_Y), // 1 Fally east bank
Tile (LUMBRIDGENE_X, LUMBRIDGENE_Y), // 2 Lumby NE
Tile (DRAYNORBANK_X, DRAYNORBANK_Y), // 3 Draynor bank
Tile (BARBVILLAGEC_X, BARBVILLAGEC_Y)]; // 4 Barb village center (S of dungeon)
// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
LNE_VWB := [Point (3223,3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (DRAYNORBANK_X, DRAYNORBANK_Y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
// Highway
SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[1] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), // Lumby northeast to varrock west bank (tiles[1..2] (note, not tiles[0]) were fucked up, check them)
Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[2] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[3] :=[Point (DRAYNORBANK_X, DRAYNORBANK_Y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[4] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
//Streets
SetArrayLength (SubStreet, 17);
// These paths are between the >60 west of draynor guarded gate, and lumbyNE node
SubStreet[0] := [Point(3094, 3242), Point(3100, 3244), Point(3105, 3247), // &#8730; Inside draynor village to draynor bank
Point(3104, 3257), Point(3102, 3262), Point(3092, 3259)];
SubStreet[1] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // &#8730; Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
SubStreet[2] := [Point(3133, 3227), Point(3136, 3218), Point(3138, 3208), // &#8730; Follows western sea that arcs around the two lumby mines, and ends at the lumby mine with addy/mith at the SE corner [south of lumby]
Point(3141, 3203), Point(3141, 3193), Point(3144, 3184),
Point(3143, 3177), Point(3146, 3167), Point(3148, 3158),
Point(3151, 3149), Point(3159, 3147), Point(3168, 3150),
Point(3177, 3150), Point(3186, 3148), Point(3196, 3148),
Point(3202, 3152), Point(3212, 3151), Point(3222, 3150),
Point(3234, 3150)];
SubStreet[3] := [Point(3133, 3227), Point(3137, 3218), Point(3143, 3213), // &#8730; Goes from south of jail, to hook around the north of the swamp below lumbridge
Point(3148, 3206), Point(3154, 3202), Point(3161, 3197),
Point(3174, 3197), Point(3185, 3195), Point(3197, 3190),
Point(3202, 3185), Point(3212, 3184), Point(3219, 3176)];
SubStreet[4] := [Point(3098, 3235), Point(3092, 3228), Point(3091, 3217), // South of draynor bank
Point(3101, 3211)];
SubStreet[5] := [Point(3072, 3276), Point(3074, 3287), Point(3072, 3297), // &#8730; Hooks north of the draynor market, and goes up to the west of draynor manor (without passing over the walls, and then hooks southeast slightly into the forest
Point(3072, 3307), Point(3076, 3314), Point(3078, 3323),
Point(3088, 3322), Point(3092, 3312)];
SubStreet[6] := [Point(3072, 3276), Point(3077, 3281), Point(3086, 3289), // &#8730; Goes east of the draynor/south fally gate >60 total guys, follows the path to the 4 way cross, goes up to draynor manor and hooks around the right side, ending on the bottom left of the draynor manor near some grey patch
Point(3094, 3291), Point(3102, 3294), Point(3109, 3297),
Point(3113, 3303), Point(3113, 3310), Point(3111, 3318),
Point(3111, 3327), Point(3110, 3339), Point(3109, 3346),
Point(3115, 3351), Point(3123, 3351), Point(3128, 3356),
Point(3128, 3364), Point(3125, 3373), Point(3116, 3376),
Point(3109, 3376), Point(3096, 3376), Point(3091, 3374),
Point(3087, 3365), Point(3087, 3357), Point(3086, 3348),
Point(3090, 3338)];
SubStreet[7] := [Point(3157, 3235), Point(3157, 3227), Point(3160, 3221), // South of ham in lumby-west, between two trees, really close to the water symbol
Point(3167, 3212), Point(3175, 3210)];
SubStreet[8] := [Point(3157, 3235), Point(3152, 3243), Point(3143, 3253), // Runs east of the jail up by the grains and continues up to the right of draynor mansion, stopping before this hole in the white wall east of the manor
Point(3135, 3262), Point(3134, 3275), Point(3134, 3288),
Point(3134, 3300), Point(3136, 3311), Point(3141, 3320),
Point(3145, 3329), Point(3147, 3333)];
SubStreet[9] := [Point(3176, 3245), Point(3172, 3252), Point(3164, 3257), //East around ham building, north in front of windmill/grain thing, and then a tile west of that as the last additional added tile
Point(3163, 3263), Point(3161, 3271), Point(3162, 3278),
Point(3163, 3287), Point(3166, 3293), Point(3167, 3301),
Point(3159, 3310)];
SubStreet[10] :=[Point(3176, 3245), Point(3180, 3232), Point(3182, 3226), // south past the right set of rare trees (west of farming patch) so the southwest side of the lumby castle (outside the walls), does not go under the castle
Point(3185, 3218), Point(3186, 3210), Point(3194, 3204),
Point(3198, 3200)];
SubStreet[11] :=[Point(3176, 3245), Point(3179, 3251), Point(3180, 3258), // east of HAM to the west side of the sheep shearer's farm place
Point(3181, 3267)];
SubStreet[12] :=[Point(3133, 3227), Point(3130, 3235), Point(3132, 3242), // runs up through the bottom of the jail and hooks around the north from the east, to the west
Point(3130, 3248), Point(3119, 3251)];
SubStreet[13] :=[Point(3133, 3227), Point(3139, 3223), Point(3143, 3217), // Walks south of that irritating wall that seperates lumby forest from lumby swamps, remember... walks south of the wall and retrieves to the brown path
Point(3146, 3211), Point(3153, 3209), Point(3160, 3203),
Point(3172, 3203), Point(3184, 3202), Point(3191, 3197),
Point(3199, 3194), Point(3208, 3194)];
SubStreet[14] :=[Point(3217, 3251), Point(3222, 3242), Point(3225, 3235), // Walk from lumbyNE node down the path through graveyard to just east of the mining spot with addy
Point(3231, 3230), Point(3236, 3225), Point(3237, 3216),
Point(3237, 3202), Point(3243, 3199), Point(3245, 3190),
Point(3243, 3180), Point(3239, 3169), Point(3241, 3159),
Point(3237, 3147)];
SubStreet[15] :=[Point(3217, 3251), Point(3221, 3243), Point(3224, 3235), // Goes from LNE node into lumby castle, and inside right to outside the cooks door/near south spiral ladder
Point(3232, 3227), Point(3234, 3218), Point(3225, 3216),
Point(3215, 3217), Point(3214, 3209), Point(3207, 3208)];
SubStreet[16] :=[Point(3217, 3257), Point(3217, 3265), Point(3215, 3274), // takes the first tile in the path that goes from LNE->VWB
Point(3210, 3278), Point(3197, 3278), Point(3190, 3285),
Point(3189, 3294), Point(3188, 3302), Point(3185, 3308),
Point(3177, 3313)];
// These paths are between 'east of lumby bridge(s) and varrock west bank

// These paths are between BBC and varrock west bank

// These paths are between falador east bank and BBC

// These paths are between fally and draynor >60 level guards
end;

// Output's the TPA for debug purposes
procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;

// Output's the TTA for debug purposes
procedure DebugTheTTA (TTA : TTileArray);
var i : Integer;
begin
writeln ('TTA debug:');
for i:=0 to high(TTA) do
begin
writeln ('['+inttostr(i)+']: Tile ('+inttostr(TTA[i].x)+','+inttostr(TTA[i].y)+')');
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('DEBUG_CURRENT_TILE: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

{******************************************************************************}
{ procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray); }
{ By: Cstrike }
{ Description: Create TTileArray from TPA }
{******************************************************************************}
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

{******************************************************************************}
{ procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: A shofrter version of CreateTPADownFromFragment (below), may }
{ screw up occasionally, don't know why. Must debug this. }
{******************************************************************************}
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{ It is considered "Invert" because at the end it inverts the TPA fragment }
{ which is useful for when you are using WalkTo. When you are retrieving }
{ to a bank, you don't need to invert because it will always have the end }
{ tile as being the bank node, but if you try and use this while walking }
{ to a branch point (to branch off on a subpath to get near your TPoint), }
{ the other function will make it so that it will always make you return }
{ to a node point. Thus, invert makes you walk in the opposite direction }
{ from a node point to your branch-off-from-the-highway-point }
{******************************************************************************}
procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]). Inverts at the end (see CTPAUFFInvert for details) }
{ (aka, does from 0 to 7 ;) ...) }
{******************************************************************************}
procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure RemoveTPFromTPA (TPA : TPointArray; Index : Integer); }
{ By: Cstrike }
{ Description: Removes TPA[Index] and truncates TPA that you input }
{******************************************************************************}
procedure RemoveTPFromTPA (TPAToRemoveFrom, ModifiedTPA : TPointArray; Index : Integer);
var i, j : Integer;
begin
j := 0;
if Index > High(TPAToRemoveFrom) then
begin
writeln ('Warning, index greater than what TPA has, setting new TPA to old TPA');
ModifiedTPA := TPAToRemoveFrom;
Exit;
end;
for i:=0 to high(TPAToRemoveFrom) do
begin
SetArrayLength (ModifiedTPA,high(TPAToRemoveFrom));
if i <> index then
begin
ModifiedTPA[j] := TPAToRemoveFrom[i];
writeln ('J = '+inttostr(j));
//DebugTheTPA (ModifiedTPA);
Inc(j);
end;
end;
writeln ('RemoveTPFromTPA result:');
DebugTheTPA (ModifiedTPA);
end;

{******************************************************************************}
{ function TMin (TIA : TIntegerArray) : Integer; }
{ By: Cstrike }
{ Description: Sets TIA[0] as the lowest number }
{******************************************************************************}
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

{******************************************************************************}
{ procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer); }
{ By: Cstrike }
{ Description: Searches an ATPA for a TPoint. Returns the ATPA index and the }
{ TPA index of where the TPoint is located. Only returns one position, which }
{ is the last one it will find }
{******************************************************************************}
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

{******************************************************************************}
{ function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean; }
{ By: Cstrike }
{ Description: Attemps to walk (blindly) towards the TPoint (or TTile, since }
{ the TPoint is converted). X increases as you go east, Y as you go north. }
{ Needs serious code fixing, but it works. WalkRadius is how many tiles it }
{ will walk in each increment. Shouldn't use a radius that is larger than }
{ the minimap. Should not use zero, try and keep it between 2 and 12. }
{******************************************************************************}
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
xinc, yinc : Extended;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

{******************************************************************************}
{ function SubPointDistances (ATPA : T2DPointArray) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to current position }
{******************************************************************************}
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos; // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
//DEBUGDEBUGwriteln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function SubPointDistancesTP (ATPA : T2DPointArray, TP : TPoint) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to a TP you input }
{******************************************************************************}
function SubPointDistancesTP (ATPA : T2DPointArray; TP : TPoint) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := PointToTile(TP); // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
//DEBUGDEBUGwriteln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function AssignNodeLocation (maxTileRadius : integer) : String; }
{ By: Cstrike }
{ Description: Using reflection tiles, it will assess your current position }
{ and based on how large of a tile radius you input, it will return the three }
{ letter node you are at. If it doesn't work, it returns as an empty string }
{******************************************************************************}
function AssignNodeLocation (maxTileRadius : integer) : String;
var i : Integer;
currentTile : TTile;
location : String;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'VWB';
1: location := 'FEB';
2: location := 'LNE';
3: location := 'DRB';
4: location := 'BBC';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
writeln ('In node range = ('+location+')');
result := location;
end;

{******************************************************************************}
{ procedure procedure TravelToNode (startNode, endNode : string); }
{ By: Cstrike }
{ Description: Travels between nodes. Must use node names. Current names are: }
{ VWB = varrock west bank FEB = falador east bank BBC = barb village center }
{ (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast of }
{ the lumby castle. Use upper case for now }
{******************************************************************************}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

{******************************************************************************}
{ function RetrieveToClosestHighwayPoint : TPoint; }
{ By: Cstrike }
{ Description: Using the SubStreet ATPA, it will search for the closest TPoint }
{ and then it will walk that path until the last TPoint in the path. Returns }
{ the last TPoint in the path. This SHOULD be a TPoint on a highway or later }
{ parts of the script probably wont work unless you re-code it }
{ Ex: Takes you from your location through a substreet to SubStreet[i][0], }
{ which is a highway point (or should be). The A next to TPAPosA/ATPAPosA }
{ has no actual meaning, just a placeholder to be 'different'. Sorry. }
{******************************************************************************}
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

{******************************************************************************}
{ function RetrieveToClosestNode : String; }
{ By: Cstrike }
{ Description: Returns a string of the node you went to. It will return three }
{ lettered node in capitals. }
{ Ex: This procedure walks the closest street to a highway, then walks the }
{ highway to a node, then returns the node name for use in other functions }
{******************************************************************************}
function RetrieveToClosestNode : String;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
result := AssignNodeLocation (8);
writeln ('Result: '+result);
end;

{******************************************************************************}
{ function DetermineNodeName (TP : TPoint) : String }
{ By: Cstrike }
{ Description: Checks node TP's with inputted TP and returns node name. If no }
{ node is found, returns ''. }
{******************************************************************************}
function DetermineNodeName (TP : TPoint) : String;
begin
if not LoggedIn then exit;
writeln ('DetermineNodeNameFunction: Point("'+inttostr(TP.x)+ '" to "'+inttostr(TP.y)+'")');
result := '';
case TP of
Point((VARROCKWESTBANK_X + X_OFFSET),(VARROCKWESTBANK_Y + Y_OFFSET)): result := 'VWB';
Point((FALADOREASTBANK_X + X_OFFSET),(FALADOREASTBANK_Y + Y_OFFSET)): result := 'FEB';
Point((LUMBRIDGENE_X + X_OFFSET),(LUMBRIDGENE_Y + Y_OFFSET)): result := 'LNE';
Point((DRAYNORBANK_X + X_OFFSET),(DRAYNORBANK_Y + Y_OFFSET)): result := 'DRB';
Point((BARBVILLAGEC_X + X_OFFSET),(BARBVILLAGEC_Y + Y_OFFSET)): result := 'BBC';
end;
end;

{******************************************************************************}
{ procedure GoToNodeFromAnywhere (Location : string); }
{ By: Cstrike }
{ Description: Takes you from anywhere, to the location you want. Location you }
{ input should be 3 capital letters like VWB. Should only use defined nodes, }
{ don't try entering something like VEB unless in the future it is defined as }
{ a node to actually go to. Use FEB/VWB/BBC/LNE/DRB for now }
{******************************************************************************}
procedure GoToNodeFromAnywhere (Location : string);
var startNode : String;
begin
if not LoggedIn then exit;
startNode := RetrieveToClosestNode;
if (startNode = Location) then writeln ('Already at '+Location) // This prevents TravelToNode from attempting to walk with 0 TTiles (which crashes the script)
else TravelToNode (startNode, Location);
end;

// If distance < 10 in WalkTo from highway or it's closest to a highway...
procedure RetrieveWalkCloseToHighway (TP, ClosestHighwayTP : TPoint);
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPos, TPAPos, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
FindTPInATPA (ClosestHighwayTP, Highway, ATPAPos, TPAPos); // Find where our closest highway TP (relative to our requested spot) is in the ATPA 'highway'
highTPA := high(Highway[ATPAPos]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPos >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment and invert');
CreateTPAUpFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment and invert');
CreateTPADownFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end;
DebugTheTPA (TPA); // Debug output
nodeName := DetermineNodeName (TPA[0]); // Our node SHOULD be at TPA[0], so find what node we should end up at
AddTPAToTTA (TPA, TTA);
DebugTheTTA (TTA); // Debug
// WALK TIME!!
GoToNodeFromAnywhere (nodeName); // First, go to closest node
WalkPath (TTA); // Now that were at the node, walk the path
wait (random(500)); // Now wait for safe measure ;)
TileToWalkTo := PointToTile (TP); // WalkToTile (TP) here
if TileOnMM (TileToWalkTo) then
begin
writeln ('Desired tile on minimap, attempting to walk to it');
WalkToTile (TileToWalkTo, 1, 0);
end else
begin
writeln ('Desired tile NOT on minimap, attempting to blindwalk to it');
FindPathToTile (TP, 9); // Change walk radius of 9 if you think its too much
end;
{
CurrentTile := GetMyPos;
result := true;
if ((currentTile.x - TP.x) < 4) or ((currentTile.x - TP.x) > -4) or ((currentTile.y - TP.y) < 4) or ((currentTile.y - TP.y) > -4) then
begin
writeln ('We are greater than 4 tiles away from desired point('+inttostr(TP.x)+','+inttostr(TP.y)+')');
result := false;
end else writeln ('At tile!!');
}
end;


// If highway >= 10 away from WalkTo and Substreet is a shorter distance than Highway
procedure RetrieveWalkCloseToSubstreet (TP, ClosestHighwayTP : TPoint);
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPosS, TPAPosS, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
if not LoggedIn then exit;
writeln ('**Beginning RetrieveWalkCloseToSubstreet');
closestTP := SubPointDistancesTP(SubStreet, TP); //Find closest point in ATPA.TPA
FindTPInATPA (closestTP, SubStreet, ATPAPosS, TPAPosS); //Determine what index it is, the S next to ATPAPos means 'S'ubstreet (since H is for 'H'ighway)
writeln ('WalkTo(Substreet) ATPAPos = '+inttostr(ATPAPosS)); writeln ('WalkTo(Substreet) TPAPos = '+inttostr(TPAPosS)); // DEBUG
rootSubstreetTP := SubStreet[ATPAPosS][0]; //Find what highway it connects to, since the SubStreet[ATPAPos][0] HAS to be a TPoint on the Highway ATPA
FindTPInATPA (rootSubstreetTP, Highway, ATPAPosH, TPAPosH); // Finds what highway index were looking for, and what point to walk from [The H next to ATPAPos/TPAPos is used for 'H'ighway, because ATPAPos is for the substreet)
highTPAHighway := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPASubstreet = '+inttostr(highTPA)); writeln ('highTPAHighway = '+inttostr(highTPAHighway)); // Debug
startFromIndexZero := false; // This is used when generating our big walk, whether to start from the top or bottom of the highway array, if true... starts from Highway[i][0]
writeln ('**Beginning HighwayNodeName determination');
if TPAPosH >= (highTPAHighway/2) then // Search if we branch off in the upper half of the highway, or the lower half of the highway
begin
writeln ('Greater than half, search highest TPA point for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+']['+inttostr(highTPAHighway)+']');
nodeName := DetermineNodeName (Highway[ATPAPosH][highTPAHighway]); // Search the top of the Highway[Index] array, since the top of the array will be a node position, and we are in the upper half of the array lets just go to the closest one ;)
writeln ('Node name determined that is closest: '+nodeName);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, search TPA[0] for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+'][0]');
nodeName := DetermineNodeName (Highway[ATPAPosH][0]);
writeln ('Node name determined that is closest: '+nodeName); // Same as the code slightly above ^^^ except were in lower half so check the bottom of the array
startFromIndexZero := true;
end;
writeln ('**Beginning FullWalkingPath creation: Create highway path');
if startFromIndexZero then // If we started getting the highway from Highway[ATPAPosH][0] then do this stuff
begin
writeln ('StartFromIndexZero = true');
CreateTPADownFromFragmentInvert (Highway, ATPAPosH, TPAPosH, FullWalkingPath); // Creates from position zero up to our desired HighwayPoint and stores it in FullWalkingPath
end else // Start from Highway[0][HighestIndex]
begin
writeln ('StartFromIndexZero = false');
CreateTPAUpFromFragmentInvert (Highway, ATPAPosH, TPAPosH, FullWalkingPath);
end; // We've done the highway, now below, create the subpath
writeln ('** Lets debug our FullWalkingPath TPA');
DebugTheTPA (FullWalkingPath);
//nodeName := DetermineNodeName (FullWalkingPath[0]); // Since our full walking path HAS to start at a node, logically if there were no errors... the very first point should be a node. This will tell us the node we have to be at! :)
writeln ('** Node name: '+nodeName+' -- determined from Point('+inttostr(FullWalkingPath[0].x)+','+inttostr(FullWalkingPath[0].y)+')');
writeln ('A_PosS = '+inttostr(ATPAPosS));
writeln ('T_PosS = '+inttostr(TPAPosS));
CreateTPADownFromFragmentInvert (SubStreet, ATPAPosS, TPAPosS, SubStreetDesiredPath); // Create a path from SubStreet[ATPAPos][0] [which we remove later since Highway[ATPAPosH][TPAPosH] = SubStreet[ATPAPos][0]
//RemoveTPFromTPA (SubStreetDesiredPathTemp, SubStreetDesiredPath, 0); // Remove position [0] since that is the root spot that connects to the highway. Since our highway code walks to the root point of the SubStreet, it would just click it twice, and we don't want that.
writeln ('** Debug substreetdesiredpath TPA');
DebugTheTPA (SubStreetDesiredPath);
FullWalkingPath := CombineTPA (FullWalkingPath, SubStreetDesiredPath);
writeln ('**TPAs combined, lets debug:');
DebugTheTPA (FullWalkingPath);
//Determine node we should be at before walking the above path
GoToNodeFromAnywhere (nodeName); // This is what it SHOULD do if there is no error. Will crash if string is '', must but FAIL-SAFE in here later FAILSAFE
writeln ('** GONE to starting node');
wait (random(500));
WalkPath (FullWalkingPath); //walk generated path
wait (random(500)); // Prevent random stupid errors I guess, maybe should use FFlag(0); or something
TileToWalkTo := PointToTile (TP); // Turn our point into a tile
if TileOnMM (TileToWalkTo) then WalkToTile (TileToWalkTo, 1, 0) // If tile's on the minimap, walk to it NEEDS FAILSAFE
else FindPathToTile (TP, 6); // Else, blindwalk because it's far
end;

{******************************************************************************}
{ procedure function WalkTo (TP : TPoint) : Boolean; }
{ By: Cstrike }
{ Description: Will take you from your location to Tile(TP.x,TP.y). Probably }
{ will not work if you're somewhere far away with no node path [ex: wildy]. }
{ Returns true if you reach TP. }
{******************************************************************************}
function WalkTo (TP : TPoint) : Boolean;
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPos, TPAPos, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
if not LoggedIn then exit;
highwayTP := SubPointDistancesTP (Highway, TP);
if Distance (TP.x, TP.y, highwayTP.x, highwayTP.y) < 10 then RetrieveWalkCloseToHighway (TP, highwayTP)
else // Else if distance greater than 10
begin
substreetTP := SubPointDistancesTP (SubStreet, TP);
if Distance (TP.x, TP.y, highwayTP.x, highwayTP.y) < Distance (TP.x, TP.y, substreetTP.x, substreetTP.y) then
begin
writeln ('Highway >= 10, and highway closer');
RetrieveWalkCloseToHighway (TP, highwayTP);
end else
begin
writeln ('Highway >= 10, and substreet closer');
RetrieveWalkCloseToSubstreet (TP, substreetTP);
end;
end;
DebugCurrentPos;
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := ''; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

//var myTPA, myTPAnew : TPointArray;
begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
WalkTo (Point(3194, 3203));
end.


This is how it works for anyone who wants to know in more detail:
Lets say we're in varrock bank and we tell it to go to a point south of draynor, this is how the script will run

** Note all major calculations are done before it starts walking. This takes literally only a few seconds.

1) Go to the closest node (Draynor bank/Varrock west bank/barb vil center/fally east bank/lumby northeast)

2) Figure out which node is closest to our point

3) Goes from current node to the closest node (if it's already there, it will move onto step #4 safely)

4) Charts the path on which is closer (highway, or a substreet) and then takes the desired path that is closest to our desired point
4b) If a substreet is closest, it goes from our node along the highway to a branch off point, then takes the branch-off point to the pre-calculated substreet path as close as it can to the requested TPoint

5) Blindwalks to TPoint if it's not on the minimap (uncommon)

And you're done!



EDIT: Here's a map of the paths if you like visuals (attached), sorry its 956 kb :( should have done JPG

Coh3n

2010-09-29 00:10:53

Looking awesome. :) Once it's up and running, you should add in Al Kaharid and Varrock East bank. :)

Cstrike

2010-09-29 11:36:06

From: Coh3n
Looking awesome. :) Once it's up and running, you should add in Al Kaharid and Varrock East bank. :)


Al Kharid will be the fun part ;)
I plan on just adding an extension where if you call a tile that is in the Al-Kharid zone, it will go to lumbridge, then cross the gate, go to the bank and then from there go to a key point.

Ok time for me to add all the subpath's now. Hopefully in less than 1 hour (when I find sumillions path maker) it should be hopefully ready to go for MSI

Shuttleu

2010-09-29 13:31:54

From: cstrike
Al Kharid will be the fun part ;)
I plan on just adding an extension where if you call a tile that is in the Al-Kharid zone, it will go to lumbridge, then cross the gate, go to the bank and then from there go to a key point.

Ok time for me to add all the subpath's now. Hopefully in less than 1 hour (when I find sumillions path maker) it should be hopefully ready to go for MSI


the path maker is in the reflection svn
http://simbareflection.googlecode.com/svn/trunk/Tools/PathMaker/

~shut

Cstrike

2010-09-29 18:21:50

Here we go, should be operational now :)
Test if you can, all the MSI spots MINUS P2P are supported. Im testing it as we speak
MUST HAVE GREATER THAN LEVEL 60 TOTAL

program ReflectionWalker;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}
{$i reflection/reflection.simba}

const
// Axis offsets
X_OFFSET = 0;
Y_OFFSET = 0;
// Node points
VARROCKWESTBANK_X = 3186 + X_OFFSET;
VARROCKWESTBANK_Y = 3439 + Y_OFFSET;
FALADOREASTBANK_X = 3013 + X_OFFSET;
FALADOREASTBANK_Y = 3356 + Y_OFFSET;
LUMBRIDGENE_X = 3217 + X_OFFSET;
LUMBRIDGENE_Y = 3251 + Y_OFFSET;
DRAYNORBANK_X = 3094 + X_OFFSET;
DRAYNORBANK_Y = 3242 + Y_OFFSET;
BARBVILLAGEC_X = 3081 + X_OFFSET;
BARBVILLAGEC_Y = 3416 + Y_OFFSET;

var NodeArray : TTileArray;
currentTile : TTile; // This is the tile we're on
VWB_LNE, VWB_BBC, // Highway variables
BBC_VWB, BBC_FEB,
DRB_LNE, DRB_FEB,
LNE_DRB, LNE_VWB,
FEB_DRB, FEB_BBC : TPointArray;
Highway, SubStreet : T2DPointArray; // ATPA's

{******************************************************************************}
{ procedure SetupNodesAndPaths; }
{ By: Cstrike }
{ Description: Sets up node points and all arrays for program to function. }
{******************************************************************************}
procedure SetupNodesAndPaths;
begin
NodeArray := [Tile (VARROCKWESTBANK_X, VARROCKWESTBANK_Y), // 0 Varrock west bank
Tile (FALADOREASTBANK_X, FALADOREASTBANK_Y), // 1 Fally east bank
Tile (LUMBRIDGENE_X, LUMBRIDGENE_Y), // 2 Lumby NE
Tile (DRAYNORBANK_X, DRAYNORBANK_Y), // 3 Draynor bank
Tile (BARBVILLAGEC_X, BARBVILLAGEC_Y)]; // 4 Barb village center (S of dungeon)
// Node highway travel only
VWB_LNE := [Point(3186, 3439),
Point(3194, 3429), Point(3207, 3428), Point(3211, 3415),
Point(3211, 3400), Point(3211, 3386), Point(3213, 3372),
Point(3218, 3359), Point(3226, 3347), Point(3228, 3337),
Point(3240, 3336), Point(3240, 3326), Point(3240, 3312),
Point(3239, 3302), Point(3239, 3294), Point(3239, 3282),
Point(3241, 3275), Point(3241, 3264), Point(3227, 3261),
Point(3217, 3257), Point(3219, 3247),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
VWB_BBC := [Point(3180, 3429),
Point(3169, 3428), Point(3163, 3421), Point(3151, 3417),
Point(3140, 3417), Point(3129, 3416), Point(3120, 3418),
Point(3111, 3420), Point(3099, 3420), Point(3089, 3419),
Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
BBC_VWB := [Point (3089,3419),
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
BBC_FEB := [Point (3075,3419),
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
DRB_LNE := [Point (3098,3235),
Point (3100,3230), Point (3110,3229), Point (3119,3228),
Point (3125,3225), Point (3133,3227), Point (3141,3229),
Point (3147,3235), Point (3157,3235), Point (3165,3238),
Point (3171,3239), Point (3176,3245), Point (3180,3247),
Point (3185,3245), Point (3193,3246), Point (3200,3247),
Point (3208,3246), Point (3212,3246),
Point(LUMBRIDGENE_X, LUMBRIDGENE_Y)];
DRB_FEB := [Point(3086, 3249),
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
LNE_DRB := [Point(3214, 3246),
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235),
Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
LNE_VWB := [Point (3223,3237),
Point (3219,3247), Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
FEB_DRB := [Point (3006,3356),
Point (3008,3345), Point (3007,3331), Point (3006,3320),
Point (3006,3311), Point (3006,3298), Point (3005,3287),
Point (3010,3278), Point (3021,3276), Point (3031,3278),
Point (3039,3276), Point (3050,3275), Point (3064,3277),
Point (3072,3276), Point (3073,3266), Point (3080,3256),
Point (3086,3249), Point (DRAYNORBANK_X, DRAYNORBANK_Y)];
FEB_BBC := [Point(3004, 3363),
Point(2993, 3368), Point(2983, 3376), Point(2969, 3379),
Point(2965, 3389), Point(2971, 3402), Point(2978, 3412),
Point(2986, 3419), Point(2989, 3429), Point(3002, 3431),
Point(3010, 3431), Point(3020, 3428), Point(3032, 3426),
Point(3044, 3419), Point(3054, 3415), Point(3064, 3417),
Point(3075, 3419), Point(BARBVILLAGEC_X, BARBVILLAGEC_Y)];
// Highway
SetArrayLength (Highway, 5); //Priority: FEB = VWB > DRB > LMB > BBC
Highway[0] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3089,3419), // Barb vil to varrock west bank
Point (3099,3420), Point (3111,3420), Point (3120,3418),
Point (3129,3416), Point (3140,3417), Point (3151,3417),
Point (3163,3421), Point (3169,3428), Point (3180,3429),
Point(VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[1] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), // Lumby northeast to varrock west bank (tiles[1..2] (note, not tiles[0]) were fucked up, check them)
Point (3217,3257), Point (3227,3261),
Point (3241,3264), Point (3241,3275), Point (3239,3282),
Point (3239,3294), Point (3239,3302), Point (3240,3312),
Point (3240,3326), Point (3240,3336), Point (3228,3337),
Point (3226,3347), Point (3218,3359), Point (3213,3372),
Point (3211,3386), Point (3211,3400), Point (3211,3415),
Point (3207,3428), Point (3194,3429), Point (3186,3439),
Point (VARROCKWESTBANK_X, VARROCKWESTBANK_Y)];
Highway[2] :=[Point(BARBVILLAGEC_X, BARBVILLAGEC_Y), Point (3075,3419), // barb vil to fally east bank
Point (3064,3417), Point (3054,3415), Point (3044,3419),
Point (3032,3426), Point (3020,3428), Point (3010,3431),
Point (3002,3431), Point (2989,3429), Point (2986,3419),
Point (2978,3412), Point (2971,3402), Point (2965,3389),
Point (2969,3379), Point (2983,3376), Point (2993,3368),
Point (3004,3363), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[3] :=[Point (DRAYNORBANK_X, DRAYNORBANK_Y), Point(3086, 3249), // draynor bank to fally east bank
Point(3080, 3256), Point(3073, 3266), Point(3072, 3276),
Point(3064, 3277), Point(3050, 3275), Point(3039, 3276),
Point(3031, 3278), Point(3021, 3276), Point(3010, 3278),
Point(3005, 3287), Point(3006, 3298), Point(3006, 3311),
Point(3006, 3320), Point(3007, 3331), Point(3008, 3345),
Point(3006, 3356), Point (FALADOREASTBANK_X, FALADOREASTBANK_Y)];
Highway[4] :=[Point(LUMBRIDGENE_X, LUMBRIDGENE_Y), Point(3214, 3246), // lumby to draynor bank
Point(3208, 3246), Point(3200, 3247), Point(3193, 3246),
Point(3185, 3245), Point(3180, 3247), Point(3176, 3245),
Point(3171, 3239), Point(3165, 3238), Point(3157, 3235),
Point(3147, 3235), Point(3141, 3229), Point(3133, 3227),
Point(3125, 3225), Point(3119, 3228), Point(3110, 3229),
Point(3100, 3230), Point(3098, 3235), Point(DRAYNORBANK_X, DRAYNORBANK_Y)];
//Streets
SetArrayLength (SubStreet, 27);
// These paths are between the >60 west of draynor guarded gate, and lumbyNE node
SubStreet[0] := [Point(3094, 3242), Point(3100, 3244), Point(3105, 3247), // &#8730; Inside draynor village to draynor bank
Point(3104, 3257), Point(3102, 3262), Point(3092, 3259)];
SubStreet[1] := [Point(3110, 3229), Point(3114, 3220), Point(3117, 3212), // &#8730; Wiz tower from below draynor bank path
Point(3114, 3205), Point(3113, 3196), Point(3113, 3187),
Point(3113, 3181), Point(3113, 3171), Point(3110, 3167),
Point(3102, 3165), Point(3101, 3155), Point(3105, 3150)];
SubStreet[2] := [Point(3133, 3227), Point(3136, 3218), Point(3138, 3208), // &#8730; Follows western sea that arcs around the two lumby mines, and ends at the lumby mine with addy/mith at the SE corner [south of lumby]
Point(3141, 3203), Point(3141, 3193), Point(3144, 3184),
Point(3143, 3177), Point(3146, 3167), Point(3148, 3158),
Point(3151, 3149), Point(3159, 3147), Point(3168, 3150),
Point(3177, 3150), Point(3186, 3148), Point(3196, 3148),
Point(3202, 3152), Point(3212, 3151), Point(3222, 3150),
Point(3234, 3150)];
SubStreet[3] := [Point(3133, 3227), Point(3137, 3218), Point(3143, 3213), // &#8730; Goes from south of jail, to hook around the north of the swamp below lumbridge
Point(3148, 3206), Point(3154, 3202), Point(3161, 3197),
Point(3174, 3197), Point(3185, 3195), Point(3197, 3190),
Point(3202, 3185), Point(3212, 3184), Point(3219, 3176)];
SubStreet[4] := [Point(3098, 3235), Point(3092, 3228), Point(3091, 3217), // South of draynor bank
Point(3101, 3211)];
SubStreet[5] := [Point(3072, 3276), Point(3074, 3287), Point(3072, 3297), // &#8730; Hooks north of the draynor market, and goes up to the west of draynor manor (without passing over the walls, and then hooks southeast slightly into the forest
Point(3072, 3307), Point(3076, 3314), Point(3078, 3323),
Point(3088, 3322), Point(3092, 3312)];
SubStreet[6] := [Point(3072, 3276), Point(3077, 3281), Point(3086, 3289), // &#8730; Goes east of the draynor/south fally gate >60 total guys, follows the path to the 4 way cross, goes up to draynor manor and hooks around the right side, ending on the bottom left of the draynor manor near some grey patch
Point(3094, 3291), Point(3102, 3294), Point(3109, 3297),
Point(3113, 3303), Point(3113, 3310), Point(3111, 3318),
Point(3111, 3327), Point(3110, 3339), Point(3109, 3346),
Point(3115, 3351), Point(3123, 3351), Point(3128, 3356),
Point(3128, 3364), Point(3125, 3373), Point(3116, 3376),
Point(3109, 3376), Point(3096, 3376), Point(3091, 3374),
Point(3087, 3365), Point(3087, 3357), Point(3086, 3348),
Point(3090, 3338)];
SubStreet[7] := [Point(3157, 3235), Point(3157, 3227), Point(3160, 3221), // South of ham in lumby-west, between two trees, really close to the water symbol
Point(3167, 3212), Point(3175, 3210)];
SubStreet[8] := [Point(3157, 3235), Point(3152, 3243), Point(3143, 3253), // Runs east of the jail up by the grains and continues up to the right of draynor mansion, stopping before this hole in the white wall east of the manor
Point(3135, 3262), Point(3134, 3275), Point(3134, 3288),
Point(3134, 3300), Point(3136, 3311), Point(3141, 3320),
Point(3145, 3329), Point(3147, 3333)];
SubStreet[9] := [Point(3176, 3245), Point(3172, 3252), Point(3164, 3257), //East around ham building, north in front of windmill/grain thing, and then a tile west of that as the last additional added tile
Point(3163, 3263), Point(3161, 3271), Point(3162, 3278),
Point(3163, 3287), Point(3166, 3293), Point(3167, 3301),
Point(3159, 3310)];
SubStreet[10] :=[Point(3176, 3245), Point(3180, 3232), Point(3182, 3226), // south past the right set of rare trees (west of farming patch) so the southwest side of the lumby castle (outside the walls), does not go under the castle
Point(3185, 3218), Point(3186, 3210), Point(3194, 3204),
Point(3198, 3200)];
SubStreet[11] :=[Point(3176, 3245), Point(3179, 3251), Point(3180, 3258), // east of HAM to the west side of the sheep shearer's farm place
Point(3181, 3267)];
SubStreet[12] :=[Point(3133, 3227), Point(3130, 3235), Point(3132, 3242), // runs up through the bottom of the jail and hooks around the north from the east, to the west
Point(3130, 3248), Point(3119, 3251)];
SubStreet[13] :=[Point(3133, 3227), Point(3139, 3223), Point(3143, 3217), // Walks south of that irritating wall that seperates lumby forest from lumby swamps, remember... walks south of the wall and retrieves to the brown path
Point(3146, 3211), Point(3153, 3209), Point(3160, 3203),
Point(3172, 3203), Point(3184, 3202), Point(3191, 3197),
Point(3199, 3194), Point(3208, 3194)];
SubStreet[14] :=[Point(3217, 3251), Point(3222, 3242), Point(3225, 3235), // Walk from lumbyNE node down the path through graveyard to just east of the mining spot with addy
Point(3231, 3230), Point(3236, 3225), Point(3237, 3216),
Point(3237, 3202), Point(3243, 3199), Point(3245, 3190),
Point(3243, 3180), Point(3239, 3169), Point(3241, 3159),
Point(3237, 3147)];
SubStreet[15] :=[Point(3217, 3251), Point(3221, 3243), Point(3224, 3235), // Goes from LNE node into lumby castle, and inside right to outside the cooks door/near south spiral ladder
Point(3232, 3227), Point(3234, 3218), Point(3225, 3216),
Point(3215, 3217), Point(3214, 3209), Point(3207, 3208)];
SubStreet[16] :=[Point(3217, 3257), Point(3217, 3265), Point(3215, 3274), // takes the first tile in the path that goes from LNE->VWB
Point(3210, 3278), Point(3197, 3278), Point(3190, 3285),
Point(3189, 3294), Point(3188, 3302), Point(3185, 3308),
Point(3177, 3313)];
// These paths are between 'east of lumby bridge(s) and varrock west bank
SubStreet[17] :=[Point(3207, 3428), Point(3216, 3426), Point(3223, 3430),
Point(3232, 3431), Point(3241, 3429), Point(3254, 3429),
Point(3254, 3420)]; // Varrock east bank
SubStreet[18] :=[Point(3207, 3428), Point(3216, 3425), Point(3223, 3429),
Point(3237, 3430), Point(3249, 3430), Point(3262, 3429),
Point(3271, 3429), Point(3279, 3430), Point(3287, 3424),
Point(3288, 3414), Point(3291, 3409), Point(3292, 3401),
Point(3293, 3393), Point(3294, 3385), Point(3293, 3377),
Point(3288, 3373), Point(3286, 3367)]; // Varrock southEast mines
SubStreet[24] := [Point(3207, 3428), Point(3208, 3434), Point(3213, 3438),
Point(3213, 3446), Point(3206, 3452), Point(3200, 3458),
Point(3197, 3466), Point(3197, 3476), Point(3196, 3484),
Point(3197, 3493), Point(3196, 3499), Point(3201, 3504),
Point(3211, 3502), Point(3219, 3502), Point(3228, 3500),
Point(3231, 3488), Point(3230, 3480)]; // Goes near varrock fountain, then up and around the castle, hooking around the west side, past the yews in the north, and then into the queens garden on the east side
// These paths are between BBC and varrock west bank
SubStreet[19] :=[Point(3169, 3428), Point(3171, 3421), Point(3171, 3412),
Point(3171, 3403), Point(3171, 3395), Point(3174, 3389),
Point(3177, 3384), Point(3175, 3377), Point(3170, 3369),
Point(3173, 3363), Point(3181, 3367)]; // Varrock southWest mine near champion guild
SubStreet[20] :=[Point(3186, 3439), Point(3186, 3445), Point(3184, 3451),
Point(3175, 3452), Point(3170, 3456), Point(3164, 3465),
Point(3164, 3473), Point(3164, 3479), Point(3165, 3487)]; // Grand exchange
SubStreet[21] :=[Point(3089, 3419), Point(3086, 3426), Point(3089, 3435),
Point(3087, 3444), Point(3087, 3450), Point(3090, 3457),
Point(3088, 3460), Point(3087, 3466), Point(3082, 3467),
Point(3080, 3477), Point(3080, 3485), Point(3086, 3490),
Point(3093, 3493)]; // Edgeville
// These paths are between falador east bank and BBC

// These paths are between fally and draynor >60 level guards
SubStreet[22] :=[Point(3010, 3278), Point(3008, 3272), Point(2998, 3270),
Point(2990, 3270), Point(2983, 3265), Point(2978, 3262),
Point(2977, 3253), Point(2977, 3241)]; // Fally south (corner of farm) going to rimmington mining field
SubStreet[23] :=[Point(3039, 3276), Point(3039, 3268), Point(3038, 3261),
Point(3040, 3255), Point(3041, 3247), Point(3042, 3235),
Point(3048, 3235)]; // Slightly SE of the opening to the farm, heads almost straight down to the port and then over to the port sarim dropoff box approximately
SubStreet[25] :=[Point(3064, 3277), Point(3062, 3271), Point(3059, 3266),
Point(3059, 3260), Point(3060, 3253)]; // West of lvl 60 gate, immediately goes south and over farming patch to the trees near the sea
SubStreet[26] :=[Point(3010, 3278), Point(3002, 3277), Point(2997, 3278),
Point(2990, 3278), Point(2985, 3276), Point(2980, 3273),
Point(2978, 3268), Point(2974, 3262), Point(2968, 3257),
Point(2964, 3253), Point(2957, 3244), Point(2953, 3241),
Point(2946, 3239), Point(2943, 3231), Point(2939, 3227),
Point(2934, 3220), Point(2932, 3215), Point(2924, 3215),
Point(2922, 3207), Point(2927, 3202), Point(2934, 3199)]; // Fally crossroads SW of farm, follows path all the way down to the chemist/distiller, then goes west and hooks around to the south
end;

// Output's the TPA for debug purposes
procedure DebugTheTPA (TPA : TPointArray);
var i : Integer;
begin
writeln ('TPA debug:');
for i:=0 to high(TPA) do
begin
writeln ('['+inttostr(i)+']: Point ('+inttostr(TPA[i].x)+','+inttostr(TPA[i].y)+')');
end;
end;

// Output's the TTA for debug purposes
procedure DebugTheTTA (TTA : TTileArray);
var i : Integer;
begin
writeln ('TTA debug:');
for i:=0 to high(TTA) do
begin
writeln ('['+inttostr(i)+']: Tile ('+inttostr(TTA[i].x)+','+inttostr(TTA[i].y)+')');
end;
end;

//Easy code for a current position output
procedure DebugCurrentPos;
begin
currentTile := GetMyPos;
writeln ('DEBUG_CURRENT_TILE: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
end;

{******************************************************************************}
{ procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray); }
{ By: Cstrike }
{ Description: Create TTileArray from TPA }
{******************************************************************************}
procedure AddTPAToTTA (TPA : TPointArray; var T_TileArray : TTileArray);
var i, j, originalHighTTA : Integer;
begin
j:=0;
originalHighTTA := high(T_TileArray)
SetArrayLength (T_TileArray, (high(TPA)+high(T_TileArray)+2));
for i:=originalHighTTA+1 to (originalHighTTA+high(TPA))+1 do
begin
T_TileArray[i] := Tile(TPA[j].x,TPA[j].y);
Inc(j);
end;
end;

{******************************************************************************}
{ procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: A shofrter version of CreateTPADownFromFragment (below), may }
{ screw up occasionally, don't know why. Must debug this. }
{******************************************************************************}
procedure AddTPAFromDownToTTA (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var i : Integer;
begin
SetArrayLength (TPA, TPAPos+1);
for i:=TPAPos downto 0 do
begin
TPA[i] := ATPA[ATPAPos][i];
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPAUpFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position up until high(TPA) }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 16 to 20, you would enter TPAPos as 16. ATPAPos is just the }
{ index of what TPA in the ATPA you're looking for (aka, ATPA[ATPAPos]) }
{ It is considered "Invert" because at the end it inverts the TPA fragment }
{ which is useful for when you are using WalkTo. When you are retrieving }
{ to a bank, you don't need to invert because it will always have the end }
{ tile as being the bank node, but if you try and use this while walking }
{ to a branch point (to branch off on a subpath to get near your TPoint), }
{ the other function will make it so that it will always make you return }
{ to a node point. Thus, invert makes you walk in the opposite direction }
{ from a node point to your branch-off-from-the-highway-point }
{******************************************************************************}
procedure CreateTPAUpFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPADifference+1);
for i:=TPAPos to highATPA do
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]) }
{******************************************************************************}
procedure CreateTPADownFromFragment (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
end;

{******************************************************************************}
{ procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray); }
{ By: Cstrike }
{ Description: Stores a TPA from an ATPA's TPA position down until TPA[0] }
{ Ex: If you have a TPA in an ATPA from 0 to 20, and want to create TPA#2 from }
{ TPA position 7 to 0 (NOT from 0 to 7!), you would enter TPAPos as 7. }
{ ATPAPos is just the index of what TPA in the ATPA you're looking for }
{ (aka, ATPA[ATPAPos]). Inverts at the end (see CTPAUFFInvert for details) }
{ (aka, does from 0 to 7 ;) ...) }
{******************************************************************************}
procedure CreateTPADownFromFragmentInvert (ATPA : T2DPointArray; ATPAPos, TPAPos : Integer; var TPA : TPointArray);
var initial, i, highATPA, TPADifference : Integer;
begin
initial := 0; // This is so the new TPA we create starts from zero, because every time I try using 'i', it ends up being something thats not zero, screwing it all up. So I just made my own variable for starting at zero
highATPA := High(ATPA[ATPAPos]);
TPADifference := (highATPA-TPAPos);
SetArrayLength (TPA, TPAPos+1);
writeln ('TPADif = ' +inttostr(TPADifference));
for i:=TPAPos downto 0 do // Start from our TPA position (lets say were 7 of 20, start at position 7), and then go down to position zero
begin
TPA[initial] := ATPA[ATPAPos][i];
Inc(initial); // Now that we've set TPA, lets increase it for next time... if it exceeds it... no big deal because it will end the loop before creating a new TPA point
end;
InvertTPA (TPA);
end;

{******************************************************************************}
{ procedure RemoveTPFromTPA (TPA : TPointArray; Index : Integer); }
{ By: Cstrike }
{ Description: Removes TPA[Index] and truncates TPA that you input }
{******************************************************************************}
procedure RemoveTPFromTPA (TPAToRemoveFrom, ModifiedTPA : TPointArray; Index : Integer);
var i, j : Integer;
begin
j := 0;
if Index > High(TPAToRemoveFrom) then
begin
writeln ('Warning, index greater than what TPA has, setting new TPA to old TPA');
ModifiedTPA := TPAToRemoveFrom;
Exit;
end;
for i:=0 to high(TPAToRemoveFrom) do
begin
SetArrayLength (ModifiedTPA,high(TPAToRemoveFrom));
if i <> index then
begin
ModifiedTPA[j] := TPAToRemoveFrom[i];
writeln ('J = '+inttostr(j));
//DebugTheTPA (ModifiedTPA);
Inc(j);
end;
end;
writeln ('RemoveTPFromTPA result:');
DebugTheTPA (ModifiedTPA);
end;

{******************************************************************************}
{ function TMin (TIA : TIntegerArray) : Integer; }
{ By: Cstrike }
{ Description: Sets TIA[0] as the lowest number }
{******************************************************************************}
function TMin (TIA : TIntegerArray) : Integer;
begin
QuickSort (TIA);
if high(TIA) > 0 then result := TIA[0] else result := 0;
end;

{******************************************************************************}
{ procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer); }
{ By: Cstrike }
{ Description: Searches an ATPA for a TPoint. Returns the ATPA index and the }
{ TPA index of where the TPoint is located. Only returns one position, which }
{ is the last one it will find }
{******************************************************************************}
procedure FindTPInATPA (TP : TPoint; ATPA : T2DPointArray; var ATPAPos, TPAPos : Integer);
var i, j : integer;
begin
if not LoggedIn then exit;
ATPAPos := 0;
TPAPos := 0;
for i:=0 to high(ATPA) do
begin
for j:=0 to high(ATPA[i]) do
begin
if ATPA[i][j] = TP then
begin
ATPAPos := i;
writeln ('ATPApos = '+inttostr(i));
TPAPos := j;
writeln ('TPApos = '+inttostr(j));
end;
end;
end;
end;

{******************************************************************************}
{ function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean; }
{ By: Cstrike }
{ Description: Attemps to walk (blindly) towards the TPoint (or TTile, since }
{ the TPoint is converted). X increases as you go east, Y as you go north. }
{ Needs serious code fixing, but it works. WalkRadius is how many tiles it }
{ will walk in each increment. Shouldn't use a radius that is larger than }
{ the minimap. Should not use zero, try and keep it between 2 and 12. }
{******************************************************************************}
function FindPathToTile (TP : TPoint; walkRadius : Integer) : Boolean;
var currentTile, walkTile, desiredTile : TTile;
i, hyp, increments, cx, cy, xincI, yincI : Integer;
xinc, yinc : Extended;
begin
if not LoggedIn then exit;
if walkRadius < 1 then // If human is stupid then
begin
writeln ('Warning, walkRadius < 1, exiting...');
result := false;
exit;
end;
currentTile := GetMyPos;
writeln ('current tile ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
desiredTile := PointToTile (TP);
writeln ('desired point ('+inttostr(TP.x)+','+inttostr(TP.y)+')');
hyp := Distance (currentTile.x, currentTile.y, TP.x, TP.y);
writeln ('hypotenuse = ' + inttostr(hyp));
increments := round(hyp/walkRadius);
writeln ('increments = '+inttostr(increments));
if increments > 0 then
begin
xinc := ((currentTile.x - TP.x)/increments);
yinc := ((currentTile.y - TP.y)/increments);
xinc := abs (xinc);
yinc := abs (yinc);
xincI := round (xinc);
yincI := round (yinc);
writeln ('x incs = '+floattostr(xinc));
writeln ('y incs = '+floattostr(yinc));
cx := currentTile.x;
cy := currentTile.y;
if (currentTile.x <= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y <= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y < TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy + yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x <= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x < TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx + xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end else
if (currentTile.x >= TP.x) and (currentTile.y >= TP.y) then
begin
writeln ('current tile x > TP.x, currentTile.y > TP.y');
for i:=0 to increments-1 do
begin
cx := cx - xincI;
cy := cy - yincI;
walkTile := Tile (cx, cy);
WalkToTile (walkTile, 0, 1); // BOOLEAN FALSE
end;
end;
end else // If increments = 0
begin
result := true;
writeln ('No need to use PathFinder, were in TPA range');
end;
if TileOnMM (desiredTile) then
begin
writeln ('Good news, tile is on minimap!');
result := true;
end else
if not TileOnMM (desiredTile) then
begin
writeln ('Tile is NOT on the minimap');
result := false;
end;
end;

{******************************************************************************}
{ function SubPointDistances (ATPA : T2DPointArray) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to current position }
{******************************************************************************}
function SubPointDistances (ATPA : T2DPointArray) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := GetMyPos; // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
//DEBUGDEBUGwriteln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function SubPointDistancesTP (ATPA : T2DPointArray, TP : TPoint) : TPoint; }
{ By: Cstrike }
{ Description: Returns TPoint from ATPA which is closest to a TP you input }
{******************************************************************************}
function SubPointDistancesTP (ATPA : T2DPointArray; TP : TPoint) : TPoint;
var distArrLowest, tempdistArrLowest, distTPAInt, tempdistTPATInt : TIntegerArray;
distArrLowestTP : TPointArray;
currentTile : TTile;
i, j, k, z : Integer;
begin
if not LoggedIn then exit;
currentTile := PointToTile(TP); // Don't remove this, it's needed
writeln ('SubPointDist: Current tile = ('+inttostr(currentTile.x)+','+inttostr(currentTile.y)+')');
writeln ('high(ATPA) = ' + inttostr(high(ATPA)));
SetArrayLength (distArrLowest, high(ATPA)+1); // The array that holds all the *smallest* distances from each TPA
SetArrayLength (tempdistArrLowest, high(ATPA)+1);
SetArrayLength (distArrLowestTP, high(ATPA)+1);
for i:=0 to high(ATPA) do // For the entire ATPA do...
begin
//writeln ('high(ATPA)[i] = ' + inttostr(high(ATPA[i])));
SetArrayLength (distTPAInt, high(ATPA[i])+1);
SetArrayLength (tempdistTPATInt, high(ATPA[i])+1);
for j:=0 to high(ATPA[i]) do // For each TPA in ATPA do...
begin
distTPAInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
tempdistTPATInt[j] := Distance (currentTile.x, currentTile.y, ATPA[i][j].x, ATPA[i][j].y);
//DEBUGDEBUGwriteln ('ATPA['+inttostr(i)+']['+inttostr(j)+'] distance = '+inttostr(distTPAInt[j])+' ('+inttostr(ATPA[i][j].x)+','+inttostr(ATPA[i][j].y)+')'); // Debug
if j = high(ATPA[i]) then // When we reach the top of our TPA, do the following [only because I cant do this outside the for loop...]
begin
TMin (tempdistTPATInt); // Return the integer thats the SMALLEST distance from the TIntegerArray
writeln ('Minimum distance (tempdistTPAInt[0])= '+inttostr(tempdistTPATInt[0]));
distArrLowest[i] := tempdistTPATInt[0];
tempdistArrLowest[i] := tempdistTPATInt[0];
for k:=0 to high(ATPA[i]) do // This goes back and gives us the TPoint that matches up with the smallest distance, and stores it in an array for future decisions
begin
if distArrLowest[i] = distTPAInt[k] then
begin
distArrLowestTP[i] := ATPA[i][k];
//writeln ('distArrLowestTP['+inttostr(i)+'] = ('+inttostr(distArrLowestTP[i].x)+','+inttostr(distArrLowestTP[i].y)+')');
end;
end;
end;
end;
end;
for z:=0 to high(ATPA) do // Debug output to get a nice chart :)
begin
writeln ('distArrLowest['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
end;
TMin (tempdistArrLowest);
for z:=0 to high(ATPA) do
begin
if tempdistArrLowest[0] = distArrLowest[z] then
begin
writeln ('Smallest distance is ['+inttostr(z)+'] = '+inttostr(distArrLowest[z])+' @ distArrLowestTP['+inttostr(z)+'] ('+inttostr(distArrLowestTP[z].x)+','+inttostr(distArrLowestTP[z].y)+')');
result := distArrLowestTP[z];
end;
end;
end;

{******************************************************************************}
{ function AssignNodeLocation (maxTileRadius : integer) : String; }
{ By: Cstrike }
{ Description: Using reflection tiles, it will assess your current position }
{ and based on how large of a tile radius you input, it will return the three }
{ letter node you are at. If it doesn't work, it returns as an empty string }
{******************************************************************************}
function AssignNodeLocation (maxTileRadius : integer) : String;
var i : Integer;
currentTile : TTile;
location : String;
begin
if not LoggedIn then exit;
currentTile := GetMyPos;
location := ''; // This is for failsafes
for i:=0 to high(NodeArray) do
begin
if (currentTile.x < (NodeArray[i].x+maxTileRadius)) and (currentTile.x > (NodeArray[i].x-maxTileRadius)) and (currentTile.y < (NodeArray[i].y+maxTileRadius)) and (currentTile.y > (NodeArray[i].y-maxTileRadius)) then // If were in a box defined by the given radius then...
begin
case i of
0: location := 'VWB';
1: location := 'FEB';
2: location := 'LNE';
3: location := 'DRB';
4: location := 'BBC';
end;
end;
end;
if location = '' then // If we can't change the variable to any text then...
begin
location := 'none';
end;
writeln ('In node range = ('+location+')');
result := location;
end;

{******************************************************************************}
{ procedure procedure TravelToNode (startNode, endNode : string); }
{ By: Cstrike }
{ Description: Travels between nodes. Must use node names. Current names are: }
{ VWB = varrock west bank FEB = falador east bank BBC = barb village center }
{ (south of dungeon entrance) DRB = draynor bank LNE = Lumbridge, northeast of }
{ the lumby castle. Use upper case for now }
{******************************************************************************}
procedure TravelToNode (startNode, endNode : string);
var pathToWalk : TPointArray;
pathToWalkTTA : TTileArray;
begin
if not LoggedIn then exit;
writeln ('Path requested ["'+startNode+ '" to "'+endNode+'"]');
case startNode of
// Varrock west bank
'VWB':
begin
case endNode of
'FEB': pathToWalk := CombineTPA(VWB_BBC, BBC_FEB);
'LNE': pathToWalk := VWB_LNE;
'DRB': pathToWalk := CombineTPA(VWB_LNE, LNE_DRB);
'BBC': pathToWalk := VWB_BBC;
end;
end;
// Falador East bank
'FEB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(FEB_BBC, BBC_VWB);
'LNE': pathToWalk := CombineTPA(FEB_DRB, DRB_LNE);
'DRB': pathToWalk := FEB_DRB;
'BBC': pathToWalk := FEB_BBC;
end;
end;
// Lumbridge north east
'LNE':
begin
case endNode of
'VWB': pathToWalk := LNE_VWB;
'FEB': pathToWalk := CombineTPA(LNE_DRB, DRB_FEB);
'DRB': pathToWalk := LNE_DRB;
'BBC': pathToWalk := CombineTPA(LNE_VWB, VWB_BBC);
end;
end;
// Draynor bank
'DRB':
begin
case endNode of
'VWB': pathToWalk := CombineTPA(DRB_LNE, LNE_VWB);
'FEB': pathToWalk := DRB_FEB;
'LNE': pathToWalk := DRB_LNE;
'BBC': pathToWalk := CombineTPA(DRB_FEB, FEB_BBC);
end;
end;
// Barbarian village center
'BBC':
begin
case endNode of
'VWB': pathToWalk := BBC_VWB;
'FEB': pathToWalk := BBC_FEB;
'LNE': pathToWalk := CombineTPA(BBC_VWB, VWB_LNE);
'DRB': pathToWalk := CombineTPA(BBC_FEB, FEB_DRB);
end;
end;
end; // End of all cases
AddTPAToTTA (pathToWalk, pathToWalkTTA);
if WalkPath (pathToWalkTTA) then
begin
writeln ('Successfully walked');
end else
begin
writeln ('Failure in walking');//["'+startNode+ '" to "'+endNode+'"]');
end;
end;

{******************************************************************************}
{ function RetrieveToClosestHighwayPoint : TPoint; }
{ By: Cstrike }
{ Description: Using the SubStreet ATPA, it will search for the closest TPoint }
{ and then it will walk that path until the last TPoint in the path. Returns }
{ the last TPoint in the path. This SHOULD be a TPoint on a highway or later }
{ parts of the script probably wont work unless you re-code it }
{ Ex: Takes you from your location through a substreet to SubStreet[i][0], }
{ which is a highway point (or should be). The A next to TPAPosA/ATPAPosA }
{ has no actual meaning, just a placeholder to be 'different'. Sorry. }
{******************************************************************************}
function RetrieveToClosestHighwayPoint : TPoint;
var TP : TPoint;
TPA : TPointArray;
ATPAposA, TPAPosA, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
TP := SubPointDistances (SubStreet); // Searches ALL the substreets, and returns TP as the closest point
FindTPInATPA (TP, SubStreet, ATPAposA, TPAPosA); // Searches all the substreets to find which TPA in the ATPA contains our point [aka: finds a TPoint in an ATPA], if multiple return for whatever reason, it will take the last one it finds I guess. Note, the last two variables are position remembering (aka: remembers the slot in the ATPA and TPA)
AddTPAFromDownToTTA (SubStreet, ATPAPosA, TPAPosA, TPA); // Now that it knows the ATPA/TPA/TP, it will take the TPoint it found, using its location and go along the TPA backwards from TPA[i] to TPA[0], which is technically our retrieved path. Remember, all our paths were designed from the highway and branch out, so it makes sense to find our spot and work backwards to a highway
AddTPAToTTA (TPA, TTA); // With this TPA we made above, convert it to a TTileArray for reflection
WalkPath (TTA); // Walk us to the point in the Highway[?]
DebugCurrentPos; // Debug
FFlag(0); writeln ('Now trying to get to nearest node'); wait (3000); // Debug
highTPA := high(TPA);
writeln ('TPA[0] = ('+inttostr(TPA[highTPA].x)+','+inttostr(TPA[highTPA].y)+')'); // Debug
result := SubStreet[ATPAPosA][0]; // Returns the TPoint that
end;

{******************************************************************************}
{ function RetrieveToClosestNode : String; }
{ By: Cstrike }
{ Description: Returns a string of the node you went to. It will return three }
{ lettered node in capitals. }
{ Ex: This procedure walks the closest street to a highway, then walks the }
{ highway to a node, then returns the node name for use in other functions }
{******************************************************************************}
function RetrieveToClosestNode : String;
var TP : TPoint;
TPA : TPointArray;
ATPAPosH, TPAPosH, highTPA : Integer;
TTA : TTileArray;
begin
if not LoggedIn then exit;
// if (no highway points on minimap) then
TP := RetrieveToClosestHighwayPoint; // This will first walk us on a street towards a highwaypoint, and then return the highway point that it reached
FindTPInATPA (TP, Highway, ATPAPosH, TPAPosH); // Find our location in terms of ATPA[ATPAPosH][TPAPosH]
highTPA := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPosH >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment');
CreateTPAUpFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment');
CreateTPADownFromFragment (Highway, ATPAPosH, TPAPosH, TPA);
end;
DebugTheTPA (TPA);
AddTPAToTTA (TPA, TTA);
WalkPath (TTA);
result := AssignNodeLocation (8);
writeln ('Result: '+result);
end;

{******************************************************************************}
{ function DetermineNodeName (TP : TPoint) : String }
{ By: Cstrike }
{ Description: Checks node TP's with inputted TP and returns node name. If no }
{ node is found, returns ''. }
{******************************************************************************}
function DetermineNodeName (TP : TPoint) : String;
begin
if not LoggedIn then exit;
writeln ('DetermineNodeNameFunction: Point("'+inttostr(TP.x)+ '" to "'+inttostr(TP.y)+'")');
result := '';
case TP of
Point((VARROCKWESTBANK_X + X_OFFSET),(VARROCKWESTBANK_Y + Y_OFFSET)): result := 'VWB';
Point((FALADOREASTBANK_X + X_OFFSET),(FALADOREASTBANK_Y + Y_OFFSET)): result := 'FEB';
Point((LUMBRIDGENE_X + X_OFFSET),(LUMBRIDGENE_Y + Y_OFFSET)): result := 'LNE';
Point((DRAYNORBANK_X + X_OFFSET),(DRAYNORBANK_Y + Y_OFFSET)): result := 'DRB';
Point((BARBVILLAGEC_X + X_OFFSET),(BARBVILLAGEC_Y + Y_OFFSET)): result := 'BBC';
end;
end;

{******************************************************************************}
{ procedure GoToNodeFromAnywhere (Location : string); }
{ By: Cstrike }
{ Description: Takes you from anywhere, to the location you want. Location you }
{ input should be 3 capital letters like VWB. Should only use defined nodes, }
{ don't try entering something like VEB unless in the future it is defined as }
{ a node to actually go to. Use FEB/VWB/BBC/LNE/DRB for now }
{******************************************************************************}
procedure GoToNodeFromAnywhere (Location : string);
var startNode : String;
begin
if not LoggedIn then exit;
startNode := RetrieveToClosestNode;
if (startNode = Location) then writeln ('Already at '+Location) // This prevents TravelToNode from attempting to walk with 0 TTiles (which crashes the script)
else TravelToNode (startNode, Location);
end;

// If distance < 10 in WalkTo from highway or it's closest to a highway...
procedure RetrieveWalkCloseToHighway (TP, ClosestHighwayTP : TPoint);
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPos, TPAPos, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
FindTPInATPA (ClosestHighwayTP, Highway, ATPAPos, TPAPos); // Find where our closest highway TP (relative to our requested spot) is in the ATPA 'highway'
highTPA := high(Highway[ATPAPos]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPA = '+inttostr(highTPA)); // Debug
if TPAPos >= (highTPA/2) then // If we are in the upper half of the TPA [or middle] then
begin
writeln ('Greater than half, do the UpFragment and invert');
CreateTPAUpFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, do the DownFragment and invert');
CreateTPADownFromFragmentInvert (Highway, ATPAPos, TPAPos, TPA);
end;
DebugTheTPA (TPA); // Debug output
nodeName := DetermineNodeName (TPA[0]); // Our node SHOULD be at TPA[0], so find what node we should end up at
AddTPAToTTA (TPA, TTA);
DebugTheTTA (TTA); // Debug
// WALK TIME!!
GoToNodeFromAnywhere (nodeName); // First, go to closest node
WalkPath (TTA); // Now that were at the node, walk the path
wait (random(500)); // Now wait for safe measure ;)
TileToWalkTo := PointToTile (TP); // WalkToTile (TP) here
if TileOnMM (TileToWalkTo) then
begin
writeln ('Desired tile on minimap, attempting to walk to it');
WalkToTile (TileToWalkTo, 1, 0);
end else
begin
writeln ('Desired tile NOT on minimap, attempting to blindwalk to it');
FindPathToTile (TP, 9); // Change walk radius of 9 if you think its too much
end;
{
CurrentTile := GetMyPos;
result := true;
if ((currentTile.x - TP.x) < 4) or ((currentTile.x - TP.x) > -4) or ((currentTile.y - TP.y) < 4) or ((currentTile.y - TP.y) > -4) then
begin
writeln ('We are greater than 4 tiles away from desired point('+inttostr(TP.x)+','+inttostr(TP.y)+')');
result := false;
end else writeln ('At tile!!');
}
end;


// If highway >= 10 away from WalkTo and Substreet is a shorter distance than Highway
procedure RetrieveWalkCloseToSubstreet (TP, ClosestHighwayTP : TPoint);
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPosS, TPAPosS, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
if not LoggedIn then exit;
writeln ('**Beginning RetrieveWalkCloseToSubstreet');
closestTP := SubPointDistancesTP(SubStreet, TP); //Find closest point in ATPA.TPA
FindTPInATPA (closestTP, SubStreet, ATPAPosS, TPAPosS); //Determine what index it is, the S next to ATPAPos means 'S'ubstreet (since H is for 'H'ighway)
writeln ('WalkTo(Substreet) ATPAPos = '+inttostr(ATPAPosS)); writeln ('WalkTo(Substreet) TPAPos = '+inttostr(TPAPosS)); // DEBUG
rootSubstreetTP := SubStreet[ATPAPosS][0]; //Find what highway it connects to, since the SubStreet[ATPAPos][0] HAS to be a TPoint on the Highway ATPA
FindTPInATPA (rootSubstreetTP, Highway, ATPAPosH, TPAPosH); // Finds what highway index were looking for, and what point to walk from [The H next to ATPAPos/TPAPos is used for 'H'ighway, because ATPAPos is for the substreet)
highTPAHighway := high(Highway[ATPAPosH]); // This gives us how big our array is, so we can later determine which node we are closer to (since it has to decide between which 2 to walk to... and the closer looks less obvious right? Imagine being next to draynor and walking all the way to lumby)
writeln ('highTPASubstreet = '+inttostr(highTPA)); writeln ('highTPAHighway = '+inttostr(highTPAHighway)); // Debug
startFromIndexZero := false; // This is used when generating our big walk, whether to start from the top or bottom of the highway array, if true... starts from Highway[i][0]
writeln ('**Beginning HighwayNodeName determination');
if TPAPosH >= (highTPAHighway/2) then // Search if we branch off in the upper half of the highway, or the lower half of the highway
begin
writeln ('Greater than half, search highest TPA point for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+']['+inttostr(highTPAHighway)+']');
nodeName := DetermineNodeName (Highway[ATPAPosH][highTPAHighway]); // Search the top of the Highway[Index] array, since the top of the array will be a node position, and we are in the upper half of the array lets just go to the closest one ;)
writeln ('Node name determined that is closest: '+nodeName);
end else // Else if we are in the lower half of the TPA then
begin
writeln ('Less than half, search TPA[0] for node');
writeln ('Using Highway['+inttostr(ATPAPosH)+'][0]');
nodeName := DetermineNodeName (Highway[ATPAPosH][0]);
writeln ('Node name determined that is closest: '+nodeName); // Same as the code slightly above ^^^ except were in lower half so check the bottom of the array
startFromIndexZero := true;
end;
writeln ('**Beginning FullWalkingPath creation: Create highway path');
if startFromIndexZero then // If we started getting the highway from Highway[ATPAPosH][0] then do this stuff
begin
writeln ('StartFromIndexZero = true');
CreateTPADownFromFragmentInvert (Highway, ATPAPosH, TPAPosH, FullWalkingPath); // Creates from position zero up to our desired HighwayPoint and stores it in FullWalkingPath
end else // Start from Highway[0][HighestIndex]
begin
writeln ('StartFromIndexZero = false');
CreateTPAUpFromFragmentInvert (Highway, ATPAPosH, TPAPosH, FullWalkingPath);
end; // We've done the highway, now below, create the subpath
writeln ('** Lets debug our FullWalkingPath TPA');
DebugTheTPA (FullWalkingPath);
//nodeName := DetermineNodeName (FullWalkingPath[0]); // Since our full walking path HAS to start at a node, logically if there were no errors... the very first point should be a node. This will tell us the node we have to be at! :)
writeln ('** Node name: '+nodeName+' -- determined from Point('+inttostr(FullWalkingPath[0].x)+','+inttostr(FullWalkingPath[0].y)+')');
writeln ('A_PosS = '+inttostr(ATPAPosS));
writeln ('T_PosS = '+inttostr(TPAPosS));
CreateTPADownFromFragmentInvert (SubStreet, ATPAPosS, TPAPosS, SubStreetDesiredPath); // Create a path from SubStreet[ATPAPos][0] [which we remove later since Highway[ATPAPosH][TPAPosH] = SubStreet[ATPAPos][0]
//RemoveTPFromTPA (SubStreetDesiredPathTemp, SubStreetDesiredPath, 0); // Remove position [0] since that is the root spot that connects to the highway. Since our highway code walks to the root point of the SubStreet, it would just click it twice, and we don't want that.
writeln ('** Debug substreetdesiredpath TPA');
DebugTheTPA (SubStreetDesiredPath);
FullWalkingPath := CombineTPA (FullWalkingPath, SubStreetDesiredPath);
writeln ('**TPAs combined, lets debug:');
DebugTheTPA (FullWalkingPath);
//Determine node we should be at before walking the above path
GoToNodeFromAnywhere (nodeName); // This is what it SHOULD do if there is no error. Will crash if string is '', must but FAIL-SAFE in here later FAILSAFE
writeln ('** GONE to starting node');
wait (random(500));
WalkPath (FullWalkingPath); //walk generated path
wait (random(500)); // Prevent random stupid errors I guess, maybe should use FFlag(0); or something
TileToWalkTo := PointToTile (TP); // Turn our point into a tile
if TileOnMM (TileToWalkTo) then WalkToTile (TileToWalkTo, 1, 0) // If tile's on the minimap, walk to it NEEDS FAILSAFE
else FindPathToTile (TP, 6); // Else, blindwalk because it's far
end;

{******************************************************************************}
{ procedure function WalkTo (TP : TPoint) : Boolean; }
{ By: Cstrike }
{ Description: Will take you from your location to Tile(TP.x,TP.y). Probably }
{ will not work if you're somewhere far away with no node path [ex: wildy]. }
{ Returns true if you reach TP. }
{******************************************************************************}
function WalkTo (TP : TPoint) : Boolean;
var highwayTP, substreetTP, closestTP, rootSubstreetTP : TPoint;
ATPAPos, TPAPos, ATPAPosH, TPAPosH, highTPA, highTPAHighway : Integer;
TPA, FullWalkingPath, SubStreetDesiredPath, SubStreetDesiredPathTemp : TPointArray;
TTA : TTileArray;
TileToWalkTo, currentTile : TTile;
useSubstreet, startFromIndexZero : Boolean; // If this is true in the script, it will use substreets to get to required TP, false means it will use a highway and then attempt to walk to it
nodeName : String;
begin
if not LoggedIn then exit;
highwayTP := SubPointDistancesTP (Highway, TP);
if Distance (TP.x, TP.y, highwayTP.x, highwayTP.y) < 10 then RetrieveWalkCloseToHighway (TP, highwayTP)
else // Else if distance greater than 10
begin
substreetTP := SubPointDistancesTP (SubStreet, TP);
if Distance (TP.x, TP.y, highwayTP.x, highwayTP.y) < Distance (TP.x, TP.y, substreetTP.x, substreetTP.y) then
begin
writeln ('Highway >= 10, and highway closer');
RetrieveWalkCloseToHighway (TP, highwayTP);
end else
begin
writeln ('Highway >= 10, and substreet closer');
RetrieveWalkCloseToSubstreet (TP, substreetTP);
end;
end;
DebugCurrentPos;
end;

procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := ''; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure SetUpScript;
begin
Smart_Server := 157;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
SetupReflectionEx(true);
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
end;

//var myTPA, myTPAnew : TPointArray;
begin
SetUpScript;
SetupNodesAndPaths;
ClearDebug;
//WalkTo (Point(2934, 3198));
end.

Remember, this program is for retrieving and moving armies only. Theoretically you could have it walk back to a bank, but it will end up going to the highways first which would be inefficient.
If anyone is going to use it with code, make sure you have your own reflection walking set up for going back and forth between places, and use this as a failsafe… or to move accounts from location wherever to your desired location.

EXAMPLE:
Lets say im in lumby and I want to go to rimmington mines.
First it will retrieve me to the lumby north east node, then it will walk to the falador bank by going through lumby–>draynor–>fally… then it will down from the fally bank all the way to the mines. In the future I may be able to code it in a way to prevent it from the extra walking, but for now it works pretty nice :)

See img below to get a feel for where it can walk so far. I will add all the paths over time :)

Cstrike

2010-10-05 16:18:26

As an update, it does not retrieve properly between falador and barbarian village. I will be looking into this ASAP – but it can walk to anywhere near a defined path though! (Just retrieval is going wrong for that section only)

Becks

2010-10-05 16:34:36

Will the path go into the wildie? Collecting white berries = easy monneyy

Cstrike

2010-10-05 16:40:44

From: Becks
Will the path go into the wildie? Collecting white berries = easy monneyy


One of the problems with places blocked off like Al Kharid/Karamja/Wildy is the script can't differentiate when it's near a point that will permanently block it [al kharid gates, wildy ditch…etc] (unless this becomes a highly advanced script or Shuttleu makes his aryanweb).

What will happen though assuming it stays relatively the same is:

- Code will be added to detect if your tile range is in the wildy, if so, it will retrieve you to the closest bank (probably edge or varrock east)
- Has to walk right next to the line
- Use some autocoloring script or reflection include to locate the ditch
- Cross over ;)

If this all works out, that WILL be added one day!
How much do they sell for anyways? May be a good way to get starter money.

** BTW as a note, the script is for retrieving and walking to anywhere, unfortunately it isn't meant to be used as an end-all-be-all for walking. But it is good if you get lost in your script and upon logging in, it retrieves you safely so you don't get set to false and lose your char.

nickrules

2010-10-08 22:22:54

Got a reason to use this project lately, and I have to say, I was nothing short of amazed. great, great work. keep it up.

Cstrike

2010-10-08 22:46:53

From: nickrules
Got a reason to use this project lately, and I have to say, I was nothing short of amazed. great, great work. keep it up.


Thanks for the kind comments :)

I'm still working on fixing that one part in falador to barb vil that isn't working. Real life has been tossing crap at me and I need to sit down and debug it properly instead of throwing 10-15 minutes at it and getting nowhere.

Also if you have any suggestions, please suggest :)

Gu3st...

2010-10-09 15:02:35

I think I'll use some of your ideas for my color world walker :)
(The path system and so on)

Like I said last time: Good job! :):):)

Cstrike

2010-10-10 14:04:35

From: Zyt3x
I think I'll use some of your ideas for my color world walker :)
(The path system and so on)

Like I said last time: Good job! :):):)


If there's a solid color walker then that is the best. Hopefully this can be used as something to fall back on, because without color… my walking can break overnight with outdated hooks. Having color is just awesome ;)


UPDATE
Hell yeah, bug fixed, it should be stable now. Check it out at version 0.01 pre alpha. I need to add more paths, but it shouldnt glitch up between barb vil and fally anymore (i tested it multiple times).
I even updated some of the code

Beware, there will be a massive debug.

Coh3n

2010-10-15 18:42:48

Sorry cstrike that I haven't checked this out yet. My internet was down for a week, and I'm really busy with other things. I really want to test this though when I get a chance, it looks awesome! :) Great job!

Cstrike

2010-10-15 19:26:54

From: Coh3n
Sorry cstrike that I haven't checked this out yet. My internet was down for a week, and I'm really busy with other things. I really want to test this though when I get a chance, it looks awesome! :) Great job!


No worries :) I'm working on reflection ATM so you have lots of time ;)

bolshak25

2010-10-30 15:23:42

gravedig/bump

any update with the below level 60 totals? i would love to move my new army and i honestly dont know how to edit or fix this. if you need multiple accounts to test it with i have alot now and would easily let you use

Cstrike

2010-10-30 15:31:03

From: bolshak25
gravedig/bump

any update with the below level 60 totals? i would love to move my new army and i honestly dont know how to edit or fix this. if you need multiple accounts to test it with i have alot now and would easily let you use


Currently I remoddeled the function names and added some cool stuff.
If you have one account near each location, I'd need to test them all.

What I will have to do first is develop my own WalkPath procedure (or modify it a bit from Drags111's procedure) so that it can have things in it like antiban…etc

Coh3n

2010-10-30 17:38:23

From: bolshak25
gravedig/bump

any update with the below level 60 totals? i would love to move my new army and i honestly dont know how to edit or fix this. if you need multiple accounts to test it with i have alot now and would easily let you use

This can be added somewhere so it will look for the text. It's in MSI_Flag, but I don't sure what cstrike uses.

if (FindNPCChatText('erous', Nothing)) then // Only if total level < 60
begin
ClickContinue(True, True);
t := GetSystemTime + 5000;
while (GetSystemTime < t) do
begin
Wait(500 + Random(300));
if (FindNPCChatText('eave', ClickLeft)) then
Break;
end;
end;

bolshak25

2010-10-31 13:59:21

does it matter where i put that? and how exactly do i input where i want to go? const doesnt have that and i honestly cant read code very well yet

Coh3n

2010-10-31 14:03:08

It would have to be put where he calls whatever Flag function he uses. I'm also not sure as to how it's setup, you'll have to wait for cstrike to explain that one.

Cstrike

2010-10-31 14:34:24

I'm working on re-writing drags111's path walker (because I have no idea how to insert code to check for the interface at the bottom), then it will be very easy to insert whatever code we want while walking – including things like antiban :)

bolshak25

2010-10-31 14:35:48

so are you abandoning this one?

Cstrike

2010-10-31 14:47:31

From: bolshak25
so are you abandoning this one?


I currently have it upgraded with more stuff (but not released yet). I want to ensure the next release will be more or less complete to the point where it will be stable/flawless and able to be included anywhere.
I renamed all the functions so that there is no chance of it clashing with any other pre-defined variables (since some of the names are really generic like DebugTheTPA…etc)

This project will be completed fully and implemented hopefully in large scripts like MSI, and another project I have underway ;)

bolshak25

2010-10-31 15:05:18

will it be easy to use for armies not using large scripts, but just using this one? like go from point x to point y and you just input the points letters/numbers?

Cstrike

2010-10-31 15:46:21

From: bolshak25
will it be easy to use for armies not using large scripts, but just using this one? like go from point x to point y and you just input the points letters/numbers?


Yep :)

All you have to do is find the X and Y tile that you want, and call


WalkTo(Point(x,y));

or in the new verson I will release:

RW_WalkTo(x,y);

and just do code like


begin
repeat
WalkTo(YourPointhere);
NextPlayer(false);
until (AllPlayersInactive)
end.

Then run it, and in however long it, takes your entire army will be moved.

EDIT: POST 666 :f::sasmokin:

bolshak25

2010-10-31 17:31:09

are you gunna add the under 60 thing that was posted? that would be extremely helpful for alot of new armies that people make

Cstrike

2010-10-31 18:48:02

From: bolshak25
are you gunna add the under 60 thing that was posted? that would be extremely helpful for alot of new armies that people make


Of course ;)

ruler

2010-10-31 22:02:31

I been working on a web for years now. Here are the features i have right now that down the road you all might needed hence should plan for. You will have to write this as a plugin to get any speed.

The nexus web has 4300 nodes and over 10000 edges, 50000 sub nodes.

Produces results in 3ms. Custom shortest path algo, took many attempts.

It takes into account Inventory, Equipment, Skill Levels, Bank Cache, Quests competition.

Re-Writes for when the linear closest *node to a place is not actually the closest. When we actually get can reach context we can re-calc and select a better point based on can reach.

restarting on some actions, used when an action moves us to a random place in which case we need to calculate a new plan and follow it.

teleporting using equipment / inventory / spells etc, only got like 20 support not many users. Most scripts hard code solutions.

Banking then teleporting.

sub queries for missing item requirements, take the path to point we can't cross and and run a sub query to find the closest bank along the way while blocking usage of any requirements we don't have up to this point, then restart.

stacking item requirements from multiple things example gold requirement.

handling inv slots, in terms of depositing items when needed and withdrawing when needed.

(no fun),(hardly used) handling dynamic additions while running in a multi threaded environment where a query may be on going and additions are being done at the same time Example Fight Cave, Pest Control


It is currently Built to do Many Points to Many Points. It is lacking Many Point to Many Point to Many Point.

One person right now emulates shortest bank cycle by.
Dungeon DUN = some place;
where Bank b has lowest cost round trip to DUN;

done by
for each bank (get distance from dungeon to bank + get distance from bank to dungeon )
Which is like 50 queries or so. One day i might integrate it all into one efficient algorithm, object creations, re use buffers from calc to calc.

With the results the person pre withdraws all the requirements for the round trip, teleports, gold etc..

Cstrike

2010-10-31 22:49:57

Thus far I've been able to have my WorldWalker generate paths in less so quickly that there's only a very small bit of lag. It is generally not noticeable. In addition when it comes down to finding if it's stuck, based on an idea by Iluffsyeww, it will find quadrants of locations and then retrieve itself to ensure speed.

Due to the size of the project I decided to keep it Tile based and stuck around common paths. In total there maybe be 150-250 paths, which Simba can sail through in not too much time. It takes forever if you debug everything though, but with no writeln's it's pretty much 0.5 second max… and my computer is crap too.
The scripter can then move to a specific location and invoke his/her Reflection scripts.

Good luck with writing it. Why does it take so long though for you working on it? I did the world walker in a few days and if I spent another day or so filling in all the paths, it'd be fully functional and almost capable of what the nexus web can do (besides handling objects of course ;)). Thus far it works flawlessly and I've not had a problem with it.

nickrules

2010-11-06 22:25:54

Perhaps you could make a custom debug function?

Something like:

Procedure CDebug(Str: String, Wlevel:integer;);
begin
If DebugLevel >= WLevel then
Writeln(Str)
end;
Then you would add a constant to the top of the script called DebugLevel, which would be a number 1-10. Higher value = less debuged. Then open script in notepad, do a replace all 'Writeln' with CDebug. Then add the level of debug to your liking.

Might speed things up a bit… Or at least less clutter for those who don't need/want it.

Other than that, once again, I must say you've done an amazing job on this, as usual. Love using this.

Cstrike

2010-11-06 23:13:26

From: nickrules
Perhaps you could make a custom debug function?

Something like:

Procedure CDebug(Str: String, Wlevel:integer;);
begin
If DebugLevel >= WLevel then
Writeln(Str)
end;
Then you would add a constant to the top of the script called DebugLevel, which would be a number 1-10. Higher value = less debuged. Then open script in notepad, do a replace all 'Writeln' with CDebug. Then add the level of debug to your liking.

Might speed things up a bit… Or at least less clutter for those who don't need/want it.

Other than that, once again, I must say you've done an amazing job on this, as usual. Love using this.


Once I fix this minor health issue thats been plauging me (explains why I'm on these forums 12 hours a day with near 100% activity xD), I'll be able to completely finish this project, and make it fully integratable [sp?] into MSI with the debug fixed too :)

mormonman

2010-11-07 00:40:11

From: cstrike
Thus far I've been able to have my WorldWalker generate paths in less so quickly that there's only a very small bit of lag. It is generally not noticeable. In addition when it comes down to finding if it's stuck, based on an idea by Iluffsyeww, it will find quadrants of locations and then retrieve itself to ensure speed.

Due to the size of the project I decided to keep it Tile based and stuck around common paths. In total there maybe be 150-250 paths, which Simba can sail through in not too much time. It takes forever if you debug everything though, but with no writeln's it's pretty much 0.5 second max… and my computer is crap too.
The scripter can then move to a specific location and invoke his/her Reflection scripts.

Good luck with writing it. Why does it take so long though for you working on it? I did the world walker in a few days and if I spent another day or so filling in all the paths, it'd be fully functional and almost capable of what the nexus web can do (besides handling objects of course ;)). Thus far it works flawlessly and I've not had a problem with it.


I'm sorry but this walker is nothing compared to the nexus web.

Cstrike

2010-11-10 14:21:49

From: mormonman
I'm sorry but this walker is nothing compared to the nexus web.


I completely agree as well, but I'd say for what we have on the table, unless someone has the knowledge and time to re-create the nexus web… this is so far the best it's going to get.
It will be able to do everything the other web can, plus we can add in our own things to it as well.


And of course, you are always welcome to contribute, or show me how to create the nexus web so I could do it myself and/or with your help.

lordsaturn

2010-11-18 00:07:25

Have you thought about using Dijkstra/AStar for path finding?

Cstrike

2010-11-18 00:22:31

From: lordsaturn
Have you thought about using Dijkstra/AStar for path finding?


How does that work [Ive never heard of it]? :)

Gu3st...

2010-11-18 02:39:42

http://en.wikipedia.org/wiki/A*
http://en.wikipedia.org/wiki/Dijkstra's_algorithm

blulightning

2010-11-29 20:32:06

Hey cstrike, is this still being added too? I hate using the RSbot AIOwalker when I could be using an SRL home grown script

Cstrike

2010-11-29 20:44:19

From: Zyt3x
http://en.wikipedia.org/wiki/A*
http://en.wikipedia.org/wiki/Dijkstra's_algorithm

If there was a way for me to convert tha algorithm to Pascal/SRL stuff, I'd do it :)
But I have no idea on going about how to do it.

From: blulightning
Hey cstrike, is this still being added too? I hate using the RSbot AIOwalker when I could be using an SRL home grown script


So far this works, but is in the back-shed for now while I finish up solving all randoms.

Gu3st...

2010-11-30 06:26:36

From: cstrike
If there was a way for me to convert tha algorithm to Pascal/SRL stuff, I'd do it :)
But I have no idea on going about how to do it.
Use the search button ;)
mixster made a world walker using a* ("Astar" in thread title if I remember correctly)

Cstrike

2010-11-30 10:41:14

From: Zyt3x
Use the search button ;)
mixster made a world walker using a* ("Astar" in thread title if I remember correctly)


Damn I wish he commented it or made his variables more understandable :( Then I could just copy all my TPoints over or make a full out graph.


If someone could provide me with the logic flow of how A* worked I could implement it, thing is no one has been able to describe it quite right yet, not even the wiki (and probably also due to my mind being elsewhere).
I was thinking of also how it'd know not to cross fence lines and stuff like that as well. All would be part of the fun coding it.

Another thing I was thinking was this:
The string idea would work on p2p since it's one big line, wouldn't work on f2p since it's a circle (and needs to be a circle).

Sir R. M8gic1an

2010-12-09 21:13:42

Added World walker to MSI.

It now uses it to walk to every location.

I added the tracker to it. Let's see how good it is :)

http://villavu.com/repositories/msi/Extras/WorldWalker_cstrike.simba

It's called in MSI_ReflectionWalk

~RM

Cstrike

2010-12-09 23:20:04

Aaah I got to add more paths :P
Didn't quite get around to making all the uber good paths as I was solving randoms, but sure as hell works great for traveling between places.

Might also need a WalkPath([]); upgrade, as the WalkPath can't handle the <60 level error, and I can't inject the data into the middle of it to search for it without messing the function up.

One thing I proposed on the dev boards was to make WalkPathEx, then we could add not only the function to determine < 60 skill total, but also in addition add our own antiban features while walking! We'd be able to turn the screen and move everything up and down while it'd be walking.

Coh3n

2010-12-10 00:42:12

Nice. :)

Are we going to switch to MSI's debugging for this, or…?

mormonman

2010-12-10 01:08:13

From: Cstrike
One thing I proposed on the dev boards was to make WalkPathEx, then we could add not only the function to determine < 60 skill total, but also in addition add our own antiban features while walking! We'd be able to turn the screen and move everything up and down while it'd be walking.


Include-wide antiban isn't "antiban" it's "ban-me-please".
Just add a SRL_Proc to it, then the scripter can add their own antiban to it.

Cstrike

2010-12-10 01:27:59

From: mormonman
Include-wide antiban isn't "antiban" it's "ban-me-please".
Just add a SRL_Proc to it, then the scripter can add their own antiban to it.


Well naturally it'd be through including a TProc instead of it's own antiban, though quite some bad ambiguity on my end.

Coh3n

2011-02-14 01:34:52

Moved this to the Extras forum. We will be working on properly implementing this as an extra sometime in the near future (yes, this will mean multiple script support).

marpis

2011-02-14 01:46:13

From: Coh3n
Moved this to the Extras forum. We will be working on properly implementing this as an extra sometime in the near future (yes, this will mean multiple script support).


Using multiple scripts in a loop has been the aim for MSI from day one.
Why make it an extra? Why not use it in the core?

Coh3n

2011-02-14 19:40:43

From: marpis
Using multiple scripts in a loop has been the aim for MSI from day one.
Why make it an extra? Why not use it in the core?

The multiple script part will be in the core, it's the world walker that will be an Extra. Why? So the user can choose which world walker to use if someone was to make another one. Also because it was written by Cstrike, who is no longer here so if it doesn't work, it would probably be tough for one of us to maintain unfamiliar code. It would just be easier if the user can enable/disable it.