ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Nearest Wayshrine to Player (https://www.esoui.com/forums/showthread.php?t=10379)

CleetusTheDiabeetus 11/25/22 03:56 PM

Nearest Wayshrine to Player
 
Hello All,

I was looking for some guidance on where to start for creating an AddOn with a UI that displays the closest Wayshrine to a player's position.

I need to:
Determine Player PosX, PosY
Find All Wayshrine Locations
Calculate the closest wayshine from the players location
Output that information to a UI
Where can I pull player position?
Where can I get a list of wayshrines and their locations?

P.S:
I tried looking at the "FasterTravel" AddOn which determines the closest wayshrine to your quest but it was too advanced for me to figure out exactly what the functions they created were doing.

Thank you.

Baertram 11/25/22 05:36 PM

There is no api to detect that, you are not the first to try this.
You'd need to manually collect all washrine positions in a table of your addon, and update it every patch.
I hope you got time?;)

CleetusTheDiabeetus 11/25/22 06:36 PM

It has been done in the AddOn FasterTravel by manually adding each entry, I can copy their table I suppose. I don't know how they have determined which one is closest though.

They found the closest Wayshrine to your quest, I just need to change it to Closest to player.

Sharlikran 11/25/22 09:43 PM

Are you going to be detecting the closest player to you in your group? Because you can't get other players positions that aren't in your group.

Masteroshi430 11/25/22 11:37 PM

Quote:

Originally Posted by CleetusTheDiabeetus (Post 46815)
Hello All,

I was looking for some guidance on where to start for creating an AddOn with a UI that displays the closest Wayshrine to a player's position.

I need to:
Determine Player PosX, PosY
Find All Wayshrine Locations
Calculate the closest wayshine from the players location
Output that information to a UI
Where can I pull player position?
Where can I get a list of wayshrines and their locations?

P.S:
I tried looking at the "FasterTravel" AddOn which determines the closest wayshrine to your quest but it was too advanced for me to figure out exactly what the functions they created were doing.

Thank you.

There is a complicated code in minimap by Fyrakin doing that which I improved because POI_TYPE_WAYSHRINE also includes non wayshrines (e. g. the harborage) but it is quite a work to extract the code.
in function
Lua Code:
  1. function FyrMM.Wayshrines()
You do a loop with
Lua Code:
  1. for nodeIndex = 1, GetNumFastTravelNodes() do
, get node info with
Lua Code:
  1. GetFastTravelNodeInfo(nodeIndex)
then it is filtered to exclude houses and other non wayshrine stuff you can port to,
distance from each wayshrine is calculated with
Lua Code:
  1. math.sqrt((player.nx-wayshrine.nX)*(player.nx-wayshrine.nX)+(player.ny-wayshrine.nY)*(player.ny-wayshrine.nY))
then you have to do a table with all your wayshrines and their distances (which will update when player moves) to find the closest.

Baertram 11/27/22 07:43 AM

oh btw, player position:
Lua Code:
  1. local playerUnitTag = "player"
  2.  
  3. --- @return zoneId integer, worldX integer, worldY integer, worldZ integer
  4. local zoneId, worldX, worldY, worldZ = GetUnitWorldPosition(playerUnitTag)
  5. local zoneId, worldX, worldY, worldZ = GetUnitRawWorldPosition(playerUnitTag)
  6.  
  7. --- @return normalizedX number, normalizedZ number, heading number, isShownInCurrentMap bool
  8. local normalizedX, normalizedZ, heading, isShownInCurrentMap = GetMapPlayerPosition(playerUnitTag)

Maybe some libs can help here too, check the Lib descriptions for the ones relating to maps, positions, etc. and also to calculate between normalized and actual positions (not sure which lib was supporting this, maybe LibMapPin or LibGPS?).


All times are GMT -6. The time now is 05:04 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI