Thread Tools Display Modes
06-15-13, 12:35 AM   #1
Lazare
An Aku'mai Servant
 
Lazare's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 36
Need help please with scripting...

Trying to figure out how to:
Target a NPC, get its name and map Coordinates, then output them to the GENERAL chat channel.
I have found how to get MY coordinates and output them to the default chat window and thru a macro do a "/1 %t is up" but can't add coordinates to it. Been keeping me up all night trying to figure this out. Thought it would be a simple thing to be able to target a NPC and either click a button or do a /command to send a report tot he world, for something like doing the barrens commanders and their location to get groups of ppl to kill them.

Thanks in advance!
  Reply With Quote
06-15-13, 12:52 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Sending your own coordinates alongside the npc name is a good compromise, because by the time you can target it you're pretty close.

The added complexity in trying to adjust for the distance from you is really not worth it for a few yards of difference.
(made even more of a hassle since you would also have to be targeting it face-on or have it in minimap range to get its angle)

Edit: If your question was more along the lines of a specific script you can give this a try.
Code:
/run SendChatMessage(("%s is up! %s(%.1f %.1f))"):format(UnitName('target'),GetMinimapZoneText(),GetPlayerMapPosition('player')),"CHANNEL",nil,GetChannelName(GENERAL))
Drycoded and untested.

If you want a button for it, put it in a macro.

Last edited by Dridzt : 06-15-13 at 01:15 AM.
  Reply With Quote
06-15-13, 08:18 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
To elaborate, it's not possible for addons to get the exact coordinates of NPCs. You can only get the coordinates for your own character, and for the player characters in your current party or raid group. You can't even get coordinates for your pet, or for the pets of group members.

You can estimate the coordinates of an NPC with a unit token (eg. target, focus, party3target, boss2) by figuring out which way the player is facing, approximating how far away the NPC is (by checking spell ranges and assuming that something in range of your 20-yd spell but out of range of your 40-yd spell is 30 yds away on average), and doing a lot of math to guess coordinates that may or may not be anywhere near the real coordinates.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
06-20-13, 07:18 PM   #4
Lazare
An Aku'mai Servant
 
Lazare's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 36
Thanks much, will try this tonight!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help please with scripting...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off