A .w3x file is not a program. It is an MPQ archive, and one of the files inside it is war3map.j: the map’s JASS script, the file that holds its triggers [1]. Everything DotA is, its lanes, its shop, its five-on-five rules, lives in that text file and the library the engine loads ahead of it.

That is the whole scene. One archive, one script, and a game that outgrew both without ever getting an engine of its own.

The wall

The script is not compiled against an engine that knows what a hero is. It is compiled against the trigger layer of a level editor built for cutscenes, and three properties of that layer shape everything written on top of it.

First, the script is not one file. The engine concatenates common.j, then Blizzard.j, then war3map.j [2]. The author’s code sits after the engine’s native declarations and after Blizzard’s own JASS library, so a helper like TriggerRegisterAnyUnitEventBJ is library code shipped with the game, written in the same language as the map.

Second, there is no global “any unit” event to register against. A map that wants to hear about every unit takes the player slots one at a time:

// blizzard.j:1722, inside TriggerRegisterAnyUnitEventBJ
call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, null)

The helper walks index up to bj_MAX_PLAYER_SLOTS, calling that native once per slot [3]. Nothing in the engine fires “a unit did something” to a single listener. The global event does not exist; it is a loop somebody wrote, and because it lives in Blizzard.j rather than in the map, every custom map inherited the loop whether it knew it or not.

Third, the editor emits a fixed skeleton. A generated map script opens with // Generated by the Warcraft III World Editor, then defines InitGlobals, then InitCustomTriggers, then main [4]. The trigger graph is generated code carrying compiler-generated names, which is why a decompiled map reads like a function table rather than like a design document.

The wall, stated plainly: the engine offers triggers and per-player events, not a unit-damage event covering every unit, and not an event bus. Damage arrives per unit until 1.31 [5], so a map that wants to react to any damage has to arrange the coverage itself.

The move

Build the game out of the layer that exists. Every rule the engine lacks becomes a trigger, and every global behaviour becomes a registration repeated across the player slots. Waiting for the engine to grow the event is not something a map author can do. Attaching a listener to each unit as it appears is only the same bookkeeping, moved from a fixed loop over slots to a per-unit subscription the map has to maintain.

Items are not a system with an inventory model; they are natives, and the slot count is in the signature:

native UnitItemInSlot takes unit whichUnit, integer itemSlot

The valid range is 0 through 5 [5]. Six is not a design decision DotA made and balance tuned. It is the width of the array the API exposes. A mod that wanted seven slots had no seventh slot index to call.

The handle model has the same shape: opaque on purpose.

a handle variable is basically a pointer. It refers to some data structure that is internal to Warcraft III which you can not manipulate directly [6]

A unit, a trigger, a timer, an item: all of them are handles. You pass them back to natives and you cannot inspect them. That keeps the script insulated from engine internals, and it also means the script cannot build anything the natives did not anticipate. There is no way to add a field to a unit; whatever a hero is, it is made of handles the engine already has, wired together by script.

A genre was not designed on this layer. It was compiled onto it, one registration per player slot at a time.

The event model changing twice

The per-unit damage event carries a patch tag of 1.00. The player-wide replacement is a different constant, tagged 1.31.0.11889:

// common.j
constant unitevent EVENT_UNIT_DAMAGED = ConvertUnitEvent(52)          // @patch 1.00
constant playerunitevent EVENT_PLAYER_UNIT_DAMAGED                     // @patch 1.31.0.11889

Both lines sit in the same declaration block, common.j:3966-3969 [5]. The second one covers natively what the loop in Blizzard.j had been covering by hand. It arrived long after the maps were written.

The earlier change was harsher. Patch 1.24 removed a type-punning trick outright: “Fixed the JASS unsafe type casting exploit (‘return bug’).” The same notes add that the patch “Added new JASS hash table functions to replace the lost functionality,” and the patch also “Increased max map file size from 4MB to 8MB” [7][8].

Read those three sentences as one decision. Removing the hole required shipping a replacement, because the hole was load-bearing. Hashtables gave maps a keyed store that did not depend on punning one type into another, and the doubled ceiling gave the resulting data somewhere to live. The map format did not change. The rules of what a script could do did, and every map that had learned the old trick had to learn the new API.

The order matters for the argument. The engine changed its event model once to close a hole the ecosystem was leaning on, and once to ship an event the ecosystem had been emulating in library code. Neither change was about DotA. Both landed on DotA.

The shadow

Six inventory slots is the clean example because it is checkable in one line: the native takes a slot index, the index runs 0 to 5, and a genre’s item economy was built inside that ceiling for as long as it stayed on the host. The number did not survive because it was good. It survived because it was the number the API would accept.

The deeper cost is governance. A game that lives in war3map.j ships no runtime of its own; when the host changes, the map changes with it. When 1.24 removed the return bug, every map that used the trick had to move. When 1.31 added a player-wide damage event, maps still carried whatever subscription pattern they had grown. The engine’s event model was the genre’s event model, and the genre had no vote.

DotA proved a scripting layer meant for triggers could host a game with lanes, items, cooldowns and a shop, convincingly enough that the layer stopped being a detail. For years the shape of the genre, down to the number of things a hero can carry, was the shape of somebody else’s API, and the API only changed when the host decided to change it.

What the code settles

QuestionAnswer
What is a map?An MPQ archive containing war3map.j, the JASS trigger script [1].
What is loaded before the map’s script?common.j, then Blizzard.j, then war3map.j [2].
Is there a global any-unit event?No. A shipped helper loops player slots up to bj_MAX_PLAYER_SLOTS [3].
How many item slots?Six, indexed 0 to 5 in UnitItemInSlot [5].
When did player-wide damage arrive?1.31, as EVENT_PLAYER_UNIT_DAMAGED [5].
What did 1.24 remove?The return bug, replaced by hashtables, alongside a 4MB to 8MB map ceiling [7][8].

References

[1] Open Realm, Warcraft III map formats, .w3x as an MPQ archive and the war3map.j row. https://corepunch.github.io/open-realm/games/warcraft-3/file-formats/map

[2] JASS documentation, script composition order common.j, Blizzard.j, war3map.j. http://jass.sourceforge.net/doc/globals.shtml

[3] Blizzard Entertainment, blizzard.j, TriggerRegisterAnyUnitEventBJ and its per-slot call at line 1722. https://raw.githubusercontent.com/cipherxof/war3-types/master/scripts/blizzard.j

[4] World Editor output, war3map.j header and the InitGlobals/InitCustomTriggers/main skeleton. https://raw.githubusercontent.com/naichabaobao/jass/master/static/war3map.j

[5] Blizzard Entertainment, common.j, EVENT_UNIT_DAMAGED (@patch 1.00), EVENT_PLAYER_UNIT_DAMAGED (@patch 1.31.0.11889) at lines 3966-3969, and native UnitItemInSlot. https://raw.githubusercontent.com/lep/jassdoc/master/common.j

[6] JASS documentation, handles as engine-internal pointers scripts cannot manipulate. http://jass.sourceforge.net/doc/types.shtml

[7] BNETDocs, news 57: return bug fix and JASS hash table functions. https://bnetdocs.org/news/57/new-warcraft-iii-patch

[8] Warcraft Wiki, patch 1.24a: map file size 4MB to 8MB. https://warcraft.wiki.gg/wiki/Warcraft_III/Patch_1.24a