I've been writing an addon to tell users where to go. My dream is to display the kind of helpful info QuestHelper does, but for almost any location for any reason. I did think of trying to use QuestHelper to do that bit for me, but that seems to be a no-go.
I've managed to hook into TomTom, but as far as I can tell, that's not what I want when you're crossing zones and continents.
So if I can't (yet) make my addon as sophisticated as I want - simplify. I don't have to always tell users how to get there. I can find out info about the current continent and zone with GetCurrentMapContinent() and GetCurrentMapZone(), but they only give a number - not a name. Is there any way of finding that out? I'd rather not have to hard-code.
There is the issue that there may be many Reasons and many Locations the user could visit. And the user will want to know which is the closest Location for a particular Reason. So I've learnt how to calculate distance within a zone, but my main sticking point at the moment is, I can't tell users to cross zones. How do you know that zone 2 is next to zone 4?
At some point I would also like to include info about Taxi Flights and Portals. I would rather not rely on hard-coded information tables. If possible I would like my addon to "learn".
I've been looking at Taxi Flights and it seems I can learn when a user talks to the right npc with the event TAXIMAP_OPENED, and I know if the user is on a taxi with UnitOnTaxi("player"), and that's it. Really? Surely I've missed something.
This is turning into quite the ramble, so I'll shut up. :)
What you want to do is set a TomTom waypoint, not "hook into" TomTom's internal API. You can specify the zone along with the coordinates, and TomTom will handle all of the calculations, including how far away the waypoint is from your current location regardless of which continent or zone you or the waypoint are in.
For taxi flights, you want to listen for the PLAYER_CONTROL_LOST and PLAYER_CONTROL_GAINED, which fire when the player actually gets onto or off of a taxi. Listening for the event that fires when the player talks to a taxi master is kind of pointless unless you're doing some kind of auto-selection. Note that UnitOnTaxi won't return correct information right away, so you have to be a bit tricky.
In one of my addons, I need to know when the user is on a taxi, so when PLAYER_CONTROL_LOST fires, I start listening for ZONE_CHANGED, which fires when your move from one subzone (yes, the event names are confusing) to another. Since there is no taxi flight that stays within a single subzone, this event is guaranteed to fire at least once during a taxi flight, and usually within a few seconds of the flight starting since subzones are usually small. When it fires, I then query UnitOnTaxi, and set a flag if it returns true. To figure out when the user gets off the taxi, I listen for PLAYER_CONTROL_GAINED, and if the "on a taxi" flag was set, I clear the flag and know that the user was on a taxi and just landed, even though UnitOnTaxi hasn't caught up yet. See my addon Diplomancer for the actual code to do this.
Thanks Phanx for your reply. So I hadn't missed anything.I will be looking at your code.
The problem I have is that I need to replicate in some way the code that TomTom uses to calculate distance. Before I can tell TomTom the chosen location, my addon needs to decide where that location should be and one of the criteria is distance.
There may be many locations (eg: mailboxes, trainer, vendors, etc) where the user may wish to visit and one maybe closer, but across a zone boarder.
As far as I can tell TomTom does not have an official API for distance calculations over ranges that cover different zones. To unpick TomTom and learn how it does this means I'm having to learn a lot of LUA, most of which I don't really understand yet. Objects being one of them.