Walker

Walker, also commonly refered to as RSWalker and RSW is the go to tool for walking and accurate positioning.

How does it work?

The details are quite complex but to put it simply, the way it works is: - A large image of the game map is loaded. This image has to include the region you are on or things won’t work as expected. - A screenshot of your minimap is taken and, rotated north and cleaned (player, npc and item dots are removed). - This minimap screenshot is then searched on our loaded map image, the closest match is then returned as our position. - Once we have an accurate position, we can do all sort of things:

  • Accurately get the position of a tile

  • Accurately hover any visible tile with the help of mm2ms

  • Color search a tile

Things to keep in mind with TRSWalker: - Coordinates are relative to the map loaded. They are literally your pixel position in the map image.

If you load map A and B and map B contains map A somewhere that is not it’s top-left corner, their coordinates will not match even if you are standing in the same tile. So if you get your position and it tells you are at X = 300 and Y = 500 it means you are in the pixel X = 300 and Y = 500 of your map image.

  • Because we search our minimap inside our map to find our position, smaller maps are much faster. It’s not exactly porportional but almost, so if you have a map that has a total of 1000 pixels and it takes 50ms to get your position, a map with 2000 pixels will take almost exactly 100ms.

  • A map image cannot be smaller than the minimap and should not even be anywhere close to it’s size. Any area you think you might be standing on on your script should have at the very minimum a 75 extra pixels of “padding” because that’s the maximum visible distance of the minimap and even then, slightly more is recommended.

Variables for users to tweak: - ScreenWalk: When set to true, walker will use only the mainscreen to walk instead of the minimap. - AdaptiveWalk: When set to true, will enable and disable ScreenWalk depending on your distance to the target,

making walking use a mix of minimap and mainscreen walking. The closer your are to the target the more likely it is to use the mainscreen and the further you are the less likely. You can also play with RSW_ADAPTIVE_SCREEN_TOGGLE_DISTANCES values to customize the behavior.


type PRSWalker

TRSWalker pointer.


type TRSWalker_OnWalkEvent

Callback method to use while walking. This can be used to perform custom tasks while walking.

Example

procedure WalkerTasks(Walker: PRSWalker; Position: TPoint; Destination: TPoint);
begin
  Antiban.RandomTab();
end;

var
  rsw: TRSWalker;

begin
  rsw.Setup('world');
  rsw.OnWalkingEvent := @WalkerTasks;
end;

type TRSWalker_OnWalkEventEx

Callback object method to use while walking. This can be used to perform custom tasks while walking.

Example

procedure TRSWalker.WalkerTasks(Walker: PRSWalker; Position: TPoint; Destination: TPoint);
begin
  Antiban.RandomTab();
end;

var
  rsw: TRSWalker;

begin
  rsw.Setup('world');
  rsw.OnWalkingEventEx := @rsw.WalkerTasks;
end;

type TRSWalker

TRSWalker is the record responsbile for walking and position.


Walker.InternalSetup

procedure TRSWalker.InternalSetup();

Internal walker method automatically called by Walker.Setup(). You probably will never need to call this directly.


Walker.Free

procedure TRSWalker.Free;

Internal walker method automatically called on script termination. You probably will never need to call this directly. If you do, you won’t be able to use your walker until you set it up again.


Walker.Setup

procedure TRSWalker.Setup(Map: String; Scaling: Int32 = 8);
procedure TRSWalker.Setup(Map: String; Regions: TBoxArray; Scaling: Integer = 8); overload;
procedure TRSWalker.Setup(Regions: TBoxArray; Scaling: Integer = 8); overload;

Setup method to be called in scripts. There’s 4 versions of the method you can call depending on the parameters you pass in. All of them have a scaling parameter in common that defaults to 8. This is used to adjust the downscaling of the map used, lower downscaling makes walker more accurate at the cost of speed. The speed difference is more or less porportional to the scaling, higher being faster. Unless you have issues with wrong positions you should probably not touch it.

Map is the map name you want to load. The file is assumed to be in the walker maps directory: Simba/Includes/SRL/osr/walker/maps If the map is not there, an error will be thrown. You can optionally load only certain regions of the map. This is useful if there’s a map that has the area you want but it’s too slow due to it’s size. The regions are specified as a TBoxArray and they are cropped from the map you specify on setup and joined into a single map image. This type of setup retains the coordinates of the original map image. You can also optionally omit the Map name to make walker use the default SRL map which you can find in: Simba/Includes/SRL/osr/walker/map.png

Example

//The following are several setup examples. Keep in mind that if the file doesn't exist in the maps folder, Walker will throw an error.
var
  rsw: TRSWalker;

begin
  rsw.Setup('world');
  rsw.Setup('world.png');
  rsw.Setup('world', 6);
  rsw.Setup();
  rsw.Setup([[4460, 1900, 4800, 2250], [75, 75, 1000, 1000]]); //loads GE and lunar isle.
end;

Walker.CleanMinimap

procedure TRSWalker.CleanMinimap(Bitmap: TMufasaBitmap);

Internal walker method used to clear minimap dots from the minimap. You probably don’t need to use this.


Walker.GetCleanMinimap

function TRSWalker.GetCleanMinimap(): TMufasaBitmap;

Internal walker method used to “screenshot” the minimap and clean it with Walker.CleanMinimap(). You probably don’t need to use this directly but you can see what it does in the following example.

Example

var
  rsw: TRSWalker;

begin
  rsw.GetCleanMinimap().Debug();
end;

Walker.ScaleMinimap

function TRSWalker.ScaleMinimap(Bitmap: TMufasaBitmap; Scaling: Int32): TMufasaBitmap;

Internal walker method used to scale down the minimap to whatever TRSWalker.Scaling is. You probably don’t need to use this directly but you can see what it does in the following example.

Example

var
  rsw: TRSWalker;

begin
  rsw.ScaleMinimap(rsw.GetCleanMinimap(), rsw.Scaling).Debug();
end;

Walker.ScaledSearch

function TRSWalker.ScaledSearch(Bitmap: TMufasaBitmap; Samples: Int32): TPointArray;

Internal walker method used to get an initial TPointArray of possible positions. This is performed in a scaled down map with a scaled down minimap. This is very innacurate by itself but by ruling down most of the map in a scaled search before doing a full sized search speed has a dramatic boost. You probably won’t ever need to call this directly.


Walker.FullSearch

function TRSWalker.FullSearch(Templ, World: TMufasaBitmap; Position: TPoint; out Match: Single): TPoint;

Internal walker method used to get the player position. This is used by TRSWalker.GetMyPos() to determine how likely is the Position passed in, our actual position. This likelyhood is returned with Match which ranges from 0 to 1. You probably won’t ever need to call this directly.


Walker.GetMyPos

function TRSWalker.GetMyPos: TPoint;

Returns the players current position on the loaded map.

Example:

WriteLn(Walker.GetMyPos());

// Check to see the match percentage if needed
WriteLn(Walker.Similarity);

Walker.WorldToMM

function TRSWalker.WorldToMM(PlayerPoint, WorldPoint: TPoint; Radians: Double): TPoint;
function TRSWalker.WorldToMM(WorldPoint: TPoint): TPoint; overload;

Converts a walker coordinate to a point in the minimap.

Example:

var
  rsw: TRSWalker;
  p: TPoint;
  bitmap: TMufasaBitmap;

begin
  rsw.Setup([RSWalkerRegions.GRAND_EXCHANGE]); //Make sure you are in GE for this example.
  p := rsw.WorldToMM([4620, 2100]);            //This is just a random point in the ge with SRL map.

  bitmap.FromClient();
  bitmap.DrawCross(p, 4, $FFFFFF);
  bitmap.Free();
end;

Walker.CheckRunEnergy

procedure TRSWalker.CheckRunEnergy();

Internal method used to check and enable the player run. You will probably never need to call this directly.

The values used are hardcoded and if you don’t like them, it’s recommended you override the method. The following example shows how one could override the function to enable run at 50% energy everytime, keep in mind though, you shouldn’t do this, you should add randomness to it!

Example

procedure TRSWalker.CheckRunEnergy(); override;
begin
  if Minimap.IsRunEnabled() or (Minimap.GetRunEnergy() < 50) then
    Exit;
  Minimap.EnableRun();
end;

Walker.AdaptiveWalkCheck

procedure TRSWalker.AdaptiveWalkCheck(Position: TPoint);

Internal method used to check if adaptive walk should toggle and toggle TRSWalker.ScreenWalk. You will probably never need to call this directly.


Walker.DoMouseAhead

procedure TRSWalker.DoMouseAhead(Position: TPoint; Forced: Boolean = False);

Internal method used to pre-hover the next walking step. You will probably never need to call this directly.


Walker.WaitMoving

procedure TRSWalker.WaitMoving(Destination: TPoint; WaitUntilDistance: Int32);

Internal method used to wait while we are moving using walker. You will probably never need to call this directly.

This is where TRSWalker.OnWalkingEvent are called.


Walker.Click

function TRSWalker.Click(MinimapPoint: TPoint; Randomness: Int32): Boolean;

Internal method used by walker to handle clicking while walking. You will probably never need to call this directly.

If you wish to modify certain walker behaviors, it’s a good approach to override this function. For example, if you are screenwalking and you don’t like it right clicking > walk here when it hovers a tree you could use the following example.

Example

function TRSWalker.Click(MinimapPoint: TPoint; Randomness: Int32): Boolean; override;
var
  P: TPoint;
begin
  Result := True;

  if Self.ScreenWalk then
  begin
    Mouse.Move(Minimap.PointToMsRect(MinimapPoint).Mean());

    if not MainScreen.IsUpText(['Walk here', 'Tree', 'tree']) then
      Exit(ChooseOption.Select('Walk here'));
  end else
  begin
    P := MinimapPoint.Random(-Randomness, Randomness);
    while not Minimap.IsPointOn(P) do
      P := MinimapPoint.Random(-Randomness, Randomness);

    Mouse.Move(P);
  end;

  Mouse.Click(MOUSE_LEFT);

  // 15% chance of spam clicking
  if (Randomness > 0) and (Random() < 0.15) then
    for 0 to Random(3) do
    begin
      Mouse.Click(Mouse.Position(), MOUSE_LEFT);

      Wait(0, 150, wdLeft);
    end;
end;

Walker.WalkFinalStep

function TRSWalker.WalkFinalStep(PlayerPoint, WorldPoint: TPoint; WaitUntilDistance: Int32): Boolean;

Internal method used by walker when finishing walking a path. You will probably never need to call this directly but it can be used to take a single step.


Walker.WalkStep

function TRSWalker.WalkStep(PlayerPoint, WorldPoint: TPoint): Boolean;

Internal method used by walker while walking a path. You will probably never need to call this directly.


Walker.IsWalkable

function TRSWalker.IsWalkable(WorldPoint: TPoint; PlayerPoint: TPoint; Angle: Double): Boolean;

Internal method used by walker to decide if the destination point is within 1 click reach. You will probably never need to call this directly.


TRSWalker.WalkPath

function TRSWalker.WalkPath(Path: TPointArray; WaitUntilDistance: Int32 = 0): Boolean;

Walks a path of points taken from the loaded map. We advice that WaitUntilDistance is not 0.

Parameters

Path

Array of points taken from the loaded map to walk. Must be ordered from start to finish.

WaitUntilDistance

Determines when the method returns once the final point has been clicked. Default value: 0.

WaitUntilDistance=0 waits until the player has reached the final point.
WaitUntilDistance=20 waits until the player is within 20 pixels of the final point.

Example

Walker.WalkPath([[100,100],[120,120],[140,140],[160,160],[180,180]]);

TRSWalker.WalkBlind

function TRSWalker.WalkBlind(Destination: TPoint; WaitUntilDistance: Int32 = 0): Boolean;

“Blindly” walks to a point taken from the loaded map. A straight line is generated between the player’s position and destination which is then walked.

Parameters

Destination

Destination point taken from the loaded map.

WaitUntilDistance

Determines when the method returns once the final point has been clicked. Default value: 0.

WaitUntilDistance=0 waits until the player has reached the final point.
WaitUntilDistance=20 waits until the player is within 20 pixels of the final point.

Example

Walker.WalkBlind([300, 300]);

TRSWalker.WebWalk

function TRSWalker.WebWalk(Destination: TPoint; WaitUntilDistance: Int32 = 0; PathRandomness: Extended = 0): Boolean;

Web walks to the destination point on the loaded map. Does not handle any obstacles. Please run webber.simba to see how webgraphs are built.

Pre built webgraphs are available for “World” and “Zeah” when used.

Parameters

Destination

Destination point taken from the loaded map.

WaitUntilDistance

Determines when the method returns once the final point has been clicked. Default value: 0.

WaitUntilDistance=0 waits until the player has reached the final point.
WaitUntilDistance=20 waits until the player is within 20 pixels of the final point.
PathRandomness

Randomness to add to the path so the absoulte shortest path isn’t always taken. Must be between 0..1

Example

var Walker: TRSWalker;

Walker.Setup('world');
Walker.WebWalk([4595, 3575]); // Lumbridge

// Or use a location from the webgraph
Walker.WebWalk(WorldWeb.LOCATION_LUMBRIDGE);

TRSWalker.DebugPosition

procedure TRSWalker.DebugPosition();

Debugs the player position in the currently loaded map.

Example

var
  rsw: TRSWalker;
begin
  rsw.Setup();
  while True do
    rsw.DebugPosition();
end;

TRSWalker.GetTileMS

function TRSWalker.GetTileMSEx(Me, Loc: TPoint; Height:Double=0; Offx,Offy:Double=0): TRectangle;
function TRSWalker.GetTileMS(Loc: TPoint; Height:Double=0; Offx,Offy:Double=0): TRectangle;

Returns a tile on the mainscreen with the help of walker and mm2ms.

Example

Debug(rsw.GetTileMS(rsw.GetMypos() + [10, 10]));

TRSWalker.MSToWorld

function TRSWalker.MSToWorldEx(Me, Loc: TPoint; Height: Int32 = 0; Accuracy: Double = 0.2): TPoint;
function TRSWalker.MSToWorld(Loc: TPoint; Height: Int32=0; Accuracy:Double=0.2): TPoint;

Converts a point on the mainscreen to a walker point.