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

Vision guide

Level 19
Joined
Dec 12, 2010
Messages
2,069
Origin by LordShinjo, good old PDfg with insane skillz. Saved from my own rus blog as PD died.
PS. The biggest WC3 resource have nothing like mechanic-related articles. Wondering how fast advanced WC3 would die unless DotA's
phenomenon.

Map Grid


To understand how vision works, the most important thing to understand is that a map is composed of a big grid.
Every square in this grid is called Cell, its dimensions are 128x128 (in Warcraft III distance units).

c3f8f1b98b.jpg


Fog Update Time
The fog of war is updated every 0.4s since the start of the map.

This means that every 0.4s, the position of every unit, their sight range, and any sight that should be blocked or not are computed.
Then, the fogged or visible status of each grid cell is decided for each player.

You can then see a visual delay when the fog goes away or comes back on some cells, but this is only visual : as soon as the fog of war begins to appear or disappear, the vision has already been completely lost or gained on a particular zone.

Whether a unit is visible or not can however be changed outside of this update time, as a unit leaving a visible cell for a fogged cell will immediately cause this unit to be fogged, without waiting for the next update.

Sight RadiusEvery unit in Warcraft III has 2 fields defining how far it can see : one for the day, and one for the night. These values are capped at 1800.

But these values aren't directly used.
Instead, they can be classified in 15 different Sight Levels, defining how many cells away the unit can see.

Vision, Sight Radius < D1Stats


Day and Night
Every unit having a day field and a night field, you can easily understand that its vision differ depending on whether it is night or day.

But a particular case is the transition between day and night : this is the only moment when a unit's sight radius can be different from these 2 values, as the game makes it transition smoothly from one value to the other.
This transition usually lasts 3.2s (less when the transition lasts 1 or 2 levels), with the vision gaining 1 or 2 levels of sight range at short intervals of time, usually 0.4s. (and more generally always a multiple of 0.2s)

The most usual transition for heroes, from 800 (level 6) to 1800 (level 14), is the perfect example, as the unit gains 1 sight level every 0.4s during 3.2s.
This particular transition is also symmetrical, as it is exactly the same from 1800 to 800, even though this is usually not the case.

Dying Units
A dying unit still has vision during a time equal to its death time, but its sight range is capped by the Gameplay Constant "Fog Reveal Radius - Dying Unit".
In DotA, this constant is set to 500. This means that units with more than 500 sight range will have their sight range reduced to 500 (level 4) while dying. Units with less than 500 will not have their vision changed at all.

Note that due to an engine bug, only units having gone through at least one day->night (or night->day) transition will have their vision reduced this way.

Another note: when a hero dies, his vision get reduced as well. But in case if he's revived WAY too fast (under Death time constant value) his vision WON'T reset as it does normally. Instead he will permanently have incorrect vision until respawns correctly. Fix is only available with Memory hack.

badvision.jpg


Occlusion
Some objects, like trees or cliffs, can block vision. These objects are called Occluders.

An occluder must cover the bottom right corner of a cell to be considered as covering the entire cell.

Vision, Occluders < D1Stats

When surrounded by multiple occluders, the resulting occlusion mask is the superposition of the occlusion masks of each occluder.
The minimum number of vision blockers to completely block a unit's vision is 8, one in each cell around the unit.

As you can see occluder doesn't work if it shares same cell with the unit who has vision radius.

ogre1.png

ogre2.png


Ogre sees no Spectre from this cell, but the next to him shows Spectre just fine, even though tree is still there.

Height
You surely know that sometimes, being higher than a tree can make your vision go over it.
This is because all trees have an Occluder Height.
This value is usually 230 for a tree of medium size (called Tree Wall in World Editor), and 300 for a bigger tree (called Canopy Tree).
But like sight range, these exact values aren't used. Instead, they are converted in Cliff Levels.
A cliff level corresponds to 128 height, but also to the height of a cliff.

Cliffs are divided by levels with step of 128, starting from 1. Zero (very ground level) is 0, first is 1-128, second 129-256, etc.

With their 230 occluder height, medium trees can be said to be occluder level 2. This means that you need to be at least on a cliff level 2 to see over them.

In this example, the north tree is level 3, the west tree level 2, and the unit is placed on a cliff level 2:

319d5869ef.jpg


Note that a unit can change height only by going on a cliff, or an elevated object (like a platform).
The "Apply Height" tool in World Editor, used to create smooth hills, will not change the height of the terrain.

4ccab369b8.jpg


When going up a ramp, the cliff level increases at a particular point : the middle of the second cell.

Flying Units
For the purpose of determining whether a unit's vision is blocked or not, flying units can be considered as being always at an infinite cliff level.
This means that their vision can never be blocked by anything.

Fog Modifiers
Some spells can create Fog Modifiers, via the CreateFogModifierRadius function.

Some hardcoded spells, Mirror Image and Storm, Earth and Fire (more known as Primal Split in DotA), also create a fog modifier.

For Mirror Image, the radius is specified by the area of effect field (this field has no other purpose), and the fog modifier is destroyed when the unit casting Mirror Image appears.
Storm, Earth and Fire creates fog modifier with a radius equal to the casting unit's sight range, and the fog modifier is destroyed after 3s.

These fog modifiers have a center and a radius, but as before, the radius isn't directly used, it is instead converted into a size, each size corresponding to the approximate radius in cells.
Fog modifiers obviously ignore any occluders.

Radius scales with step 128, starting from 0. Zero level is 0-127 (zero vision), first is 128-255 (1st level), 2nd is 258-383 (2nd level), etc.

There is a second way for fog modifiers to be created : whenever a unit is attacked or targeted by a spell of a second unit, a fog modifier is created around the second unit.

This fog modifier has a radius equal to the "Fog Reveal Radius - Attacking Unit" Gameplay Constant, and it will disappear either after a number of seconds equal to "Decay Time (Sec) - Fog of War Flash", or when the second unit creates another fog modifier this way.
 
Level 23
Joined
Feb 6, 2014
Messages
2,466
Theoretical question: If I were to simulate flying vision by periodically creating a fog modifier and destroying it on the next "onPeriod" event (then creating a new one), the timeout of 0.4 will yield the same result as a timeout of 0.1 since fogs update at 0.4 second intervals?

I haven't tested yet but if I recall correctly, it appears that fog modifiers gives instant vision.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
everything being refreshed with roughly 0.4s interval (it differs on some occastions between 0.38 and 0.5, maybe rounding error, idk)
if your modifier been caught in one of those operations, it will stay at least 0.4s. if it been created and killed earlier, no vision will appear at all
 
Level 23
Joined
Oct 18, 2008
Messages
938
Another note: when a hero dies, his vision get reduced as well. But in case if he's revived WAY too fast (under Death time constant value) his vision WON'T reset as it does normally. Instead he will permanently have incorrect vision until respawns correctly. Fix is only available with Memory hack.

couldn't you just set death time to zero and make dying units' vision manually? didn't know this field even existed. if I understand correctly vision is the only thing it affects?
 
Top