HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Movement orders

03-15-2003, 04:37 AM#1
Ari
I wanted to see how close a unit ever came to the actual point you ordered them to go to.
I created the following code:

local location p

set p = GetOrderPointLoc()


[later, when movement is done]
call DisplayTextToForce( GetPlayersAll(), R2S(DistanceBetweenPoints(GetUnitLoc(udg_Unit), p) ))

In theory, this code should record the location of the issued movement order, and then after a unit has arrived at its destination, display to the user the distance between the unit's postion and where it was *supposed* to go. In tests, I've discovered that this distance is often 10-15 and at least once was around 32, or so. This isn't a huge, gameplay affecting issue (since even a discrepancy of 50 would barely be noticable to the eye unless you were looking for it), but it was somewhat important to a trigger of mine.

Can anybody confirm this and/or think of a reason why that is (note, I don't really care about possible workarounds at this point - I'm just trying to understand the behavior).
03-15-2003, 09:20 AM#2
PitzerMike
It's not the Position of the unit that is wrong, the unit is exactly where it should be i think

But the function that gets the distance between points is not really reliable because of the different collision size of units. Some are so tiny and others are huge and that causes the difference.
03-15-2003, 04:30 PM#3
MicrosoftXP
distance between points (position of unit (X)) and (position of unit (Y))

DOES NOT take collision size into account. im 100% sure of this because i did some trigger based spells (spells: which do take collision size into account) and It gave me quite the headache before i solved it.
03-15-2003, 04:34 PM#4
Ari
I was under the impression that a unit's location was given to be the exact center of the unit, not some arbitrary point within the unit. Besides, that alone wouldn't acount for my observations. The number seemed to vary at random, and not depending on the angle between the order location and the unit location (which you'd expect if the unit's position was off-center).

Edit: you just beat me to the punch, XP. I agree. Any ideas?
03-15-2003, 05:36 PM#5
Guest
In early versions of my Spell Enhancer (before I switched to the mana detection method), I was using Distance Between Points (DBP) and found it very unreliable. I came to the conclusion that this is because the DBP is in 3D and also figures in terrain and hover hieght when calculating the position of the units.

Another major problem I encountered is that, as XP mentioned, it seems to measure from the "center" of the position of the unit. While the events "within region" and "within range" seem to use the outer edge of the collision size. This can be very difficult to fix since some units have much larger collision sizes.

The best way to fix this is to use (DBP + 50) and hope that fixes the range problem.