Regenerate war3map files from a Warcraft III map script.
$ dotnet add package War3Net.CodeAnalysis.DecompilersWar3Net.CodeAnalysis.Decompilers is a library for regenerating Warcraft III map data files from JASS scripts. It parses the JASS script from a map and extracts structured map data that can be used to reconstruct or analyze map components. It is part of the War3Net modding library.
using War3Net.Build;
using War3Net.Build.Audio;
using War3Net.CodeAnalysis.Decompilers;
// Load a map with its script
var map = Map.Open("path/to/map.w3x");
// Create the decompiler
var decompiler = new JassScriptDecompiler(map);
// Decompile sounds
if (decompiler.TryDecompileMapSounds(MapSoundsFormatVersion.V3, out var sounds))
{
foreach (var sound in sounds.Sounds)
{
Console.WriteLine($"Sound: {sound.Name}, File: {sound.FilePath}");
}
}
using War3Net.Build;
using War3Net.Build.Script;
using War3Net.CodeAnalysis.Decompilers;
var map = Map.Open("path/to/map.w3x");
var decompiler = new JassScriptDecompiler(map);
if (decompiler.TryDecompileMapTriggers(
MapTriggersFormatVersion.V7,
MapTriggersSubVersion.V4,
out var triggers))
{
foreach (var variable in triggers.Variables)
{
Console.WriteLine($"Variable: {variable.Name} ({variable.Type})");
}
}
using War3Net.Build;
using War3Net.Build.Environment;
using War3Net.CodeAnalysis.Decompilers;
var map = Map.Open("path/to/map.w3x");
var decompiler = new JassScriptDecompiler(map);
// Decompile regions
if (decompiler.TryDecompileMapRegions(MapRegionsFormatVersion.V5, out var regions))
{
foreach (var region in regions.Regions)
{
Console.WriteLine($"Region: {region.Name} at ({region.CenterX}, {region.CenterY})");
}
}
// Decompile cameras
if (decompiler.TryDecompileMapCameras(MapCamerasFormatVersion.V0, useNewFormat: false, out var cameras))
{
foreach (var camera in cameras.Cameras)
{
Console.WriteLine($"Camera: {camera.Name}, Distance: {camera.TargetDistance}");
}
}
using War3Net.Build;
using War3Net.Build.Widget;
using War3Net.CodeAnalysis.Decompilers;
var map = Map.Open("path/to/map.w3x");
var decompiler = new JassScriptDecompiler(map);
if (decompiler.TryDecompileMapUnits(
MapWidgetsFormatVersion.V8,
MapWidgetsSubVersion.V11,
useNewFormat: false,
out var units))
{
foreach (var unit in units.Units)
{
Console.WriteLine($"Unit at ({unit.Position.X}, {unit.Position.Y})");
}
}
The main types provided by this library are:
War3Net.CodeAnalysis.Decompilers.JassScriptDecompiler - Primary class for decompiling JASS scripts back into map data structuresWar3Net.CodeAnalysis.Decompilers is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
This README was generated with the assistance of AI and may contain inaccuracies. Please verify the information and consult the source code for authoritative details.