View Single Post
11/25/22, 11:37 PM   #5
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
Originally Posted by CleetusTheDiabeetus View Post
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.
  Reply With Quote