Skip to main content

Class MapUtil

Utility helper class for game maps and coordinate translations that don't require state.

The conversion methods were found in 89 54 24 10 56 41 55 41 56 48 81 EC, which itself was found by looking for uses of AddonText 1631.

Assembly: Dalamud.dll
View Source
Declaration
public static class MapUtil

Methods

ConvertWorldCoordXZToMapCoord(float, uint, int)

Helper method to convert one of the game's Vector3 X/Z provided by the game to a map coordinate suitable for display to the player.

View Source
Declaration
public static float ConvertWorldCoordXZToMapCoord(float value, uint scale, int offset)
Returns

System.Single: Returns a converted float for display to the player.

Parameters
TypeNameDescription
System.SinglevalueThe raw float of a game Vector3 X or Z coordinate to convert.
System.UInt32scaleThe scale factor of the map, generally retrieved from Lumina.
System.Int32offsetThe dimension offset for either X or Z, generally retrieved from Lumina.

ConvertWorldCoordYToMapCoord(float, int, bool)

Helper method to convert a game Vector3 Y coordinate to a map coordinate suitable for display to the player.

View Source
Declaration
public static float ConvertWorldCoordYToMapCoord(float value, int zOffset, bool correctZOffset = false)
Returns

System.Single: Returns a converted float for display to the player.

Parameters
TypeNameDescription
System.SinglevalueThe raw float of a game Vector3 Y coordinate to convert.
System.Int32zOffsetThe zOffset for this map. Retrieved from TerritoryTypeTransient.
System.BooleancorrectZOffsetOptionally enable Z offset correction. When a Z offset of -10,000 is set, replace
it with 0 for calculation purposes to show a more sane Z coordinate. |

WorldToMap(Vector3, int, int, int, uint, bool)

All-in-one helper method to convert a World Coordinate (internal to the game) to a Map Coordinate (visible to players in the minimap/elsewhere).

View Source
Declaration
public static Vector3 WorldToMap(Vector3 worldCoordinates, int xOffset = 0, int yOffset = 0, int zOffset = 0, uint scale = 100, bool correctZOffset = false)
Returns

System.Numerics.Vector3: Returns a Vector3 representing visible map coordinates.

Parameters
TypeNameDescription
System.Numerics.Vector3worldCoordinatesA Vector3 of raw World coordinates from the game.
System.Int32xOffsetThe offset to apply to the incoming X parameter, generally Lumina's Map.OffsetX.
System.Int32yOffsetThe offset to apply to the incoming Y parameter, generally Lumina's Map.OffsetY.
System.Int32zOffsetThe offset to apply to the incoming Z parameter, generally Lumina's TerritoryTypeTransient.OffsetZ.
System.UInt32scaleThe global scale to apply to the incoming X and Y parameters, generally Lumina's Map.SizeFactor.
System.BooleancorrectZOffsetAn optional mode to "correct" a Z offset of -10000 to be a more human-friendly value.

WorldToMap(Vector3, Map, TerritoryTypeTransient, bool)

All-in-one helper method to convert a World Coordinate (internal to the game) to a Map Coordinate (visible to players in the minimap/elsewhere).

View Source
Declaration
public static Vector3 WorldToMap(Vector3 worldCoordinates, Map map, TerritoryTypeTransient territoryTransient, bool correctZOffset = false)
Returns

System.Numerics.Vector3: Returns a Vector3 representing visible map coordinates.

Parameters
TypeNameDescription
System.Numerics.Vector3worldCoordinatesA Vector3 of raw World coordinates from the game.
Lumina.Excel.GeneratedSheets.MapmapA Lumina map to use for offset/scale information.
Lumina.Excel.GeneratedSheets.TerritoryTypeTransientterritoryTransientA TerritoryTypeTransient to use for Z offset information.
System.BooleancorrectZOffsetAn optional mode to "correct" a Z offset of -10000 to be a more human-friendly value.

WorldToMap(Vector2, int, int, uint)

All-in-one helper method to convert a World Coordinate (internal to the game) to a Map Coordinate (visible to players in the minimap/elsewhere).

View Source
Declaration
public static Vector2 WorldToMap(Vector2 worldCoordinates, int xOffset = 0, int yOffset = 0, uint scale = 100)
Returns

System.Numerics.Vector2: Returns a Vector2 representing visible map coordinates.

Parameters
TypeNameDescription
System.Numerics.Vector2worldCoordinatesA Vector2 of raw World coordinates from the game.
System.Int32xOffsetThe offset to apply to the incoming X parameter, generally Lumina's Map.OffsetX.
System.Int32yOffsetThe offset to apply to the incoming Y parameter, generally Lumina's Map.OffsetY.
System.UInt32scaleThe global scale to apply to the incoming X and Y parameters, generally Lumina's Map.SizeFactor.

WorldToMap(Vector2, Map)

All-in-one helper method to convert a World Coordinate (internal to the game) to a Map Coordinate (visible to players in the minimap/elsewhere).

View Source
Declaration
public static Vector2 WorldToMap(Vector2 worldCoordinates, Map map)
Returns

System.Numerics.Vector2: Returns a Vector2 representing visible map coordinates.

Parameters
TypeNameDescription
System.Numerics.Vector2worldCoordinatesA Vector2 of raw World coordinates from the game.
Lumina.Excel.GeneratedSheets.MapmapA Lumina map to use for offset/scale information.

GetMapCoordinates(IGameObject, bool)

Extension method to get the current position of a GameObject in Map Coordinates (visible to players in the minimap or chat). A Z (height) value will always be returned, even on maps that do not natively show one.

View Source
Declaration
public static Vector3 GetMapCoordinates(this IGameObject go, bool correctZOffset = false)
Returns

System.Numerics.Vector3: A Vector3 that represents the X (east/west), Y (north/south), and Z (height) position of this object.

Parameters
TypeNameDescription
Dalamud.Game.ClientState.Objects.Types.IGameObjectgoThe GameObject to get the position for.
System.BooleancorrectZOffsetWhether to "correct" a Z offset to sane values for maps that don't have one.
Exceptions

System.InvalidOperationException
Thrown if ClientState is unavailable.