ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Determining distance between two players (https://www.esoui.com/forums/showthread.php?t=7245)

code65536 07/27/17 12:41 PM

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?

Ayantir 07/27/17 12:46 PM

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

sirinsidiator 07/27/17 12:54 PM

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.

Ayantir 07/27/17 01:27 PM

hum, yes, true. forget libgroupsocket.


All times are GMT -6. The time now is 01:51 AM.

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