- Joined
- Aug 1, 2023
- Messages
- 52
Getting the tools
You might already have gcc or clang or msvc on your computer. You can find that out by running the where gcc command in a terminal/console.After you've downloaded all the tools, you have to make a map in your favorite WorldEditor. Now you can write the script for your map in C (mostly, and some Jass2). Then you can build your map (so that the war3.exe can actually run it) using the following batch script:
PHP:
@echo off
rem we assume that gcc or clang or msvc are in our PATH environment variable
set typecheckGcc=gcc -m32 -Wall -Wextra -Wconversion -fsyntax-only
rem set typecheckClang=clang -m32 -Wall -Wextra -Wconversion -fsyntax-only
rem set typecheckMsvc=cl -nologo -W2 -Zs main.c
set commonj="path\to\common.j"
set blizzardj="path\to\blizzard.j"
set pjass="path\to\pjass.exe"
set cjc="path\to\cjc.exe"
set mpqeditor="path\to\mpqeditor.exe"
rem type check our C code
%typecheckGcc% main.c
if 0 neq %errorlevel% (
exit /b %errorlevel%
)
rem run the C to Jass2 compiler
%cjc% -o a.j -callcode main.c runtime.j
if 0 neq %errorlevel% (
exit /b %errorlevel%
)
rem type check our Jass2 code
%pjass% %commonj% %blizzardj% a.j
rem it is okay for pjass to complain about some of the type casting functions in runtime.j
rem if 0 neq %errorlevel% (
rem exit /b %errorlevel%
rem )
rem make a copy of the map and only modify the copy
copy map.w3x m.w3x
rem add the generated Jass2 code to the map
%mpqeditor% add m.w3x a.j war3map.j
rem try loading m.w3x in the game
The reason that gcc or clang or msvc are needed is because cjc doesn't do type checking. The reason pjass is needed is because the C code needs to call functions written in Jass2.
You could also try loading the map from a batch script by reading this guide (using the -loadfile command line option of war3.exe).