Heyup i hope you dont mind readySteadyGo but i have made a few modifications to your webWalk ..
i have found it slow to Begin the Walk at times
i have fixed this i think .. works for me :)
by Moving Closest Node into its own Function and
Added DoWalk to detect Run energy over 50% and to Enable Run
// WebWalk.simba by ReadySteadyGo
// Updated By Sm0K3 : Moved ClosestNode into own Function . Reason: i found that this would speed up the start of the walking process
// : Added Energy detection and running . Reason: So You Can RUN
const // Location Bookmarks
VARROCK_EAST_BANK = 0;
VARROCK_WEST_BANK = 48;
const // Maps
WORLD_MAP = 0;
type
TGraph = record
Node : TPointArray;
Edge : TPointArray;
Dist : TIntegerArray;
Previous : TIntegerArray;
Visited : Array Of Boolean;
end;
var
WorldMap: TGraph;
// Loads the Web information
procedure LoadWeb;
begin
WorldMap.Node := [Point(3254, 3422), Point(3248, 3430), Point(3235, 3431), Point(3224, 3429), Point(3213, 3425), Point(3203, 3430), Point(3191, 3431), Point(3177, 3429), Point(3165, 3426), Point(3155, 3418), Point(3142, 3417), Point(3131, 3417), Point(3117, 3420), Point(3109, 3422), Point(3097, 3421), Point(3271, 3430), Point(3282, 3429), Point(3287, 3421), Point(3289, 3412), Point(3291, 3400), Point(3292, 3389), Point(3260, 3429), Point(3263, 3416), Point(3259, 3406), Point(3253, 3401), Point(3252, 3395), Point(3242, 3390), Point(3230, 3391), Point(3220, 3391), Point(3212, 3390), Point(3211, 3402), Point(3211, 3411), Point(3211, 3419), Point(3212, 3378), Point(3216, 3366), Point(3223, 3359), Point(3198, 3422), Point(3204, 3412), Point(3212, 3436), Point(3201, 3444), Point(3191, 3453), Point(3178, 3458), Point(3167, 3464), Point(3164, 3474), Point(3164, 3486), Point(3172, 3453), Point(3173, 3440), Point(3185, 3450), Point(3186, 3440), Point(3170, 3414), Point(3171, 3403), Point(3174, 3392), Point(3179, 3383)];
WorldMap.Edge := [Point(0, 1), Point(1, 2), Point(2, 3), Point(3, 4), Point(4, 5), Point(5, 6), Point(6, 7), Point(7, 8), Point(8, 9), Point(9, 10), Point(10, 11), Point(11, 12), Point(12, 13), Point(13, 14), Point(15, 16), Point(16, 17), Point(17, 18), Point(18, 19), Point(19, 20), Point(0, 21), Point(21, 22), Point(22, 23), Point(23, 24), Point(22, 0), Point(1, 21), Point(21, 15), Point(23, 25), Point(25, 26), Point(26, 27), Point(27, 28), Point(28, 29), Point(29, 30), Point(30, 31), Point(31, 32), Point(32, 4), Point(29, 33), Point(33, 34), Point(34, 35), Point(6, 36), Point(36, 37), Point(37, 30), Point(3, 38), Point(38, 39), Point(39, 40), Point(40, 41), Point(41, 42), Point(42, 43), Point(43, 44), Point(42, 45), Point(45, 46), Point(41, 47), Point(47, 48), Point(48, 6), Point(48, 7), Point(7, 46), Point(46, 8), Point(8, 49), Point(49, 50), Point(50, 51), Point(51, 52)];
end;
procedure DoRun;
begin
if R_GetMMLevels('run') > 50 then
SetRun(True);
end;
// Finds the Closest Node in 'Graph' from the location 'Source'
function ClosestNode(Source: TPoint; Graph: TGraph): Integer;
var i: Integer;
begin
Result := 0;
for i:= 0 to High(Graph.Node) do
begin
if Distance(Source.x, Source.y, Graph.Node[i].x, Graph.Node[i].y) < Distance(Source.x, Source.y, Graph.Node[Result].x, Graph.Node[Result].y) then
Result := i;
end;
end;
// Blindly Walks to 'Target'
function BlindWalk(Target: TPoint): Boolean;
begin
Result := r_WebWalk(PointToTile(Target));
end;
// Uses the Dijkstra algorithm to determine the shortest path
function ShortestPath(Source, Target: Integer; Graph: TGraph):TIntegerArray;
var
i, u: Integer;
Current, TempDist: Integer;
Neighbours: TIntegerArray;
begin
SetLength(Graph.Dist, Length(Graph.Node));
SetLength(Graph.Previous, Length(Graph.Node));
SetLength(Graph.Visited, Length(Graph.Node));
for i:= 0 to high(Graph.Node) do // Initializations
begin
Graph.Dist[i] := -1; // Unknown distance function from source to v
Graph.Previous[i] := -1; // Previous node in optimal path from source
Graph.Visited[i] := False;
end;
Graph.Dist[source] := 0; // Distance from source to source
Current := source;
repeat
SetLength(Neighbours, 0);
for i := 0 to high(Graph.Edge) do
begin
if Graph.Edge[i].x = Current then
begin
SetLength(Neighbours, Length(Neighbours) + 1);
Neighbours[High(Neighbours)] := Graph.Edge[i].y;
end;
if Graph.Edge[i].y = Current then
begin
SetLength(Neighbours, Length(Neighbours) + 1);
Neighbours[High(Neighbours)] := Graph.Edge[i].x;
end;
end;
for i := 0 to High(Neighbours) do //Check Unvisited Neighbour Nodes
begin
if Graph.Visited[Neighbours[i]] then
Continue;
TempDist := Distance(Graph.Node[Neighbours[i]].x, Graph.Node[Neighbours[i]].y, Graph.Node[Current].x, Graph.Node[Current].y);
TempDist := Graph.Dist[Current] + TempDist;
if (TempDist < Graph.Dist[Neighbours[i]]) or (Graph.Dist[Neighbours[i]] = -1) then
begin
Graph.Dist[Neighbours[i]] := TempDist;
Graph.Previous[Neighbours[i]] := Current;
end;
end;
Graph.Visited[Current] := True;
if (Current = Target) then
Break;
Tempdist := -1;
for i:= 0 to high(Graph.Node) do // Node with smallest Dist
begin
if (Graph.Dist[i] = - 1) or Graph.Visited[i] then
Continue;
if (Graph.Dist[i] < TempDist) or (TempDist = -1) then
begin
TempDist := Graph.Dist[i];
Current := i;
end;
end;
until False;
// Traces Shortest Path
u := Target;
SetLength(Result, 0);
repeat
SetLength(Result, Length(Result)+1);
for i := High(Result) - 1 downto 0 do
Result[i+1] := Result[i];
Result[0] := u; //insert u at the beginning of S
if u = Source then
Break;
u := Graph.Previous[u];
until False;
end;
// Walks to the Closest node in the TGraph: CGraph
Function WalkTOcNode(CLoc:Integer; CGraph:TGraph): Boolean;
var i, cNode: Integer;
begin
cNode := ClosestNode(GetMyPos,CGraph);
if BlindWalk(CGraph.Node[cNode]) then
begin
WriteLn('Blind Walked to nearest Node');
end else
WriteLn('Failed to reach nearest node!');
end;
// Walks from your current position to the TargetNode which uses the Bookmark Constants at the top of this Include
function WebWalk(TargetNode: Integer; Graph: TGraph): Boolean;
var
i, cNode: Integer;
IntArray: TIntegerArray;
PtArray: TPointArray;
begin
cNode := ClosestNode(GetMyPos, Graph);
IntArray := ShortestPath(cNode, TargetNode, Graph);
SetLength(PtArray, Length(IntArray));
for i:= 0 to High(IntArray) do
PtArray[i] := Graph.Node[IntArray[i]];
DoRun;
Result := WalkPath(PtArray);
if Result then
begin
WriteLn('Walked shortest path to Target Node');
end else
WriteLn('Failed to make it through the web!');
end;
// Walks from your current position to the tile defined by 'Target'
function WebWalkEx(Target: TPoint; Graph: TGraph): Boolean;
var
ClosestToTarget: Integer;
begin
Result := False;
ClosestToTarget := ClosestNode(Target, Graph);
DoRun;
if WebWalk(ClosestToTarget, Graph) then
Result := BlindWalk(Target);
if Result then
begin
WriteLn('Blind Walked to Target Tile');
end else
WriteLn('Failed to Walk from Target Node to Target Tile!');
end;