• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] (Trigger) Getting Distances between Target A and B

Status
Not open for further replies.
Level 4
Joined
Aug 6, 2014
Messages
87
Hey I was wondering if there's a way to gather the distance between target A and B. My plan is to do a spell which deals extra damage for the distance traveled or at least the distance when it was cast between the caster and the target, how should I do that?


Also: Is it possible to get if sum1 got hit by a Shockwave / Crushing Wave?
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
There is an operation "Distance between points"

You wont be able to get who was hit by shockwave using the default spells, but if you trigger your own, you can get that information.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Hey I was wondering if there's a way to gather the distance between target A and B.
There is and it involves using highschool mathematics. Such highschool level mathematics have been implemented in the GUI function "Distance between points" as pOke has suggested.

The implementation of that GUI function is...
JASS:
function DistanceBetweenPoints takes location locA,location locB returns real
    local real dx = GetLocationX(locB) - GetLocationX(locA)
    local real dy = GetLocationY(locB) - GetLocationY(locA)
    return SquareRoot(dx * dx + dy * dy)
endfunction
As you can see here, this is the kind of stuff you learn in S2 in Scotland at highschool, a long way from any kind of advanced mathematics so the sort everyone knows (should know...).

It is an implementation of 2D Euclidean distance formula, equivalent to Pythagoras's theorem so invented at least 2500 years ago.

When one casts an ability or issues an order you can get a point for both the caster/ordered unit and the target unit/object/point. These can be put into the Euclidean distance formula to get a distance out.

Distance returned will be in Warcraft III units, which have a meaning of 128 units per tile edge. Eg a distance of 512 Warcraft III units is exactly 4 tiles if parallel with one of the tile edges. To this day no one is sure why Blizzard chose such strange distance unit for Warcraft III, with their later StarCraft II game having a much more sensible distance unit of tile edge length. Due to a lack of aspect ratio correction tiles may appear rectangular when Warcraft III is played on a non 4:3 display, however internally they are a perfect square when viewed top down.

Also: Is it possible to get if sum1 got hit by a Shockwave / Crushing Wave?
A damage detection system can detect the damage. However it is very difficult to detect if it was only from a shockwave / crushing wave / carrion swarm ability and not any other available damage source, especially which deals similar damage values.

In StarCraft II they really boosted damage detection by allowing one to filter and query what effect caused the damage. Unfortunately WC3 lacks the concept of damage effects so it is not something I would expect to see patched in any time soon.
 
Last edited:
Level 4
Joined
Aug 6, 2014
Messages
87
There is an operation "Distance between points"

You wont be able to get who was hit by shockwave using the default spells, but if you trigger your own, you can get that information.
OK thx 4 the info

And @Dr Super Good, oh well I'm quite good in maths and understand it yeah but I've looked for the function because I haven't really found one, now I found it thanks to you :p

Have a great day and happy new year in 4 days to both of you.
 
Status
Not open for further replies.
Top