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
public static class MapUtil
Fields
NoRawZ
A raw Z coordinate of -30000 indicates that it has no value.
public const int NoRawZ = -30000
NoOffsetZ
A Dalamud.Excel.Sheets.TerritoryTypeTransient.OffsetZ value of -10000 indicates that the map position should not display a Z coordinate.
public const int NoOffsetZ = -10000
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.
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. |
ConvertMapCoordXYToWorldCoord(float, float, short)
Helper method to convert one of the map's X/Y coordinate to a world coordinate.
public static float ConvertMapCoordXYToWorldCoord(float value, float scale, short offset)
Returns
System.Single: A 3D world coordinate.
Parameters
| Type | Name | Description |
|---|---|---|
System.Single | value | The coordinate value. |
System.Single | scale | The SizeFactor value of the Map row. |
System.Int16 | offset | The OffsetX/OffsetY value of the Map row. |
ConvertWorldCoordYToMapCoord(float, int, bool)
Helper method to convert a game Vector3 Y coordinate to a map coordinate suitable for display to the player.
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. |
ApplyTerritoryOffsetToWorldCoordianteY(uint, float)
Helper method to apply Dalamud.Excel.Sheets.TerritoryTypeTransient.OffsetZ to a Y (altitude) value of a coordinate.
public static int ApplyTerritoryOffsetToWorldCoordianteY(uint territoryId, float y)
Returns
System.Int32: An adjusted altitude.
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | territoryId | The TerritoryType Id. |
System.Single | y | The y-coordinate value. |
RemoveTerritoryOffsetFromWorldCoordinateY(uint, float)
Helper method to remove the Dalamud.Excel.Sheets.TerritoryTypeTransient.OffsetZ from a Y (altitude) value of a coordinate.
public static float RemoveTerritoryOffsetFromWorldCoordinateY(uint territoryId, float y)
Returns
System.Single: An adjusted altitude.
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | territoryId | The TerritoryType Id. |
System.Single | y | The y-coordinate value. |
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).
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. |
Remarks
Note that this method will swap Y and Z in the resulting Vector3 to appropriately reflect the game's display.
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).
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. |
Dalamud.Excel.Sheets.Map | map | A Lumina map to use for offset/scale information. |
Dalamud.Excel.Sheets.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. |
Remarks
Note that this method will swap Y and Z to appropriately reflect the game's display.
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).
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).
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. |
Dalamud.Excel.Sheets.Map | map | A Lumina map to use for offset/scale information. |