Warcraft 3 Files

From Source Peek Wiki

Jump to: navigation, search

Contents

Warcraft III File Structure

When it's looking for a file, Warcraft III looks first in the "real" directories (the one you see in Windows Explorer) if you set up a specific registery key which is:

   Path: HKEY_CURRENT_USER\Software\Blizzard Entertainment\Warcraft III\
   Key name: "Allow Local Files"
   Key type: dword
   Key value: 1

If the registery key is not set or the file was not found in the "real" directories, then it looks in your map (w3m file), then in the last patch mpq (War3Patch.mpq) and finally in the main mpq (War3.mpq).

It means that you don't need to modify official MPQs (DON'T modify your War3.mpq!), you just need to use the same directory/file structure in your "C:\Program Files\Warcraft III\". Adding files in a map (.w3m file) works with most of the files but not all. It Works (for example) for:

   Units\unitUI.slk
   Units\UnitMetadata.slk
   Units\HumanUnitFunc.txt
   Units\HumanUnitStrings.txt
   Units\HumanAbilityFunc.txt
   Units\HumanAbilityStrings.txt
   Units\HumanUpgradeFunc.txt
   Units\HumanUpgradeStrings.txt

But it doesn't work for:

   Units\AbilityData.slk
   Units\MiscData.txt

When you really need to change a file that have to be loaded outside or before a map is loaded, I recommand you backup your "war3patch.mpq" and create a new one, add the files of the original war3patch.mpq and then add your modified files to that new "war3patch.mpq" you just created. Don't forget to make a backup of your original war3patch.mpq! You may need to put it back when playing with other people (to avoid desync problems) or when you need to update your war3.

Example:

You have a file called "UI\MiscData.txt" in both "War3Patch.mpq" and "War3.mpq". Warcraft will use the one in "War3Patch.mpq". If you want to modify it, just create in your "C:\Program Files\Warcraft III\" diectory a "UI\" directory and extract the file "MiscData.txt" of your "War3Patch.mpq" there (you'll have: "C:\Program Files\Warcraft III\UI\MiscData.txt"). The set the registery key described above with regedit. You can now modify it and next time you'll start War3, it'll use it instead of the original ones.

Warning!

  • In some cases, if you play with others, everybody will need to have the same modified files or you'll get an error (like "netsync error").
  • Some files have a "special" format and if you modify them, you could "falsify" this format. In some cases it will work, in some others it won't. Be aware of that 'cause War3 will try to find a "standard file" instead (the ones of the MPQs instead of yours and you'll think it didn't try your stuff).
  • Some files outside both War3.mpq and War3Patch.mpq will not be used by Warcraft 3. These are exceptions.

Map files (W3M Files)

To edit a map, you'll have to unpack the files of the "w3m" somewhere, then modify them and finally put them back in a "w3m" file (usually a new one). Since retail, W3M are a little bit different from simple MPQ files: they got a header and a footer. You can find more information, and details on these files, under Category:W3M Files.

Warcraft 3 Data Format

Blizzard uses several way to store data in its files. However they often use generic types.

Integers

  • Intergers are stored using 4 bytes in "Little Endian" order. It means that the first byte read is the lowest byte.
  • They are just like the C++ "int" (signed) type. In some other documentation of this kind you may see them named "long".
  • Size: 4 bytes
  • Example: 1234 decimal = [00 00 04 D2]h will be stored in this order: [D2 04 00 00]h

Short Integers

  • Short Integers are stored using 2 bytes in "Little Endian" order.
  • They are close to the C++ signed short but their range is from -16384 to 16383. It means the 2 highest bit are free of use for a flag for example.
  • Size: 2bytes

Floats

  • Floats are using the standard IEEE 32bit float format. They are stored using 4 bytes and the "Little Endian" order.
  • They are just like the C++ "float" type.
  • Size: 4 bytes
  • Example: 7654.32 decimal, this number can't be stored using this format so the system will take the closest value that can be represented using binary digits. The closest one is: 7654.319824 decimal = [45 EF 32 8F]h and will be stored as [8F 32 EF 45]h

Chars and Array of Chars

  • They are just stored like standard chars (1 char = 1 byte) and array of chars (no null terminating char needed).
  • Size (chars): 1 byte
  • Size (array of chars): usually 4 bytes

Trigger Strings and Strings

  • Strings are just arrays of chars terminated with a null char (C++ '\0'). However Blizzard sometimes use special control codes to change the displayed color for the string. These codes are like "|c00BBGGRR" where "BB", "GG" and "RR" are hexadecimal values (using 2 digits each) for the blue, the green and the red values. If a string starts with "TRIGSTR_" (case sensitive), it's considered as a trigger string. A trigger string is kept in memory as is ("TRIGSTR_***") and is only changed when Warcraft 3 needs to display it. Instead of just writing "TRIGSTR_000" on the user screen, War3 will look in its trigger string table created when the map was loaded and display the corresponding trigger string instead. Trigger strings only work for files inside a w3m (Jass, w3i, ...) except for the WTS which is used to define the trigger string table itself. If the number following "TRIGSTR_" is negative the trigger string will refer to a null (empty) string, if "TRIGSTR_" is followed by text, it'll be considered as trigger string #0 ( = "TRIGSTR_000").
  • "TRIGSTR_7", "TRIGSTR_07", "TRIGSTR_007" and "TRIGSTR_7abc" are all representing trigger string #7. "TRIGSTR_ab7", "TRIGSTR_abc" and "TRIGSTR_" refer to trigger string #0. "TRIGSTR_-7" is negative and will not refer to a trigger string; it'll be displayed as "". By convention, "TRIGSTR_" is followed by 3 digits and the null char that ends the string.
  • Example 1: your got the string "blah |c000080FFblah", War3 will display "blah blah" but the second "blah" will be orange (blue=00 + green=80 + red=FF ==> orange)
  • Example 2: you got "TRIGSTR_025" and trigger string 25 is defined (in the .wts file) as "blah|c000080FFblah", it'll display the same result as the previous example.
  • Size (string): vary. String length + 1 (null terminating char)
  • Size (Trigger string): 12 bytes

Flags

  • Flags are boolean values (true or false, 1 or 0). They can be stored using 4 bytes. Each bit is a flag (4 bytes = 32 bit = 32 flags). Blizzard uses integers to store its flags.
  • Size: usually 4 bytes

Custom Types

  • Sometimes, an integer and one or several flags can share bytes. This is the case in the W3E file format: the water level and 2 flags are using the same group of 4 bytes. How? the 2 highest bit are used for the flags, the rest is reserved for the water level (the value range is just smaller). Sometimes a byte can contain two or more different data.

Structures

  • Warcraft 3 also uses structured types of various size.
Personal tools
Sponsors