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
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
public static float ConvertWorldCoordXZToMapCoord(float value, uint scale, int offset)
Returns
System.Single
: Returns a converted float for display to the player.
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The raw float of a game Vector3 X or Z coordinate to convert. |
System.UInt32 | scale | The scale factor of the map, generally retrieved from Lumina. |
System.Int32 | offset | The 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
public static float ConvertWorldCoordYToMapCoord(float value, int zOffset, bool correctZOffset = false)
Returns
System.Single
: Returns a converted float for display to the player.
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The raw float of a game Vector3 Y coordinate to convert. |
System.Int32 | zOffset | The zOffset for this map. Retrieved from TerritoryTypeTransient. |
System.Boolean | correctZOffset | Optionally 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
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
Type | Name | Description |
---|---|---|
System.Numerics.Vector3 | worldCoordinates | A Vector3 of raw World coordinates from the game. |
System.Int32 | xOffset | The offset to apply to the incoming X parameter, generally Lumina's Map.OffsetX. |
System.Int32 | yOffset | The offset to apply to the incoming Y parameter, generally Lumina's Map.OffsetY. |
System.Int32 | zOffset | The offset to apply to the incoming Z parameter, generally Lumina's TerritoryTypeTransient.OffsetZ. |
System.UInt32 | scale | The global scale to apply to the incoming X and Y parameters, generally Lumina's Map.SizeFactor. |
System.Boolean | correctZOffset | An 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
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
Type | Name | Description |
---|---|---|
System.Numerics.Vector3 | worldCoordinates | A Vector3 of raw World coordinates from the game. |
Lumina.Excel.GeneratedSheets.Map | map | A Lumina map to use for offset/scale information. |
Lumina.Excel.GeneratedSheets.TerritoryTypeTransient | territoryTransient | A TerritoryTypeTransient to use for Z offset information. |
System.Boolean | correctZOffset | An 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
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
Type | Name | Description |
---|---|---|
System.Numerics.Vector2 | worldCoordinates | A Vector2 of raw World coordinates from the game. |
System.Int32 | xOffset | The offset to apply to the incoming X parameter, generally Lumina's Map.OffsetX. |
System.Int32 | yOffset | The offset to apply to the incoming Y parameter, generally Lumina's Map.OffsetY. |
System.UInt32 | scale | The 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
public static Vector2 WorldToMap(Vector2 worldCoordinates, Map map)
Returns
System.Numerics.Vector2
: Returns a Vector2 representing visible map coordinates.
Parameters
Type | Name | Description |
---|---|---|
System.Numerics.Vector2 | worldCoordinates | A Vector2 of raw World coordinates from the game. |
Lumina.Excel.GeneratedSheets.Map | map | A 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
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
Type | Name | Description |
---|---|---|
Dalamud.Game.ClientState.Objects.Types.IGameObject | go | The GameObject to get the position for. |
System.Boolean | correctZOffset | Whether to "correct" a Z offset to sane values for maps that don't have one. |
Exceptions
System.InvalidOperationException
Thrown if ClientState is unavailable.