npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@voces/wc3maptranslator

v4.0.3

Published

Module to translate between `war3map` and `json` formats for WarCraft III .w3x maps

Downloads

20

Readme

Overview

WC3MapTranslator is a module to convert a JSON representation of WarCraft III (.w3x) data to their war3map files, and vice-versa. This makes the map data readable and easily modifiable.

TranslationExample

WC3MapTranslator is written in TypeScript starting from version 3.0.0, offering type safety and improved development experience.

Install

npm install wc3maptranslator

Requires Node >= 8
Tested with tsc Version 3.7.2

Usage

JavaScript (version < 3.0.0)

var Translator = require('wc3maptranslator'),
    mapJson = { // Refer to "Specification"
        units: [...],
        doodads: [...],
        ...
    };
var unitResult = new Translator.Units.jsonToWar(mapJson.units);

TypeScript (version >= 3.0.0)

// JS import
const TranslatorLib = require('wc3maptranslator');
const Translator = new TranslatorLib();
console.log(Translator);
//... or TS import
import { Translator } from 'wc3maptranslator';
const myTranslator = new Translator();
console.log(Translator);

Using the Translator

// e.g. unit translator
const unitResult = new Translator.Units.jsonToWar(mapJson.units);
// all:
* Doodads
* Strings
* Terrain
* Units
* Regions
* Cameras
* Sounds
* Objects
* Imports
* Info

We can now write the unitResult.buffer content to a file named "war3mapUnits.doo" and put it in a .w3x archive! Using individual translators, we may convert JSON representation to generate a WC3 .w3x map file. See the Wiki for more information.

Examples

There is an examples directory that demonstrates how to use each translator, both for converting from war3map to JSON, and JSON to war3map formats. This is a great starting point to learn how to use any translator.

To get started with either example, cd into /examples/ and run npm install to install all the dependencies. Then run npm start which kicks off the TypeScript build and then executes the resulting JavaScript. A few output files will be written under the /examples/ directory, but the output is purposely not comprehensive to avoid spamming the directory and because the translation process is sufficiently demonstrated using just one example of translating in each direction.

File Support

World files

| Type | Json → War | War → Json | File | |-------------------------|:-----------:|:-----------:|---------------| | Terrain | check | times | war3map.w3e | | Units | check | check | war3mapUnits.doo | | Doodads | check | check | war3map.doo | | Regions | check | check | war3map.w3r | | Cameras | check | check | war3map.w3c | | Sounds (definitions) | check | check | war3map.w3s |

Object data files

| Type | Json → War | War → Json | File | |-------------------------|:-----------:|:-----------:|---------------| | Units - Objects | check | check | war3map.w3u | | Items - Objects | check | check | war3map.w3t | | Abilities - Objects | check | check | war3map.w3a | | Destructables - Objects | check | check | war3map.w3b | | Doodads - Objects | check | check | war3map.w3d | | Upgrades - Objects | check | check | war3map.w3q | | Buffs - Objects | check | check | war3map.w3h |

Trigger files

| Type | Json → War | War → Json | File | |-------------------------|:-----------:|:-----------:|---------------| | LUA | times | times | war3map.lua | | JASS | times | times | war3map.j | | Strings | check | check | war3map.wts |

Map files

| Type | Json → War | War → Json | File | |-------------------------|:-----------:|:-----------:|---------------| | Info File | check | check | war3map.w3i | | Imported Files | check | check | war3map.imp | | Pathing | times | times | war3map.wpm | | Shadow map | times | times | war3map.shd |

Not included

times Custom Text Trigger File (war3map.wct)
times Trigger Names File (war3map.wtg)
times Menu Minimap (war3map.mmp)
times Minimap Image (war3mapMap.blp)
times Minimap Image (war3mapMap.b00
times Minimap Image (war3mapMap.tga)
times Map Preview Image (war3mapPreview.tga)

Specification

We have a detailed specification on our Wiki explaining how to format a map in JSON. It explains everything from the high-level map object, all the way down to creating individual units, tiles, or custom objects.

The underlying WarCraft map files (e.g. war3map.doo) have been documented on our Wiki as well. If you are curious about how a .w3x file is composed, this is the place to learn!

Contributing

We encourage contributions! Generally, the process of making a change is:

  1. Fork this repo
  2. Develop your changes on a new branch
  3. Submit a pull request to master

Your code should:

  • run (your code needs to work, of course)
  • include tests (write unit tests to demonstrate your code works under different conditions)
  • be linted (run npm run lint and follow the project's coding standards)
  • pass CI (we enforce: ESLint, unit tests pass, code coverage)

A code review is required on your PR to be accepted into master. A project member will get back to you within one week. If you haven't heard from someone regarding your PR, feel free to ping @chiefofgxbxl.

Special Thanks

We owe a lot of thanks to Chocobo on TheHelper for the detailed documentation of the files found in a .w3x archive. Two tutorials are here (1) and here (2).