Map¶
This file is responsible for the TMap positioning system. It was made from scratch by Torwent but heavily inspired in the original TWalker by Slacky and it’s future iterations made by Olly. Without them, this wouldn’t be possible.
type TGamePosition¶
TGamePosition = record(TPoint)
Z: Int32;
Plane: Int32;
end;
Record holding a player’s full position:
X, Y coordinate
Z which is the player height on the current heightmap
Plane which is the player’s current plane if several planes are being used.
type TMap¶
TMap = record
Walker: TWalkerV2;
RegionIndex: Int32;
Region: TMapRegion;
Similarity: Double;
Cache: TMatchTemplateRGBCache;
Loader: TMapLoader;
Sample: TMapSample;
Filters: array of record
Box: TBox;
Inside: Boolean;
end;
IsSetup, DisableHeightmap: Boolean;
end
Record responsible for positioning.
Map.InternalSetup¶
procedure TMap.InternalSetup();
Internal TMap setup method. This is caleld automatically for you and you shouldn’t need to call it.
Map.Setup¶
procedure TMap.Setup(filename: String; downscale: Int32 = 8);
procedure TMap.SetupRegions(filename: String; regions: TBoxArray; downscale: Int32 = 8);
procedure TMap.SetupRegion(filename: String; region: TBox; downscale: Int32 = 8);
procedure TMap.SetupFromURL(url: String; filename: String = ''; downscale: Int32 = 8; force: Boolean = False);
procedure TMap.SetupChunksEx(chunks: TBoxArray; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TMap.SetupChunkEx(chunk: TBox; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TMap.SetupChunks(chunks: array of TMapChunk; downscale: UInt32 = 8);
procedure TMap.SetupChunk(chunk: TMapChunk; downscale: UInt32 = 8);
procedure TMap.SetupChunks(chunks: array of EChunk; downscale: UInt32 = 8); overload;
procedure TMap.SetupChunk(chunk: EChunk; downscale: UInt32 = 8); overload;
Setup a TMap.
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 TMap.Add(filename: String; downscale: Int32 = 8);
procedure TMap.AddRegions(filename: String; regions: TBoxArray; downscale: Int32 = 8);
procedure TMap.AddRegion(filename: String; region: TBox; downscale: Int32 = 8);
procedure TMap.AddFromURL(url: String; filename: String = ''; downscale: Int32 = 8; force: Boolean = False);
procedure TMap.AddChunksEx(chunks: TBoxArray; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TMap.AddChunkEx(chunk: TBox; levels: TIntegerArray = [0]; downscale: UInt32 = 8);
procedure TMap.AddChunks(chunks: array of TMapChunk; downscale: UInt32 = 8);
procedure TMap.AddChunk(chunk: TMapChunk; downscale: UInt32 = 8);
procedure TMap.AddChunks(chunks: array of EChunk; downscale: UInt32 = 8); overload;
procedure TMap.AddChunk(chunk: EChunk; downscale: UInt32 = 8); overload;
TMap to add maps to an already setup TMap. 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.ScaledSearch¶
function TMap.ScaledSearch(bitmap: TMufasaBitmap; samples: Int32): TPointArray;
Internal TMap 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 TMap.FullSearch(template, world: TMufasaBitmap; position: TPoint; out match: Single): TPoint;
Internal TMap method used to get the player position. This is used by TMap.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 TMap.Position(): TPoint;
function TMap.FullPosition(): TGamePosition;
Returns the players current position on the loaded map.
TMap.FullPosition() also returns the current Z level.
Example:
WriteLn(Map.Position());
WriteLn(Map.Similarity); // Check to see the match percentage if needed
Map.Height¶
function TMap.Height(p: TPoint = [-1,-1]; global: Boolean): Single;
function TMap.Height(p: TPoint = [-1,-1]): Single; overload;
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();
TMap.InRange¶
function TMap.InRange(p: TPoint; distance: Int32 = 4): Boolean;
function TMap.InRange(tpa: TPointArray; distance: Int32 = 4): Boolean; overload;
Method used to quickly check if we are within distance of a certain point or points. This distance is measure in pixels and in a radial way.
Map.Map2MM¶
function TMap.Map2MM(playerPoint, mapPoint: TPoint; radians: Double): TPoint;
function TMap.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;
TMap.MM2Map¶
function TMap.MM2Map(playerPoint, minimapPoint: TPoint; radians: Single = $FFFF): TPoint;
function TMap.MM2Map(minimapPoint: TPoint; radians: Single = $FFFF): TPoint;
Converts a point on the minimap to a map coordinate.
TMap.MS2Map¶
function TMap.MS2Map(playerPoint, minimapPoint: TPoint; height: Int32 = 0; accuracy: Double = 0.2): TPoint;
function TMap.MS2Map(minimapPoint: TPoint; height: Int32=0; accuracy:Double=0.2): TPoint; overload;
Converts a point on the mainscreen to a map coordinate.
TMap.GetTileMS¶
function TMap.GetTileMS(playerPoint, mapPoint: TPoint; height: Double = 0; offset: Vector2 = [0,0]): TRectangle;
function TMap.GetTileMS(mapPoint: TPoint; height, offset: Vector2 = [0,0]): TRectangle; overload;
Returns a tile on the mainscreen with the help of TMap and MM2MS.
Example:
Debug(Map.GetTileMS(Map.Position() + [10, 10]));
Map.DebugPosition¶
function TMap.DebugPosition(): TPoint;
Debugs the player position in the currently loaded map.
Example:
Map.Setup();
while True do
Map.DebugPosition();
TMap.Debug¶
procedure TMap.Debug(map: EGameMapType = EGameMapType.NORMAL; graph: Boolean = False);
Displays one of the maps loaded. You can optionally overlay the webgraph on top of you map.
Example:
Map.SetupChunks([[18,56,22,60], [42,50, 46, 45]], [0, 1]);
Map.Debug(EGameMapType.HEIGHT);
var Map¶
Global TMap variable