View Single Post
05/24/14, 02:24 PM   #4
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 656
That makes sense, sure they don't want players exploiting the API. I only need X and Y, I don't need Z. Say the player's position is [X] = 0.467469, [Y] = 0.409835 and the position of the target is [X] = 0.415760, [Y] = 0.427441. At the moment, if someone were to make a combat mod, it is returning X and Y for NPCs, so it's not really protected to prevent misuse.

At the moment most of the equations I have seen for calculating the distance of a harvest node, a Crate, a barrel, an NPC seem to use just the difference of x1 and x2, then y1 and y2. HarvestMap, uses more of what I am looking for.



Standard Form: (x-a)2 + (y-b)2 = r2

HarvestMap:

dx = entry[1] - x
dy = entry[2] - y
dx * dx + dy * dy < 0.000025 ( 0.005 ^ 2 )

Say the NPC, Barrel, Crate, Sack, is at the center (a,b) and the player is at (x,y). I want to calculate that distance. Basically that is what is happening in RangeReticle. I tossed in a plethora of d("") lines to print out information. The mod successfully returned my distance from the center of the circle (a,b) in meters.

I could have been standing on the circle the same "r" distance from (a,b) and RangeReticle calculated the distance correctly. However, when I went to use GetMapPlayerPosition('reticleover') to get the position of what my reticle was on, all the values were 0, not just the Z value, but X and Y also.

Which is why I am wondering if there is another option.

Warning: Spoiler

That is the function I used from RangeReticle to test with. I basically turned it into a function I could pass the arguments to of the Node. So say the Node is a fishing hole, I was passing the locations of all the fishing holes to that function.

Lua Code:
  1. for i = 1, #sv do
  2.         local item = sv[i]
  3.        
  4.         d("Range of loot : " .. getTargetDistance(item[1], item[2]).range)
  5.     end
Just to see what the values were, and what it returned. It returns a nice neat distance of 0 to, oh say 48 meters.

Well that is a lot to calculate, and I could ask permission to use the code, but I want to use my own code. In fact all I really want to use is Standard Form of (x-a)2 + (y-b)2 = r2. I can't get (a,b) from GetMapPlayerPosition('reticleover') unless it's an NPC.

Last edited by Sharlikran : 05/24/14 at 02:27 PM.
  Reply With Quote