• 🏆 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!

Melee unit range

Status
Not open for further replies.
Level 21
Joined
Mar 27, 2012
Messages
3,232
At short ranges melee units don't really care as much about their range.
I made 2 units with 8 collision size. One of them 0 range, the other 50.
I let the 50 range unit hit the 0 range one once. Then I ordered the 0 range to hit back. It didn't move to do so.
I tested a bit more and it seems the game actually considers range in units of 64, because as I changed the longer range to 64 the shortrange had to move.
However, later tests gave weird results. Sometimes a range of 50 is too short for the 0-range to move, sometimes it's not. Turns out that the minimum range of a melee unit is not strict.
It's actually so that no matter how short the range you set, it can always attack the nearest cell(the smallest one, which is 32 size).
So if your unit has 32 range it can actually attack to a range of 32-64, depending on circumstances. E.g, if you put 2 units at the edges of small cells then they are still in neighbouring cells and thus can attack each other, even though out of each other's range.
 
Level 23
Joined
Oct 18, 2008
Messages
937
I hope you're not relying on the longer range unit starting an attack to check range because that has a random component. it will keep walking for a short bit after getting in range.

I actually did a bit of testing to see how that works and found something potentially interesting

  • Events
    • Unit - A unit Is attacked
  • Conditions
  • Actions
    • Game - Display to (All players) for 30.00 seconds the text: (String((Distance between (Position of (Attacking unit)) and (Position of (Attacked unit)))))

  • Events
    • Player - Player 1 (Red) skips a cinematic sequence
  • Conditions
  • Actions
    • Unit - Move Footman 0004 <gen> instantly to (Center of (Playable map area))
the extra walk distance is almost entirely consistent depending on the point the unit was standing in when given the order. returning it to the middle by trigger between hits produces a string of identical distances. probably the check for being close enough runs every X movement instance. it becomes random again after a while though so there may also be some kind of reset based on time or whatever.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Actually I tried it and it's not random. It seems related to cell distances. When I put a unit at the middle of a tiny cell the attack range from all cardinal directions was exactly the same, while from the corners it was higher. This is consistent with the theory that it considers neighbouring cells in 8 directions. The diagonal directions naturally can be farther, so it makes sense that those ranges were higher.
When I repeated the same experiment with a unit at the edge of a tiny cell it was consistent with what I expected - shorter ranges from the side that it was closer to and longer from the other side.
I don't see any other explanation for those things other than the distance checks for unit attacks being based on the 32-edge cells. It also makes sense from an efficiency point of view.
Note that I didn't have the option of making a visual mistake, because I used a DistanceBetweenPoints call at damage event to test the distance.
 
Status
Not open for further replies.
Top