Skip to content

Commit 5685fda

Browse files
committed
fix(webwalking): failed to advance path
shouldn't fail anymore to advance path on last step when it's already there
1 parent 8228ddc commit 5685fda

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

osrs/walker.simba

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ begin
698698

699699
Self.WaitMoving(mapPt, minDist);
700700
if index = High(Self._Path) then
701-
Result := Self.Position().InRange(mapPt, Max(minDist, 3));
701+
Result := Self.Position().InRange(mapPt, minDist);
702702
end;
703703

704704
function TRSWalker.CrossDoor(me: TPoint; index: Integer; attempts: Integer = 3): Boolean;
@@ -913,7 +913,7 @@ begin
913913
nearest := Self._Path.NearestIndex(me);
914914
Self._Index := nearest;
915915

916-
while (nearest < High(Self._Path)) and (not Self.IsWalkable(Self._Path[nearest+1].Node, me, tmp, angle)) do
916+
while (nearest < High(Self._Path)) and not Self.IsWalkable(Self._Path[nearest+1].Node, me, tmp, angle) do
917917
Inc(nearest);
918918

919919
furthest := nearest;
@@ -933,20 +933,28 @@ begin
933933

934934
Result := index > previous;
935935

936-
if Biometrics.RandomBoolean(0.002) then
936+
if not Result then
937+
begin
938+
WriteLn(' idx: ', index, ' prev: ', previous, ' near: ', nearest, ' far: ', furthest, ' hi: ', High(Self._Path));
939+
end;
940+
941+
if Result and Biometrics.RandomBoolean(0.002) then
937942
index := Random(nearest, furthest);
938943
end;
939944

940-
function TRSWalker._WalkPathHelper(out index: Integer; out radians: Double; me: TPoint; fails: Integer; debug: Boolean): Integer;
945+
function TRSWalker.GetNextStep(out index: Integer; out radians: Double; me: TPoint; fails: Integer; debug: Boolean): Integer;
941946
begin
942947
if debug then
943948
Self.DebugPath(index, me);
944949

945-
Result := fails;
950+
if index = High(Self._Path) then
951+
Exit(0);
946952

947953
if Self._AdvancePath(index, me, radians) then
948954
Exit(0);
949955

956+
Result := fails;
957+
950958
//Likely haven't moved far enough to advance to next point
951959
if Inc(Result) < 5 then
952960
begin
@@ -997,17 +1005,20 @@ function TRSWalker.WalkPath(path: TGraphNodeArray; minDist: Integer = 0; debug:
9971005
var
9981006
me: TPoint;
9991007
idx, fails: Integer;
1000-
angle: Double;
1008+
radians: Double;
10011009
begin
10021010
Self._WalkPathSetup(path);
10031011

1004-
angle := Minimap.CompassRadians;
1012+
radians := Minimap.CompassRadians;
1013+
minDist := Min(minDist, Max(minDist, 3));
1014+
10051015
while Self.Walking and (fails < 10) do
10061016
begin
10071017
me := Self.Position();
10081018

1009-
fails := Self._WalkPathHelper(idx, angle, me, fails, debug);
1010-
if fails > 0 then Continue;
1019+
fails := Self.GetNextStep(idx, radians, me, fails, debug);
1020+
if fails > 0 then
1021+
Continue;
10111022

10121023
case Self._Node of
10131024
EGraphNode.NORMAL: if Self.WalkStep(me, idx, minDist) and (idx = High(Self._Path)) then Exit(True);

utils/webgraphgen.simba

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ script **BEFORE INCLUDING WASPLIB**:
1313
{$DEFINE WL_WEBGRAPHGEN_INCLUDED}
1414
{$INCLUDE_ONCE WaspLib/utils.simba}
1515
{$R-}
16+
{.$DEFINE WL_GENERATE_GRAPH_ALWAYS}
1617

1718
type
1819
(*

0 commit comments

Comments
 (0)