Map

This file is responsible for the TRSMap positioning system. It was made from scratch by Torwent but heavily inspired in the original TRSWalker by Slacky and it’s future iterations made by Olly. Without them, this wouldn’t be possible.


Map.InternalSetup

procedure TRSMap.InternalSetup();

Internal TRSMap setup method. This is caleld automatically for you and you shouldn’t need to call it.


Map.Setup

procedure TRSMap.Setup(filename: String; downscale: Int32 = 8);
procedure TRSMap.SetupRegions(filename: String; regions: TBoxArray; downscale: Int32 = 8);
procedure TRSMap.SetupRegion(filename: String; region: TBox; downscale: Int32 = 8);
procedure TRSMap.SetupFromURL(url: String; filename: String = ''; downscale: Int32 = 8; force: Boolean = False);
procedure TRSMap.SetupChunksEx(chunks: TBoxArray; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TRSMap.SetupChunkEx(chunk: TBox; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TRSMap.SetupChunks(chunks: array of TRSMapChunk; downscale: UInt32 = 8);
procedure TRSMap.SetupChunk(chunk: TRSMapChunk; downscale: UInt32 = 8);

Setup a TRSMap. If for some reason you can’t setup all your maps at once, you can later use the Add methods. This however is not recommended if you can avoid it, read more about it there.

Methods with the “Chunk” keyword are the recommended ones to use. If for some reason you need a custom map, use any of the other methods.

With the “Chunk” methods you are able to setup multiple levels from 0 to 3.


Map.Add

procedure TRSMap.Add(filename: String; downscale: Int32 = 8);
procedure TRSMap.AddRegions(filename: String; regions: TBoxArray; downscale: Int32 = 8);
procedure TRSMap.AddRegion(filename: String; region: TBox; downscale: Int32 = 8);
procedure TRSMap.AddFromURL(url: String; filename: String = ''; downscale: Int32 = 8; force: Boolean = False);
procedure TRSMap.AddChunksEx(chunks: TBoxArray; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TRSMap.AddChunkEx(chunk: TBox; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TRSMap.AddChunks(chunks: array of TRSMapChunk; downscale: UInt32 = 8);
procedure TRSMap.AddChunk(chunk: TRSMapChunk; downscale: UInt32 = 8);

TRSMap to add maps to an already setup TRSMap. If it’s possible to add all your maps during setup, avoid using this, because this has to repeat several slow step the setup methods already take.

Methods with the “Chunk” keyword are the recommended ones to use. If for some reason you need a custom map, use any of the other methods.

With the “Chunk” methods you are able to setup multiple levels from 0 to 3.


Map.CleanMinimap

procedure TRSMap.CleanMinimap(bitmap: TMufasaBitmap); static;

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


Map.GetCleanMinimap()

function TRSMap.GetCleanMinimap(): TMufasaBitmap; static;

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

Example:

Map.GetCleanMinimap().Debug();

Map.ScaleMinimap

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

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

Example:

Map.SetupChunks([[18,56,22,60], [42,50, 46, 45]], [0, 1]);
Map.ScaleMinimap(Map.GetCleanMinimap(), Map.Scaling).Debug();

Map.ScaledSearch

function TRSMap.ScaledSearch(bitmap: TMufasaBitmap; samples: Int32): TPointArray;

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


Map.FullSearch

function TRSMap.FullSearch(template, world: TMufasaBitmap; position: TPoint; out match: Single): TPoint;

Internal TRSMap method used to get the player position. This is used by TRSMap.Position() 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.


Map.Position

function TRSMap.Position(): TPoint;
function TRSMap.FullPosition(): T3DPoint;

Returns the players current position on the loaded map. TRSMap.FullPosition() also returns the current Z level.

Example:

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

Map.Height

function TRSMap.Height(p: TPoint = [-1,-1]; global: Boolean = True): Single;

Returns the height of the player at the specified coordinate if there’s a heightmap loaded. If p is [-1,-1], which is the default then we will use our current position. global decides wether the coordinate is converted to global coordinates or internal walker coordinates (read about walker regions for more info).

Example:

WriteLn rsw.GetHeight();

Map.Map2MM

function TRSMap.Map2MM(playerPoint, mapPoint: TPoint; radians: Double): TPoint;
function TRSMap.Map2MM(mapPoint: TPoint): TPoint; overload;

Converts a map coordinate to a point on the minimap.

Example:

var
  p: TPoint;
  bitmap: TMufasaBitmap;
begin
  Map.SetupChunk([49,54,49,54], [0, 1]); //Make sure you are in GE for this example.
  p := Map.Map2MM([4620, 2100]);         //This is just a random point in the ge with SRL map.

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

TRSMap.MM2Map

function TRSMap.MM2Map(playerPoint, minimapPoint: TPoint; radians: Single = $FFFF): TPoint;
function TRSMap.MM2Map(minimapPoint: TPoint; radians: Single = $FFFF): TPoint;

Converts a point on the minimap to a map coordinate.


TRSMap.MS2Map

function TRSMap.MS2Map(playerPoint, minimapPoint: TPoint; height: Int32 = 0; accuracy: Double = 0.2): TPoint;
function TRSMap.MS2Map(minimapPoint: TPoint; height: Int32=0; accuracy:Double=0.2): TPoint; overload;

Converts a point on the mainscreen to a map coordinate.


TRSMap.GetTileMS

function TRSMap.GetTileMS(playerPoint, mapPoint: TPoint; height: Double = 0; offset: Vector2 = [0,0]): TRectangle;
function TRSMap.GetTileMS(mapPoint: TPoint; height,  offset: Vector2 = [0,0]): TRectangle; overload;

Returns a tile on the mainscreen with the help of TRSMap and MM2MS.

Example:

Debug(Map.GetTileMS(Map.Position() + [10, 10]));

Map.DebugPosition

procedure TRSMap.DebugPosition();

Debugs the player position in the currently loaded map.

Example:

Map.Setup();
while True do
  Map.DebugPosition();

TRSMap.Debug

procedure TRSMap.Debug(map: ERSMapType = ERSMapType.NORMAL);

Displays one of the maps loaded.

Example:

Map.SetupChunks([[18,56,22,60], [42,50, 46, 45]], [0, 1]);
Map.Debug();
Wait(5000);
Map.Debug(ERSMapType.HEIGHT);

var Map

Global TRSMap variable