MM2MS

The core for our minimap to mainscreen projection. Supports rotation, and zoom, and resizable client.

MM2MS extends the Minimap interface as well as the mainscreen interface with functionality to convert coordinates to & from the minimap to the mainscreen (mm2ms).

Original work done by slacky.

It’s thanks to MM2MS that we can have the following grid:

_images/mm2ms.png

MM2MS by itself is just a 3D grid with infinite cross sections in all axis (read MM2MS Projector for more information).

It’s up to you to give it coordinates you want to be converted, for example:

{$I WaspLib/osrs.simba}

begin
  while True do
  begin
    Options.GetZoomLevel(False);
    Minimap.DebugTiles([]);
  end;
end.
_images/mm2ms_flat.gif

But you can for example, use it with a TRSMap heightmap data for more advanced projections:

{$I WaspLib/osrs.simba}

begin
  Map.Setup([ERSChunk.VARROCK]);

  while True do
  begin
    Options.GetZoomLevel(False);
    Map.DebugHeight();
  end;
end.
_images/mm2ms_height.gif

TRSMM2MS

Main record responsible for minimap to mainscreen (MM2MS) conversion.


MM2MS.Run

function TRSMM2MS.Run(arr: TVector3Array; roll: Single): TPointArray;

Core method that will run the TMM2MSProjector to convert points from the minimap to the mainscreen.

You will likely not need to use this directly and will only interact with the TRSMinimap and TRSMainScreen extensions below.


MM2MS variable

Global TRSMM2MS variable.

It’s unlikely you need to use this directly.

You usually only need the TRSMinimap and TRSMainScreen extensions below.


Minimap Vectors To MainScreen

function TRSMinimap.Vectors2MS(vectors: TVector3Array; angle: Single): TPointArray;
function TRSMinimap.Vector2MS(vector: TVector3; angle: Single): TPoint;

Converts a minimap vector or vectors to the mainscreen with the help of MM2MS.


Minimap Points To MainScreen

function TRSMinimap.Points2MS(points: TPointArray; angle: Single = $FFFF): TPointArray;
function TRSMinimap.Point2MS(pt: TPoint; angle: Single = $FFFF): TPoint;
function TRSMinimap.ATPA2MS(atpa: T2DPointArray; angle: Single = $FFFF): T2DPointArray; overload;

Converts minimap points to the mainscreen with the help of MM2MS.


Minimap Points To MainScreen Quads

function TRSMinimap.Vector2MSQuad(vector: TVector3; angle: Single; size: TVector2 = [1,1]; offset: TVector3 = [0,0,0]): TQuad;
function TRSMinimap.Point2MSQuad(pt: TPoint; size: TVector2 = [1,1]; angle: Single = $FFFF): TQuad;

Converts a minimap point pt or vector to a mainscreen TQuad with the help of MM2MS.

Example:

while True do
begin
  quad := Minimap.Point2MSQuad(Minimap.Center);
  ShowOnTarget(quad);
end;

Minimap Points To MainScreen Cuboids

function TRSMinimap.Vector2MSCuboid(vector, size: TVector3; angle: Single; offset: TVector3 = [0,0,0]): TCuboid;
function TRSMinimap.Point2MSCuboid(pt: TPoint; size: TVector3; angle: Single = $FFFF): TCuboid;

Converts a minimap point pt or vector to a mainscreen TCuboid with the help of MM2MS.

Example:

while True do
begin
  cuboid := Minimap.Point2MSCuboid(Minimap.Center, [2,2,6]);
  ShowOnTarget(cuboid);
end;

MainScreen.Point2MM

function TRSMainScreen.Point2MM(pt: TPoint; height: Integer; angle: Single; accuracy: Single = 0.2): TVector3;

Converts a mainscreen point pt to a minimap TPoint with the help of MM2MS. This is not an exact reversion of what MM2MS does but it’s very accurate.


Minimap.ZoomQuad

property TRSMinimap.ZoomQuad: TQuad;

Returns a TQuad on the minimap of what’s visible on the mainscreen at the current zoom level.

Example:

while True do
begin
  Options.GetZoomLevel(False);
  ShowOnTarget(Minimap.ZoomQuad);
end;

Minimap.PointOnZoomQuad

function TRSMinimap.PointOnZoomQuad(pt: TPoint): Boolean;

Returns True/False if a point pt is within our “zoom quad”. Read Minimap.ZoomQuad for more information.

Example:

WriteLn Minimap.PointOnZoomQuad(pt);

Minimap.RandomPointOnZoomQuad

function TRSMinimap.RandomPointOnZoomQuad(pt: TPoint; randomness: Integer): TPoint;

Creates a random point within the zoom quad that is within randomness distance from pt.


Minimap.FacePoint

function TRSMinimap.FacePoint(pt: TPoint; randomness: Integer = 0): Boolean;

This method will rotate the camera so that pt is within the zoom rectangle without adjusting the zoom level.

Example:

WriteLn Minimap.FacePoint([620, 100]); //keep in mind this example uses a static point, you will probably never do this.

MainScreen.FacePoint

function TRSMainScreen.FacePoint(pt: TPoint; randomness: Integer = 0): Boolean; override;

Rotates the camera to face point pt.


MainScreen.NormalizeDistance

function TRSMainScreen.NormalizeDistance(dist: Integer; accuracy: Single = 1.05): Integer;

Converts a distance acquired from the *fixed client and default zoom to the current mainscreen.

Example:

// 20 pixels on the fixed client and default zoom(50) is currently x pixels at the current zoom & client size.
WriteLn(MainScreen.TranslateDistance(20));

Minimap.InZoomRange

function TRSMinimap.InZoomRangeEx(pt: TPoint; out corner: TPoint): Boolean;
function TRSMinimap.InZoomRange(pt: TPoint): Boolean;
function TRSMinimap.AnyInZoomRange(tpa: TPointArray): Boolean; overload;

Method used to know if a point ptis within reach of the Zoom rectangle without adjusting the zoom level. Check TRSMinimap.ZoomQuad for information on the zoom quad.

Example:

WriteLn Minimap.InZoomRange([620, 100]);

Minimap.GetZoomToPoint

function TRSMinimap.GetZoomToPoint(p: TPoint; randomness: Integer = 0): Integer;

This function gives us a zoom level where P would be visible in the MainScreen.

Example:

p := Minimap.GetDots(ERSMinimapDot.ITEM)[0]; //find an item dot and returns it's coodinates.
Options.SetZoomLevel(Minimap.ZoomToVisiblePoint(p));

Minimap.SetZoom2Point

function TRSMinimap.SetZoom2Point(pt: TPoint; randomness: Integer = 0): Boolean;

This function adjusts the zoom level so the point pt is true in TRSMinimap.InZoomRange().


Minimap.MakePointVisible

function TRSMinimap.MakePointVisible(p: TPoint): Boolean;

Uses both Minimap.Zoom2Point() and Minimap.FacePoint() to make a point visible on the Mainscreen.


Minimap.DebugTiles

procedure TRSMinimap.DebugTiles(dots: ERSMinimapDots = [ERSMinimapDot.PLAYER, ERSMinimapDot.NPC, ERSMinimapDot.ITEM]);

Simply meant for debugging purposes. Will draw a grid of tiles on the mainscreen with the help of MM2MS.

You can optionally specify which minimap ERSMinimapDot you want to highlight. By default all are highlighted.

Example:

Minimap.DebugTiles();

MainScreen.PlayerBox

property TRSMainScreen.PlayerBox: TBox;

Returns a TBox on the mainscreen that tightly bounds the player.

Results are cached per zoom level to avoid unnecessary recomputation.

Example:

{$I WaspLib/osrs.simba}

begin
  while True do
  begin
    Options.GetZoomLevel(False);
    ShowOnTarget(MainScreen.PlayerBox);
  end;
end.
_images/mm2ms_playerbox.gif