Blizzardry
JavaScript library for mastering the wizardry that is Blizzard's game files.
Blizzardry currently focusses on Wrath of the Lich King game content.
Licensed under the MIT license, see LICENSE for more information.
Installation
Blizzardry is available via npm:
npm install blizzardry
Or for usage in the browser, soon™.
Usage
Map tiles containing terrain and object information.
A map tile consists of 16 by 16 map chunks.
var r = require('blizzardry/lib/restructure');
var ADT = require('blizzardry/lib/adt');
var io = fs.readFileSync('Azeroth_31_39.adt');
var stream = new r.DecodeStream(io);
var adt = ADT.decode(stream);
adt.version
adt.flags
adt.MTEX.filenames
adt.MMDX.filenames
adt.MCNKs.forEach(function(chunk) {
chunk.areaID
chunk.position
chunk.indexX
chunk.indexY
});
Texture format holding up to 16 pre-rendered mipmaps.
Blizzardry uses BLPConverter to process BLPs.
OSX
Install using Homebrew:
brew install --HEAD https://raw.githubusercontent.com/timkurvers/homebrew-games/formula/blp-converter/blp-converter.rb
Windows
Download BLPConverter and generate the project using CMake:
cmake -DWITH_LIBRARY=YES CMakeLists.txt
Build the DLL using Visual Studio in Release mode, rename blp.dll
to libblp.dll
and ensure it ends up on the load PATH.
By default, node-gyp compiles ffi for x64 so make sure libblp.dll
matches this architecture.
Other platforms
Compile from source and ensure the library ends up on the load path.
var BLP = require('blizzardry/lib/blp');
BLP.open('RabbitSkin.blp', function(blp) {
blp.version
blp.mipmapCount
blp.largest.width
blp.largest.height
blp.largest.data
blp.smallest.width
blp.smallest.height
blp.smallest.data
blp.mipmaps[3].width
blp.mipmaps[3].height
});
var blp = BLP.open('RabbitSkin.blp');
blp.close();
CASC
Archive format, used in recent Blizzard games. Supersedes MPQ.
Blizzardry will use CascLib to handle CASC storage containers.
Support to be added soon™.
Client database format, containing data on items, NPCs, environments and more.
var r = require('blizzardry/lib/restructure');
var DBC = require('blizzardry/lib/dbc');
var io = fs.readFileSync('Faction.dbc');
var stream = new r.DecodeStream(io);
var dbc = DBC.decode(stream);
dbc.signature
dbc.recordCount
dbc.records[0]
Use pre-defined DBC entities for convenience:
var Faction = require('blizzardry/lib/dbc/entities/faction');
var dbc = Faction.dbc.decode(stream);
dbc.records.forEach(function(record) {
record.id
record.parentID
record.name
record.description
});
3D model format for player characters, NPCs and doodads, among others.
var r = require('blizzardry/lib/restructure');
var M2 = require('blizzardry/lib/m2');
var io = fs.readFileSync('Rabbit.m2');
var stream = new r.DecodeStream(io);
var m2 = M2.decode(stream);
m2.signature
m2.name
m2.vertices[0].position
Archive format, used in most Blizzard games. Superseded by CASC.
Blizzardry uses StormLib to handle MPQ archives.
OSX
Install using Homebrew:
brew tap homebrew/games
brew install stormlib
Windows
Download StormLib and build the DLL in Release mode using StormLib_dll.vcproj
(Visual Studio),
rename StormLib.dll
to libstorm.dll
and ensure it ends up on the load PATH.
By default, node-gyp compiles ffi for x64 so make sure libstorm.dll
matches this architecture.
Other platforms
Compile from source and ensure the library ends up on the load path.
var MPQ = require('blizzardry/lib/mpq');
MPQ.open('common.MPQ', function(mpq) {
mpq.files.contains('Creature\\Illidan\\Illidan.m2')
mpq.files.extract('Creature\\Illidan\\Illidan.m2', '~/Illidan.m2');
mpq.files.all.forEach(function(result) {
result.filename
result.name
result.filesize
});
mpq.files.find('*Illidan*');
var file = mpq.files.get('Creature\\Illidan\\Illidan.m2');
file.name
file.size
file.data
});
var mpq = MPQ.open('common.MPQ');
mpq.close();
World definition file specifying which map tiles are present.
A map consists of 64 by 64 map tiles.
var r = require('blizzardry/lib/restructure');
var WDT = require('blizzardry/lib/wdt');
var io = fs.readFileSync('Azeroth.wdt');
var stream = new r.DecodeStream(io);
var wdt = WDT.decode(stream);
wdt.version
wdt.flags
wdt.tiles[30 * 64 + 24]
wdt.tiles[30 * 64 + 25]
Root world map definition file listing textures, doodads and orientation.
Actual model data is stored in group files.
var r = require('blizzardry/lib/restructure');
var WMO = require('blizzardry/lib/wmo');
var io = fs.readFileSync('trolltent.wmo');
var stream = new r.DecodeStream(io);
var wmo = WMO.decode(stream);
wmo.version
wmo.flags
wmo.groupCount
wmo.MOTX.filenames
For a root file named trolltent.wmo
, its group files are named trolltent_000.wmo
,
trolltent_001.wmo
and so forth.
The amount of groups is exposed as groupCount
in the root file (see above).
var r = require('blizzardry/lib/restructure');
var WMOGroup = require('blizzardry/lib/wmo/group');
var io = fs.readFileSync('trolltent_000.wmo');
var stream = new r.DecodeStream(io);
var group = WMOGroup.decode(stream);
group.version
group.flags
group.MOVT.vertices[0]
Development & Contribution
Blizzardry is written in ES2015, compiled by Babel, developed with Gulp
and tested through Mocha.
Getting this toolchain up and running, is easy and straight-forward:
-
Get the code:
git clone git://github.com/timkurvers/blizzardry.git
-
Download and install Node.js – including npm
– for your platform.
-
Install dependencies:
npm install
-
Install BLPConverter and StormLib as outlined above.
-
Run npm run gulp
which will automatically build and test the project when
source files change.
When contributing, please:
- Fork the repository
- Accompany each logical unit of operation with at least one test
- Open a pull request