Quantcast Determining distance between two players - ESOUI
Thread Tools Display Modes
07/27/17, 12:41 PM   #1
code65536
AddOn Author - Click to view addons
Join Date: Mar 2016
Posts: 16
Determining distance between two players

Let's say I have two players in a group together. I would like to calculate the distance between these two players in units that are compatible with ability ranges and radii.

For example, the Circle of Protection ability has an ability radius of 500 (5 meters).

I've tried using the GetMapPlayerPosition function (calling it on "groupX" unit tags) to try to determine the distance between players (I get the x and y coordinates of two players and then sqrt the squared sums), and I end up getting something like 8.3 meters as the distance between two players who are approximately 5 meters apart (as measured using the CoP ability above).

Obviously, I am doing something wrong and this is not the correct way to calculate distances between players. At least, not in a unit that is compatible with the distance units used for ability ranges/radii.

What's the correct way to do this? Or is this even possible?
  Reply With Quote
07/27/17, 12:46 PM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,022
You need to use libGPS for global positionning, because maps are not scaled at a fixed size

then you'll have the 2 coords, then you'll have your distance.

ps: you also need to give a hug to sirinsidiator
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil

Last edited by Ayantir : 07/27/17 at 01:28 PM.
  Reply With Quote
07/27/17, 12:54 PM   #3
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,153
I don't see why libgroupsocket would be required for this? You can get the position of any group member on your own client. Other than that Ayantir is right. you need to convert the local positions into global ones, because different maps use different scaling. Then you just need to figure out what the relation between meters and the normalized global distance is.
__________________
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
07/27/17, 01:27 PM   #4
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,022
hum, yes, true. forget libgroupsocket.
__________________
Obsessive Compulsive Coder

My little french Guild: Cercle de l'Eveil
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Determining distance between two players

Thread Tools
Display Modes

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