NNBuild
NNBuild is one program for playing, hosting and building for Duke Nukem 3D and other games made with the Build engine. It adds modern online play, a built-in map editor, and mods written in JavaScript or TypeScript.
NNBuild is free and open source. It is based on NetDuke32, part of the EDuke32 family of community-made versions of the game. You bring your own copy of each game’s data files; NNBuild supplies the program that runs them.
What you can do with it
Play online
Join a match that is already running, come back if you drop out, and get custom maps and mods sent to you automatically.
Host a server
Run a dedicated server with map rotation, kick and ban, live mod switching and scripts.
Build maps
Use the built-in editor, alone or with other people editing the same map at the same time.
Write mods
Script the game in JavaScript or TypeScript, and debug with breakpoints in VS Code.
Where to go next
| I want to… | Start here |
|---|---|
| Install and run a game | Installing |
| See which games work | Supported games |
| Play with friends | Playing online |
| Run my own server | Dedicated server |
| Make a map | Map editor overview |
| Write my first mod | Modding quick start |
| Look up a launch option | Launch options |
| Build the program myself | Building from source |
About the name
NNBuild was called VibeBuild32 until recently. The program file is still named
vibebuild32, and you will see the old name in some file names and messages.
They are the same thing.
NNBuild Features
NNBuild is one program for playing, hosting and building for Duke Nukem 3D and other games made with the Build engine. It is based on NetDuke32, a community-made version of the game from the EDuke32 family. This page lists what NNBuild adds on top of that, in plain language.
NNBuild was called VibeBuild32 until recently. You will still see the old name on the program file (
vibebuild32) and in some messages.
At a glance
- Join a match that is already running, and come back if you drop out
- Find and host games from a Multiplayer menu inside the game
- Custom maps and mods download automatically when you join
- Run a dedicated server with admin tools, map rotation and scripts
- Several games in one program: Duke Nukem 3D, Ion Fury, NAM, WWII GI, Shadow Warrior, Blood, Redneck Rampage and Exhumed/PowerSlave
- Play as one of the enemies
- Build maps in a built-in editor that several people can use at the same time
- Write mods in JavaScript or TypeScript and debug them in VS Code
Playing online
Getting into a game
- Mid-game join. You no longer have to be there when the match starts. A host can leave spots open, and new players drop into the running match at one of the map’s starting points, ready to play. The match pauses briefly while the newcomer is brought up to date.
- Come back after a drop. If your game crashes, your connection fails or you are dropped for lagging, you can rejoin the same match and your score is restored. The game recognizes you by an ID saved with your settings, not by your nickname, so someone else using your name does not inherit your score.
- Multiplayer menu. The main menu has a Multiplayer entry. From there you can host a game (public or local network) or join one, without typing any launch commands.
- Game list. Join Game shows the games people are hosting, with the server name, size and current map. Pick one to join, or type an address yourself. The list comes from a lobby server, and NNBuild can run as that lobby server too, so any community can keep its own list.
- Fewer router headaches. When a host sits behind a home router, the lobby server helps the two computers find each other. In many cases nobody has to change router settings.
- Old and new internet addresses. Connections work over both the older (IPv4) and newer (IPv6) kinds of internet address.
- Automatic downloads. If a game uses a custom map or mod you don’t have, it is sent to you when you join. Files you already have are recognized and are not downloaded again. You still need your own copy of the base game.
- A proper joining screen. While you join, you see what is happening (connecting, downloading “file 2 of 3”, receiving the game) with a progress bar and a Cancel option. If the server isn’t up yet, the game keeps trying and tells you so.
While you play
- No more frozen matches. If one player’s connection stalls, everyone sees a countdown. The other players can press F9 to vote that player out. When the countdown ends or enough of the others agree, the match carries on without them. Players who vanish completely are removed automatically after a few seconds.
- Automatic recovery. If your game falls out of step with the host’s, it tells you, reconnects by itself and gives you your score back. Before, the match simply broke.
- Instant-feeling shots (optional). A “zero ping” option shows your own gunfire the moment you press fire, instead of waiting for the server to answer.
- No-wait mode (optional). A host can choose a mode where the match never waits for a slow player. Only the slow player feels the delay.
- Mixed computers. Windows, Linux and Mac players can share a match. Matches between different kinds of computer used to fall apart within seconds; that is fixed.
Hosting a server
- Dedicated server mode. Run a server that only hosts. It has no window, graphics or sound and runs in a text terminal, which suits a rented or remote machine. The server does not show up in the match or on the scoreboard as a player.
- Always-open server. A server can start right away, even when empty, and let players come and go whenever they like.
- Kick and ban. Remove a troublemaker, or ban them so they can’t come back. The ban list is kept between sessions.
- Map rotation. Give the server a list of maps and it moves on to the next one when a match ends, in order or at random. The list can mix built-in levels, custom maps and mods. The host can also skip to the next map at any time.
- Switch maps and mods without shutting down. The host can change to a different map or mod pack during a session. Players are carried along automatically and download whatever they are missing. If a new mod pack turns out to be broken, the current match keeps going.
- Change the match on the fly. Add an enemy or item next to a player, or clear every monster from the level. It happens live, for everyone at once.
- Set-and-forget startup. List the commands a server should run when it starts, either directly or in a text file.
- Server scripts. Small scripts (JavaScript or TypeScript) can make timed
announcements, change maps on a schedule or add chat commands. Players type
something like
!rulesin the chat and get an answer. - Remote control for AI assistants. A server or a running game can be supervised by an AI assistant through the open MCP standard: checking who is online, changing maps, removing players.
Several games in one program
- One download, many games. The same program runs Duke Nukem 3D (1.3D, Atomic Edition and World Tour), Ion Fury, NAM, WWII GI, Shadow Warrior, Blood, Redneck Rampage and Exhumed/PowerSlave. You supply each game’s own data files.
- It works out which game you mean. Point NNBuild at a data file or folder and it recognizes the game. If several are installed, it asks, or you can name one when you start it.
- Online features travel with it. The server list and automatic file sending are available in the other games too, to different degrees. Each game’s page in the documentation says exactly what works.
- World Tour commentary. The developer commentary in Duke Nukem 3D: World Tour can be switched on and played back.
- Mix and match (experimental). The Shadow Warrior game can load and play Duke Nukem 3D levels, with Duke’s enemies and scenery behaving as they do in Duke.
The games other than Duke Nukem 3D are newer additions and have had less testing.
Play as the enemy
- Enemy skins. In multiplayer you can choose to look like one of Duke’s enemies: Assault Trooper, Assault Captain, Octabrain, Assault Commander, Enforcer, Pig Cop or Alien Beast. Other players see and hear you as that creature. It walks, attacks, gets hurt and dies with that enemy’s own animations and voice, and the body left behind matches too. This is purely cosmetic and does not change how you play. (Alien Beast needs the Atomic Edition.)
Built-in map editor
Open Map Editor from the title menu.
- See what you build. Switch between a floor-plan view and a textured 3D view you can fly through.
- Draw rooms by clicking corners. Rooms that share an edge connect automatically, and you can extend a new room from any wall.
- Browse and place. A panel shows the game’s textures and common objects. Click to apply a texture or to place an enemy, weapon or item.
- Edit anything, undo anything. Select a room, wall or object to change its height, texture and settings. Every change can be undone and redone.
- Ready-made building blocks. Add pillars, staircases and walkable catwalks in a few steps. A side-on view lets you check heights and clearances.
- Working mechanisms in a few clicks. Presets set up lifts, doors, switches, crusher traps and light switches, and the editor can show what is linked to what.
- Change many things at once. Select a group of objects and move, shade or align them together.
- Map check. The editor finds common mistakes, such as a switch that leads nowhere, a cramped starting point or a missing texture, and takes you to them.
- Test instantly. Press F5 to play your map, and press it again to return to editing exactly where you left off. “Play From Here” starts you at any spot you pick.
- Classic tools included. The original-style Build editor is included for advanced work, and changes made there flow back into the modern editor.
- Several games supported. The editor saves the classic map format and can target Duke Nukem 3D 1.3D, Atomic Edition, NAM, NAPALM or WWII GI.
Building together
- Live editing. Host a session and up to 32 people can edit the same map at the same time. You see each other’s cursors and selections, a shared history shows who changed what, and undo works across everyone’s changes.
- AI co-builders. An AI assistant can join a session as a participant with its own cursor and label. It can build rooms and place objects, and its changes appear in the shared history and can be undone like anyone else’s.
Make your own mods and games
- Start a mod with one command. NNBuild can create a ready-to-edit mod project in JavaScript or TypeScript, with type hints and a VS Code setup included.
- Script the game. Mods can react to what happens in the game, show text on screen, spawn things, play sounds, change menus and add chat commands.
- Debug like any other program. Set breakpoints in VS Code, step through your script while the game is paused, and inspect variables. A DevTools window in the game shows the script log and lets you try expressions.
- Files and the network. Scripts can read and write files, send and receive network messages, and fetch data from web addresses.
- Projects. Keep the maps, scripts, textures and sounds of a mod together in one folder, managed from inside the editor.
- One-file sharing. Export a project as a single ZIP file. Players drag the ZIP onto the program to play it.
- Stand-alone games. A project can bring all of its own artwork, sound and rules, so it runs on its own without the original game’s files.
- Scripted map objects. In the editor’s Modern Mode, attach a small script to a door, an item or a room to give it behaviour the classic game could not do. Projects that use this need NNBuild to run.
- Prefabs. Save a group of objects as a reusable piece and stamp copies of it wherever you need them.
- Safety switch. Scripts inside a downloaded project ZIP do not run unless the player allows them.
- Example game included. Ashline Relay is a small stand-alone game made as an NNBuild project, using free Freedoom artwork. It shows what a project can be and can be opened in the editor.
Smoother everyday experience
- Faster level loading. In our tests, a level that took around ten seconds to load now takes about two.
- No more creeping input delay. A single hiccup could leave the controls feeling up to a second behind for the rest of the match. That is fixed.
- Faster joining. Sending the running game and mod files to a new player is many times quicker than before, so large add-ons no longer time out.
- Six ready-made builds. Windows (64-bit and 32-bit), Linux (x64 and ARM64) and macOS (Apple silicon and Intel).
- Clearer launch options. Options have readable long names such as
--game,--leveland--dedicated, next to the short classic ones. - Tidier scoreboard. Only real players are listed, numbered in order.
- New name and look. The program is now called NNBuild and has new icons.
Good to know
- Joining a match that is already running needs the same kind of build as the host: a 64-bit player cannot join a 32-bit host mid-game, or the other way round. Use the 64-bit build unless your computer cannot run it.
- NNBuild does not include any game’s data. You need your own copy of each game you want to play.
Want the details?
The documentation is at https://nnb.nukemnet.com:
- Getting started
- Supported games
- Playing online and running a server
- Map editor
- Modding
- Every launch option
Downloads
Ready-made builds are published on GitHub Releases. Each link below always points at the newest release.
| System | Download |
|---|---|
| Windows, 64-bit | nnbuild-windows-x64.zip |
| Windows, 32-bit | nnbuild-windows-x86.zip |
| Linux, x64 | nnbuild-linux-x64.tar.gz |
| Linux, ARM64 | nnbuild-linux-arm64.tar.gz |
| macOS, Apple silicon (M1 and later) | nnbuild-macos-arm64.zip |
| macOS, Intel | nnbuild-macos-x64.zip |
All releases, with their notes, are listed on the releases page.
The downloads contain the program only. You also need the data files of each game you want to play, from your own copy of that game. See Installing.
After downloading
Windows
Unpack the ZIP into a folder of its own and run vibebuild32.exe. Windows may
show a “Windows protected your PC” notice because the program is not signed;
choose More info, then Run anyway.
Linux
Unpack the archive and run ./vibebuild32 from a terminal. The program uses
the system’s SDL2 library. On Debian or Ubuntu, install it with:
sudo apt install libsdl2-2.0-0
macOS
Unpack the ZIP and move the app to your Applications folder. The app is not notarized by Apple, so the first time you open it, right-click the app and choose Open, then confirm.
Source code
The source is on GitHub. To compile it yourself, see Building from source.
Installing
NNBuild is a program. It does not contain any game. To play, you need NNBuild plus the data files from your own copy of each game.
Getting the program is covered on the Downloads page. This page explains where the game data goes, how to point NNBuild at it, and where NNBuild keeps its own files.
The program file is named vibebuild32 (vibebuild32.exe on Windows). The
examples on this site use that name.
What you need
- The NNBuild program. The download also contains a file named
eduke32.datnext to the program. Keep it there. On macOS it is inside the app bundle. - The data files of each game you want to play. A data file is the large archive that holds a game’s levels, art and sounds.
| Game | Main data file |
|---|---|
| Duke Nukem 3D | DUKE3D.GRP |
| Duke Nukem 3D: 20th Anniversary World Tour | DUKE3D.GRP plus the loose files installed next to it |
| Ion Fury | fury.grp |
| NAM | NAM.GRP |
| NAPALM | NAPALM.GRP |
| WWII GI | WW2GI.GRP |
| Shadow Warrior | SW.GRP |
| Blood | BLOOD.RFF and the rest of the Blood folder |
| Redneck Rampage | REDNECK.GRP |
| Exhumed / PowerSlave | STUFF.DAT |
Each game has its own page with the exact files and versions NNBuild recognises. Start from Supported games.
Where NNBuild looks first
When it starts, NNBuild checks two places for each game:
- the folder you started it from, and
- a subfolder of that folder named after the game.
| Game | Subfolder | File it looks for |
|---|---|---|
| Duke Nukem 3D | duke3d | DUKE3D.GRP or duke3d.grp |
| World Tour | worldtour, world-tour or duke3d_wt | see below |
| Shadow Warrior | sw | SW.GRP, Sw.grp or sw.grp |
| Blood | blood | BLOOD.RFF or blood.rff |
| Redneck Rampage | rr | REDNECK.GRP or redneck.grp |
| NAM | nam | NAM.GRP or nam.grp |
| NAPALM | napalm | NAPALM.GRP or napalm.grp |
| WWII GI | ww2gi | WW2GI.GRP or ww2gi.grp |
| Exhumed / PowerSlave | exhumed | STUFF.DAT or stuff.dat |
| Ion Fury | ionfury | fury.grp or FURY.GRP |
On systems where upper and lower case are different letters in file names (Linux, and some macOS disks), use one of the spellings in the table.
A folder set up for three games looks like this:
nnbuild/
vibebuild32
duke3d/
DUKE3D.GRP
sw/
SW.GRP
blood/
BLOOD.RFF
(the other Blood files)
“The folder you started it from” is the current folder of the program, also called the working directory. When you double-click the program it is normally the program’s own folder. In a terminal it is the folder you are in when you type the command.
A folder counts as World Tour only when it holds all of these files:
DUKE3D.GRP, GAME.CON, DEFS.CON, USER.CON, FLAMETHROWER.CON,
FIREFLYTROOPER.CON, EPISODE5BOSS.CON, TILES020.ART and maps/E5L1.map.
Once a game is chosen, NNBuild switches into the folder where it found that game’s data and runs the game from there. What happens when more than one game is found is described in First launch.
Pointing NNBuild at data somewhere else
You do not have to copy anything. These launch options tell NNBuild where the data is. All of them also let NNBuild work out which game you mean.
| Option | Use it for |
|---|---|
--grp <file> or -g <file> | A data file: the main data file of a game, or a mod pack to load on top of it. |
--gamegrp <file> | The main data file, when you want to say exactly which one. Use it to start an official add-on. |
--game-dir <folder> | The folder that holds the game’s data. |
-j <folder> | An extra folder to search for files. |
vibebuild32 --grp ~/games/duke3d/DUKE3D.GRP
vibebuild32 --game sw --grp ~/games/sw/SW.GRP
vibebuild32 --game blood --game-dir ~/games/blood
vibebuild32.exe --grp C:\Games\Duke3D\DUKE3D.GRP
Give full paths, as in the examples. NNBuild changes folder before the game starts, so a path written relative to where you typed the command may no longer be found.
The full list of options is in Launch options.
Installed copies that are found automatically
The Duke Nukem 3D family and Shadow Warrior also search the usual install
locations of the store versions. This search runs after the game has been
chosen, so it is most useful when you start NNBuild with --game:
vibebuild32 --game duke
The locations are listed per system below. If your copy is somewhere else, use one of the options above.
Windows
- Installed copies. NNBuild reads the install location from the Windows registry for these releases: Duke Nukem 3D (Megaton Edition and World Tour on Steam, the 3D Realms Anthology, and the GOG.com and ZOOM Platform Atomic Edition), NAM (Steam, GOG.com), WWII GI (Steam, GOG.com), Ion Fury (Steam, GOG.com) and Shadow Warrior (Classic Redux and Classic on Steam, GOG.com).
- Settings. By default the settings files are written into the folder the
game runs from. That is the folder NNBuild switched into, such as
duke3d. To keep them in your user profile instead, create an empty file nameduser_profiles_enabledin that folder. The settings then go to a folder under%APPDATA%, named as in the table below.
Linux
- Installed copies. For the Duke Nukem 3D family NNBuild searches Steam
(
~/.steam/steamand the library folders listed there), the GOG.com folders~/GOG Games/Duke Nukem 3D Atomic Editionand~/GOG Games/ION Fury, and the system folders/usr/share/games/jfduke3d,/usr/local/share/games/jfduke3d,/usr/share/games/eduke32and/usr/local/share/games/eduke32. For Shadow Warrior it searches Steam and the GOG.com folders~/GOG Games/Shadow Warrior Classic Reduxand~/GOG Games/Shadow Warrior Classic Complete. - Settings. Settings are kept in a folder under
~/.config, one per group of games (see the table below). NNBuild creates the folder the first time it is needed. Game data placed in that folder is found as well. - Keeping everything in one folder. Start with
-usecwd, or create an empty file nameduser_profiles_disabledin the folder the game runs from. Settings are then read from and written to that folder.-usecwdalso skips the search of installed copies.
macOS
- Installed copies. For the Duke Nukem 3D family NNBuild searches Steam
under Application Support, the GOG.com and ZOOM Platform app bundles in the
Applications folders, and the folders
JFDuke3DandEDuke32under Application Support. The folder that contains the program is searched too. - Settings. As on Linux, settings are kept under
.configin your home folder, and-usecwdor auser_profiles_disabledfile keeps them in the folder the game runs from. - Log files. Shadow Warrior, Blood, Redneck Rampage and Exhumed write
their log to
~/Library/Logs. With-usecwdthe log stays in the folder the game runs from.
Files NNBuild writes
One NNBuild program contains several game engines, and each keeps its own settings.
| Games | Settings folder (Linux, macOS) | Folder under %APPDATA% (Windows, optional) | Settings file | Log file |
|---|---|---|---|---|
| Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM, WWII GI | ~/.config/vibebuild32 | VibeBuild32 | vibebuild32.cfg | vibebuild32.log |
| Shadow Warrior | ~/.config/voidsw | VoidSW | voidsw.cfg | voidsw.log |
| Blood | ~/.config/notblood | NotBlood | notblood.cfg | notblood.log |
| Redneck Rampage | ~/.config/rednukem | Rednukem | rednukem.cfg | rednukem.log |
| Exhumed / PowerSlave | ~/.config/kexhumed | Kexhumed | kexhumed.cfg | kexhumed.log |
- The Duke Nukem 3D family also writes
vibebuild32_settings.cfgnext to its settings file. It holds key bindings and console settings. - The log file is a plain text record of one run. It is written to the folder the game runs from, except on macOS as noted above. Look there first when something does not start.
grpfiles.cacheremembers which data files were found, so later starts are faster. It is safe to delete.netcacheis a folder for maps and mod packs downloaded from servers you joined.banlist.txtis the ban list of a server you host.autojsholds script mods. It lives in the folder you start NNBuild from. See Modding quick start.
Next step
Continue with First launch.
First launch
This page describes what NNBuild does between the moment you start it and the moment a game appears, and how to skip the steps you do not need.
It assumes your game data is in place. If it is not, read Installing first.
What happens when you start NNBuild
- A game is chosen. One NNBuild program can run several games. It decides which one from the launch options you gave and from the data files it finds.
- If it cannot decide, it asks. When data for more than one game is found and nothing else settles the choice, NNBuild shows a short text prompt, the game picker.
- NNBuild switches into the game’s folder. The game runs from the folder where its data was found.
- The startup window may open. This is a small window with video and input settings. It appears before the game itself.
- The game starts and its settings are saved for next time.
How the game is chosen
NNBuild goes through these rules in order and stops at the first one that gives an answer.
-
You named it.
--game <name>(short form-gm <name>) always wins. The names are listed in Supported games.vibebuild32 --game sw -
You pointed at data. If you gave a data file or folder, NNBuild works out the game from it. It looks at
--grp,--gamegrp,--rff,--ini,--game-dir,-j, and at any file name given without an option, from left to right. A file is recognised by its size and checksum when it is a known release, otherwise by its name (for exampleSW.GRPorSTUFF.DAT). A folder is recognised when it holds the main data file of exactly one game.vibebuild32 --grp ~/games/sw/SW.GRP -
Only one game is installed. If the places NNBuild looks first hold data for a single game, that game starts.
-
Several games are installed. The game picker asks which one you want.
-
Nothing was found. NNBuild starts Duke Nukem 3D, which then runs its own search for installed copies and reports an error if it finds none.
If your copy of NNBuild was built without one of the games, choosing that game starts Duke Nukem 3D instead.
The game picker
The picker is a text prompt in the terminal NNBuild was started from. It lists the games whose data was found:
Select a game:
1) Duke Nukem 3D
2) Shadow Warrior
3) Blood
Choice [1]:
Type the number and press Enter. Pressing Enter alone picks the first entry.
NNBuild only asks when a person can answer. When it was not started from a terminal, for example by double-click, or when its input comes from another program, it does not ask and uses the first entry.
Games are always listed in this order: Duke Nukem 3D, Duke Nukem 3D: World Tour, Shadow Warrior, Blood, Redneck Rampage, NAM, Napalm, World War II GI, Kexhumed (the name NNBuild uses for Exhumed / PowerSlave), Ion Fury.
The startup window
The startup window belongs to the Duke Nukem 3D family. It lets you set:
- the video mode and whether to use the full screen,
- which input devices to use (mouse, joystick),
- which game to run, when several recognised data files were found (for example the Atomic Edition and an add-on),
- a custom game content directory,
- whether to always show this window at startup.
Press Start to continue or Cancel to quit.
The window opens when there is no settings file yet, when “Always show this
window at startup” is ticked (it is ticked at first), or when you ask for it
with --menu. It exists in Windows and macOS builds, and in Linux builds made
with GTK 2 support. Other builds go straight to the game.
For Shadow Warrior, Blood, Redneck Rampage and Exhumed, start with
--skip-menu. These games then go straight to their own title screen.
Skipping the menus
| Option | Effect |
|---|---|
--game <name> | No game picker: you already chose. |
--skip-menu or -sm | Skips the game picker and the startup window. If several games are installed and you did not choose one, the first in the list above is used. |
--no-game-menu or -ngm | Skips only the game picker. |
--menu or -m | Shows the startup window even if it would be skipped. |
--skip-cinema or -sc | Skips the logos and intro movie. |
A typical command that goes straight into the game:
vibebuild32 --game duke --skip-menu --skip-cinema
In the Duke Nukem 3D family, some options skip the startup window by
themselves, because they only make sense for a direct start: -net
(multiplayer), --debug and --devtools (script debugging), and starting a
project. --grp often does the same. Add --skip-menu when you want to be
sure.
Where settings are stored
Each group of games has its own settings file, written when the game exits. The file names and folders for every system are in Files NNBuild writes.
In short:
- Linux and macOS: a folder under
.configin your home folder, for example~/.config/vibebuild32/vibebuild32.cfg. - Windows: the folder the game runs from, unless you opted in to the
folder under
%APPDATA%. -usecwdkeeps settings in the folder the game runs from on every system.
For the Duke Nukem 3D family the settings file also holds a player ID that NNBuild creates on first run. A server uses it to give you your score back when you rejoin a match, so keep the file if you play online.
To try something without touching your normal settings, name another file:
vibebuild32 --game duke -cfg ~/games/test.cfg
-cfg works for the Duke Nukem 3D family, Blood, Redneck Rampage and Exhumed.
Next step
Read the page for your game under Supported games, or go to Playing online.
Supported games
One NNBuild program runs all the games on this page. You choose a game when
you start the program, with --game <name>, or NNBuild works it out from the
data files it finds. See First launch.
You need your own copy of each game’s data files. Installing explains where to put them.
The games
| Game | --game name | Main data file | Status |
|---|---|---|---|
| Duke Nukem 3D | duke | DUKE3D.GRP | The main game. Every NNBuild feature is available. |
| Duke Nukem 3D: 20th Anniversary World Tour | worldtour | DUKE3D.GRP and the loose World Tour files | Runs on the Duke Nukem 3D runtime, with World Tour’s own scripts and levels. |
| Ion Fury | ionfury | fury.grp | Runs on the Duke Nukem 3D runtime. |
| NAM | nam | NAM.GRP | Runs on the Duke Nukem 3D runtime. |
| NAPALM | napalm | NAPALM.GRP | Runs on the Duke Nukem 3D runtime. |
| WWII GI | ww2gi | WW2GI.GRP | Runs on the Duke Nukem 3D runtime. The Platoon Leader add-on is recognised. |
| Shadow Warrior | sw | SW.GRP | Its own runtime. Single player, multiplayer with a server list, and a limited set of script features. |
| Blood | blood | BLOOD.RFF | Its own runtime. Single player, and multiplayer with lobby options on the command line. |
| Redneck Rampage | rr | REDNECK.GRP | Its own runtime. Single player, and multiplayer with lobby options on the command line. |
| Exhumed / PowerSlave | exhumed | STUFF.DAT | Its own runtime. Single player, multiplayer, and KEX mode for the remaster’s data. |
A runtime is the part of the program that runs one game or one family of games. NNBuild contains five of them. The Duke Nukem 3D runtime carries almost all of the new features, and the games that run on it share them.
If your copy of NNBuild was built without one of the separate runtimes, choosing that game starts Duke Nukem 3D instead.
Other names you can type
--game accepts several spellings for each game. Upper and lower case do not
matter.
| Game | Accepted names |
|---|---|
| Duke Nukem 3D | duke, duke3d, dukenukem3d |
| World Tour | worldtour, world-tour, wt, duke3dwt, duke-wt, duke20, duke-20, duke3d-world-tour, twentieth, 20th |
| Ion Fury | ionfury, ion-fury, fury, aftershock, ionfury-aftershock, ion-fury-aftershock |
| NAM | nam, nam3d, nam-3d |
| NAPALM | napalm, napalm3d, napalm-3d |
| WWII GI | ww2gi, wwii, wwiigi, wwii-gi, worldwariigi, world-war-ii-gi, gi |
| Shadow Warrior | sw, shadowwarrior, shadow-warrior |
| Blood | blood |
| Redneck Rampage | rr, redneck, redneckrampage, redneck-rampage |
| Exhumed / PowerSlave | exhumed, kexhumed, powerslave, power-slave, pcexhumed |
A name NNBuild does not know is ignored, and the game is then chosen as if
--game had not been given.
Which features work in which game
The table lists what each runtime offers. A dash means the feature is not part of that runtime.
| Feature | Duke Nukem 3D family | Shadow Warrior | Blood | Redneck Rampage | Exhumed |
|---|---|---|---|---|---|
| How a network game is started | -net | -net | -server, -client | -server, -connect | -net |
| Host and join from the game’s menus | Multiplayer menu | A server list only, see Shadow Warrior | - | - | - |
List your game on a lobby server (--advertise) | Yes | Yes | Yes | Yes | Yes |
Join the first listed game (--joinlobby) | - | Yes | Yes | Yes | Yes |
| Join a match that is already running | Yes | - | - | - | Yes |
| Server without a window | Yes | - | - | Yes | Yes |
| Server console (type commands in the terminal) | Yes | - | - | - | Linux and macOS |
| Kick, ban, map rotation and the other host commands | Yes | - | - | - | - |
| JavaScript and TypeScript mods | Yes | Limited | - | - | - |
| Map editor and projects | Yes | - | - | - | - |
| Control by an AI assistant (MCP) | Yes | - | - | - | - |
The “Duke Nukem 3D family” column covers Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM and WWII GI.
Playing one game’s levels in another
NNBuild can load the levels of one game while another game’s runtime is running. Three options control this. Each takes a game name from the table above.
| Option | Short form | Meaning |
|---|---|---|
--game.levels <name> | -gm.lvls <name> | The game the levels come from. |
--game.items <name> | -gm.its <name> | The game whose item pickups to use. |
--game.weapons <name> | -gm.wpns <name> | The game whose weapon and ammo pickups to use. |
When an option is left out, it means “the game that is running”.
You also have to give the data of the game the levels come from, with --grp.
NNBuild sees that the file belongs to a different game than the one running and
uses it only as a source of levels and art.
vibebuild32 --game sw --grp ~/games/sw/SW.GRP \
--game.levels duke --grp ~/games/duke3d/DUKE3D.GRP -map E1L1.MAP
Two runtimes take part in this:
- Shadow Warrior can load levels from Duke Nukem 3D, World Tour, NAM, NAPALM and WWII GI. See Shadow Warrior.
- The Duke Nukem 3D runtime can load Shadow Warrior levels. See Duke Nukem 3D.
Blood, Redneck Rampage and Exhumed do not use these options.
Duke Nukem 3D
Duke Nukem 3D is the main game of NNBuild. Every feature described on this site works with it. This page also covers the official add-ons and World Tour.
--game name | duke (World Tour: worldtour) |
| Main data file | DUKE3D.GRP |
| Folder NNBuild looks in first | duke3d (World Tour: worldtour) |
| Settings and log | vibebuild32.cfg, vibebuild32.log |
Data files
You need DUKE3D.GRP from your own copy of the game. NNBuild recognises a data
file by its size and checksum, not by its name, and knows these releases:
| Release | Kind |
|---|---|
| Duke Nukem 3D 1.3D | Full game |
| Duke Nukem 3D 1.3D, South Korean censored release | Full game |
| Duke Nukem 3D: Atomic Edition (1.5) | Full game |
Duke Nukem 3D: Atomic Edition, the DUKE3D.GRP that comes with World Tour | Full game |
| Duke Nukem 3D: Plutonium Pak | Full game |
| Shareware 0.99, 1.0, 1.1 and 1.3D | Shareware |
| Mac Demo and MacUser Demo | Shareware |
These official add-ons are recognised too. An add-on is offered only when the full game it needs is found as well.
| Add-on | Needs |
|---|---|
| Duke it out in D.C. (1.3D release) | Duke Nukem 3D 1.3D |
| Duke it out in D.C. | Atomic Edition |
| Duke Caribbean: Life’s a Beach (1.3D release) | Duke Nukem 3D 1.3D |
| Duke Caribbean: Life’s a Beach (Plutonium Pak release) | Plutonium Pak |
| Duke Caribbean: Life’s a Beach | Atomic Edition |
| Duke: Nuclear Winter, and its demo | Atomic Edition |
| Duke!ZONE II (1.3D release) | Duke Nukem 3D 1.3D |
| Duke!ZONE II | Atomic Edition |
| Duke Nukem’s Penthouse Paradise | Atomic Edition |
How the data is found
- At start, NNBuild looks for a file named
DUKE3D.GRP(orduke3d.grp) in the folder you started it from and in itsduke3dsubfolder. - Once Duke Nukem 3D is chosen, the game checks every
.grp,.ssi,.datand.zipfile in its search folders against the list above. The search folders include the installed store copies listed in Installing. - If several recognised files are found, the Game list in the startup
window lets you choose. On the command line,
--gamegrp <file>chooses.
vibebuild32 --grp ~/games/duke3d/DUKE3D.GRP
To start an add-on, name the add-on’s own data file with --gamegrp. Keep
the full game’s DUKE3D.GRP in the same folder:
vibebuild32 --gamegrp ~/games/duke3d/dukedc.grp
Other games and total conversions can be made known to NNBuild with .grpinfo
files placed in a search folder.
Starting the game
# Data in the duke3d subfolder, or an installed store copy
vibebuild32 --game duke
# Straight into the game, no startup window, no intro
vibebuild32 --game duke --skip-menu --skip-cinema
# Episode 1, level 3, skill 3
vibebuild32 --game duke --volume 1 --level 3 --skill 3
# A map file of your own
vibebuild32 --game duke -map ~/maps/arena.map
# No monsters
vibebuild32 --game duke --volume 1 --level 1 --monsters 0
--monsters <n> turns monsters off when n is 0. A value of 1 or more turns
them on and also sets the skill. Higher numbers are harder. The skill used is
n minus one, so --monsters 3 gives the same skill as --skill 2.
All options are listed in Launch options.
World Tour
Duke Nukem 3D: 20th Anniversary World Tour is run by the same runtime. It
needs the DUKE3D.GRP of World Tour together with the loose files the game
installs next to it. NNBuild treats a folder as World Tour when it holds all
of these:
DUKE3D.GRP
GAME.CON
DEFS.CON
USER.CON
FLAMETHROWER.CON
FIREFLYTROOPER.CON
EPISODE5BOSS.CON
TILES020.ART
maps/E5L1.map
Put that folder at worldtour (or world-tour, or duke3d_wt) next to where
you start NNBuild, or point at it:
vibebuild32 --game worldtour --game-dir "/home/you/games/World Tour"
Details:
- NNBuild loads World Tour’s own
GAME.CONscript automatically. Give--con <file>to load a different one. - If the loose files are missing, the World Tour
DUKE3D.GRPis used as a plain Atomic Edition data file. - The developer commentary is off by default. Turn it on in the sound setup
menu or with the console setting
wt_commentary 1. See Console commands.
What you can do in this game
- Multiplayer. The title menu has a Multiplayer entry with Join Game (a list of games from a lobby server, or an address you type) and Host Game (internet or LAN). You can join a match that is already running and come back to it after dropping out. See Playing online and Hosting a match.
- Dedicated server. A server without a window that takes commands in the terminal: kick and ban, map changes, mod pack changes and map rotation. See Dedicated server and Console commands.
- Automatic downloads. Custom maps and mod packs used by a server are sent to players when they join.
- Enemy skins. In multiplayer you can appear as one of the enemies. Set it
with the console setting
skin. - Mods in JavaScript or TypeScript. See Modding.
- Map editor and projects. Open Map Editor from the title menu or
start with
--editor. See Map editor. - Control by an AI assistant. See AI assistants and MCP.
Playing other games’ levels
The Duke Nukem 3D runtime can load a Shadow Warrior level. Name Shadow Warrior as the source of the levels and give its data file:
vibebuild32 --game duke --gamegrp ~/games/duke3d/DUKE3D.GRP \
--game.levels sw --grp ~/games/sw/SW.GRP -map LEVELNAME.MAP
Replace LEVELNAME.MAP with the name of a map inside SW.GRP.
You keep Duke’s player, weapons and rules. Item and weapon pickups in the level are replaced by their Duke Nukem 3D counterparts. Every other Shadow Warrior object in the level, including its enemies, is removed.
--game.items and --game.weapons are explained in
Supported games.
Known limits
- Shareware data. With a shareware data file you cannot load map files
(
-map), use themapandchangemapconsole commands, or open the map editor. - Players. A match has at most 16 player slots.
- Joining a running match. The joining player needs the same kind of build as the host: both 64-bit, or both 32-bit.
- Base game data is never sent. Every player needs their own copy of the same edition the server uses. A server can share up to eight mod packs.
--grpand mod packs. In multiplayer, a mod pack given with--grpis offered to the players who join. A file that NNBuild recognises as game data, such asDUKE3D.GRPor an official add-on, is not offered. The game’s own data file can be given with--grpor with--gamegrp.- World Tour and the editor. The map editor can target Duke Nukem 3D 1.3D and Atomic / Plutonium. It has no World Tour target.
Ion Fury
Ion Fury runs on the same runtime as Duke Nukem 3D. NNBuild switches that runtime into Ion Fury mode when you choose this game.
--game name | ionfury (also ion-fury, fury, aftershock) |
| Main data file | fury.grp |
| Folder NNBuild looks in first | ionfury |
| Settings and log | vibebuild32.cfg, vibebuild32.log (shared with Duke Nukem 3D) |
Data files
You need fury.grp from your own copy of Ion Fury. Leave it in the game’s own
folder, next to the files it was installed with.
NNBuild has one release built in: Ion Fury: Aftershock. It is recognised by
the size and checksum of its fury.grp. Other releases are recognised when a
.grpinfo file that describes them is in a search folder. Ion Fury installs
normally include one, named fury.grpinfo. For that reason, point NNBuild at
the game’s own folder rather than at a copy of fury.grp alone.
How the data is found:
- At start, NNBuild looks for
fury.grp(orFURY.GRP) in the folder you started it from and in itsionfurysubfolder. - A file named
fury.grpthat you pass on the command line selects Ion Fury. - Once Ion Fury is chosen, the game also searches the usual Steam and GOG.com install locations of Ion Fury.
Starting the game
# Data in the ionfury subfolder
vibebuild32 --game ionfury
# The game's own folder
vibebuild32 --game ionfury --game-dir "/home/you/games/Ion Fury"
# Naming the data file selects Ion Fury by itself
vibebuild32 --grp "/home/you/games/Ion Fury/fury.grp"
# No startup window and no intro
vibebuild32 --game ionfury --game-dir "/home/you/games/Ion Fury" --skip-menu --skip-cinema
Ion Fury uses its own main script (scripts/main.con) and definitions file
(ashock.def). NNBuild selects both for you.
What you can do in this game
Because Ion Fury uses the Duke Nukem 3D runtime, the launch options of that runtime apply. See Launch options.
- Multiplayer from the command line.
-net,--latejoin,--startnow,--dedicatedand--advertiseare available, and so are the host console commands. See Hosting a match. - Mods in JavaScript or TypeScript. See Modding.
Playing a Duke Nukem 3D level with Ion Fury
You can give a Duke Nukem 3D data file as a second data source. NNBuild sees that it belongs to another game and uses it only for its levels and art. This example is the one printed by the program’s own help:
vibebuild32 --game ionfury --game-dir "/home/you/games/Ion Fury" \
--grp ~/games/duke3d/DUKE3D.GRP -map E3L6
It starts level E3L6 of Duke Nukem 3D with Ion Fury as the game.
Known limits
- No Multiplayer or Map Editor entry in the title menu. Ion Fury’s title menu offers New Game, Continue, Options, Read Me and Quit. Start network games with launch options.
- The map editor has no Ion Fury target. It can target Duke Nukem 3D, NAM, NAPALM and WWII GI.
- Only Aftershock is built in. Other releases depend on a
.grpinfofile, as described above.
NAM and WWII GI
NAM, NAPALM, WWII GI and the WWII GI add-on Platoon Leader all run on the same runtime as Duke Nukem 3D. NNBuild switches that runtime into the right mode when you choose one of them.
| Game | --game name | Main data file | Folder NNBuild looks in first |
|---|---|---|---|
| NAM | nam | NAM.GRP | nam |
| NAPALM | napalm | NAPALM.GRP | napalm |
| WWII GI | ww2gi | WW2GI.GRP | ww2gi |
| Platoon Leader | ww2gi | PLATOONL.GRP, together with WW2GI.GRP | ww2gi |
Settings and the log are shared with Duke Nukem 3D: vibebuild32.cfg and
vibebuild32.log.
Data files
NNBuild recognises one release of each game by the size and checksum of its data file:
| Data file | Recognised as |
|---|---|
NAM.GRP | NAM |
NAPALM.GRP | NAPALM |
WW2GI.GRP | WWII GI |
PLATOONL.GRP | Platoon Leader, an add-on that needs WW2GI.GRP |
How the data is found:
- At start, NNBuild looks for the file names in the first table, in upper or lower case, in the folder you started it from and in the game’s subfolder.
- A data file that you pass on the command line selects the game, by its checksum or by its name.
- Once the game is chosen, it also searches the Steam and GOG.com install locations of NAM and WWII GI.
Platoon Leader is offered only when WW2GI.GRP is found as well. Keep the two
files in the same folder.
Starting the games
# Data in the nam, napalm or ww2gi subfolder
vibebuild32 --game nam
vibebuild32 --game napalm
vibebuild32 --game ww2gi
# Naming the data file selects the game by itself
vibebuild32 --grp ~/games/nam/NAM.GRP
vibebuild32 --grp ~/games/ww2gi/WW2GI.GRP
# Platoon Leader
vibebuild32 --gamegrp ~/games/ww2gi/PLATOONL.GRP
# No startup window and no intro
vibebuild32 --game ww2gi --skip-menu --skip-cinema
The older switches -nam, -napalm and -ww2gi still exist. They change the
mode of the runtime but do not help NNBuild find the data, so prefer --game.
What you can do in these games
These games use the Duke Nukem 3D runtime, so its features and launch options apply. See Duke Nukem 3D and Launch options.
- Multiplayer. The title menu has the same Multiplayer entry, and the same launch options and host console commands are available. The deathmatch modes are named Gruntmatch in NAM and NAPALM, and GI Match in WWII GI.
- Mods in JavaScript or TypeScript. See Modding.
- Map editor. NAM, NAPALM and WWII GI are target games of the editor. See Map editor.
Known limits
- Each player in a network game needs their own copy of the same data file. Base game data is never sent to other players.
- NAM and NAPALM can share files: when the script or definitions file of one is missing, the runtime uses the other’s.
- Platoon Leader cannot start without
WW2GI.GRP.
Shadow Warrior
Shadow Warrior has its own runtime inside NNBuild. It plays the game, has multiplayer with lobby support, and runs a limited set of script features. The map editor, the dedicated server and the host console commands belong to the Duke Nukem 3D runtime and are not available here.
--game name | sw (also shadowwarrior, shadow-warrior) |
| Main data file | SW.GRP |
| Folder NNBuild looks in first | sw |
| Settings and log | voidsw.cfg, voidsw.log |
Data files
You need SW.GRP from your own copy of the game. NNBuild recognises these
releases by size and checksum:
| Release | Kind |
|---|---|
| Shadow Warrior (registered) | Full game |
| Shadow Warrior, European, UK and censored releases | Full game |
| Shadow Warrior Shareware 1.0, 1.1 and 1.2 | Shareware |
| Shadow Warrior Mac Demo | Shareware |
| Wanton Destruction | Add-on, needs the registered game |
| Twin Dragon (three known releases) | Add-on, needs the registered game |
How the data is found:
- At start, NNBuild looks for
SW.GRP(alsoSw.grporsw.grp) in the folder you started it from and in itsswsubfolder. - A data file that you pass on the command line selects Shadow Warrior, by
its checksum or by one of these names:
SW.GRP,WANTON.GRP,TD.GRP,TWIN DRAGON.GRP,TWIN_DRAGON.GRP. - Once Shadow Warrior is chosen, the game scans its search folders, which include the Steam and GOG.com install locations of the Classic releases.
To start an add-on whose data file was found, add one of these switches:
| Switch | Starts |
|---|---|
-addon0 | Shadow Warrior itself |
-addon1 | Wanton Destruction |
-addon2 | Twin Dragon |
Starting the game
Start Shadow Warrior with --skip-menu. It then goes straight to its own
title screen.
# Data in the sw subfolder
vibebuild32 --game sw --skip-menu
# Data somewhere else
vibebuild32 --game sw --grp ~/games/sw/SW.GRP --skip-menu --skip-cinema
# Start at level 4 on skill 3
vibebuild32 --game sw --skip-menu --level 4 -s3
# A map file of your own (not with shareware data)
vibebuild32 --game sw --skip-menu -map ~/maps/dojo.map
# Wanton Destruction
vibebuild32 --game sw --skip-menu -addon1
Useful options of this runtime:
| Option | Meaning |
|---|---|
--level <n> | Start at level n. Level 1 is the first level. |
-s<n> | Skill, 1 to 4. |
-map <file> | Load a map file. |
-monst | No monsters. |
-name <name> | Your player name. |
-nodemo | Do not play demos at the title screen. |
-nometers | Hide the air and boss meter bars. |
Set the video mode in the game’s own options menu.
Multiplayer
Shadow Warrior uses the same -net syntax as Duke Nukem 3D. The host names
the number of players and everyone else names the host. The game starts when
all players are connected. A match holds up to 8 players, or 4 with shareware
data.
# Host a 2-player game on UDP port 23513
vibebuild32 --game sw --skip-menu -name Host -net /p23513 /n0:2
# Join it
vibebuild32 --game sw --skip-menu -name Guest -net /n0 192.0.2.10:23513
-net and everything after it must come last on the command line. The parts
of the -net block are explained in
Launch options.
Lobby options, written before -net:
| Option | Meaning |
|---|---|
--advertise <address> | Host: list this game on the lobby server at address. |
--lobbylist <address> | Write the games listed on that lobby server to the log, then continue starting. |
--joinlobby <address> | Join the first game listed on that lobby server. No -net block is needed. |
# Host and list the game on a lobby server
vibebuild32 --game sw --skip-menu --advertise lobby.example.org -net /p23513 /n0:2
# Join whatever that lobby server lists first
vibebuild32 --game sw --skip-menu --joinlobby lobby.example.org
The short forms -ad (for --advertise) and -ll (for --lobbylist) work
too. Write --joinlobby in full: Shadow Warrior ignores its short form -jl.
When the host has loaded a map file with -map, it is sent to the other
players before the level starts.
When Shadow Warrior runs as a network game, New Game opens the Network
Game menu. Its Browse Servers entry shows the games on a lobby server and
joins the one you pick. It asks the lobby server named with
-masteraddr <address>, or this computer if that option was not given.
Joining from this list works on Linux and macOS.
Script mods
Shadow Warrior loads JavaScript and TypeScript mods the same way Duke Nukem 3D
does: from autojs/<name>/index.ts or index.js, or with --js <file>.
It offers the part of the script interface that does not depend on Duke Nukem
3D: events with on and off, log, the built-in modules, fetch, and
debugging in VS Code. Functions that read or change Duke Nukem 3D game state
stop the script with an error. See Modding.
Playing Duke Nukem 3D levels
The Shadow Warrior runtime can load levels from Duke Nukem 3D, World Tour, NAM, NAPALM and WWII GI. You play as Lo Wang, with Shadow Warrior’s weapons, inside the other game’s level.
vibebuild32 --game sw --grp ~/games/sw/SW.GRP \
--game.levels duke --grp ~/games/duke3d/DUKE3D.GRP \
-map E1L1.MAP --skip-menu
--game.levels dukenames the game the levels come from.- The second
--grpgives that game’s data. NNBuild uses it only as a source of levels, art and sounds. -mapnames the level to start.
What happens to the level:
- Item, weapon and ammo pickups become their Shadow Warrior counterparts.
- The Duke Nukem 3D enemies stay in the level.
To add a Duke Nukem 3D mod, give its file with another --grp after the base
game. A file that NNBuild does not recognise as a known game is taken as add-on
data for the game named by --game.levels. Files of type .grp, .zip,
.pk3, .pk4 and .ssi are accepted.
vibebuild32 --game sw --grp ~/games/sw/SW.GRP \
--game.levels duke --grp ~/games/duke3d/DUKE3D.GRP --grp ~/games/duke3d/vacation.grp \
-map VACA1.MAP --skip-menu
A single map file is played with -map, plus -j <folder> when it is not in
a folder that is already searched:
vibebuild32 --game sw --grp ~/games/sw/SW.GRP \
--game.levels duke --grp ~/games/duke3d/DUKE3D.GRP \
-j ~/maps -map MYLEVEL.MAP --skip-menu
--game.items and --game.weapons are explained in
Supported games. Left out,
they mean Shadow Warrior.
Known limits
- No dedicated server, no server console and no host commands such as kick or map rotation.
- Players cannot join a match after it has started.
- Shareware data cannot load map files or extra data files.
- The video mode is not set from the command line.
- Joining from Browse Servers is not available on Windows.
Blood
Blood has its own runtime inside NNBuild. It plays the game and has multiplayer with lobby options on the command line. The map editor, script mods, the dedicated server and the host console commands belong to the Duke Nukem 3D runtime and are not available here.
--game name | blood |
| Main data file | BLOOD.RFF |
| Folder NNBuild looks in first | blood |
| Settings and log | notblood.cfg, notblood.log |
Data files
Blood does not keep its data in a single file. Use the whole folder of your own copy of the game. The runtime opens these files from it:
BLOOD.RFF,SOUNDS.RFFandGUI.RFFBLOOD.INI- the art files, starting with
TILES000.ART SURFACE.DAT,VOXEL.DATandSHADE.DAT
If a file named notblood.pk3 is in a search folder, it is loaded as well.
Episode sets are described by .ini files. These three are known by name:
| File | Episode set |
|---|---|
BLOOD.INI | Blood: One Unit Whole Blood |
CRYPTIC.INI | Cryptic Passage. Also needs the art files CPART07.AR_ and CPART15.AR_. |
DW.INI | Death Wish |
How the data is found:
- At start, NNBuild looks for
BLOOD.RFF(orblood.rff) in the folder you started it from and in itsbloodsubfolder. - A file that you pass on the command line selects Blood when it is a Blood
.rffarchive, a Blood episode.inifile, or is namedBLOOD.RFForBLOOD.INI. - A folder given with
--game-diror-jselects Blood when it holdsBLOOD.RFFand no other game’s main data file.
Starting the game
Start Blood with --skip-menu. It then goes straight to its own title screen.
# Data in the blood subfolder
vibebuild32 --game blood --skip-menu
# Data somewhere else
vibebuild32 --game blood --game-dir ~/games/blood --skip-menu
# Episode 1, level 3
vibebuild32 --game blood --skip-menu -level 1 3
# A map file of your own
vibebuild32 --game blood --skip-menu -map ~/maps/crypt.map
# Cryptic Passage
vibebuild32 --game blood --skip-menu --ini ~/games/blood/CRYPTIC.INI
Useful options of this runtime:
| Option | Meaning |
|---|---|
-level <episode> <level> | Start at that level. Write it with one dash. |
-map <file> | Load a map file. |
--ini <file> | Use another episode .ini file. The default is BLOOD.INI. |
--rff <file> | Use another main .rff archive. |
-snd <file> | Use another sound .rff archive. |
-art <file> | Use another base art file name. |
--monsters <n> | 0 turns monsters off. 1 or more turns them on and sets the skill to n minus one. |
-nodudes | No monsters. |
-s <n> | Difficulty, 0 to 4. |
-name <name> or -pname <name> | Your player name. |
-nodemo | Do not play demos. |
-quick | Skip the intro screens. --skip-cinema does the same. |
-cfg <file> | Use another settings file. |
-g <file>, -j <folder> | Load an extra data file, or search an extra folder. |
Blood is strict about options. If it is given an option it does not know,
it stops with an “Invalid argument” error. Options that belong to other games,
for example -nosound, --level, --volume or --con, cannot be used with
Blood.
Set the video mode in the game’s own options menu.
Multiplayer
Blood uses its own network system. One player starts a server for a number of players, and the others connect to it.
# Server for 2 players
vibebuild32 --game blood --skip-menu -server 2
# Client
vibebuild32 --game blood --skip-menu -client 192.0.2.10
| Option | Meaning |
|---|---|
-server <players> | Start a server for that many players, 1 to 8. |
-client <host> | Connect to a server. |
-port <n> | The server’s port. The default is 23513. |
-clientport <n> | The local port a client uses. |
-netretry | Client: keep trying to connect. Hold Escape to stop. |
-auto | Start the network game without waiting in the menu. Also skips the intro. |
-mp_mode <0-2> | Game mode: 0 co-op, 1 Bloodbath, 2 teams. |
-mp_level <episode> <level> | Level for the match. |
-mp_map <file> | Map file for the match. |
-mp_diff <0-4> | Difficulty. |
-mp_dudes <0-2> | Monsters: 0 none, 1 spawn, 2 respawn. |
-mp_weaps <0-3> | Weapons: 0 do not respawn, 1 permanent, 2 respawn, 3 respawn with markers. |
-mp_items <0-2> | Items: 0 do not respawn, 1 respawn, 2 respawn with markers. |
-mp_score <1-255> | Score or lives limit. |
-mp_time <1-60> | Time limit. |
Further -mp_ options are listed in
Launch options.
Lobby options:
| Option | Meaning |
|---|---|
--advertise <address> | Server: list this game on the lobby server at address. |
--lobbylist <address> | Write the games listed on that lobby server to the log. |
--joinlobby <address> | Connect to the first game listed on that lobby server. -client is not needed. |
--netfile <file> | Server: send this file to players who connect. Can be given up to eight times. |
# Server listed on a lobby server, sharing a mod file
vibebuild32 --game blood --skip-menu -server 4 \
--advertise lobby.example.org --netfile mymod.pk3
# Join whatever that lobby server lists first
vibebuild32 --game blood --skip-menu --joinlobby lobby.example.org
Write the lobby options in full. Blood does not know their short forms, such
as -ad or -jl, and stops when it is given one.
A player who receives a file with --netfile gets it written into the folder
the game runs from. Files of type .grp, .zip, .pk3, .pk4 and .rff
are loaded at once. A file the player already has is not sent again.
Known limits
- Unknown options stop the game, as described above.
- The cutscene movies of the game are not played.
- Maps that depend on the “modern map” extensions of other Blood ports are not supported.
- The video mode is not set from the command line.
- No dedicated server console and no host commands such as kick or map rotation.
- Blood does not take part in playing one game’s levels in another.
Redneck Rampage
Redneck Rampage has its own runtime inside NNBuild. It plays Redneck Rampage and Redneck Rampage: Rides Again, and has multiplayer with lobby options on the command line. The map editor, script mods and the host console commands of the Duke Nukem 3D runtime are not available here.
--game name | rr (also redneck, redneckrampage, redneck-rampage) |
| Main data file | REDNECK.GRP |
| Folder NNBuild looks in first | rr |
| Settings and log | rednukem.cfg, rednukem.log |
Data files
You need REDNECK.GRP from your own copy of the game. NNBuild recognises two
releases by size and checksum:
| Release | Data file |
|---|---|
| Redneck Rampage | REDNECK.GRP |
| Redneck Rampage: Rides Again | REDNECK.GRP of Rides Again |
Both games name their data file REDNECK.GRP. Keep them in separate folders
and point NNBuild at the one you want.
How the data is found:
- At start, NNBuild looks for
REDNECK.GRP(orredneck.grp) in the folder you started it from and in itsrrsubfolder. - A data file that you pass on the command line selects Redneck Rampage, by
its checksum or by one of these names:
REDNECK.GRP,RR.GRP,RRRA.GRP,RIDES.GRP.
Starting the game
Start Redneck Rampage with --skip-menu. It then goes straight to its own
title screen.
# Data in the rr subfolder
vibebuild32 --game rr --skip-menu
# Data somewhere else
vibebuild32 --game rr --grp ~/games/redneck/REDNECK.GRP --skip-menu
# Rides Again
vibebuild32 --game rr --grp ~/games/rides/REDNECK.GRP --skip-menu
# Episode 1, level 2, skill 3
vibebuild32 --game rr --skip-menu --volume 1 --level 2 --skill 3
# A map file of your own
vibebuild32 --game rr --skip-menu -map ~/maps/barn.map
Useful options of this runtime:
| Option | Meaning |
|---|---|
--volume <n>, --level <n> | Start at that episode and level. |
--skill <n> | Skill level. |
-map <file> | Load a map file. |
--monsters 0 | No enemies. |
-name <name> | Your player name. |
-cfg <file> | Use another settings file. |
--con <file> | Load another main script. |
--def <file> | Load another definitions file. |
-ns, -nm | No sound, no music. |
Set the video mode in the game’s own options menu.
Multiplayer
Redneck Rampage uses its own network system. One player starts a server and the others connect to it.
# Server
vibebuild32 --game rr -server
# Client
vibebuild32 --game rr -connect 192.0.2.10
| Option | Meaning |
|---|---|
-server | Start a server. |
-connect <host> or -connect <host>:<port> | Connect to a server. |
-port <n> | The port to host on or connect to. The default is 23513. |
-password <text> | The password of the server. |
-server and -connect skip the startup window and the intro by themselves.
Lobby and server options:
| Option | Meaning |
|---|---|
--advertise <address> | Start a server and list it on the lobby server at address. |
--lobbylist <address> | Write the games listed on that lobby server to the log. |
--joinlobby <address> | Connect to the first game listed on that lobby server. |
--netfile <file> | Server: send this file to players who connect. Can be given up to eight times. |
--headless or --dedicated | Start a server without a window. It waits for players and starts the match by itself. |
--nplayers <n> | How many players the server waits for before it starts the match. The default is 2. |
--wait | Server without a window: do not start the match automatically. |
--startnow | Server with a window: start the match automatically as well. |
Each of these options has a short form: -ad, -ll, -jl, -nf, -hl or
-dd, -np, -w and -sn, in the order of the table.
# A server without a window, listed on a lobby server, starting when 3 players are in
vibebuild32 --game rr --headless --advertise lobby.example.org --nplayers 3
# Join whatever that lobby server lists first
vibebuild32 --game rr --joinlobby lobby.example.org
A player who receives a file with --netfile gets it written into the folder
the game runs from. Files of type .grp, .zip, .pk3, .pk4 and .rff
are loaded at once. A file the player already has is not sent again.
The game’s console has its own connect, disconnect, listplayers, kick,
kickban and password commands.
Known limits
- A server without a window has no console in the terminal.
--monsterscan only turn enemies off in this game. Use--skillto set the skill.- The video mode is not set from the command line.
-netis not used by this game. It stops with a message that points to-serverandconnect.- Duke Nukem 64 is not included, although the code this runtime comes from supports it.
- Redneck Rampage does not take part in playing one game’s levels in another.
Exhumed / PowerSlave
The DOS game known as PowerSlave in North America and Exhumed in Europe has its own runtime inside NNBuild. NNBuild’s name for this runtime is Kexhumed, and that is the name you see in the game picker and the window title.
The runtime plays the classic game, has multiplayer, and has a KEX mode that uses the data of the PowerSlave Exhumed remaster. The map editor, script mods and the host console commands of the Duke Nukem 3D runtime are not available here.
--game name | exhumed (also kexhumed, powerslave, power-slave, pcexhumed) |
| Main data file | STUFF.DAT |
| Folder NNBuild looks in first | exhumed |
| Settings and log | kexhumed.cfg, kexhumed.log |
Data files
You need STUFF.DAT from your own copy of the game. Leave it in the game’s
folder, next to the files it was installed with. NNBuild recognises these
releases by size and checksum:
| Release | Kind |
|---|---|
| PowerSlave | Full game |
| Exhumed | Full game |
| PowerSlave Demo | Demo |
| Exhumed Demo | Demo |
How the data is found:
- At start, NNBuild looks for
STUFF.DAT(orstuff.dat) in the folder you started it from and in itsexhumedsubfolder. - A data file that you pass on the command line selects this game, by its
checksum or by the name
STUFF.DAT.
Starting the game
Start with --skip-menu. The game then goes straight to its own title
screens.
# Data in the exhumed subfolder
vibebuild32 --game exhumed --skip-menu
# Data somewhere else
vibebuild32 --game exhumed --grp ~/games/powerslave/STUFF.DAT --skip-menu
# Jump straight to level 3, without the intro
vibebuild32 --game exhumed --skip-menu -quick -3
# A map file of your own
vibebuild32 --game exhumed --skip-menu -map ~/maps/tomb.map
Useful options of this runtime:
| Option | Meaning |
|---|---|
-<n> | Jump to level n, for example -3. |
-map <file> | Load a map file. |
-quick | Skip the intro screens and movie. --skip-cinema also skips them. |
-nocreatures | No enemies. |
-nosound, -nomusic | No sound effects, no music. |
-record, -playback | Record a demo to DATA.VCR, or play that file back. |
-name <name> | Your player name in a network game. |
-color <0-7> | Your player colour in a network game. |
-cfg <file> | Use another settings file. |
-g <file>, -j <folder> | Load an extra data file, or search an extra folder. |
This runtime does not understand --level, --volume, --monsters or the
video options. Use the options in the table, and set the video mode in the
game’s own menu.
Multiplayer
The multiplayer of this runtime is new code written for NNBuild. It uses the
same -net syntax as Duke Nukem 3D and holds up to 8 players.
# Host a 2-player game on UDP port 23513
vibebuild32 --game exhumed --skip-menu -name Host -net /p23513 /n0:2
# Join it
vibebuild32 --game exhumed --skip-menu -name Guest -net /n0 192.0.2.10:23513
-net and everything after it must come last on the command line. The parts
of the -net block are explained in
Launch options.
Options written before -net:
| Option | Short form | Meaning |
|---|---|---|
--advertise <address> | -ad | Host: list this game on the lobby server at address. |
--lobbylist <address> | -ll | Write the games listed on that lobby server to the log, then continue starting. |
--joinlobby <address> | -jl | Join the first game listed on that lobby server. No -net block is needed. |
--netfile <file> | -nf | Host: send this file to players before the level loads. |
--dedicated or --headless | -dd, -hl | Run a server without a window. On Linux and macOS it reads console commands typed in its terminal. |
--nplayers <n> | -np | Start once n players are connected. The default is 2. |
--startnow | -sn | Start with the players who are present. The other slots stay reserved. |
--latejoin | -lj | Host: let players enter a reserved slot while the level is running. Use it together with --startnow. |
--wait | -w | Server without a window: do not start automatically. |
A server without a window starts the match by itself unless --wait is given.
# A server with four slots. It starts when one player has joined.
# Players can keep joining while the level runs.
vibebuild32 --game exhumed --skip-menu -name Server \
--dedicated --startnow --nplayers 2 --latejoin -net /p23513 /n0:4
# The same server, listed on a lobby server and sharing a mod file
vibebuild32 --game exhumed --skip-menu -name Server \
--dedicated --advertise lobby.example.org --netfile mymod.grp -net /n0:4
# Join whatever that lobby server lists first
vibebuild32 --game exhumed --skip-menu -name Guest --joinlobby lobby.example.org
Chat. The console command say <text> sends a chat message to the other
players. On a server without a window (Linux and macOS), type it in the
terminal:
say The next level starts in one minute
KEX mode
PowerSlave Exhumed, the 2022 remaster by Nightdive Studios, is a different program with its own data. KEX mode lets this runtime use that data.
vibebuild32 --game exhumed --skip-menu \
-j ~/games/powerslave -kex "/home/you/games/PowerSlave Exhumed"
-kex <folder>names the folder of your own PowerSlave Exhumed install. NNBuild loads the filePowerslaveEX.kpffrom it and also searches that folder for other files.- The remaster’s levels are not Build maps. They have to be converted to
.mapfiles first, with the converter script that is part of NNBuild’s source code (source/exhumed/tools/kexmap.py). Put the converted files in a folder NNBuild searches, for example with-j. - You still need
STUFF.DATfrom the DOS game. - In KEX mode, New Game starts the remaster’s campaign. The level comes
from the remaster’s level-select screen, or from the map named in the file
kexstart.txtthat the converter writes. - KEX mode has its own default key bindings.
To start one converted level directly, add -map:
vibebuild32 --game exhumed --skip-menu \
-j ~/games/powerslave -kex "/home/you/games/PowerSlave Exhumed" -map THOTH.MAP
Known limits
- The video mode is not set from the command line.
- File names given without an option are ignored. Use
-g,-mapand-j. - There is no list of games in the menus. Use
--joinlobby. - Players can join a running match only when the host used
--latejoinand a slot is free. - KEX mode needs the converter step described above.
- Exhumed does not take part in playing one game’s levels in another.
Playing online
This page is for players. It explains how to find and join a match, what you see while you join, what is downloaded for you, and what happens when a connection goes wrong.
Most of this page describes the Duke Nukem 3D family: Duke Nukem 3D, Duke Nukem 3D: World Tour, NAM, NAPALM, World War II GI and Ion Fury. They share one game runtime, and that runtime has the full set of online features. The table in Other games shows what Shadow Warrior, Blood, Redneck Rampage and Exhumed support.
Some words used on this page:
- The host is the computer that runs the match. Every other player connects to it. A host that only runs the match and does not play is a server.
- A slot is a place for one player in a match.
- The lobby server keeps a list of matches that are open. The menus and logs call it the masterserver.
- A GRP is the data file of the original game, for example
DUKE3D.GRP. - A mod pack is one file that holds a mod: a GRP, ZIP, PK3, PK4 or SSI file.
Before you join
- You need your own copy of the game data. The host never sends the base
game. If the host uses an edition you also have installed, NNBuild selects
it for you. If you do not have it, the join stops and the log says
The server uses different base game data. - Use the same NNBuild version as the host. If the versions differ, the
game closes with
You cannot play with different versions of NNBuild!. - Use the 64-bit build unless your computer cannot run it. To join a match that is already running, your build must be of the same kind as the host’s: 64-bit with 64-bit, or 32-bit with 32-bit. See 32-bit and 64-bit builds.
- Tell NNBuild which lobby server to use, if you want a server list. See the next section.
Choose a lobby server
NNBuild asks one lobby server for the list of matches. Its address is the
console setting cl_masterserver. Until you change it, the address is
127.0.0.1, which is your own computer, so the list stays empty unless you
run a lobby yourself.
-
Open the in-game console.
-
Type the setting and the address your community uses:
cl_masterserver lobby.example.orgAdd a port if the lobby does not use the standard one, for example
lobby.example.org:23600. The standard port is 23519.
The address is saved with your other settings. More about lobbies is on the lobby server page.
Join from the menu
- Choose MULTIPLAYER in the main menu. The NETWORK GAME screen opens with PLAYER SETUP, JOIN GAME and HOST GAME.
- Choose JOIN GAME. NNBuild asks the lobby server for its list and shows
up to 12 matches. The bottom of the screen shows which lobby was asked, as
Masterserver:followed by its address. - Move to a match and press Enter.
Each row shows the server’s name, the player and slot numbers the server
reported, the map and the address. A row that ends in +v6 also has an IPv6
address. A row that ends in v6 has only an IPv6 address.
NNBuild then restarts itself as a player in that match. The window closes and opens again. This is normal.
Below the matches there are two more entries:
-
Enter address manually… opens JOIN BY ADDRESS. Type the address and port, then press Enter. Press Esc to go back. Use this for a match on your local network, or for one that is not on the list.
203.0.113.10:23513 [2001:db8::10]:23513The first form is an IPv4 address and the second is an IPv6 address. If you leave out the port, 23513 is used.
-
Refresh list asks the lobby again.
The screen can also show these messages:
| Message | Meaning |
|---|---|
Could not reach the masterserver. | The lobby’s address could not be looked up. Check cl_masterserver. |
No servers advertised. | The lobby’s list is empty, or the lobby did not answer in time. |
Could not reach <address> (offline or unreachable). | You tried to join and nothing answered for about 30 seconds. NNBuild brought you back to this screen. |
A server that is full does not answer new players, and neither does a server that has banned your address. Both look the same as a server that is offline.
Ion Fury’s main menu has no MULTIPLAYER entry. Join from the command line instead.
Join from the command line
Put the network options last. Everything after --net belongs to the
connection.
vibebuild32 --name DUKEFAN --net /n0 203.0.113.10:23513
--namesets your nickname for this run./n0followed by an address means “join the match hosted at this address”.- The address can be an IPv4 address, an IPv6 address in square brackets, or a
host name. Add
:portwhen the host does not use port 23513.
vibebuild32 --name DUKEFAN --net /n0 play.example.org:23600
vibebuild32 --name DUKEFAN --net /n0 '[2001:db8::10]:23513'
The quotes around the IPv6 address stop the shell from treating the square brackets as a pattern.
If you run two copies of the game on one computer, give each copy its own
local port with /p. The number must be from 1025 to 65534.
vibebuild32 --name TESTER --net /p23514 /n0 127.0.0.1:23513
While the game waits for the server, the log shows a line every three seconds (and the startup window, where there is one, shows it in its title):
Waiting for the server - retrying (4)... Cancel to abort
A command-line join keeps trying until the server answers or you cancel. It is safe to start your game before the server is up.
If you have data for more than one game installed, add --game duke (or the
name of the game you mean) before --net. Without it, NNBuild asks which game
to run when it is started from a terminal, and takes the first game it finds
when it is not. See First launch.
Joining a match that is already running
A host can leave slots open so that players may join at any time. When you join such a match you see a joining screen instead of the game:
- a status line,
- a progress bar and a percentage,
- two choices, WAITING and CANCEL.
The status line changes as the join moves forward:
| Status line | What is happening |
|---|---|
Connecting to game in progress | The host knows you are there. |
Downloading <file> (2 of 3) | A file you do not have is being sent. |
Receiving game state | The host is sending the running match. |
Entering the level | Everything has arrived. |
To give up, press Esc, or move down to CANCEL and press Enter. The game then closes.
Mod packs are downloaded earlier, before the game window opens. During that
time the same Downloading text is written to the log and, where there is a
startup window, shown in its title.
While you receive the running match, the match is paused for everyone. When
you are in, the other players see a short message with your name followed by
joined. You appear at one of the map’s start points with fresh weapons. Your
score starts at zero, unless you are coming back to a match you left (see
Leaving and coming back).
If nothing arrives from the host for 20 seconds, the join stops with
Timed out joining the game in progress (no data from host).
If the host has not started the match yet, your game waits with it and enters the level together with everyone else.
32-bit and 64-bit builds
NNBuild comes as a 64-bit build and as a 32-bit build. A player cannot join a running match with the other kind. The running match is sent to a new player in the form of a saved game, and a saved game made by one kind of build cannot be read by the other.
- Use the 64-bit build unless your computer cannot run it. The Downloads page lists the builds.
- A player with the 32-bit build cannot join a running match on a 64-bit host. A player with the 64-bit build cannot join a running match on a 32-bit host.
- 64-bit with 64-bit works, and 32-bit with 32-bit works. The operating system does not matter. A Windows player can join a Linux server, for example.
If your build is the wrong kind, the join runs to the end of the transfer and then the game closes with one of these messages:
This match is hosted by a 64-bit build.
Joining a match in progress needs the 64-bit build of the game.
This match is hosted by a 32-bit build.
Joining a match in progress needs the 32-bit build of the game.
The same rule applies whenever your game joins a running match by itself: when you come back after a lost connection, after it lost sync, and after the server changed its mod pack.
Automatic downloads
When you join, the host tells your game which files the match uses. For each one your game checks the name, the size and a checksum. Only files you do not have are sent.
The host sends:
- the mod packs the match is using,
- the custom map being played, together with the files that belong to it: a
map-hack file (
.mhk), map music, and map art files such asarena_00.art.
The host does not send the base game data. Each player needs their own copy.
Your game looks for a file you already have in three places before it downloads: its download cache, its normal game folders, and the folders below the one it runs from. A file with the same name and the same content is used even if it sits in another folder.
Downloads are kept in a folder named netcache inside the folder the game
runs from. On Linux and macOS that is ~/.config/vibebuild32 unless you start
the game with -usecwd. A file that is already in the cache is not downloaded
again.
Leaving and coming back
To leave, quit the game in the usual way. The other players see your name
followed by is history!. You can join the same server again later. After a
normal quit you start again with a score of zero.
If you did not mean to leave, the host keeps your score for you. It saves your frags, suicides and deaths when it removes you for one of these reasons:
- your connection went silent, for example after a crash or a network failure. The host frees the slot of a player it has not heard from for five seconds;
- you started the game again and connected before the host had noticed that you were gone. The host then drops the old connection and lets you in;
- you were removed by the lag countdown or vote;
- your game restarted itself after losing sync;
- you were kicked.
To come back, join the same server again. If the match is still running, your score is restored a moment after you appear.
- The host recognises you by a player ID, not by your nickname. NNBuild creates the ID the first time it runs and keeps it in your settings file. Someone who copies your name does not get your score.
- Scores are kept for the current match only. When the host starts a new game or changes the level, saved scores are discarded.
- If you delete your settings file you get a new ID, and the host treats you as a new player.
Coming back needs a host that lets players join a running match. Matches started from the HOST GAME menu allow it.
When a player lags
The usual way to run a match is called lockstep: the game moves forward only when it has every player’s input for the next moment. If one player’s input stops arriving, everyone would wait. NNBuild limits that wait.
After half a second without progress, every player sees:
WAITING FOR PLAYERS
DUKEFAN is lagging
Continuing in 30...
The countdown starts at 30 seconds.
- If you are not the one lagging, you also see
Press F9 to vote to drop. Press F9 to vote. The line changes toVote to drop cast. - If you are the one lagging, you see
Reconnect or you will be dropped.
The lagging player is removed when the countdown reaches zero, or earlier when enough players have voted. The host counts the players who are not lagging, leaving itself out, and removes the lagging player once the votes reach half of that number. In a match with only two players, only the countdown applies.
A player whose connection goes completely silent is removed after five seconds, without a vote.
If the lagging player catches up, the message disappears and the match continues. A removed player can join again, as described above.
A host can also run the match in a no-wait mode. In that mode there is no countdown, because the match never stops for a slow player. See Lockstep and no-wait mode.
When your game loses sync
Every copy of the game must stay exactly the same as the host’s. NNBuild checks this all the time. If your copy has drifted away, you see:
LOST SYNC WITH HOST (...)
The game desynchronized.
Reconnecting...
After about two seconds your game restarts itself with the same launch options and joins the match again. Your score is restored in the same way as after leaving and coming back. You do not need to do anything.
This also needs a host that lets players join a running match. If the restart
fails, the game closes with Reconnect after desync failed; please rejoin.
How multiplayer works explains why this can happen.
When the server changes its mod pack
A server can switch to another mod pack while players are connected. Every game must then load the new pack from the start, so the match begins again and your game follows by itself:
- Your game stops for about two seconds.
- It restarts itself with the same launch options and connects to the server again. The window closes and opens again.
- If you do not have the new pack, it is downloaded and kept in your download cache.
- You see the joining screen, and then you are in the new match.
You do not need to do anything. Scores start at zero for everyone, because this is a new match.
The log shows Reconnecting to load the server's selected pack when this
happens. A server that rotates maps may do it several times in an evening,
each time the rotation moves to a level from another pack.
Player options
Open MULTIPLAYER, then PLAYER SETUP. The screen has these entries: Name, Color, Team, Skin, Auto aim, Mouse aim, Switch weapons on pickup, Switch weapons when empty and Multiplayer macros.
You can also set the first four from the console or at launch:
| Option | Console | Launch option |
|---|---|---|
| Name | name DUKEFAN | --name DUKEFAN |
| Colour | color <palette number> | --color <colour> |
| Team | team <0-3> | |
| Skin | skin <0-9> | --skin <name or number> |
- Name. A name is cut to 10 characters and is shown in capital letters.
- Colour.
--colortakes one ofbrown,gray,purple,red,yellow,olive,green,blue, or a value such as#2050e0, which picks the closest of those eight. - Team. The teams are Blue (0), Red (1), Green (2) and Gray (3).
- Skin. See below.
Skins
A skin changes how other players see you. The first seven after Duke are enemies from Duke Nukem 3D. The last two are characters from other games.
| Number | Skin |
|---|---|
| 0 | Duke |
| 1 | Assault Trooper |
| 2 | Assault Captain |
| 3 | Octabrain |
| 4 | Assault Commander |
| 5 | Enforcer |
| 6 | Pig Cop |
| 7 | Alien Beast |
| 8 | Lo Wang |
| 9 | Shelly |
- An enemy skin can be chosen only when the game data contains that enemy’s art. Alien Beast needs the Atomic Edition.
- Lo Wang needs Shadow Warrior data and Shelly needs Ion Fury data.
- A skin that is not available falls back to Duke.
At launch you can give the number or the name. Spaces, hyphens and capital letters in the name do not matter.
vibebuild32 --skin pigcop --net /n0 203.0.113.10:23513
vibebuild32 --skin "Assault Commander" --net /n0 203.0.113.10:23513
Optional settings for your own game
-
--zeropingshows your own gunfire the moment you press fire, instead of waiting for the shot to come back from the host. It changes only what you see. Each player decides this for themselves.vibebuild32 --zeroping --net /n0 203.0.113.10:23513 -
cl_preferipv6 1makes the JOIN GAME list connect over IPv6 when a server offers both kinds of address. Without it, IPv4 is used.
Chat commands
Some servers run scripts that answer commands typed in the chat box. A message
that starts with ! is such a command, for example !rules. It goes to the
server only, and the answer is shown only to you. If the server has no such
command, you get Unknown server command.
Other games
NNBuild can also run Shadow Warrior, Blood, Redneck Rampage and Exhumed (PowerSlave). Each has its own runtime, and the online features differ. “No” means the code of that runtime does not contain the feature.
| Feature | Duke Nukem 3D family | Shadow Warrior | Blood | Redneck Rampage | Exhumed |
|---|---|---|---|---|---|
| Server list in the game | JOIN GAME | Browse Servers in the Network Game menu | No | No | No |
| Join by address at launch | --net /n0 <address> | --net /n0 <address> | --client <host>, with --port <port> if needed | --connect <address> | --net /n0 <address> |
Join the first match on a lobby with --joinlobby <lobby> | No | Yes | Yes | Yes | Yes |
| Join a running match | Yes | No | No | No | Yes, if the host allows it with --latejoin and has a free slot |
| Come back with your score | Yes, except after a normal quit | No | No | No | Yes, into the slot you left |
| Files sent to you | Mod packs and custom maps, checked against what you have | Files the host names with --netfile, and the custom map | Files the host names with --netfile | Files the host names with --netfile, and the custom map | Files the host names with --netfile, and the custom map |
| Lag countdown and F9 vote | Yes | No | No | No | No. A silent player is removed after 12 seconds. |
| Automatic reconnect after losing sync | Yes | No | No | No | No. The game shows OUT OF SYNC. |
| Enemy skins | Yes | No | No | No | No |
--zeroping | Yes | No | No | No | No |
In Shadow Warrior, Blood and Redneck Rampage all players must be connected before the match starts.
Hosting a match
This page explains how to host a match that you also play in. To run a server that only hosts, read Running a dedicated server afterwards. It builds on this page.
The page describes the Duke Nukem 3D family (Duke Nukem 3D, Duke Nukem 3D: World Tour, NAM, NAPALM, World War II GI and Ion Fury). The last section, Other games, lists what differs for Shadow Warrior, Blood, Redneck Rampage and Exhumed.
Some words used on this page:
- The host is the computer that runs the match. Other players connect to it.
- A slot is a place for one player. The host uses one slot itself.
- A GRP is the data file of the original game, for example
DUKE3D.GRP. - A mod pack is one file that holds a mod: a GRP, ZIP, PK3, PK4 or SSI file.
- The lobby server keeps a list of open matches. Menus and logs call it the masterserver. See The lobby server.
- NAT is what a home router does when several devices share one internet address. A router with NAT blocks connections that come in from outside unless you tell it otherwise.
Host from the menu
- Choose MULTIPLAYER in the main menu.
- Choose HOST GAME.
- Choose one of:
- HOST INTERNET GAME to host and put the match on the lobby server’s list.
- HOST LAN GAME to host without putting it on any list.
Both choices do the same thing apart from the list. NNBuild restarts itself as a host with these settings:
- 4 slots,
- UDP port 23513,
- the match starts at once, without waiting for anyone,
- players can join at any time.
The menu text names E1L1 as the starting level. To move to another level, open
the console and use the map command, for example map E1L3. See
Administering a server.
HOST INTERNET GAME uses the lobby address in the console setting
cl_masterserver. Until you change that setting it is 127.0.0.1, your own
computer, so set it first.
Playing online shows how.
Players on your local network join a HOST LAN GAME match by address: they
choose JOIN GAME, then Enter address manually…, and type your
computer’s local address and the port, for example 192.168.1.20:23513.
Ion Fury’s main menu has no MULTIPLAYER entry. Host from the command line instead.
Host from the command line
The command line gives you every setting. The network part starts with --net
and must come last: everything after --net belongs to the connection, and
every other option must come before it.
vibebuild32 [options] --net [/p<port>] /n0:<slots>
/n0:<slots>hosts a match with that many slots. The host counts as one./n0alone means 2 slots./p<port>chooses the UDP port to listen on. The number must be from 1025 to 65534. Without/p, port 23513 is used.
The tokens after --net may also be written with a dash, as -n0:4 and
-p23513.
If you have data for more than one game installed, add --game duke (or the
name of the game you mean) before --net. Without it, NNBuild asks which game
to run when it is started from a terminal, and takes the first game it finds
when it is not. See First launch.
Worked examples
A match for two. The host waits for the second player, then the match starts on episode 1, level 1.
vibebuild32 --name HOST --coop 1 --volume 1 --level 1 --net /n0
The other player joins with:
vibebuild32 --name GUEST --net /n0 203.0.113.10:23513
An open deathmatch with 8 slots. The match starts at once, and players come and go as they like.
vibebuild32 --name ARENA --startnow --coop 1 --volume 1 --level 1 --net /n0:8
A co-op game for four that starts when the first friend arrives. The other two can join later.
vibebuild32 --name HOST --latejoin --coop 2 --volume 1 --level 1 --net /n0:4
A different port. Players then add :23600 to your address.
vibebuild32 --name ARENA --startnow --coop 1 --volume 1 --level 1 --net /p23600 /n0:8
A mod pack and a custom map. Players who join get both files automatically.
vibebuild32 --name ARENA --startnow --coop 1 --grp arena.pk3 --map "User Arena.map" --net /n0:8
A match on the lobby list. Add --advertise and the lobby’s address.
vibebuild32 --name ARENA --startnow --coop 1 --volume 1 --level 1 --advertise lobby.example.org --net /n0:8
Number of slots
The number after /n0: is the number of slots, with the host included. A
match needs at least 2 slots. The largest match that players can join has 15
slots.
On a dedicated server the server itself takes one slot and does not play, so
/n0:8 leaves room for 7 players.
Game mode and starting level
| Option | Meaning |
|---|---|
--coop 1 | Dukematch |
--coop 2 | Cooperative |
--coop 3 | Team Dukematch |
--coop 4 | Survival |
--volume <n> | Episode to start in |
--level <n> | Level to start on, within that episode |
--map <file> | Start on a custom map instead |
--monsters 0 | No monsters |
--monsters <n> | Monsters on, at skill level n (1 or higher) |
-y<n> | Frag limit, for example -y20 |
The older short forms still work: -c1, -c2 and -c3 for the game mode,
-v1 for the episode and -l1 for the level. Write the number directly after
the letter. -c followed by a space means something else: it gives a
startup command.
--map also accepts the name of a built-in level, such as --map E2L1.
The setup screen inside the game
A host who starts without a level and without --startnow arrives at the
title menu once the players have connected. Choosing NEW GAME there opens
a setup screen with GAME TYPE, EPISODE, LEVEL, MONSTERS,
GAME FLAGS, USER MAP and START GAME.
The same screen is available during a match: press Esc and choose NEW GAME. When the host chooses START GAME, the new game starts for everyone. When another player does, a vote starts and the others are asked to press F1 to accept or F2 to decline.
Open slots and joining in progress
How the match starts depends on one option:
| Option | When the match starts | Joining later |
|---|---|---|
| none | When every slot is filled | Not possible |
--latejoin (short -lj) | When one other player has connected | Possible while slots are free |
--startnow (short -sn) | At once, even if the host is alone | Possible while slots are free |
--startnow includes --latejoin. The older spelling -nowait means the
same as --startnow.
With one of these options a player can also leave and come back, and can be brought back automatically after losing sync. See Playing online.
When a player joins a running match, the match pauses for everyone while the host sends the newcomer the current state of the game. The pause lasts as long as that transfer.
Without either option, ask players to connect close together. A player’s game that has connected and then hears nothing from the host for 20 seconds stops waiting and closes.
32-bit and 64-bit builds
NNBuild comes as a 64-bit build and as a 32-bit build. A player can join a running match only with the same kind of build as the host’s.
- Host with the 64-bit build unless the machine cannot run it, and ask your players to use the 64-bit build too.
- A 32-bit player cannot join a running match on a 64-bit host, and a 64-bit player cannot join a running match on a 32-bit host.
- 64-bit with 64-bit works, and 32-bit with 32-bit works. The operating system does not matter: a Linux server and Windows players get along.
The reason is that the host sends a newcomer the running match as a saved game, and a saved game made by one kind of build cannot be read by the other. A player with the wrong kind of build is told so at the end of the transfer, and the game closes. The other players still see the usual pause while that join is attempted.
The rule covers every way of entering a running match: joining late, coming back, reconnecting after a loss of sync, and reconnecting after a change of mod pack.
Lockstep and no-wait mode
NNBuild keeps every player’s game identical by running the same steps on every computer. There are two ways to pace those steps.
Lockstep is the normal mode. The match moves forward only when the host has every player’s input for the next step. Everyone sees the same thing at the same moment. The cost is that one slow connection slows everybody. NNBuild limits the damage with a countdown and a vote, described in Playing online.
No-wait mode is turned on by the host with --async (short -as).
vibebuild32 --name ARENA --startnow --async --coop 1 --volume 1 --level 1 --net /n0:8
In this mode the host never waits. If a player’s input is late, the host repeats that player’s last input for now and uses the real one when it arrives. The match keeps its pace for everyone else.
The trade-off: each player’s own actions travel to the host and back before they take effect. On a slow connection your own controls feel delayed, while in lockstep the delay is shared by all. There is no lag countdown in this mode. A player whose connection goes completely silent is still removed after five seconds.
Players do not need to set anything. The host tells each game which mode is in use.
Peer-to-peer mode
The older /n1 form is another way to start a match. There is no host that
players join by address. Instead, every player gives the addresses of all
players at launch.
List every player’s address, your own included. The order does not matter:
vibebuild32 --net /n1 192.168.1.2 192.168.1.100 192.168.1.4
Every player runs the same command. NNBuild sorts the addresses the same way on each computer and finds its own entry by comparing the list with the computer’s network addresses. This works on Linux and macOS.
On Windows, use the original form instead. Each player lists only the other
players, and the position of /n1 marks that player’s own place in the order:
| Player | Address | Command ends with |
|---|---|---|
| First | 192.168.1.2 | --net /n1 192.168.1.100 192.168.1.4 |
| Second | 192.168.1.100 | --net 192.168.1.2 /n1 192.168.1.4 |
| Third | 192.168.1.4 | --net 192.168.1.2 192.168.1.100 /n1 |
The game mode, level and other match settings are taken from the player who comes first in the order.
The map cycle (mapcycle, nextmap and map rotation) and chat commands that
start with ! work only in the host-based /n0 mode. The rest of this
section of the manual describes /n0.
Ports and routers
- The host must be reachable on its UDP port: 23513, or the port given with
/p. - If the host is behind a home router, forward that UDP port to the host’s computer in the router’s settings. If the host’s computer has a firewall, allow the port there too.
- Players who only join do not need to open anything.
Hole punching can make the port forward unnecessary. It is a way for two computers behind routers to reach each other with the help of a third computer that both can reach, here the lobby server. It applies when:
- the host is on a lobby’s list (started with
--advertise, or with HOST INTERNET GAME), and - the player joins through the same lobby, by picking the match in JOIN GAME.
It does not work with every router. If players cannot connect, forward the port. The lobby server explains the steps and the limits.
IPv4 and IPv6
The game listens on IPv4 and IPv6 at the same time when the system allows it, and on IPv4 only when it does not. At startup it prints which:
mmulti: bound UDP port 23513 (IPv4+IPv6)
An address can be written in these ways, here and in the join screens:
| Form | Example |
|---|---|
| IPv4 with port | 203.0.113.10:23513 |
| IPv6 with port | [2001:db8::10]:23513 |
| Host name with port | play.example.org:23513 |
| Any of them without a port | Port 23513 is used |
When a host name has both an IPv4 and an IPv6 address, the IPv6 address is used.
Put the match on a lobby list
Add --advertise (short -ad) and the lobby’s address before --net:
vibebuild32 --name ARENA --startnow --coop 1 --volume 1 --level 1 --advertise lobby.example.org --net /n0:8
- The address can be a host name, an IPv4 address or an IPv6 address in square
brackets. Add
:portif the lobby does not use port 23519. - The match appears on the list once it is running, and the entry is renewed every five seconds.
- The list shows your
--nameas the server’s name. A name is cut to 10 characters and shown in capital letters. - When the host quits, it tells the lobby, and the entry is removed.
Mods and custom maps
Start the host with the mod pack and it is shared with everyone who joins:
vibebuild32 --name ARENA --startnow --coop 1 --grp arena.pk3 --volume 1 --level 1 --net /n0:8
--grp <file>(short-g <file>) loads a mod pack. A pack can be a GRP, ZIP, PK3, PK4 or SSI file. You can give--grpseveral times. Up to 8 packs are offered to players.- Each player’s game checks every pack by name, size and checksum, downloads the ones it lacks, and loads the same packs before it reads the game’s scripts and art.
- A custom map given with
--mapis sent in the same way, together with the files that share its name: a map-hack file (.mhk), map music, and map art such asarena_00.art. - The base game data is never sent. Every player needs their own copy of the same edition.
- Only packs are shared. Files that the host loads loose from a folder are not sent, so put a mod’s files into one pack.
The base game can be given with --grp as well, for example
--grp ~/games/duke3d/DUKE3D.GRP. NNBuild recognises it as game data and does
not treat it as a mod pack.
A running host can change to another mod pack, or go back to the plain game,
without being stopped. The mod command does this, and a map rotation can do
it by itself. The players’ games reconnect and download the new pack
automatically. See
Switch mod packs on a live server.
Other games
“No” means the code of that runtime does not contain the feature.
| Duke Nukem 3D family | Shadow Warrior | Blood | Redneck Rampage | Exhumed | |
|---|---|---|---|---|---|
| Start a host | --net /n0:<slots> | --net /n0:<slots> | --server <players> | --server | --net /n0:<slots> |
| Choose the port | /p<port> after --net | /p<port> after --net | --port <port> | --port <port> | /p<port> after --net |
| Standard port | 23513 | 23513 | 23513 | 23513 | 23513 |
| Start without waiting for every player | --latejoin, --startnow | No | No | --startnow with --nplayers <n> | --startnow with --nplayers <n> |
| Join a running match | With --latejoin or --startnow | No | No | No | With --latejoin |
| Put the match on a lobby list | --advertise <lobby> | --advertise <lobby> | --advertise <lobby> | --advertise <lobby> | --advertise <lobby> |
| Send files to players | Automatic for mod packs and the custom map | --netfile <file> and the custom map | --netfile <file> | --netfile <file> and the custom map | --netfile <file> and the custom map |
Notes:
--netfilecan be given up to 8 times. The player’s game keeps a file it already has and writes a missing one into the folder it runs from.--nplayers <n>sets how many players must be connected before the match starts. The smallest value is 2.
Running a dedicated server
A dedicated server hosts a match and does not play in it. It can run on a rented machine or a spare computer and stay up while players come and go.
Read Hosting a match first. Everything there about slots, ports, game modes, mods and the lobby list also applies to a dedicated server. This page adds what is special about a server that runs on its own.
The page describes the Duke Nukem 3D family (Duke Nukem 3D, Duke Nukem 3D: World Tour, NAM, NAPALM, World War II GI and Ion Fury). See Other games at the end for the rest.
What a dedicated server is
Start NNBuild with --headless (short -hl) or --dedicated (short -dd).
In the Duke Nukem 3D family the two options do the same thing:
- The server is headless. Headless means it has no window, no graphics and no sound, and it does not look for game controllers. It needs only a terminal, so it runs on a machine without a screen and over SSH.
- The server reads commands from its terminal. Whatever you type on its standard input is run as a console command. This is the admin console.
- The server does not play. It holds the first slot as a spectator that
cannot be seen, cannot be hit and is left out of the scoreboard and the frag
bar. With
/n0:8there is room for 7 players.
A dedicated server has nobody at the keyboard, so always give it:
--startnow, so that the match starts by itself and players can join at any time,- a game mode and a starting level.
vibebuild32 --headless --startnow --name ARENA --coop 1 --volume 1 --level 1 --net /p23513 /n0:8
As on the hosting page, --net and what follows it must come last.
The admin console
Type a command in the server’s terminal and press Enter. The answer is printed in the same terminal and written to the log.
listplayers
Players:
0: ARENA (this machine) [host]
1: DUKEFAN 203.0.113.77:23530
In the terminal each line of the answer also carries the log’s usual prefix, which is left out here.
A line you type can be up to 4096 characters long. The commands are described in Administering a server.
Startup commands
You can give the server console commands to run when it starts. They run in the order they appear on the command line, as soon as the server is up.
| Option | Meaning |
|---|---|
--cmd <text> (short -c <text>) | Run this console command. The text may hold several commands, one per line. |
--cmd-file <path> (short -cf <path>) | Run the commands in this text file, one per line. |
Both options can be given more than once.
vibebuild32 --headless --startnow --name ARENA --coop 1 --volume 1 --level 1 \
--cmd-file startup.txt --cmd "echo Server ready" \
--net /p23513 /n0:8
In a command file:
- each line is one command,
- empty lines are skipped,
- a line that starts with
#is a comment, - spaces and tabs at the start of a line are ignored.
# startup.txt
sv_maprotation 1
fraglimit 20
mapcycle list
If the file cannot be read, the server does not start and the log says
Could not read startup command file. A command file can be up to 1 MB.
-c followed by a space is a startup command. -c1, -c2 and -c3, with
the number attached, are the older way to set the game mode. Use --cmd and
--coop to keep the two apart.
Server scripts
A server can run a script written in JavaScript or TypeScript, for example to
make timed announcements or to answer chat commands such as !rules. Give the
script file on the command line, either by itself or after --js:
vibebuild32 --headless --startnow --name ARENA --coop 1 --volume 1 --level 1 \
--js server.ts --net /p23513 /n0:8
Server scripts explains how to write one.
Control through MCP
MCP is an open standard that lets an AI assistant operate a program. A server can offer its console that way.
| Option | Meaning |
|---|---|
--mcp-http <port> | Listen for MCP requests at http://127.0.0.1:<port>/mcp. Only programs on the same machine can connect. |
--mcp-stdio | Speak MCP on standard input and output. The typed admin console is then not available. |
The tools that matter for a server are server_status (role, port, slots and
the list of connected players), console_execute (run a console command) and
console_output (read recent console messages).
If the environment variable VIBEBUILD_MCP_TOKEN is set, each HTTP request
must carry that value as a bearer token.
AI assistants and MCP describes MCP in NNBuild in full.
Logs
- The server writes its log to
vibebuild32.login the folder it runs from. The file is started afresh each time the server starts. When the server restarts itself for a change of mod pack, it continues the same file. - The same lines are printed to the terminal, on standard error.
- The answers to console commands appear in both places.
Run under a process supervisor
A process supervisor starts the server when the machine boots and starts it
again if it stops. This is a sample unit for systemd. It assumes a server
directory prepared as in the worked example below, placed
at /srv/nnbuild, and a user named nnbuild that owns it.
[Unit]
Description=NNBuild dedicated server
After=network-online.target
Wants=network-online.target
[Service]
User=nnbuild
WorkingDirectory=/srv/nnbuild
ExecStart=/srv/nnbuild/vibebuild32 -usecwd --game duke --headless --startnow --name "ARENA ONE" --coop 1 --volume 1 --level 1 --cmd-file startup.txt --net /p23513 /n0:8
Restart=on-failure
[Install]
WantedBy=multi-user.target
Save it as /etc/systemd/system/nnbuild.service, then:
sudo systemctl daemon-reload
sudo systemctl enable --now nnbuild
journalctl -u nnbuild -f
Things to know:
- There is no keyboard. A service has no terminal on standard input, so
you cannot type admin commands. Put the commands the server needs in the
startup file, use a server script, or add
--mcp-httpand send commands through it. If you want to type commands by hand, run the same command line inside a terminal multiplexer such astmuxorscreeninstead of as a service. - Name the game.
--game dukemakes NNBuild run Duke Nukem 3D whatever other game data it finds. A server without a terminal is never asked which game to run. Without--gameit runs the first game it finds data for. - A change of mod pack restarts the server in place. On Linux and macOS the server replaces itself within the same process, so the supervisor notices nothing. On Windows the server starts a new process and the old one ends. See Switch mod packs on a live server.
- Keep the files together.
-usecwdkeeps the settings file, the ban list and the download cache in the working directory instead of the user’s profile folder. - The log goes to the journal. systemd collects what the server prints.
The file
vibebuild32.login the working directory is written as well.
Worked example
This example goes from an empty directory to a public server for Duke Nukem 3D with 7 player slots, a three-map rotation and an entry on a lobby list.
-
Make a directory for the server and go into it.
mkdir ~/nnbuild-server cd ~/nnbuild-server -
Unpack NNBuild into the directory, so that
vibebuild32and the files that came with it are there. -
Copy your game data into the directory.
cp ~/games/duke3d/DUKE3D.GRP . -
Create
maplist.txtwith the levels to rotate through, one per line.# maplist.txt E1L1 E1L2 E1L3 -
Create
startup.txtwith the commands to run at startup.# startup.txt sv_maprotation 1 fraglimit 20 mapcycle listsv_maprotation 1turns on rotation in order.fraglimit 20ends a level when someone reaches 20 frags.mapcycle listprints the rotation so that you can check it in the log. -
Start the server.
./vibebuild32 -usecwd --game duke --headless --startnow \ --name "ARENA ONE" --coop 1 --volume 1 --level 1 \ --advertise lobby.example.org \ --cmd-file startup.txt \ --net /p23513 /n0:8Part Meaning -usecwdKeep the settings file, the ban list and downloads in this directory. --game dukeRun Duke Nukem 3D without asking. --headlessNo window, graphics or sound. Read commands from the terminal. The server does not play. --startnowStart the match at once and let players join at any time. --name "ARENA ONE"The server’s name, as players see it. At most 10 characters. --coop 1Dukematch. --volume 1 --level 1Start on episode 1, level 1. --advertise lobby.example.orgPut the server on this lobby’s list. Leave it out for a server that players reach by address only. --cmd-file startup.txtRun the startup commands. --net /p23513 /n0:8Listen on UDP port 23513 with 8 slots: the server and 7 players. -
Check the output. Among the lines you should find:
Headless dedicated server: no video, no sound (terminal only). Start-now enabled: match begins immediately, players may join anytime. mmulti: bound UDP port 23513 (IPv4+IPv6) Map cycle (3, sequential) -
Open UDP port 23513 for incoming traffic: in the machine’s firewall, and in the router if the machine is behind one.
-
Join from another computer, by picking the server in JOIN GAME or with:
vibebuild32 --name DUKEFAN --net /n0 203.0.113.10:23513Then type
listplayersin the server’s terminal to see the new player.
To use your own lobby instead of someone else’s, see The lobby server.
Stop the server
Type quit (or exit) in the admin console. The server tells the lobby that
it is going away and then ends. It can take several seconds.
The players are not told that a dedicated server has stopped. Their games
stop moving forward, and each player has to leave by hand. A host that also
plays is different: when it quits, the other players’ games close with
Host has terminated the game.
If the server is ended in another way, for example by a supervisor, its lobby entry may stay on the list until it expires, 30 seconds after the last update.
Other games
- Exhumed.
--headlessor--dedicatedstarts a server without a window. On Linux and macOS it reads console commands from its terminal. It starts the match by itself once enough players are connected.--nplayers <n>sets that number (2 if you do not say), and--waitturns the automatic start off. The console commandsay <text>sends a chat message to the players. - Redneck Rampage.
--headlessor--dedicatedstarts a server without a window that waits in the pre-game lobby. It starts the match by itself once enough players are connected.--nplayers <n>sets that number (2 if you do not say), and--waitturns the automatic start off. - Shadow Warrior and Blood. Both accept
--headlessand--dedicatedand then open no window. The code does not show more than that for a dedicated server in these two games.
The admin commands in Administering a server belong to the Duke Nukem 3D family.
Administering a server
This page lists the commands a host uses to look after a running match: remove players, change the level, switch mod packs, rotate maps and change the match while it is being played.
It describes the Duke Nukem 3D family (Duke Nukem 3D, Duke Nukem 3D: World
Tour, NAM, NAPALM, World War II GI and Ion Fury), in the usual host-based
mode started with /n0.
Where to type the commands
All of these are console commands. Only the host’s copy of the game obeys them. You can give them in several ways:
- On a dedicated server, type them in the server’s terminal. See The admin console.
- On a host that also plays, open the in-game console and type them there.
- At startup, with
--cmdor--cmd-file. See Startup commands. - From a script or an AI assistant. See Server scripts and AI assistants and MCP.
A slot is a player’s place in the match. Each slot has a number. The host is slot 0.
See who is connected
listplayers
The answer has one line per player: slot number, name and address. The host’s
own line says (this machine) and ends in [host].
Players:
0: ARENA (this machine) [host]
1: DUKEFAN 203.0.113.77:23530
2: PIGCOP99 [2001:db8::77]:23530
Remove a player
kick
kick <name or slot>
Removes a player from the match. The player may join again.
kick DUKEFAN
kick 1
- A name does not have to be complete. The first connected player whose name starts with what you typed is chosen, and capital letters do not matter. Use the slot number when two names start alike.
- The player’s game closes with
You were removed from the game.The others see a short message that the player left. - You cannot kick the host itself.
ban
ban <name, slot or IPv4 address>
Removes a player and adds the player’s address to the ban list. A banned address cannot connect: the server does not answer it.
ban DUKEFAN
ban 1
ban 203.0.113.77
- The third form bans an address that is not connected at the moment.
- The list holds IPv4 addresses, and up to 256 of them.
- A player who is connected over IPv6 cannot be banned. The command is
refused, and the log tells you to use
kickinstead. - Addresses of the server’s own machine (127.x.x.x) are never banned.
unban
unban <IPv4 address or name>
Takes entries off the ban list. With a name, every entry whose recorded name starts with what you typed is removed. The answer says how many entries were removed.
unban 203.0.113.77
unban DUKEFAN
listban
listban
Prints the ban list: the number of entries, then one address and name per line.
The ban list file
The ban list is kept in a text file named banlist.txt, so it survives a
restart.
-
The file is in the folder the server runs from. That is the folder you start it in when you use
-usecwd. Otherwise it is the profile folder,~/.config/vibebuild32on Linux and macOS. -
Each line is one address, optionally followed by a name. A line that starts with
#is a comment.# NNBuild ban list - one entry per line: <ip> <name> 203.0.113.77 DUKEFAN 198.51.100.4 -
The server reads the file once, when it starts, and writes it again after every
banandunban. To edit the file by hand, stop the server first.
Change the level
map and changemap
map <level> [pack]
changemap <level> [pack]
The two names mean the same. The command starts a fresh game on the given level for everyone in the match.
A level is either a built-in level or a custom map file:
map E1L3
map "maps/User Arena.map"
map castle
- A built-in level is written as
E, the episode number,L, the level number. Capital letters do not matter. - Anything else is taken as a map file.
.mapis added if you leave it out. Put quotes around a name that contains spaces. - A custom map is sent to every connected player who does not have it, together with the files that share its name (a map-hack file, map music and map art).
- If the level cannot be found, the log says so and the current match continues.
- Scores saved for players who left are discarded, as for any new game.
Without a pack, the level is played with the mod packs the server is running now. To change the mod pack at the same time, name it after the level:
map "maps/User Arena.map" "packs/arena.pk3"
map E1L1 base
A change of pack is a bigger step than a change of level. Read Switch mod packs on a live server before you use it.
These commands are not available with shareware game data.
changelevel
changelevel <episode> <level>
The older command for built-in levels. Both values are numbers.
changelevel 1 3
When a player other than the host uses it, it starts a vote instead.
nextmap
nextmap
Moves on to the next entry of the map cycle right away. In random rotation it picks a random entry. If the cycle is empty, the command reports that it could not advance and the match continues.
Switch mod packs on a live server
A mod pack is one file that holds a mod: a GRP, ZIP, PK3, PK4 or SSI file. A server can change to another mod pack, or back to the plain game, without being stopped. The players are taken along automatically.
mod
mod <pack> [level]
Changes the mod pack and starts a fresh match.
<pack>is the pack file, or the wordbasefor the game without any mod pack.[level]is the level to start on, written as formap. Without it the match starts on E1L1.
mod "packs/arena.pk3" E2L1
mod "packs/arena.pk3" "maps/User Arena.map"
mod base E1L1
map <level> <pack> does the same with the two parts the other way round.
Things to know about the pack:
- The file is looked for in the game’s folders, so a path such as
packs/arena.pk3is relative to the folder the server runs from. - The new pack replaces every pack the server was running, including several
packs given with
--grpat startup. - Level codes mean what the pack says they mean.
E2L1is episode 2, level 1 as the new pack defines them. - The base game data cannot be named as a pack.
What happens
- The server checks the pack first. It starts a second, hidden copy of itself that loads the base game with the new pack, reads the pack’s game scripts and opens the level. The running match is not touched and keeps going during the check.
- If the check passes, the server logs
Restarting the match with the selected pack; players will reconnect, tells every player, and restarts itself with the new pack. - The server comes back on the same address and port, with the same name and number of slots, and it lets players join at any time.
- Each player’s game restarts by itself, connects again, downloads the pack if it does not have it, and joins the new match. The players do not have to do anything. Playing online describes what they see.
While the check runs, the server refuses another level change and changes to the map cycle.
Players come back in the same way as someone who joins a running match, so they need the same kind of build as the server, 32-bit or 64-bit. See 32-bit and 64-bit builds.
What is kept
The restarted server keeps the game mode, the skill, the frag limit, the game
flags, the rotation setting and the map cycle, including changes you made with
mapcycle and the place the rotation had reached. The ban list is kept in its
file as always.
It does not run the startup commands again. A server script starts again from the beginning. Scores start at zero, because this is a new match.
If the pack is rejected
A pack that fails never reaches the players. The running match continues as if nothing had happened.
- If the pack file cannot be found, or is not a pack, the log says
Could not open server packand no check is started. - If the check fails, the log says
Could not activate the requested pack and level. This happens when the pack’s scripts do not load, when the level does not exist in the pack, or when the check takes longer than 60 seconds. The check keeps a log of its own,content-probe.log. Look there for the reason.
On a host that also plays
The commands work the same on a host that plays. The host’s own game restarts too.
Map rotation
A server can change the level by itself each time a level ends. A level ends when a player uses the exit or when the frag limit is reached.
Turn rotation on
sv_maprotation <0, 1 or 2>
| Value | Meaning |
|---|---|
0 | Off. Levels follow each other as in the original game. |
1 | In order. After the last entry the cycle starts again from the first. |
2 | Random. Any entry can be picked, including the one just played. |
Only the host can change this setting.
The map cycle
The map cycle is the list of levels to rotate through. It can hold up to
64 entries. The server fills it from the file maplist.txt the first time it
is needed, and you can change it from the console while the server runs.
| Command | Meaning |
|---|---|
mapcycle or mapcycle list | Print the cycle. maplist does the same. |
mapcycle add [pack] <level> | Add an entry to the end. |
mapcycle clear | Empty the cycle. |
mapcycle reload | Read maplist.txt again and print the result. |
An entry is a level, optionally with a mod pack in front of it. The pack can be:
- a pack file, such as
"packs/arena.pk3", base, for the game without any mod pack,current, for whatever the server is running when the entry comes up. This is also what an entry without a pack means.
mapcycle add E3L2
mapcycle add "maps/User Arena.map"
mapcycle add base E1L1
mapcycle add "packs/arena.pk3" E2L1
mapcycle add "packs/arena.pk3" "maps/User Arena.map"
mapcycle list
The list looks like this:
Map cycle (4, sequential)
1. base | E1L1
2. base | E1L2
3. packs/arena.pk3 | E2L1 (current)
4. packs/arena.pk3 | maps/User Arena.map
The first line gives the number of entries and the rotation mode. Each entry
shows its pack, a bar and its level. (current) at the end of a line marks
the entry the rotation last moved to.
Changes made with mapcycle last until the server stops, and they survive a
change of mod pack. They are not written to maplist.txt. mapcycle clear
and mapcycle reload also forget which entry was being played, so the next
rotation starts from the first entry.
The maplist.txt file
Put maplist.txt in the folder the server runs from.
- One entry per line: a level, or a pack followed by a level. Both are written
as for
mapcycle add. - A line that starts with
#or;is a comment. A#comment may also follow an entry on the same line. - Put quotes around a file name that contains spaces.
- Only the first 64 entries are used.
- A line the server cannot understand is skipped, and the log names its line number.
A cycle of built-in levels and custom maps, all played with what the server is running:
# maplist.txt
E1L1
E1L2
E2L1 # a comment after an entry
"maps/User Arena.map"
castle.map
; another comment
A cycle that mixes the plain game with a mod pack:
# maplist.txt
base E1L1
base E1L2
"packs/arena.pk3" E2L1
"packs/arena.pk3" "maps/User Arena.map"
base "maps/castle.map"
Built-in levels, custom maps and mod packs can be mixed freely. A custom map
in the cycle is sent to players in the same way as with map.
When a cycle uses more than one pack, name the pack on every line. An entry without a pack is played with whatever pack the entry before it left running.
Rotation across mod packs
When the next entry names a pack other than the one that is running, the
server changes pack exactly as the mod command does. The pack is checked
first, the server restarts with it, and the players’ games reconnect and
download it by themselves. See
Switch mod packs on a live server.
Entries that follow each other with the same pack change only the level.
When rotation cannot continue
- If rotation is on and the cycle is empty, the current level starts again when it ends.
- If the next entry cannot be loaded when a level ends, the current level
starts again and the log says
Map cycle could not advance; restarting the current level. This includes an entry whose mod pack is rejected.
Change the match while it runs
These commands change the match for every player at the same moment.
fraglimit
fraglimit <number>
Sets the number of frags that ends a level. Players see FRAGLIMIT CHANGED TO
and the number. fraglimit without a number shows the current value.
monsters
monsters off
monsters on [skill]
monsters <skill>
monsters offremoves every enemy from the level and turns monsters off.monsters onturns monsters on again. With a skill from 1 to 4, it also sets the skill. It does not put back the enemies thatmonsters offremoved.monsters 3is a short way to writemonsters on 3.
The command works only while a level is being played.
spawn
spawn <tile> <player>
spawn <tile> <x> <y> [z]
Adds an enemy or an item to the level that is being played.
<tile>is a tile number or the name the game’s scripts use for it, such asLIZTROOPorSHOTGUNSPRITE.- With a player’s name or slot, the object appears a short distance in front of that player.
- With coordinates, it appears at that point of the map. The point must be
inside the level. Without
zit is placed just above the floor.
spawn LIZTROOP DUKEFAN
spawn SHOTGUNSPRITE 1
spawn LIZTROOP 2048 -4096
Send a file to all players
sendfile <file>
Sends one file to every connected player. Each player’s game stores it in its download cache, unless it already has an identical file. The game does not load the file by itself. Base game data is refused.
Other commands
| Command | Meaning |
|---|---|
name <text> | Change the host’s name. On a dedicated server this is the server’s name, also on the lobby list. |
echo <text> | Print text to the console and the log. Useful as a marker in a startup file. |
quit or exit | Stop the host. See Stop the server. |
serverlist [lobby] | Print the matches on a lobby’s list. See The lobby server. |
Quick reference
| Command | Purpose |
|---|---|
listplayers | Show slots, names and addresses |
kick <name or slot> | Remove a player |
ban <name, slot or IPv4 address> | Remove a player and ban the address |
unban <IPv4 address or name> | Take entries off the ban list |
listban | Show the ban list |
map <level> [pack], changemap <level> [pack] | Start a fresh game on a level, optionally with another mod pack |
changelevel <episode> <level> | Start a fresh game on a built-in level |
nextmap | Go to the next entry of the map cycle |
mod <pack> [level] | Change the mod pack and start a fresh match |
sv_maprotation <0, 1 or 2> | Rotation off, in order, or random |
mapcycle, mapcycle list, maplist | Show the map cycle |
mapcycle add [pack] <level> | Add an entry to the cycle |
mapcycle clear | Empty the cycle |
mapcycle reload | Read maplist.txt again |
fraglimit <number> | Set the frag limit |
monsters off, monsters on [skill], monsters <skill> | Remove or allow monsters |
spawn <tile> <player>, spawn <tile> <x> <y> [z] | Add an enemy or item |
sendfile <file> | Send a file to all players |
name <text> | Change the host’s name |
quit, exit | Stop the host |
The lobby server
A lobby server keeps a list of matches that are open right now. Hosts report their matches to it, and players ask it for the list. It also helps players reach a host that sits behind a home router.
The menus, the logs and the option names call it the masterserver. This manual calls it the lobby server.
The lobby only keeps the list and passes on requests to connect. Game traffic never goes through it. Any community can run its own.
Most of this page describes the Duke Nukem 3D family. Other games lists what the other runtimes do.
Run a lobby server
NNBuild itself is the lobby program. Start it with -masterserver:
vibebuild32 --headless -masterserver
To use another port, write the port number directly after the option:
vibebuild32 --headless -masterserver 23600
-masterserveris written with one dash.- Without a number, the lobby listens on UDP port 23519.
- No game data is needed, and NNBuild does not ask which game to run.
--headlesskeeps NNBuild from opening its startup window.- The lobby runs until you stop the process.
The lobby listens on IPv4 and IPv6. When it starts it prints:
VibeBuild32 masterserver listening on UDP 23519 (IPv4:on IPv6:on)
After that it prints a line for each event:
masterserver: + 203.0.113.10:23513 "ARENA ONE" (E1L1)
masterserver: punch 198.51.100.4:23530 <-> 203.0.113.10:23513
masterserver: - 203.0.113.10:23513 "ARENA ONE" (going away)
| Line | Meaning |
|---|---|
+ | A server was added to the list. |
punch | The lobby helped a player and a server find each other. |
- ... (going away) | A server said it was shutting down. |
- ... (timed out) | A server stopped reporting and was dropped. |
The same lines are written to vibebuild32.log in the folder the lobby was
started in.
Open the lobby’s UDP port for incoming traffic in the machine’s firewall, for IPv4 and for IPv6. Hosts and players must both be able to reach it.
Put a match on the list
A host reports its match with --advertise (short -ad) and the lobby’s
address, placed before --net:
vibebuild32 --name ARENA --startnow --coop 1 --volume 1 --level 1 --advertise lobby.example.org --net /n0:8
The address can be a host name, an IPv4 address, or an IPv6 address in square
brackets. Add :port if the lobby does not listen on 23519, for example
lobby.example.org:23600.
A host started from the menu with HOST INTERNET GAME reports to the lobby
in the console setting cl_masterserver.
The host sends its name, its game port, its player and slot numbers and the name of the current map. The lobby adds the address the report came from.
Use a lobby as a player
Players point their game at a lobby with the console setting cl_masterserver:
cl_masterserver lobby.example.org
- Until it is changed, the setting is
127.0.0.1, the player’s own computer. - The setting is saved with the player’s other settings.
- JOIN GAME asks the lobby when the screen opens and again when you choose Refresh list. It shows the first 12 matches.
Playing online describes the screen.
The serverlist command
The console command serverlist asks a lobby for its list and prints it.
serverlist
serverlist lobby.example.org
Without an address, the command asks the lobby in cl_masterserver, the same
one JOIN GAME uses. With an address, it asks that lobby instead.
The answer starts with the number of matches. Then there is one line per
match with its address, the player and slot numbers it reported, the map and
the server’s name. If a match also has an IPv6 address, a second line starting
with also IPv6: follows. The command prints up to 64 matches.
How long an entry lives
- A host starts reporting once its match is running.
- It reports again every 5 seconds. Each report renews the entry and updates its details.
- When a host quits normally, it tells the lobby, and the entry is removed at once.
- If the reports stop without that message, for example because the host crashed or lost its connection, the lobby drops the entry after 30 seconds without a report.
IPv4 and IPv6
- A host reports over IPv4 and over IPv6 when the lobby’s host name has both kinds of address and the host can use both. The lobby joins the two reports into one entry.
- In JOIN GAME, an entry with both kinds of address is marked
+v6, and an entry with only an IPv6 address is markedv6. - A player’s game connects over IPv4 when an entry has an IPv4 address. Set
cl_preferipv6 1in the console to use the IPv6 address when there is one.
Hole punching
NAT is what a home router does when several devices share one internet address. Such a router lets answers in, but it blocks a connection that starts from outside. A host behind such a router is normally unreachable until its owner forwards the game port.
Hole punching gets around this. The host sends a packet to the player first. To the host’s router the player’s packets then look like answers, and it lets them in. The lobby’s part is to tell the host where the player is.
The steps:
- The player picks a match in JOIN GAME. The player’s game tries to connect to the listed address.
- While there is no answer, the player’s game asks the lobby for help every three seconds. It sends the request from the same port it uses for the game.
- The lobby tells the host the address and port the request came from.
- The host sends a small packet from its game port to that address.
- The player’s game is still trying, and its next attempt gets through.
Nothing has to be set up for this beyond the lobby itself. If the host can be reached directly, the first attempt succeeds and none of this is needed.
Limits
- The host must be on the same lobby’s list. The lobby can only help with matches it knows.
- The player must use the listed address. Picking the match from the list does this. Typing the address in JOIN BY ADDRESS works too, but only if it is written exactly as the list shows it.
- The host’s router must keep the port number. The lobby lists a host under the address it saw, with the port number the host reported. If the router changes that port number on its public side, players are sent to the wrong port.
- The player’s router must not change the port per destination. The host sends its packet to the address and port the lobby saw. If the player’s router uses a different one towards the host, the packet opens nothing.
- There is no relay. If hole punching fails, the lobby does not carry the game instead. Forward the host’s port.
- The attempt ends after about 30 seconds. The player is then returned to JOIN GAME with a message that the server could not be reached.
From the command line
A join typed on the command line does not ask a lobby for help unless you name the lobby and the server:
vibebuild32 --name DUKEFAN --punchtarget 203.0.113.10:23513 --masteraddr lobby.example.org --net /n0 203.0.113.10:23513
--punchtarget(short-pt) is the server’s address as the lobby lists it.--masteraddr(short-ma) is the lobby’s address.
The menu adds both for you when you join from JOIN GAME.
Limits of the list
- A lobby holds up to 256 matches.
- The list is sent to a player in one packet. A very long list is cut short.
- JOIN GAME shows the first 12 matches and
serverlistthe first 64. - The lobby does not record which game a match is for. If a community plays several of the games NNBuild runs, a separate lobby per game keeps the lists apart.
Other games
“No” means the code of that runtime does not contain the feature.
| Duke Nukem 3D family | Shadow Warrior | Blood | Redneck Rampage | Exhumed | |
|---|---|---|---|---|---|
Report a match with --advertise <lobby> | Yes | Yes | Yes | Yes | Yes |
| Server list in the game | JOIN GAME | Browse Servers | No | No | No |
Print a lobby’s list at startup with --lobbylist <lobby> | No | Yes | Yes | Yes | Yes |
Join the first listed match with --joinlobby <lobby> | No | Yes | Yes | Yes | Yes |
| Hole punching when hosting | Yes | Yes | No | No | Yes |
| Hole punching when joining | Yes | Yes | Only the request is sent | Only the request is sent | Yes |
Notes:
- Shadow Warrior’s Browse Servers screen asks the lobby given at launch
with
--masteraddr <lobby>, or127.0.0.1without it. Press Enter to join and R to refresh. - For a join by address in Shadow Warrior and Exhumed,
--punchto <server>and--masteraddr <lobby>ask the lobby for help, as--punchtargetand--masteraddrdo in the Duke Nukem 3D family. - In Blood and Redneck Rampage, a host does not act on a lobby’s request to open a path. Forward the host’s port for these games.
How multiplayer works
This page explains, in plain language, what happens between the computers in a match. You do not need it to play or to host. It is here for players and server owners who want to know why NNBuild behaves the way it does.
It describes the Duke Nukem 3D family. The technical version, written for people who work on the code, is NETCODE.md.
Every computer runs the whole game
In many online games one server works out what happens and tells everyone the result. NNBuild works differently. Every computer in the match runs the complete game: every monster, every door, every rocket. The computers do not send each other where things are. They only send what each player pressed.
The game moves forward in small steps, about 30 each second. For each step the host collects the input of every player and sends the full set to everyone. Each computer then works out that step from the same starting point and the same inputs, and so arrives at the same result. This way of working is called lockstep.
Lockstep has one hard rule: nobody can work out a step until the input of every player for that step has arrived. That is why one slow connection can hold up the whole match. NNBuild softens this with a countdown and a vote, and with a no-wait mode in which the host fills in for a late player. Both are described in Hosting a match.
Why everyone needs identical data
Because every computer works the game out for itself, every computer must start from the same material. The maps, the game’s rule scripts and the art all take part in the result. If one player’s copy of a map has one extra monster, that monster exists on that computer only, and from then on that computer is playing a different game.
The same is true for chance. When the game rolls dice, for example to decide where a shot lands, every computer must roll the same numbers in the same order. NNBuild keeps one shared sequence of random numbers for this. Anything that uses a number from it on one computer must use it on all of them.
This is why NNBuild checks files so carefully when you join. It compares the name, size and checksum of every mod pack and custom map with the host’s, and downloads what is missing or different. It is also why each player needs the same edition of the base game as the host.
It also explains what happens when a server changes its mod pack. A pack can replace the game’s rules, and the rules are read once, when the game starts. So the server starts again with the new pack, and every player’s game restarts, fetches the pack and joins the new match.
What a desync is
A desync is the moment when one computer’s game stops matching the others. It may start small: a monster one step to the left. But every later step builds on the one before, so the difference grows until the players are no longer in the same match.
NNBuild watches for this constantly. On every step each computer sums up its view of the game in a few short check values: the players’ positions and state, the monsters and other objects, the projectiles, the map and the random numbers. Each player’s values are compared with the host’s.
A copy of the game that has drifted cannot be steered back, because nobody knows which earlier step went wrong. So NNBuild does the reliable thing. The player’s game says that it has lost sync, restarts itself and joins the match again as a new arrival, which brings it a fresh copy of the host’s game. The player’s score is given back afterwards.
How joining a running match works
A new player needs the entire game as it is at one exact moment. NNBuild gets that moment by pausing. When the host notices a new connection, it stops handing out input. Every computer runs out of steps at the same place and waits there.
While everyone waits, the host and the newcomer compare files and the missing ones are sent. Then the host saves the game as it stands, in the same way a saved game is made, and sends that to the newcomer piece by piece. This is the progress bar on the joining screen.
Finally the host tells every computer to add the new player. They all do it on the same step and in the same way, so the newcomer’s starting point is chosen identically everywhere. All computers confirm that they are ready, and the match continues. The pause lasts as long as the transfer takes.
The saved game is also the reason for one restriction. A saved game written by a 64-bit build of NNBuild cannot be read by a 32-bit build, and the other way round. A player can therefore join a running match only with the same kind of build as the host’s.
How coming back works
Coming back uses the same path as joining. The only extra question is whose score the returning player should get.
When the host removes a player, for example because the connection went silent, it frees the slot and notes the score under that player’s ID. The ID was created by the player’s own copy of NNBuild and is kept in its settings file. A nickname is not used for this, because anybody can type any nickname. A player who quits on purpose is not noted and starts from zero next time.
When a player joins, the host looks for a saved score with the same ID and, if it finds exactly one, gives it back and tells everyone. If two saved scores carry the same ID, the host uses the player’s address to choose between them, and if that does not settle it either, the player starts from zero. The saved scores are thrown away when a new game starts, so a score never follows a player into a different match.
Why some changes must be host commands
Suppose a host could simply add a monster to its own copy of the game. The monster would exist on the host and nowhere else, and the match would desync at once. The same goes for removing a player or clearing all monsters.
So changes like these go through commands that every computer carries out together. The host picks a step a short time in the future, and tells every computer “on that step, do this”. The step is far enough ahead that the message arrives everywhere first. Then all computers make the same change on the same step and stay identical.
This is the reason for the console commands spawn and monsters, and why
kicking a player takes effect a moment after you type it. It is also why a
server script should change the world through such commands and not directly.
See Administering a server.
Map editor overview
NNBuild has a map editor built into the game. You draw a room, press F5, and walk through it a moment later. This page explains what the editor makes, how to open it, and what each part of its window is for.
Older guides call the program VibeBuild32. It is the same program, and the
executable is still named vibebuild32.
What you can make
Classic maps. The editor opens and saves version 7 .MAP files, the map
format of Duke Nukem 3D and the games built on it. You choose which game a map
is for. The choices are:
- Duke Nukem 3D 1.3D
- Duke Nukem 3D Atomic / Plutonium
- NAM
- NAPALM
- WWII GI
Projects. A project is a folder that keeps your maps, scripts, textures and sounds together with a small settings file. You can pack a project into one ZIP file for players. See Projects.
Stand-alone games. A project can bring its own rules, art and palette, so it
runs without the data files of another game. The example game in
examples/ashline-relay/ is made this way. See
Stand-alone games.
The editor also includes:
- everyday editing tools with undo and redo,
- building tools for pillars, stairs and catwalks,
- linked mechanisms such as lifts and doors,
- playtesting and a map check,
- live editing with other people,
- control by AI assistants,
- the classic Build tools for advanced work.
Requirements
- SDL2 and OpenGL. The editor needs a build of the program that uses SDL2 and OpenGL, and OpenGL must be working. It does not open in a headless (no-window) session.
- A full game. The editor does not open with shareware game data.
- A local session. The editor does not open while you are in a multiplayer game.
If the game is running in an 8-bit video mode, the editor switches to a 32-bit window of at least 1024 by 680 pixels. Your video settings come back when you return to the title menu.
Open the editor
From the title menu
- Start the game.
- Choose MAP EDITOR in the title menu. It sits between CREDITS and QUIT.
The menu entry is hidden when the editor cannot open, and when the running game is Ion Fury.
From the command line
Add --editor to start directly in the editor. To open a map at once, put a
.map path straight after --editor.
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor "My Map.map"
To open a project for editing, add --project with the project folder:
./vibebuild32 --editor --project examples/ashline-relay
The editor then opens the project’s entry map. See Projects.
If the editor cannot open, the program writes this message to its log and exits:
The map editor requires a local Duke3D game with SDL2 and OpenGL.
Leave the editor
Choose File → Return to title. If the map has unsaved changes, the editor asks whether to save, discard or cancel.
The window
The window is divided into fixed panels. There is a screenshot on the Live editing page.
| Panel | Where | What it is for |
|---|---|---|
| Toolbar | Top | The File and Build menus, the Session button, Undo and Redo, the map name, Playtest F5 and Spawn…. A second row holds the tools: Select Q, Room R, Sprite E, Player Start T, Batch Select, and the Snap grid size. |
| Hierarchy | Left | A list of everything in the map: the player start, every sector and every sprite. Type in Search scene to filter it. Click a row to select the object. Double-click to bring it into view. |
| Scene | Centre | The map itself. Buttons at the top switch between Plan (a floor plan), 3D (a textured view you fly through) and Section (a side view). Frame brings the selection into view. |
| Inspector | Right | The properties of the selected object: heights, textures, positions, tags and flags. |
| Assets | Bottom | Three tabs. Tiles shows the game’s pictures. Entities shows common objects to place. Project shows the files of the open project. |
| Status line | Very bottom | The latest message. Problems are shown in red. On the right it shows the number of sectors, walls and sprites in the map. |
A star after the map name in the toolbar means the map has unsaved changes.
Some tools open a small extra window on the right side: the mechanism presets, Build stairs, Build catwalk, Map check and Change history.
Words you will meet
Build-engine maps are made of a few simple things. The editor uses these names for them.
| Word | Meaning |
|---|---|
| Sector | One room or area of floor. A sector is a closed outline with one floor height and one ceiling height. |
| Wall | One straight edge of a sector’s outline. |
| Solid wall | A wall with nothing behind it. |
| Portal | A wall shared by two sectors. The player can see and walk through it. In Plan, portals are drawn in teal and solid walls in light grey. |
| Vertex | A corner point where two walls meet. |
| Sprite | An object placed in a sector: an enemy, a weapon, a switch, a decoration, or an invisible marker that controls an effect. |
| Entity | The editor’s word for a sprite that does something in the game, such as an enemy or a pickup. |
| Tile | A numbered picture from the game’s art. Walls, floors, ceilings and sprites each show a tile. |
| Tag | A number stored on a sector, wall or sprite that tells the game how it behaves. Each object has two: LoTag and HiTag. A switch and the thing it controls usually share a tag number. |
| Player start | The place and direction where the player begins the map. |
Two kinds of numbers need a short explanation.
Heights. The Z fields in the Inspector hold the map’s raw height values. Z grows downward, so a lower number is higher up. The building tools and the editor’s messages use height units. One height unit is 256 in the Z fields. For example, “48 units of headroom” means a difference of 12,288 between Floor Z and Ceiling Z.
Angles. A full turn is 2,048 steps. In Plan, angle 0 points right, 512 points down, 1,024 points left and 1,536 points up.
Your first room in five minutes
- Open the editor. Choose MAP EDITOR in the title menu. A new map
called
Untitled.mapopens. It already has one room and a player start in the middle. The status line says “Starter room ready”. - Look at the plan. Scroll the mouse wheel to zoom. Hold the right mouse button and drag to pan.
- Look in 3D. Click 3D above the Scene. Hold the right mouse button and move the mouse to look around. While you hold it, press W, A, S and D to fly. Click Plan to go back.
- Add a second room. Hold Ctrl and click one wall of the room. The Inspector now shows that wall. Click Extend room. A new room appears behind the wall, joined to the first one.
- Change the floor. The new room is selected. Open the Tiles tab in Assets, click a picture you like, and click Apply tile. To change the ceiling instead, click Ceiling in the Inspector first.
- Place an enemy. Open the Entities tab and click Trooper. Click inside a room to place it. Press Q to go back to the Select tool.
- Play it. Press F5. The game starts in your map. Press F5 again to return to the editor.
- Save. Press Ctrl+S. Choose a folder, type a name and click Save
map. The editor adds
.mapto the name for you.
Where to go next
- Editing maps: the everyday tools and all shortcuts.
- Building tools: pillars, stairs, catwalks and batch edits.
- Linked mechanisms: lifts, doors, traps and light switches.
- Playtesting: test runs and the map check.
- Projects: folders, ZIP files, stand-alone games, scripts and prefabs.
- Live editing: edit one map with other people.
- AI and MCP: let an AI assistant work in the editor.
- Classic Build tools: the original-style editor.
Editing maps
This page covers the tools you use all the time: looking around, selecting, drawing rooms, placing objects, changing properties, and saving. A complete shortcut table is at the end.
If words such as sector, wall, sprite, tile or tag are new to you, read Words you will meet first.
Views
Three buttons above the Scene choose the view: Plan, 3D and Section. The Section view is described in Building tools.
Plan
Plan is a floor plan seen from above. You draw and move things here.
| What you see | Meaning |
|---|---|
| Light grey line | A solid wall |
| Teal line | A portal (a wall shared by two sectors) |
| Orange | The selected object |
| Teal dot with a short line | A sprite and the direction it faces |
| Blue rectangle | A catwalk |
| Orange arrow | The player start and its direction |
To move around in Plan:
- Scroll the mouse wheel to zoom in and out around the pointer.
- Hold the right or middle mouse button and drag to pan.
- Press F, or click Frame, to fit the selected object’s sector in the view. With nothing selected, the whole map is fitted.
3D
3D shows the map with its textures, as the player will see it.
- Hold the right mouse button and move the mouse to look around.
- While you hold the right button, press W and S to fly forward and back, A and D to move sideways, Q to rise and E to sink.
- Hold Shift as well to fly faster.
- Click a wall, a floor, a ceiling or a sprite to select it. Clicking a floor or a ceiling selects its sector and sets the Inspector to that surface.
- Press F, or click Frame, to move the camera to the middle of the selected sector. With nothing selected, the camera goes to the player start.
The camera cannot leave the map.
The drawing tools work in Plan. If you choose Room, Sprite or Player Start while in 3D, the Scene switches to Plan. Opening 3D switches back to the Select tool.
The snap grid
The Snap list in the toolbar sets the grid size: Off, 32, 64, 128, 256, 512 or 1024. It starts at 128.
New corners, new sprites and the player start land on the grid. When you drag something, it moves in whole grid steps. Choose Off for free placement.
Select
Use the Select tool (Q). In Plan, what you get depends on where you click.
| Action | Selects |
|---|---|
| Click a sprite or the player start | That sprite or the start |
| Click a corner | The vertex |
| Click a wall line | The wall |
| Click open floor | The sector |
| Ctrl-click | A wall only. Nearby sprites and vertices are ignored. |
| Shift-click | The sector under the pointer. Everything else is ignored. |
A portal is really two walls, one for each sector. Click just inside a sector, close to the portal, to select that sector’s side.
You can also select by clicking a row in the Hierarchy, or by clicking in the 3D view.
On macOS, the Command key also works where this guide says Ctrl.
Move
- Choose the Select tool and make sure Batch Select is off.
- Press the left mouse button on the object in Plan.
- Drag, then release.
| You drag | What moves |
|---|---|
| A vertex | That corner |
| A wall | Both ends of the wall |
| A sector | The whole outline, the sprites inside it, and the player start if it is inside |
| A sprite | The sprite. It keeps its height above the floor. |
| The player start | The start |
Corners shared by neighbouring rooms move together, so rooms stay joined.
Each drag is one undo step. The editor refuses a move that would make walls cross, turn a sector inside out, or leave a sprite outside its sector. The status line tells you why and the map stays as it was.
To place something at exact numbers, type X and Y in the Inspector and press Enter.
Draw a room
- Press R, or click Room R.
- Click each corner of the room in Plan. If you click close to an existing corner, the new corner locks onto it.
- To close the outline, click the first corner again or press Enter. A room needs at least three corners.
Press Escape to throw away an unfinished outline.
The Room tool stays active so you can draw another room. Press Q to return to the Select tool.
A new room gets a default floor, ceiling and wall tile. Its floor is at Z 0 and its ceiling is 64 height units above.
Joining rooms. If an edge of the new room has exactly the same two end points as a solid wall of another room, the two walls become a portal. Use the snap grid, or click on existing corners, to make the end points match.
If the outline crosses itself or cannot be closed, the status line shows:
Close a simple outline with at least three corners. Shared edges must have matching endpoints.
Extend a room from a wall
This is the quickest way to add a joined room.
- Hold Ctrl and click a solid wall in Plan. You can also click the wall in 3D.
- In the Inspector, type a Room depth and press Enter. The value can be from 128 to 32768. It starts at 1536.
- Click Extend room.
A rectangular room appears behind the wall. It copies the floor height, ceiling height, tiles and shades of the room it came from. The wall you selected becomes a portal.
Extend room is greyed out for a portal, because there is already a room behind it.
Split a wall
- Select a wall.
- Click Split at midpoint in the Inspector.
The wall becomes two walls with a new vertex in the middle. The new vertex is selected, so you can drag it straight away to bend the wall. Splitting a portal splits both of its sides.
A few walls have no usable middle point. The status line then says “This wall cannot be split at its midpoint.”
Delete
Select a sector or a sprite. Then press Delete, or click Delete sector or Delete sprite at the bottom of the Inspector.
- Deleting a sector also deletes the sprites inside it. Portals that led to it become solid walls.
- If the player start was in the deleted sector, place a new one before you save.
- Undo brings back the sector and its sprites.
Single walls and vertices cannot be deleted here. For work such as joining or splitting sectors, use the classic Build tools.
Place sprites and entities
- Choose what to place.
- Open the Entities tab in Assets and click an entity. The editor switches to the Sprite tool for you.
- Or open the Tiles tab, click a tile, and press E.
- Click inside a sector in Plan.
- Click again to place more. Press Q when you are done.
A new sprite stands on the floor at the point you clicked. To raise it, see Sprite heights.
The Entities tab offers these objects. The numbers are Duke Nukem 3D tile numbers.
| Entity | Tile | Entity | Tile |
|---|---|---|---|
| Trooper | 1680 | Keycard | 60 |
| Pigcop | 2000 | Effector | 1 |
| Commander | 1820 | Activator | 2 |
| Shotgun | 28 | Touchplate | 3 |
| RPG | 23 | Respawn | 9 |
| Shells | 49 | Co-op start | 1405 |
| First Aid | 53 | Exit switch | 142 |
For any other object, find its tile in the Tiles tab and place that. When you make a map for another game, use that game’s own tiles and tags.
Set the player start
- Press T, or click Player Start T.
- Click inside a sector in Plan.
The sector needs at least 48 height units between floor and ceiling. The start is placed at eye height, 40 units above the floor.
Select the start to change its Angle in the Inspector. Click Preview from start to see the 3D view from that spot.
You can also drag the start with the Select tool.
The Assets panel
Tiles
The Tiles tab shows the pictures of the game that is running.
- Type in Search name or tile ID to find a tile by name or number.
- Click a tile to make it the current tile. Its number is shown beside Apply tile.
- Click Apply tile to put the current tile on the selection. You can also double-click a tile.
What the tile is applied to depends on the selection:
| Selection | The tile goes on |
|---|---|
| Sector | The floor, or the ceiling if Ceiling is chosen in the Inspector |
| Wall | The wall |
| Sprite | The sprite |
| A batch selection | Every wall and sprite in the group |
Entities
The Entities tab holds the objects listed above. Click one to start placing it.
Project
The Project tab lists the files of the open project. See Projects.
The Inspector
The Inspector shows the properties of the selected object.
- Type a number and press Enter to apply it.
- Tick boxes and buttons apply at once.
- Each change is one undo step.
- A folded section stays open or closed while you select other objects of the same kind.
Sector
| Field | Meaning |
|---|---|
| Floor Z, Ceiling Z | Heights. A lower number is higher up. |
| Floor / Ceiling | Chooses which surface the fields below describe |
| Tile | The picture on that surface |
| Shade | Brightness, from −128 to 127. Lower is brighter. |
| Palette | Colour set, from 0 to 255 |
| Parallax sky | Draws the surface as sky |
| Slope, Slope amount | Tilts the surface |
The section Tags and surface flags adds LoTag, HiTag, Extra, Flags, Pan X, Pan Y and Visibility. Tick End level on entry to make the level end when the player walks into the sector. Such a sector is marked “(Exit)” in the Hierarchy.
Wall
The top line says “Solid boundary”, or “Portal to sector N”.
| Field | Meaning |
|---|---|
| Tile, Shade, Palette | As for a sector |
| Blocking | Stops the player from passing |
| Mask overlay, Overlay tile | Draws a second picture over the wall. Overlay tile chooses the picture. |
The section Mapping and tags adds X repeat, Y repeat, Pan X, Pan Y, Flags, LoTag, HiTag and Extra. Repeat and pan stretch and shift the picture on the wall.
Below that are Split at midpoint, Room depth and Extend room.
Vertex
X and Y. Neighbouring corners at the same point move with it.
Sprite
| Field | Meaning |
|---|---|
| X, Y, Z | Position |
| Above floor | Height above the floor, or above the catwalk the sprite stands on, in height units |
| Angle | Direction, from 0 to 2047 |
| Tile, Shade, Palette | As for a sector |
| Blocking | The player cannot walk through it |
The section Sprite flags and tags adds LoTag, HiTag, Extra, X repeat, Y repeat, Offset X, Offset Y, Clip distance, Status and Flags. The repeat values set the sprite’s size.
Player Start
X, Y, Z, Angle, and the Preview from start button.
Undo and redo
- Undo: Ctrl+Z, or the Undo button.
- Redo: Ctrl+Shift+Z or Ctrl+Y, or the Redo button.
The editor keeps the last 48 changes. Undo clears the selection. Opening another map, or starting a new one, empties the history.
Build → Change history lists recent changes with the newest first. Open a change to see who made it and which objects it touched. Click an object in the list to bring it into view.
In a live session, undo and redo work on the shared map. See Live editing.
Open and save
New map
Choose File → New map, or press Ctrl+N. You get the starter room.
Open a map
- Choose File → Open map…, or press Ctrl+O.
- Browse to the file. Click Up for the parent folder. Click a folder to
enter it. The list shows folders and
.mapfiles. - Double-click a map, or click it once and then click Open map.
Other ways to open a map:
- Type a file name or a full path in the box and press Enter.
- Open Maps in game data in the dialog. It lists the levels that come with the game. Click a level, then click Open map.
- Drag a
.mapfile from your file manager onto the editor window.
A map opened from the game data has no file of its own yet. The first time you save it, the editor asks for a name.
The Import as list sets which game the map is for. Leave it on Inherit unless the map belongs to a different game than the one you are running. See Game targets.
Save
- File → Save, or Ctrl+S, saves to the current file.
- File → Save as…, or Ctrl+Shift+S, saves under a new name. You then keep working on the new file.
In the save dialog, the editor adds .map if you leave it out. If the file
already exists, it asks Replace map? first.
A map can only be saved when it is complete enough to play:
- it has at least one sector,
- the player start is inside a sector.
If the map uses project features, a small settings file is saved beside it. See Per-map settings.
Unsaved changes
If you start a new map, open another one, join a session or leave the editor with unsaved changes, the editor offers Save and continue, Discard changes or Cancel.
Map limits
The editor saves classic version 7 maps. These limits come from that format.
| Item | Limit |
|---|---|
| Sectors | 1,024 |
| Walls | 8,192 |
| Sprites | 4,096 |
| Coordinates | From −524,288 to 524,288 on X and Y |
| Tile numbers | Below 3,840 for Duke Nukem 3D 1.3D. Below 5,120 for the other game targets. |
| Script components | 1,024 per map |
The editor opens version 7 maps only. A map that uses flags from an extended map format is refused with a message that names the problem.
Shortcuts
Keyboard
| Key | Action |
|---|---|
| F5 | Start a playtest. During a playtest, return to the editor. |
| Ctrl+N | New map |
| Ctrl+O | Open a map |
| Ctrl+S | Save |
| Ctrl+Shift+S | Save as |
| Ctrl+Z | Undo |
| Ctrl+Shift+Z, Ctrl+Y | Redo |
| Q | Select tool |
| R | Room tool |
| E | Sprite tool |
| T | Player Start tool |
| F | Frame the selection |
| Delete | Delete the selected sector or sprite |
| Enter | Close the room or pillar outline. In a number field, apply the number. |
| Escape | Throw away the outline being drawn. In a dialog, cancel. |
On macOS, the Command key also works where the table says Ctrl.
Shortcuts are ignored while you type in a text box, while a menu or dialog is open, and during a drag.
Keyboard in 3D
These keys work while you hold the right mouse button. During that time they do not switch tools.
| Key | Action |
|---|---|
| W, S | Fly forward, back |
| A, D | Move left, right |
| Q, E | Rise, sink |
| Shift | Fly faster |
Mouse in Plan
| Action | Result |
|---|---|
| Wheel | Zoom |
| Right-drag or middle-drag | Pan |
| Click | Select, or use the current tool |
| Ctrl-click | Select a wall |
| Shift-click | Select a sector |
| Drag a selected object | Move it |
| Right-click a floor | Open the menu with Play From Here |
Mouse in 3D
| Action | Result |
|---|---|
| Hold right button and move | Look around |
| Click | Select a wall, sprite, floor or ceiling |
| Right-click a floor or catwalk without moving | Open the menu with Play From Here |
Mouse elsewhere
| Where | Action | Result |
|---|---|---|
| Section view | Click a floor or catwalk | Select it and show only that level in Plan |
| Hierarchy | Click | Select |
| Hierarchy | Double-click | Select and bring into view |
| Tiles tab | Click | Choose the tile |
| Tiles tab | Double-click | Apply the tile to the selection |
| Entities tab | Click | Choose the entity and switch to the Sprite tool |
| File dialog | Click a folder | Enter the folder |
| File dialog | Double-click a map | Open it, or save over it |
Building tools
These tools build common shapes in a few steps and help you work with heights and with many objects at once. You find most of them in the Build menu of the toolbar.
Heights on this page are in height units. One height unit is 256 in the Inspector’s Z fields. See Words you will meet.
Pillars
A pillar is a solid block standing inside a room. In the map it is a closed ring of solid walls inside a sector.
- Select the sector that will hold the pillar. Shift-click inside it in Plan. Selecting any object inside the sector also works.
- Choose Build → Draw pillar. The toolbar shows “Draw pillar”.
- Click each corner of the pillar inside the sector.
- Press Enter, or click the first corner again, to close the outline.
The editor returns to the Select tool and the status line says “Pillar added”.
Rules:
- The whole outline must be inside the sector.
- It must not touch or cross the sector’s walls.
- No sprite, and not the player start, may be inside it.
If a rule is broken, the status line shows:
Draw the pillar entirely inside an open area of the sector, clear of sprites and the start.
The pillar’s walls take their tile, shade and palette from the first wall of the sector. Select a pillar wall afterwards to change them.
Draw pillar is greyed out when nothing in a sector is selected.
Stairs
The stairs tool adds a row of new sectors. Each one is a step higher, or lower, than the one before.
- Choose Build → Stairs…. The Build stairs window opens.
- In Plan, hold Ctrl and click the solid wall where the stairs begin.
- Set the three numbers.
- Click Create stairs.
| Field | Meaning | Allowed | Starts at |
|---|---|---|---|
| Steps | How many steps to build | 2 to 32 | 4 |
| Tread depth | How deep each step is, in map units | 128 to 4096 | 384 |
| Rise per step | Height of each step. Positive goes up, negative goes down. | −16 to 16, not 0 | 8 |
The steps lead away from the wall you selected. Each step keeps the ceiling height of the room it starts from.
Rules:
- The wall must be solid.
- The floor and ceiling of the starting room must be level, not sloped.
- Every step needs at least 48 units between its floor and the ceiling.
- The stairs must not overlap or cross existing rooms.
| Message | What to do |
|---|---|
| Select a solid wall at the foot of the stairs. | Pick a wall that has no room behind it. |
| Use 2–32 steps, at least 128 units of tread, and at most 16 units of rise per step. | Bring the numbers into range. |
| Use a level floor and ceiling at the start of the stairs. | Remove the slope from the starting room. |
| The stair flight needs more headroom. Raise the parent ceiling or reduce the rise. | Raise the ceiling of the starting room, or use fewer or lower steps. |
| The stair flight would overlap existing rooms. | Start from another wall, or shorten the flight. |
| The stair flight reaches the edge of the map or the classic map limits. | Shorten the flight. |
The whole staircase is one undo step.
Catwalks
A catwalk is a platform that the player can walk on and also walk under. It is made from one flat sprite that shows a tile.
- Choose Build → Catwalk…. The Build catwalk window opens.
- Set the numbers.
- Click Place in Plan. The toolbar shows “Place catwalk”.
- Click the centre point of the catwalk in Plan.
| Field | Meaning | Starts at |
|---|---|---|
| Tile | The picture on the platform | 342 |
| Length | Size along the platform, in map units. At least 128. | 1024 |
| Width | Size across the platform, in map units. At least 128. | 512 |
| Height above floor | Height of the walking surface, in height units. At least 48. | 48 |
| Angle (0–2047) | Direction of the platform | 0 |
At angle 0 the length runs left to right in Plan. At 512 it runs top to bottom.
Rules:
- The tile must have art.
- The whole catwalk must be inside one sector.
- It needs 48 units of clearance below it and 48 units above it.
- It must not cross a wall or a pillar.
- The tile must be able to cover the size as one sprite. If it cannot, use a larger tile or a smaller catwalk.
In Plan a catwalk is drawn as a blue rectangle. Select it like any sprite. To change its height later, edit Above floor in the Inspector.
To put objects on a catwalk, choose its level in the floor list and then place sprites as usual.
The Section view
Section is a side view. It cuts through the map along a straight line and shows the floors and ceilings that the line crosses. Use it to check heights and clearances.
- Select an object where you want to look.
- Click Section above the Scene. The cut runs through the selection.
To move the cut:
- Click Along X or Along Y to turn the cut by a quarter turn. The button shows the current direction.
- Click Pick cut, then click a spot in Plan.
- Click - or + to shift the cut by one snap step.
- Select another object and press F.
What the view shows:
| Drawing | Meaning |
|---|---|
| A box labelled “Sector N … clearance” | A sector, from its floor to its ceiling, with the space between them |
| A blue line labelled “Catwalk … above · … below” | A catwalk, with the space above it and below it |
| An orange line with two dots | The travel of a lift, between the floor heights of its neighbours |
Move the pointer over a sector or a catwalk to read its exact floor, ceiling and clearance at the top of the view. The line at the bottom shows where the cut is.
Click a sector or a catwalk in Section to select it. This also sets the floor list in Plan to that level.
If the cut does not cross any part of the map, the view says “Move the cut through the map.”
Show one floor at a time
Maps often have rooms at several heights, and catwalks above floors. The floor list hides everything that is not on the level you are working on.
The list is above the Scene in Plan, to the right of Frame. It shows All floors at first.
- Open the list.
- Choose a level. There is one entry for each floor height and each catwalk height in the map.
While a level is chosen:
- Plan shows only the rooms, walls and sprites on that level.
- Clicking selects only things on that level.
- A sprite you place over a catwalk on that level lands on the catwalk.
- Play From Here starts you on that level.
Choose All floors to see everything again. Opening another map also returns the list to All floors.
Batch selection
Batch selection lets you pick several walls and sprites, and change them together.
- Click Batch Select in the toolbar. The button lights up.
- Click a sprite to add it to the group. Click it again to remove it.
- Hold Ctrl and click a wall to add or remove it.
The top of the Inspector shows how many objects are in the group. Open Selected objects to see the list. Click an entry to bring that object into view. Click Clear to empty the group.
Good to know:
- The group holds walls and sprites only.
- While Batch Select is on, you cannot drag objects in Plan.
- Turning Batch Select off empties the group.
- Adding or deleting sectors, walls or sprites also empties the group.
Batch edits
The batch tools appear at the top of the Inspector while Batch Select is on and the group is not empty. They are in two sections, Move and Appearance. Each button makes one undo step.
Move
| Field | Meaning |
|---|---|
| Offset X, Offset Y | How far to move, in map units |
| Rise (sprites) | How far to raise the sprites, in height units. Negative lowers them. |
Click Move selection.
- Walls move sideways only. Corners shared with neighbouring rooms move with them.
- Sprites keep their height above the floor, plus the rise you entered.
- A sprite must stay inside the map and between its floor and ceiling.
Appearance
- Shade offset and Adjust shade: the number is added to the shade of every wall and sprite in the group. A negative number makes them brighter.
- Align wall textures: see Wall alignment.
- Height above floor and Set sprite height: see Sprite heights.
Tile
Choose a tile in the Tiles tab of Assets and click Apply tile. Every wall and sprite in the group gets that tile.
Wall alignment
Use this when a picture should run smoothly across several walls.
- Turn on Batch Select.
- Ctrl-click each wall of the run.
- Click Align wall textures in the Inspector.
The first wall of the run stays as it is. Each following wall continues the picture where the previous wall ends.
Rules:
- Select at least two walls.
- All of them must be solid walls, not portals.
- All of them must show the same tile.
- They must form one unbroken run in one sector, each wall starting where the previous one ends.
| Message | Meaning |
|---|---|
| Select two or more connected walls with the same tile. | Fewer than two walls are in the group. |
| Use solid, unflipped walls with the same available tile. | A wall is a portal, shows a different tile, or has a flip or overlay flag set. |
| Select a continuous run of walls in one sector. | The walls do not join end to end. |
Sprite heights
A new sprite stands on the floor. Switches, lights and decorations usually belong higher up.
One sprite
- Select the sprite.
- Type a number in Above floor in the Inspector and press Enter.
The height is measured from the floor. If the sprite stands on a catwalk, it is measured from the catwalk.
Several sprites
- Turn on Batch Select and click the sprites.
- Type a number in Height above floor. It starts at 40, which is the player’s eye height.
- Click Set sprite height.
Each sprite is set to that height above its own floor. The editor refuses the change if a sprite would end up above its ceiling.
Linked mechanisms
In Build-engine games, moving parts are made from numbers. A lift is a sector with a special tag. A hidden marker sprite inside it listens for a signal. A switch on a wall sends that signal because it carries the same tag number. Setting this up by hand means typing matching numbers in several places.
A preset does it for you. You choose the sector, the walls for the switches and a few settings. The editor then writes the tags and places the sprites in one step.
If sector, sprite or tag are new words, see Words you will meet.
Which maps can use presets
The presets create Duke Nukem 3D mechanisms. They work when the map’s game target is Duke Nukem 3D 1.3D or Duke Nukem 3D Atomic / Plutonium. For other targets the menu is greyed out.
The presets
Open them from Build → Linked mechanisms.
| Preset | What the player gets |
|---|---|
| Lift | A platform that travels between two floor heights, with call buttons |
| Ceiling door | A door that opens upward when a switch is used |
| Crusher trap | A floor that drops and a ceiling that closes down on it, set off by a trigger |
| Light switch | A switch that turns the lights of a room on and off |
Steps for every preset
- Select the sector that should move or change. This is the target.
- Choose Build → Linked mechanisms and pick a preset. A window with the preset’s name opens.
- Check Target. It shows the selected sector. To change it, pick another sector from the list, or select one in the Scene and click Use selected sector.
- Fill in the settings of the preset. They are described below.
- Add a wall for each switch:
- Hold Ctrl and click a solid wall in Plan. You can also click the wall in 3D.
- Click Add selected wall in the preset window.
- Repeat for more switches.
- Click Create linked mechanism.
The status line confirms the result and shows the tag number that was used, for example “Create Lift · tag 100”. The whole mechanism is one undo step.
Each chosen wall appears in the window. Click its name to bring it into view. Click Remove to take it out of the list.
While the window is open, Plan draws a line from each chosen wall to the target.
If a solid wall is selected when you open a preset, that wall is added as the first switch, and its sector becomes the target.
Rules for every preset
- The target sector must not have a tag yet. Its LoTag must be 0.
- The target must not already contain effector, activator or speed marker sprites.
- You need at least one switch wall.
- Each switch wall must be solid and at least 128 map units wide.
- The room in front of each switch wall needs 48 height units between floor and ceiling.
- For Lift, Ceiling door and Crusher trap, the floor and ceiling of the target must be level, not sloped.
If a rule is broken, the status line says what to change and nothing is created.
What every preset creates
- A new tag number. The editor picks the lowest number from 100 upward that is not used as a LoTag or HiTag anywhere in the map.
- One switch sprite per wall. It is placed in the middle of the wall, just in front of it, facing into the room. Its LoTag is the new tag number.
- Marker sprites inside the target. They are placed together at a free point in the sector. The player never sees them.
Lift
A lift is a sector whose floor moves between two heights.
Before you start
- Build the lift platform as its own sector.
- It needs two neighbours with different floor heights. These are the two stops. The player must be able to walk through the portals to them.
- Set the platform’s Floor Z to the same height as one of the stops.
Settings
| Setting | Meaning |
|---|---|
| First stop, Second stop | The two neighbouring sectors the lift serves. The editor suggests them. |
| Speed (Build) | Movement speed, from 1 to 32767. It starts at 256. |
| Call buttons | The walls that get a button. Add one at each stop. |
Extra rules
- The two stops must have different floor heights.
- The platform’s floor must be level with one of them.
- There must be 48 units between the higher stop’s floor and the platform’s ceiling.
- Every neighbour of the platform must be level and at one of the two stop heights.
What is created
| Where | What |
|---|---|
| Target sector | LoTag set to 17 |
| Inside the target | An Activator sprite with the new tag as LoTag |
| Inside the target | A speed marker sprite (GPSPEED) with the speed as LoTag |
| Each chosen wall | A POWERSWITCH1 sprite, 40 units above the floor |
Ceiling door
A ceiling door is a sector whose ceiling moves up to open and down to close.
Before you start
- Build the door as its own sector between two rooms.
- Either close it, by setting Ceiling Z equal to Floor Z, or leave it open with at least 48 units of height.
- At least one neighbouring room must have its ceiling 48 units or more above the door’s floor.
Settings
| Setting | Meaning |
|---|---|
| Speed (Build) | Movement speed, from 1 to 32767. It starts at 256. |
| Switches | The walls that get a switch |
What is created
| Where | What |
|---|---|
| Target sector | LoTag set to 20 |
| Inside the target | An Activator sprite with the new tag as LoTag |
| Inside the target | A speed marker sprite (GPSPEED) with the speed as LoTag |
| Each chosen wall | A POWERSWITCH1 sprite, 40 units above the floor |
Crusher trap
In the game, the room looks normal until the trigger is used. Then the floor drops and the ceiling comes down after it, stopping 8 units above the dropped floor. Using the trigger again resets the trap. The player can use the trigger or shoot it.
Before you start
- The trap sector needs 48 units between floor and ceiling.
- Put the trigger in a different sector, for example a neighbouring room.
Settings
| Setting | Meaning |
|---|---|
| Floor drop | How far the floor falls, from 16 to 4096 height units. It starts at 384. |
| Speed (Build) | Movement speed, from 1 to 32767. It starts at 24576. The editor may lower it a little so the drop divides evenly. |
| Switches | The walls that get a trigger |
What is created
| Where | What |
|---|---|
| Target sector | Floor Z lowered by the floor drop. The editor shows the floor in its dropped position. |
| Inside the target | An Activator sprite with the new tag as LoTag |
| Inside the target | A speed marker sprite (GPSPEED) with the speed as LoTag |
| Inside the target | A Sector Effector with LoTag 31 and angle 512, at the old floor height |
| Inside the target | A Sector Effector with LoTag 32 and angle 1536, 8 units above the dropped floor |
| Each chosen wall | An enlarged DIPSWITCH2 sprite, 32 units above the floor |
Light switch
Using the switch brightens the room to the shade you choose. Using it again returns the room to its own shade.
Settings
| Setting | Meaning |
|---|---|
| Light shade | The shade of the room when the light is on. It must be lower, which means brighter, than the room’s current floor shade. It starts at −12. |
| Light palette | The palette of the room when the light is on, from 0 to 255. It starts at 0. |
| Switches | The walls that get a switch |
For a clear effect, make the room dark first by raising the Shade of its floor and ceiling. Then run the preset.
A sloped sector may be used for this preset.
What is created
| Where | What |
|---|---|
| Inside the target | A Sector Effector with LoTag 12. Its HiTag is the new tag. Its Shade and Palette are the light values. |
| Each chosen wall | A LIGHTSWITCH sprite, 40 units above the floor |
See what is linked
Choose Build → Show links to draw the links of the whole map. Opening a preset turns this on for you.
- In Plan, a line runs from each switch to the sector that reacts to it.
- Select a switch, a marker or a linked sector. Its lines turn orange, and the tag number appears on each line.
- In 3D, a small floor plan in the top right corner shows the same lines.
Choose Build → Show links again to hide them.
A link is drawn when both ends exist:
| End | What counts |
|---|---|
| Switch | A wall or sprite that shows one of the game’s switch tiles and has a LoTag above 0 |
| Receiver | An Activator, locked Activator, Master Switch or Respawn sprite with the same LoTag |
| Receiver | A Sector Effector of type 12, 21, 24, 25 or 34 whose HiTag is that number |
| Receiver | A wall with a force field overlay and the same LoTag |
Links are shown for the same two game targets as the presets.
Change a mechanism
A preset writes ordinary map data. Nothing is locked. To change a mechanism, edit the objects it created.
| To change | Edit |
|---|---|
| Which switch works the mechanism | The LoTag of the switch sprite |
| The speed | The LoTag of the speed marker sprite in the target |
| The lit shade or palette of a light | The Shade and Palette of the Sector Effector in the target |
| The height of a switch on the wall | Above floor of the switch sprite |
| The look of a switch | Tile of the switch sprite |
To find the marker sprites, select the target sector, turn on Show links and look for the sprites inside it in Plan. You can also search the Hierarchy.
To remove a mechanism straight after creating it, press Ctrl+Z. Later, do it by hand: delete the marker sprites and the switch sprites, and set the sector’s LoTag back to 0. For a crusher trap, also raise Floor Z back to its old value.
A preset refuses a target that already holds marker sprites. Change that mechanism by hand instead.
Check for broken links
Build → Check map lists every switch whose tag has no receiver. See Map check.
Playtesting
A playtest runs your map in the real game without leaving the editor. This page also covers the Map check, which looks for common mistakes.
Start a playtest
- Press F5, or click Playtest F5 in the toolbar.
- The game starts in your map as a normal single-player game. The words “PLAYTEST F5 TO EDIT” appear at the top of the screen for a few seconds.
Good to know:
- You do not need to save first. The playtest runs on a temporary copy, and your map file is not touched.
- The map must be complete enough to play. It needs at least one sector and a player start inside a sector. If something is missing, the status line says what.
- The playtest uses the game that is running now. To test a map made for another game, start NNBuild with that game’s data.
- Script components run during a playtest when Modern Mode is on for the map.
If the game cannot start the map, you are returned to the editor with this message:
Duke3D could not start this playtest. Check the start and sector geometry.
Return to the editor
Use any of these:
- Press F5 again.
- Press Escape to open the menu and choose RETURN TO EDITOR. Choose RESUME PLAYTEST to keep playing.
- Finish the level. Reaching the end of the level returns you to the editor.
The status line says “Playtest stopped”. Your map, the undo history, the view and the selection are as you left them.
Choose a spawn
Click Spawn… beside the Playtest button to start somewhere other than the map’s player start.
| Entry | Starts you at |
|---|---|
| Map start | The map’s player start |
| DukeMatch start #N · Sector S | A multiplayer start sprite whose LoTag is 0 |
| Co-op start #N · Sector S | A multiplayer start sprite whose LoTag is 1 |
| Player start #N · Sector S | A start sprite with any other LoTag |
N is the sprite’s number and S is its sector. The list has one entry for each player start sprite in the map. You add such sprites with the Co-op start entity in the Entities tab. A new one has LoTag 0. Set its LoTag to 1 in the Inspector to make it a co-op start.
Choosing an entry starts the playtest at once. The map is not changed.
Play From Here
Use this to test one room without walking there.
- Right-click a floor in Plan or in 3D. Do not drag while you click.
- Choose Play From Here.
The playtest starts at that spot. From 3D, you face the way the camera was looking. From Plan, you face the way the map’s player start faces.
In 3D, right-click a floor or a catwalk.
The spot must have room for the player. If it does not, the status line shows one of these messages and the playtest does not start.
| Message | Meaning |
|---|---|
| Choose a walkable surface inside a sector. | The spot is not inside a sector. |
| This surface needs at least 48 units of headroom. | The ceiling is too low there. |
| The player start is too close to a blocking wall. Move it inward. | The spot is within 128 map units of a wall the player cannot pass. |
| A blocking floor sprite leaves too little room for the player. | A flat blocking sprite is just above the spot. |
| A blocking sprite overlaps the player start. | A blocking object stands on the spot. |
If you change the map while the menu is open, Play From Here is greyed out. Right-click again.
Play on a catwalk
A catwalk has a floor below it, so one spot in Plan can mean two places.
- In Plan, with the floor list on All floors, right-click a spot under a catwalk. The menu shows two entries. Play From Here starts you on the floor. Play on catwalk starts you on top of the catwalk.
- In Plan, with a level chosen in the floor list, Play From Here starts you on that level.
- In 3D, right-click the catwalk itself and choose Play From Here.
Playtest during a live session
A playtest is local. The other participants keep editing, and they see “Playtesting” beside your name. See Live editing.
Map check
The map check looks through the whole map and lists what it finds.
- Choose Build → Check map. The Map check window opens.
- Read the list. The top line names the game the map is checked for and counts the findings.
- Click the name of an object, such as “Sector 4” or “Sprite 12”, to select it and bring it into view in Plan.
- Fix the problem. The list updates when the map changes. You can also click Refresh.
When nothing is wrong, the window says “No issues found.”
Findings about the player start
| Finding | What to do |
|---|---|
| Place a Player Start inside a sector. | Use the Player Start tool. |
| A player needs 48 units of headroom and a start between the floor and ceiling. | Raise the ceiling, or move the start. |
| The player start is too close to a blocking wall. Move it inward. | Move the start at least 128 map units from solid walls. |
| A blocking floor sprite leaves too little room for the player. | Move the start, or the sprite. |
| A blocking sprite overlaps the player start. | Move the start, or the sprite. |
For maps that target Duke Nukem 3D 1.3D or Atomic / Plutonium, the same checks run on every multiplayer start sprite. Such a finding begins with the name of the start, for example “Co-op start #12 · Sector 3.” A start sprite that lies outside its sector is reported as “Move this spawn inside its assigned sector.”
Findings about tiles
| Finding | What to do |
|---|---|
| Floor, Ceiling, Wall, Overlay or Sprite tile N is outside the target’s tile range. | Choose a tile number that the target game has. See Map limits. |
| Floor, Ceiling, Wall, Overlay or Sprite tile N has no loaded art. | The tile number is empty in the loaded game. Choose another tile, or add the art to your project. |
| Load the selected base game and its project art to check tile availability. | The map is for a different game than the one that is running. The editor cannot check which tiles have art. Start NNBuild with the target game to check. |
Findings about switches
This check runs for maps that target Duke Nukem 3D 1.3D or Atomic / Plutonium.
| Finding | What to do |
|---|---|
| Switch tag N has no matching activator, light, or other known receiver. | The switch does nothing. Give it the tag of the thing it should control, or create that thing. See Linked mechanisms. |
Findings about the map format
| Finding | What to do |
|---|---|
| Sector flags exceed the classic v7 target format. | Clear the extra bits in the sector’s Flags. |
| Wall flags exceed the classic v7 target format. | Clear the extra bits in the wall’s Flags. |
| Sprite flags exceed the classic v7 target format. | Clear the extra bits in the sprite’s Flags. |
| The two sides of this portal do not point to each other. | The portal is damaged. Repair it with the classic Build tools, or delete and redraw the sector. |
Findings about script components
| Finding | What to do |
|---|---|
| Enable modern features or remove the script attachment. | The map has script components but Modern Mode is off. Turn it on, or remove the components. |
| Script attachment requires VibeBuild32. Stock game plays the map without it. | A reminder. The script runs only in NNBuild. Other programs load the map without it. |
| An attachment lost its map object. Reattach script. | The object the script was attached to is gone. Attach the script to an object again, or detach it in Map settings. |
| Missing project script script. | The script file is not in the project. Add it, or detach it. |
See Script components.
Findings that stop saving
The last finding in the list can be the reason the map cannot be saved or played yet. It is one of these.
| Finding |
|---|
| A classic map needs a sector and must fit the version 7 sector, wall and sprite limits. |
| Use Player Start to place Duke inside a sector. |
| A sector points to a missing wall. |
| A sector uses a tile outside this Duke3D edition’s art range. |
| A sector uses flags from an extended map format. |
| Two sectors own the same wall. |
| A wall does not belong to a closed sector loop. |
| A portal points to a missing wall or sector. |
| A wall uses an out-of-range position or tile. |
| A masked or one-way wall needs an overlay tile. |
| A wall uses flags from an extended map format. |
| A sprite uses an invalid sector, angle, status or tile. |
| A sprite uses flags from an extended map format. |
Projects
A project is a folder that keeps everything for a mod or a game in one place: maps, scripts, art and sounds, plus a small settings file. You can pack the folder into one ZIP file and give it to players.
This page uses the example game in examples/ashline-relay/ to show how the
parts fit together.
The project folder
A folder is a project when it has a file called vibebuild.project.json at
its top level. Every other file in the folder is an asset. You may arrange
assets in subfolders as you like.
The example project looks like this:
ashline-relay/
vibebuild.project.json project settings
GAME.CON game rules (stand-alone games)
tiles000.art art (stand-alone games)
palette.dat colours (stand-alone games)
Tiles.tsv a list of tile numbers, for people to read
README.md
Maps/
Ashline.map the map
Ashline.map.vbmap.json settings for that map
Scripts/
Station.js a script component
Sounds/
alarm.wav, relay.mid, ...
Attribution/
licence notices for the art
Create or open a project
Choose File → Project…. The Project settings dialog opens. You can also click Project… in the Project tab of the Assets panel.
Create
- Type the path of the folder in Folder.
- Click Create project.
The folder is created if it does not exist. Its parent folder must exist. A folder that already has project settings is refused.
A new project starts with these settings:
| Setting | Starts as |
|---|---|
| Project name | The folder’s name |
| Base game | The game that is running |
| Modern Mode | Off |
| Entry map | None |
Open
- Type the path of the project folder in Folder.
- Click Open folder.
To open a project when you start the program, use --editor with --project:
./vibebuild32 --editor --project examples/ashline-relay
Starting this way also loads the project’s own files together with the game. Use it when the project brings its own art.
Change the settings
With a project open, the dialog shows:
| Control | What it does |
|---|---|
| Project name | Type a name and press Enter. |
| Base game | The game target for the maps of the project |
| Enable Modern Mode | Turns on Modern Mode |
| Entry map | Shows the current entry map |
| Asset file, Add asset | Copies a file into the project |
| Close project | Closes the project. The files stay where they are. |
Each change is written to vibebuild.project.json at once.
A relative path in these dialogs starts from the folder in which you started NNBuild.
The settings file
vibebuild.project.json is a small text file. This is the one from the
example project:
{
"name": "Ashline Relay",
"target": "standalone",
"entry": "Maps/Ashline.map",
"modern": true,
"version": 1
}
| Field | Type | Needed | Meaning |
|---|---|---|---|
version | number | Yes | Must be 1. |
name | text | Yes | The project’s name, from 1 to 128 characters. |
target | text | Yes | The base game. One of the IDs under Game targets, but not inherit. |
entry | text | No | The map a player starts in, as a path inside the project that ends in .map. Leave it empty for none. |
modern | true or false | No | true turns on Modern Mode. If the field is missing, Modern Mode is off. |
The editor writes this file for you. If you edit it by hand and it is no longer valid, the project does not open and you see “The folder needs a valid vibebuild.project.json.”
Paths inside a project
Paths in the settings files are written from the top of the project folder,
with forward slashes, for example Maps/Ashline.map.
A path is refused if it:
- starts or ends with a slash,
- contains
\,:,<,>,",|,?or*, - has a part that ends in a dot or a space, such as
.., - has a part named
CON,NUL,PRN,AUX,COM1toCOM9orLPT1toLPT9.
Two files whose paths differ only in upper and lower case cannot both be in a project that you export.
Add assets
Use any of these:
- Copy files into the folder with your file manager. Then click Refresh in the Project tab.
- Save a map into the folder with File → Save as….
- Add asset. In Project settings, type the path of a file in Asset file and click Add asset. The file is copied to the top level of the project under the same name. An existing file is not replaced.
- Drag a file onto the editor window while a project is open. The
Project settings dialog opens with the path filled in. Click Add
asset. A dragged
.mapfile is opened for editing instead.
The Project tab
The Project tab of the Assets panel lists every file and folder of the project.
| Control | What it does |
|---|---|
| Project… | Opens Project settings |
| Map settings… | Opens the settings of the current map |
| Search assets | Filters the list |
| Refresh | Reads the folder again |
| Set entry map | Appears when a map is selected. Makes it the entry map. |
| Place Prefab | Appears when a prefab is selected and Modern Mode is on |
Double-click a map to open it. Double-click a prefab to place it.
Each row starts with a small badge that shows which game the file is for: D3, DA, N, NP, GI or S. See the table under Game targets. The entry map is marked “(Entry)” and prefabs are marked “(Prefab)”.
Entry map
The entry map is the map a player starts in when they run the project.
- Open the Project tab.
- Click a map in the list.
- Click Set entry map.
If a project has no entry map, running it starts the first map found in the
folder. A player can also name a map with
--project-map.
Game targets
A game target says which game a map is made for. These are all of them:
| ID | Name in the editor | Badge | Highest tile number |
|---|---|---|---|
duke13 | Duke Nukem 3D 1.3D | D3 | 3,839 |
duke_atomic | Duke Nukem 3D Atomic / Plutonium | DA | 5,119 |
nam | NAM | N | 5,119 |
napalm | NAPALM | NP | 5,119 |
ww2gi | WWII GI | GI | 5,119 |
standalone | Standalone | S | 5,119 |
inherit | Inherit | Per-map only. The map uses the project’s base game. |
The target affects four things:
- Tile range. A map cannot be saved or exported if it uses a tile number above the target’s limit.
- Mechanisms. The mechanism presets, the link display and
the switch check work for
duke13andduke_atomic. - Game data. When a player runs the project, NNBuild looks for that game’s
data files. For
duke_atomicit accepts the Atomic Edition, the Plutonium Pak and World Tour. - Stand-alone launch.
standalonemakes the project run from its own files. See Stand-alone games.
Changing the target does not change the map. Tile numbers and tags stay as they are, so use the target game’s own tiles and tags when you build.
You set the target in three places:
| Where | Applies to |
|---|---|
| Base game in Project settings | Every map of the project that does not say otherwise |
| Base game in Map settings | The current map |
| Import as in the Open map dialog | The map you are opening |
With no project open, a map is checked against the game that is running.
The Tiles tab and the playtest always use the game that is running. To see and test another game’s art, start NNBuild with that game’s data.
Per-map settings
A map can override the project’s settings. Choose File → Map settings….
| Control | What it does |
|---|---|
| Base game | Inherit, or one game target for this map |
| Modern Mode | Inherit, Off or On for this map |
| Object script, Attach to selected object | Attaches a script to the selected object. Shown when Modern Mode is on. |
| Detach | Removes one script attachment from the list |
| MAP, Export MAP | Writes a plain classic map. See Export a classic map. |
The line under the lists shows the game that is in effect for the map.
Map settings belong to the map. Changing them marks the map as unsaved. They are written when you save the map.
The map settings file
The settings are stored beside the map in a file with the map’s full name plus
.vbmap.json. For Maps/Ashline.map this is Maps/Ashline.map.vbmap.json.
The file is written only when the map has something to store: a game target of its own, a Modern Mode choice, or script components. A plain classic map has no such file.
This is a shortened copy of the one in the example project:
{
"target": "inherit",
"scripts": [
{
"kind": "sector",
"script": "Scripts/Station.js",
"index": 29
},
{
"kind": "sprite",
"script": "Scripts/Station.js",
"index": 15
}
],
"version": 1
}
| Field | Type | Meaning |
|---|---|---|
version | number | Must be 1. |
target | text | A game target ID, or inherit |
modern | true or false | true is On and false is Off. Leave the field out for Inherit. |
scripts | list | The script components of the map. At most 1,024. |
scripts[].kind | text | sector, wall or sprite |
scripts[].script | text | Path of the script inside the project. It must end in .js, .ts, .mjs or .mts. |
scripts[].index | number | The number of the sector, wall or sprite. -1 means the object was lost and the script is unassigned. |
Keep this file together with its map when you copy or move the map.
Import and export
Export a classic map
Use this to hand out a single map without project data.
- Choose File → Map settings….
- Type the destination in MAP.
- Click Export MAP.
The editor adds .map if you leave it out. It writes only the map, with no
settings file beside it. An existing file is not replaced.
Export a project ZIP
- Save the current map.
- Choose File → Project….
- Type the path of the ZIP file in ZIP.
- Click Export ZIP.
The ZIP holds every file and folder of the project. Before writing it, the editor checks that the entry map exists and that every map in the project is valid for its game target. If a map fails, the message names it.
An existing ZIP file is not replaced. Choose a new name.
A project ZIP can hold up to 16,384 files and folders.
Import a project ZIP
- Choose File → Project….
- Type the path of the ZIP file in ZIP.
- Type the path of a new folder in Folder. The folder must not exist yet. Its parent must exist.
- Click Import ZIP into folder.
The project is unpacked and opened. You can also drag a project ZIP onto the editor window. This opens the dialog with ZIP filled in.
A ZIP is accepted as a project when vibebuild.project.json is at the top
level of the archive, not inside a subfolder.
How a player runs a project
A player needs NNBuild and your project as a folder or as a ZIP.
| The player has | Command |
|---|---|
| A project folder | ./vibebuild32 --project "/path/to/My Project" |
| A project ZIP | ./vibebuild32 "My Project.zip" |
| A project ZIP, written out in full | ./vibebuild32 --project "My Project.zip" |
Drag and drop. Dragging the ZIP onto the program’s icon starts it the same way, because the system passes the ZIP as the first argument.
Another map. Add --project-map with a path inside the project to start
in a different map:
./vibebuild32 "My Project.zip" --project-map "Maps/Outpost.map"
Edit instead of play. Add --editor:
./vibebuild32 --editor --project "/path/to/My Project"
What happens when a project starts:
- A ZIP is unpacked to a temporary folder. The folder is removed when the program closes.
- The project folder is added to the places where the game looks for files.
- The startup window and the logo are skipped.
- The entry map starts.
Game data
A project for one of the classic games uses the player’s own copy of that game. If NNBuild cannot find the data, it stops with a message like this:
This project needs NAM data. Add the data folder with -j or pass -gamegrp.
The player then adds the folder that holds the game data:
./vibebuild32 -j/path/to/game-data --project "/path/to/My Project"
A stand-alone project does not need any of this.
Scripts in a ZIP
Scripts inside a project ZIP do not run unless the player allows them:
./vibebuild32 --allow-project-scripts "My Project.zip"
Without the option, the project still starts, but its script components stay off. A project that is run from a folder does not need the option.
Stand-alone games
A stand-alone game does not use the data files of another game. Set Base game to Standalone.
The top level of the project must then contain these three files:
| File | What it is |
|---|---|
GAME.CON | The game’s rules script |
tiles000.art | The first art file |
palette.dat | The colour palette |
If one is missing, the project does not start:
A standalone project needs its own GAME.CON, tiles000.art, and palette.dat.
Add whatever else your GAME.CON uses, such as sounds, music and more art
files.
When a stand-alone project starts, NNBuild works from inside the project
folder, loads the project’s GAME.CON, and does not load add-ons from the
autoload folder.
The example: Ashline Relay
examples/ashline-relay/ is a one-map stand-alone game.
vibebuild.project.jsonsets the target tostandalone, the entry map toMaps/Ashline.map, and Modern Mode to on.GAME.CON,tiles000.artandpalette.datare the three required files. The art and sounds come from Freedoom. The notices are inAttribution/.Scripts/Station.jsis one script. The map’s settings file attaches it to four sectors and four sprites.Tiles.tsvlists which picture is at which tile number. It is a reference for people. The program does not read it.
Run it from the top of the source tree:
./vibebuild32 --project examples/ashline-relay
Open it in the editor:
./vibebuild32 --editor --project examples/ashline-relay
Run it from an exported ZIP, with its scripts allowed:
./vibebuild32 --allow-project-scripts --project "/path/to/Ashline Relay.zip"
Modern Mode
Modern Mode turns on the features that only NNBuild has:
- script components on sectors, walls and sprites,
- prefabs.
When you turn it on, the editor shows this warning and asks you to confirm:
Modern Mode requires VibeBuild32. This project is incompatible with other source ports and the original game.
VibeBuild32 is the older name of NNBuild.
For the whole project
- Choose File → Project….
- Tick Enable Modern Mode.
- Click Enable Modern Mode in the warning.
For one map
- Choose File → Map settings….
- Set Modern Mode to On, Off or Inherit. If your choice turns Modern Mode on for the map, the same warning appears.
The map’s own choice wins. Inherit uses the project’s setting. With no project open, Modern Mode is off unless the map says On.
Script components
A script component is a JavaScript or TypeScript file attached to a sector, a wall or a sprite. It runs while the map is played and gives that object its own behaviour. Modern Mode must be on.
How to write components is covered in Map script components. This section shows how to attach them in the editor.
Attach a component
- Select a sector, a wall or a sprite.
- In the Inspector, find Script components and click Add Component.
- Choose one of these:
- New TypeScript component… or New JavaScript component…. Type
a path inside the project, such as
Scripts/Door.ts, and click Create and Attach. The editor writes a starter file with empty functions. This needs an open project. - An existing script from the list.
- New TypeScript component… or New JavaScript component…. Type
a path inside the project, such as
An object can have several components. Click Remove beside one to detach it. Outside a live session, attaching and removing can be undone.
You can also attach by path. Open File → Map settings…, type the path in Object script, and click Attach to selected object. The same dialog lists every attachment of the map with a Detach button.
What a component can contain
| Function | When it runs |
|---|---|
onAttach(component) | When the object becomes active. It may return a clean-up function. |
onUpdate(component, deltaSeconds) | Every frame. Use it for visuals. |
onFixedUpdate(component, deltaSeconds) | Every game tick. Use it for gameplay. |
onDetach(component) | When the object or the level is unloaded, or the playtest stops |
component has four fields: kind, index, map, and state. Use state
to keep values for that one attachment.
Good to know
- A map can have up to 1,024 component attachments.
- Each playtest loads the script files again, so you can edit a script and press F5 to try it.
- When you add or delete geometry, the editor keeps each attachment on its object. If it cannot, the attachment becomes unassigned and the map check reports it.
- Players who run your project from a ZIP must allow scripts. See Scripts in a ZIP.
Prefabs
A prefab is a saved group of sprites that you can place again and again, such
as a desk with a lamp and a switch. It is stored in the project as a file
ending in .vbprefab. Prefabs need an open project with Modern Mode on.
Create a prefab
- Select a sprite. For several, turn on Batch Select and click each sprite.
- Click Create Prefab… in the Inspector.
- Type a path inside the project, such as
Prefabs/Desk.vbprefab. - Click Save Prefab.
The editor adds .vbprefab if you leave it out. An existing file is not
replaced.
A prefab stores:
- where each sprite is, measured from the first sprite you selected,
- how high each sprite is above the floor,
- every property of each sprite,
- the script components attached to each sprite,
- the game target of the map it came from.
A .vbprefab file is JSON text. It holds version (always 1), target (a
game target ID) and a sprites list. Each entry in the list has these number fields: x, y, z, tile,
flags, palette, shade, blend, clip_distance, repeat_x, repeat_y,
offset_x, offset_y, angle, status, owner, velocity_x,
velocity_y, velocity_z, lotag, hitag and extra. It also has a
components list with the paths of its scripts.
Place a prefab
- Open the Project tab.
- Double-click the prefab. You can also click it once and click Place Prefab. The toolbar shows “Place prefab”.
- Click in Plan. Small circles show where the sprites will land.
- Click again for another copy. Press Q when you are done.
Each copy is one undo step. Its sprites are ordinary sprites that you can move and change.
Rules:
- Every sprite of the prefab must land inside a sector.
- The script files that the prefab refers to must be in the project.
- In a live session, only the host can place a prefab that has script components.
To share prefabs, export the project as a ZIP. The prefab files and the scripts travel with it.
Live editing
In a live session, several people edit the same map at the same time. One person hosts the session from their editor. The others join it. Everyone sees the map change as the others work.
A session holds up to 32 participants: the host and 31 others. An AI assistant can take one of these places. See AI and MCP.
In the picture, the host is on the left and a second participant is on the right. Both lists of Participants show two names. The host’s Plan shows the other participant’s pointer with a name label.
Requirements
- The same version of NNBuild on every machine.
- The same game edition. Everyone must run the same game data as the host, for example the Atomic Edition on all machines. AI participants are exempt.
- A reachable UDP port on the host. The session uses UDP port 23514 unless the host chooses another. Participants connect to the host’s machine, so that port must be open in the host’s firewall. To host across the internet, forward the port on the host’s router to the host’s machine.
- Every participant must be able to open the editor. See Requirements.
Host a session
- Open the map you want to share.
- Click Session in the toolbar. The Live editing box opens.
- Type a name in Your name. It may be up to 36 characters long.
- Check Host port. Leave it at 23514 unless you need another port.
- Click Host this map.
The status line says “Live session listening on UDP port 23514”. The Session button now reads Live 1. The number counts the participants.
Tell the others your address. If you changed the port, tell them the port too.
Join a session
- Click Session in the toolbar.
- Type a name in Your name.
- Type the host’s address in Host address.
- Click Join session.
| Address form | Example |
|---|---|
| Name or IPv4 address, default port | 192.168.1.20 |
| Name or IPv4 address with a port | 192.168.1.20:33184 |
| IPv6 address, default port | [fe80::1] |
| IPv6 address with a port | [fe80::1]:33184 |
Joining replaces the map in your editor with the host’s map. If your map has unsaved changes, the editor asks you to save or discard them first.
While the editor connects, the box shows Cancel connection. When you are
in, the status line says “Joined the live editor”. The shared map is called
Live draft.map on your machine.
What you see of the others
In the Hierarchy. A Participants list appears at the top. Each name is shown in that participant’s colour. Your own entry is marked “(You)”. An AI participant is marked “(AI)”. Under each other name is what that person is doing:
| Text | Meaning |
|---|---|
| Plan view, 3D view | Nothing selected, in that view |
| Sector 5, Wall 12, Sprite 3, Player Start | The object they have selected |
| Moving Sprite 3 | They are dragging that object |
| Drawing a room | They are using the Room or the pillar tool |
| Placing sprites | They are using the Sprite, catwalk or prefab tool |
| Placing the start | They are using the Player Start tool |
| Playtesting | They are in a playtest |
In Plan. Each participant’s pointer is drawn in their colour with a name label. The object they have selected is outlined in the same colour. A participant who is in the 3D view appears as a small ring at their camera position.
In 3D. The pointers of other participants who are also in 3D are drawn in your view. A small floor plan in the top right corner, the live plan, shows everyone’s pointers and selections and your own camera. Click Live plan above the Scene to hide it or show it again.
In the status line. After each change by someone else, the status line shows who did what, for example “Dana · Draw room”.
How edits are shared
Each finished action is sent as one edit.
- A drag is sent when you release the mouse button.
- A number typed in the Inspector is sent when you press Enter.
- A tool such as Extend room or Create stairs is sent when it completes.
The host checks every edit, gives the map a new revision number, and sends the result to everyone.
While the host confirms your edit, the editor does not accept another one from you. This normally takes a moment.
When two people edit at once
The editor compares the map piece by piece: each sector, each wall, each sprite, and the player start.
Edits that merge. If two people change different pieces at the same time, both edits are kept. For example, one person retextures a wall while another moves a sprite.
Edits that conflict. Your edit is refused when:
- someone else changed the same piece first, in a different way, or
- the number of sectors, walls or sprites changed while you were making your edit, or your own edit adds or removes them, or
- your edit was made on a map that is more than 24 revisions old.
When an edit is refused, your editor shows the latest shared map and this message:
The host changed the same map records first. Review the live draft and retry.
Nothing is lost on the shared map. Look at the current map and make your change again.
When someone adds or removes sectors, walls or sprites, the numbers of other objects can shift. Your selection and your batch group are cleared when that happens.
Change history and shared undo
Choose Build → Change history to see the last 24 changes of the session. The newest is at the top. Open a change to see:
- the name of the person who made it, in their colour, with “(AI)” for an AI participant,
- the revision number,
- “Structure updated” if it added or removed sectors, walls or sprites,
- the objects it touched. Click one to bring it into view.
Undo and redo are shared. Undo takes back the most recent change of the session, whoever made it. This includes changes made by an AI participant. Redo brings it back. Both appear in the history as changes of their own, such as “Undo Draw room”.
The session keeps up to 24 undo steps. The undo history you had before the session is not available while you are in it.
Save and playtest during a session
- Save. Saving writes a copy on your own machine. It does not affect the
others. A joined participant’s
Live draft.maphas no file yet, so the editor asks for a name the first time. - Playtest. Press F5 as usual. The playtest runs only on your machine. The others keep editing and see “Playtesting” beside your name.
- Another map. The host can open another map or start a new one. This replaces the shared map for everyone. A joined participant must leave the session first to open a different map.
- Classic Build tools. See Classic Build tools.
Projects in a session
A session shares the map: its sectors, walls, sprites and player start. It does not send project files.
- Give every participant the project, for example as a project ZIP, so that they all have the same art and scripts.
- Script component attachments are kept by the host’s project. Only the host can place a prefab that has script components.
End a session
- Leave. A joined participant clicks Session, then Leave session. The map stays open in their editor as it was at that moment.
- Stop hosting. The host clicks Session, then Stop hosting. The others are disconnected and keep their copy of the map.
Returning to the title menu also leaves the session.
Messages you may see
| Message | Likely reason |
|---|---|
| The editor host did not answer. Check the address and open slots. | The address or port is wrong, the port is blocked, or the session is full. |
| Could not resolve the editor’s address. | The address is mistyped. |
| Select the same Duke3D edition as the host. | Your game data differs from the host’s. |
| Disconnected from the editor host. | The host stopped the session, the connection dropped, or the two programs are different versions. |
| Could not listen on that UDP port. | Another program uses the port. Choose another Host port. |
| Wait for the host to confirm the current edit. | Your last edit is still on its way. Try again in a moment. |
| Leave the live session to open a different map. | Only the host can change the shared map. |
AI assistants and MCP
The Model Context Protocol (MCP) is an open standard that lets an AI assistant use tools offered by another program. The assistant’s side is called the MCP client. NNBuild can be the other side, the MCP server.
NNBuild offers MCP in two ways.
| You want the assistant to | Use | Start NNBuild with |
|---|---|---|
| Join a live editing session as one more participant | The participant adapter | --editor-mcp |
| Control a game, a server or the editor on this machine | The built-in control endpoint | --mcp-stdio or --mcp-http |
Both speak MCP over one of two transports:
- stdio. The MCP client starts NNBuild itself and talks to it through the program’s standard input and output.
- HTTP. NNBuild listens on a local web address and the client sends requests to it.
Join a live session as a participant
The participant adapter is a small process with no window. It joins a live session like a person would. The others see it in the Participants list with its own colour and the mark “(AI)”. Its pointer and its selection are visible in their Plan view. Its changes appear in the shared change history and can be undone like anyone else’s.
- A person hosts a session in the editor.
- The MCP client starts the adapter:
./vibebuild32 --editor-mcp 127.0.0.1:23514 --name "Layout Assistant"
The form of the command is:
vibebuild32 --editor-mcp [host[:port]] [--name name] [--mcp-http port]
| Part | Meaning | If left out |
|---|---|---|
host[:port] | Address of the session host | 127.0.0.1, port 23514 |
--name name | The name the others see | AI Editor |
--mcp-http port | Use the HTTP transport on this port | stdio is used |
Good to know:
- The adapter tries to join when it starts. If the session is not up yet, the
assistant can join later with the
editor_connecttool. - Use one adapter process for each AI participant.
- The adapter does not choose a game and does not load game data. It starts at once and never asks a question. It may run on a different machine than the host.
- An AI participant does not have to match the host’s game edition.
- Only the parts shown above may follow
--editor-mcp. Any other option after it makes the adapter stop with a usage message.
Example: stdio client for the adapter
Most MCP clients keep their servers in a JSON block like this one. Use the full path of the program.
{
"mcpServers": {
"nnbuild-live": {
"command": "/full/path/to/vibebuild32",
"args": [
"--editor-mcp", "127.0.0.1:23514",
"--name", "Layout Assistant"
]
}
}
}
The name of the file and of the keys can differ between MCP clients. Check your client’s documentation.
Control a game, a server or the editor
Add --mcp-stdio or --mcp-http PORT to a normal launch. The game then
offers tools to read its state, type console commands, send input, and drive
the editor and its projects.
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor --mcp-stdio
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor --mcp-http 8787
- With
--editorthe program starts in the editor. Without it, the assistant can open the editor witheditor_controland the actionenter. - Add
-smto skip the startup window, if your setup shows one. - The assistant acts as the local user. Offline, its edits are listed in the change history under the name “Assistant”. In a live session, it uses the local participant’s place.
- When the assistant points at something, a pointer labelled “Assistant (AI)” appears in Plan.
- With
--mcp-stdio, the program’s own text output goes to standard error. Standard output is kept for MCP. - The options also work on a multiplayer server. Add them to the server’s
normal launch options. A dedicated server normally reads admin commands
from standard input. With
--mcp-stdioit does not, so send them withconsole_execute.
Name the game
When data for several games is installed and the command line names none of
them, NNBuild normally asks on the console which game to start. It does not
ask when --mcp-stdio is given. It also does not ask when its standard input
is not a terminal, which is usual when another program starts it. In both
cases it starts the first game it finds.
To be sure that the right game starts, name it in one of these ways:
- Add
--gamewith the game’s name, for example--game duke. Other names areworldtour,nam,napalmandww2gi. - Give the game’s data file, for example
-gamegrp /path/to/DUKE3D.GRP. NNBuild recognises the game from a known data file.
Example: stdio client for the game
{
"mcpServers": {
"nnbuild": {
"command": "/full/path/to/vibebuild32",
"args": [
"--game", "duke",
"-gamegrp", "/path/to/DUKE3D.GRP",
"--editor",
"--mcp-stdio"
]
}
}
}
Replace duke and the data file with those of the game you run.
Example: HTTP client
Start NNBuild yourself, with a token:
VIBEBUILD_MCP_TOKEN=change-this-token ./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor --mcp-http 8787
Then point the client at the address and give it the same token:
{
"mcpServers": {
"nnbuild": {
"type": "http",
"url": "http://127.0.0.1:8787/mcp",
"headers": {
"Authorization": "Bearer change-this-token"
}
}
}
}
The HTTP endpoint
With --mcp-http PORT, NNBuild listens at:
http://127.0.0.1:PORT/mcp
It listens on the local machine only. A program on another machine cannot reach it. If a remote client must connect, put your own HTTPS proxy with a login in front of it.
Environment variables
| Variable | Effect |
|---|---|
VIBEBUILD_MCP_TOKEN | When set, every request must carry the header Authorization: Bearer followed by this value. Other requests get the answer 401. |
VIBEBUILD_MCP_ORIGIN | One extra value that is allowed in the Origin header of a request. |
Token. Without a token, any program on the same machine can call the tools. The tools can run console commands and write files, so set a token.
Origin. Web browsers add an Origin header to requests. NNBuild accepts a
request with no Origin header. If the header is present, it must be
http://127.0.0.1:PORT, http://localhost:PORT, or exactly the value of
VIBEBUILD_MCP_ORIGIN. Other origins get the answer 403.
Limits
- Requests use
POST /mcp. AGETis answered with 405. - Each request holds one JSON-RPC message of at most 128 KB and must state
its
Content-Length. - NNBuild answers and then closes the connection.
- It serves up to eight connections at a time. A connection must finish within eight seconds.
Protocol notes
- The server answers
initialize,ping,tools/listandtools/call. - It accepts the protocol versions
2024-11-05,2025-03-26and2025-06-18, and otherwise answers with2025-11-25. - Over stdio, each message is one line of JSON.
- A tool answers with JSON. When a tool fails, the answer is marked as an error and holds a sentence that says what to change.
Which tools are available
| Tool | With --editor-mcp | Game with --mcp-stdio or --mcp-http | --build-editor with an MCP option |
|---|---|---|---|
editor_status | Yes | Yes | No |
editor_connect | Yes | No | No |
editor_disconnect | Yes | No | No |
editor_inspect | Yes | Yes | No |
editor_presence | Yes | Yes | No |
editor_edit | Yes | Yes | No |
editor_history | Yes | Yes | No |
editor_export | Yes | Yes | No |
editor_check | No | Yes | No |
editor_control | No | Yes | No |
project_status | No | Yes | No |
project_control | No | Yes | No |
game_status | No | Yes | Yes |
server_status | No | Yes | No |
console_execute | No | Yes | Yes |
console_output | No | Yes | Yes |
ui_input | No | Yes | Yes |
In the game, the editor tools that read or change the map work only while the editor is open.
Rules that apply to all map tools
- Positions are in map units. X and Y run from −524,288 to 524,288.
- Z grows downward. One height unit is 256.
- Angles run from 0 to 2047.
- Sectors, walls and sprites are numbered from 0. A number is called an index.
- The map has a revision number that rises with every change. An edit must name the current revision. If the map changed in the meantime, the edit is refused and the assistant must read the map again.
- Adding or deleting sectors, walls or sprites can change the indexes of other objects. Read the map again after such an edit.
Editor tools
editor_status
Reads the state of the session and who is in it. No arguments.
| Field in the answer | Meaning |
|---|---|
state | With the adapter: offline, connecting, joined or hosting. In the game: closed, editing or playtest. |
revision | The current revision of the map |
slot | This participant’s place in the session |
tile_limit | Tile numbers must be below this value |
players | One entry for each participant: slot, name, ai, activity, and if present selection and cursor |
notice | Adapter only. A message from the session, such as the reason for a refusal. |
In the game, the answer also has session, name, path, view (plan,
3D or section), dirty, busy, can_undo and can_redo.
editor_connect
Adapter only. Joins a session, or joins again after a disconnect.
| Argument | Meaning |
|---|---|
address | Optional. Host address. The default is the address the adapter was started with. |
name | Optional. Name to show. The default is the name the adapter was started with. |
editor_disconnect
Adapter only. Leaves the session. The adapter keeps running. No arguments.
editor_inspect
Reads a summary of the map, or a range of its records.
| Argument | Meaning |
|---|---|
kind | map for the summary only, or sectors, walls or sprites. The default is map. |
index | First record to read. The default is 0. |
count | How many records to read, from 1 to 80. The default is 32. |
Every answer holds revision, sector_count, wall_count, sprite_count
and start (the player start with x, y, z, angle and sector).
A record holds the property names listed under Properties for set, and these read-only fields:
| Record | Read-only fields |
|---|---|
| Sector | index, first_wall, wall_count |
| Wall | index, x, y, point2 (the next wall of the outline), next_wall and next_sector (the other side of a portal, or −1), sector |
| Sprite | index, x, y, sector |
editor_presence
Moves the assistant’s visible pointer and selects an object, so that people can follow what it is doing.
| Argument | Meaning |
|---|---|
x, y | Where to point. Give both. |
kind | What to select: none, sector, wall, vertex, sprite or start |
index | The index of that object. Not needed for none and start. |
clear | true removes the pointer and the selection |
editor_edit
Makes one change to the map. See Edit operations.
| Argument | Meaning |
|---|---|
revision | Required. The revision the assistant last read. |
operation | Required. One of the operations below. |
label | Optional. A short text for the change history, up to 64 characters. |
| other | The arguments of the chosen operation |
After a successful edit, the assistant’s pointer and selection move to the
object it changed. The answer is the same as for editor_status.
editor_history
Reads the most recent changes.
| Argument | Meaning |
|---|---|
count | How many changes to read, from 1 to 24. The default is 8. |
Each change has revision, author, slot, label, ai,
structure_changed, and the lists touched and removed with the kind and
index of each object. The lists show up to 80 objects each. touched_count
and removed_count give the full numbers.
editor_export
Saves the current map as a classic version 7 .map file. The file is written
on the machine where the adapter or the game runs.
| Argument | Meaning |
|---|---|
path | Required. Must end in .map. Use a full path. |
overwrite | true to replace an existing file. The default is false. |
With the adapter, this saves the adapter’s own copy. It does not save the map in the host’s editor.
editor_check
Game only. Runs the map check on the local map.
| Argument | Meaning |
|---|---|
index | First finding to read. The default is 0. |
count | How many findings to read, from 1 to 80. The default is 40. |
The answer has finding_count and a list findings. Each finding has kind,
index and message.
editor_control
Game only. Controls the editor window. The answer is the same as for
editor_status.
| Action | What it does | Arguments |
|---|---|---|
enter | Opens the editor from the title menu | |
new | Starts a new map | discard |
open | Opens a map | path (required), target, discard |
save | Saves the map | path, overwrite |
undo, redo | Takes back or repeats the last change | |
playtest | Starts a playtest | none, or spawn, or x, y, sector with optional angle and platform |
stop_playtest | Returns from the playtest to the editor | |
close | Leaves the editor and returns to the title menu | discard |
plan, perspective, section | Switches to the Plan, 3D or Section view | |
frame | Brings the selection into view | |
host | Hosts a live session | port, name |
join | Joins a live session | address (required), name, discard |
leave | Leaves the live session | |
build_tools | Opens the classic Build tools on the map | port |
| Argument | Meaning |
|---|---|
path | A map file. For open it can also be the file name of a level in the game data. For save, leave it out to save to the current file. |
target | For open: the game the map is for. One of inherit, duke13, duke_atomic, nam, napalm, ww2gi, standalone. |
discard | true allows the action to throw away unsaved changes. Without it, the action is refused while the map is unsaved. |
overwrite | For save: true allows replacing another existing file. |
spawn | For playtest: the index of a player start sprite to start from |
x, y, sector | For playtest: a temporary start position. Give all three. |
angle | For playtest: the direction to face, from 0 to 2047 |
platform | For playtest: the index of a catwalk sprite to stand on at that position |
port | For host: the UDP port, 23514 if left out. For build_tools: a TCP port on which the classic tools offer their own MCP endpoint. |
name | For host and join: the name to show |
address | For join: the host’s address |
Project tools
project_status
Game only. Reads the open project and the settings of the current map.
| Argument | Meaning |
|---|---|
index | First asset to list. The default is 0. |
count | How many assets to list, from 1 to 80. The default is 40. |
| Field in the answer | Meaning |
|---|---|
root | The project folder. Empty when no project is open. |
name, entry, target, modern | The project settings |
requires_vibebuild32 | true when Modern Mode is in effect |
compatibility_warning | The Modern Mode warning text, when it applies |
map | The current map’s target, effective_target, modern (−1 inherit, 0 off, 1 on), effective_modern and scripts |
asset_count | Number of files and folders in the project |
assets | For each listed asset: path, directory, target, icon, and type (folder, map, script, prefab or file) |
project_control
Game only. Manages the project. The editor must be open. The answer is the
same as for project_status.
| Action | What it does | Arguments |
|---|---|---|
create | Creates a project folder and opens it | path (required), name, target, modern |
open | Opens a project folder | path (required) |
close | Closes the project | |
import_zip | Unpacks a project ZIP into a new folder and opens it | path (the ZIP), destination (the new folder) |
export_zip | Writes the project to a ZIP | path (required), overwrite |
add_asset | Copies a file into the project | path (the file), destination, overwrite |
settings | Changes the project settings | name, target, modern, entry |
map_settings | Changes the settings of the current map | target, modern |
attach | Attaches a script component to an object | kind, index, script |
detach | Removes a script component from an object | kind, index, script |
export_map | Writes the current map as a plain classic map | path (required), target, overwrite |
create_component | Creates a starter script and attaches it | path (the new script), kind, index |
save_prefab | Saves sprites as a prefab | path (required), sprites, overwrite |
place_prefab | Places a prefab in the map | path (required), x, y, sector, floor_z |
| Argument | Meaning |
|---|---|
path | A file or folder. For create_component, save_prefab and place_prefab it is a path inside the project. |
destination | For import_zip: the new folder. For add_asset: the path inside the project. If left out, the file keeps its name at the top of the project. |
name | The project’s name |
entry | For settings: the entry map, as a path inside the project. An empty text clears it. |
target | A game target: duke13, duke_atomic, nam, napalm, ww2gi, standalone, or inherit for a map |
modern | on or off. For map_settings also inherit. |
kind | sector, wall or sprite |
index | The index of that object |
script | Path of the script inside the project |
sprites | For save_prefab: a list of sprite indexes |
x, y | For place_prefab: where to place it |
sector | For place_prefab: optional. The sector to prefer at that spot. |
floor_z | For place_prefab: optional. The Z of the floor level to place on. |
overwrite | true allows replacing an existing file |
Script components and prefabs need Modern Mode. See Modern Mode.
Game and server tools
game_status
Reads what the program is doing. No arguments.
| Field in the answer | Meaning |
|---|---|
mode | menu, game, editor, playtest or build_tools |
menu | true while a menu is open |
headless | true when the program runs without a window |
width, height | Size of the picture in pixels |
episode, level, level_name, user_map | The level being played |
player | The local player’s x, y, z, angle, sector and health |
The last two rows are present only during a game.
server_status
Reads the multiplayer state. No arguments. The answer has everything from
game_status, and:
| Field in the answer | Meaning |
|---|---|
role | offline, host, client or dedicated |
local_slot | This machine’s player number |
port | The network port |
slots | Number of player slots |
late_join, asynchronous, changing_map | Server settings and state |
players | For each connected player: slot, name, host, spectator and bot |
console_execute
Runs one line in the game console. Server commands use the same console.
| Argument | Meaning |
|---|---|
command | Required. One line of up to 4,096 characters. |
The answer holds the console text that the command produced, in the same form
as console_output.
Useful commands: listsymbols lists every command, and help NAME explains
one. On a server, listplayers, changemap, mapcycle and kick manage
the match.
console_output
Reads recent console text.
| Argument | Meaning |
|---|---|
after | Optional. A cursor value from an earlier answer. Only newer lines are returned. |
limit | How many lines to read, from 1 to 80. The default is 32. |
The answer has lines, cursor (pass it as after next time) and latest.
The program keeps the last 256 lines.
ui_input
Sends keyboard, mouse or text input to the game window, as if a person had made it. The game’s window must have the keyboard focus.
| Argument | Meaning |
|---|---|
events | Required. A list of 1 to 32 events. |
Event type | Other fields |
|---|---|
key_down, key_up | key: an SDL key name such as F5, Return, Escape or Left Shift |
text | text: up to 31 characters to type |
move | x, y: pointer position in the window. Optional dx, dy: relative movement. |
button_down, button_up | button: left, middle or right. x, y: pointer position. |
wheel | dy: wheel steps, from −32 to 32 |
Send a key or button release in a later call than the press, so that the game has time to see the key held down.
Edit operations
These are the values of operation for editor_edit.
| Operation | Arguments | What it does |
|---|---|---|
room | points: a list of at least three [x, y] pairs | Adds a sector with that outline. An edge with the same two end points as an existing solid wall becomes a portal. |
extend | index: a solid wall. Optional depth, from 128 to 32768. The default is 1536. | Adds a rectangular room behind the wall |
split | index: a wall | Adds a vertex at the middle of the wall |
move_vertex | index: the wall that starts at the vertex. x, y. | Moves the vertex, together with the corners joined to it |
sprite | tile, x, y. Optional sector to prefer. | Places a sprite on the floor |
move_sprite | index: a sprite. x, y. | Moves the sprite. It keeps its height above the floor. |
start | x, y. Optional sector and angle. | Sets the player start |
set | kind: sector, wall, sprite or start. index (not for start). properties: names and whole numbers. | Sets properties |
delete | kind: sector or sprite. index. | Deletes the object |
batch | edits: a list of 1 to 64 operations | Applies several operations as one change |
Batch edits
Use batch for changes that belong together, such as a room with its
furniture.
{
"revision": 12,
"operation": "batch",
"label": "Add storage room",
"edits": [
{ "operation": "extend", "index": 1, "depth": 1024 },
{ "operation": "sprite", "tile": 28, "x": 2560, "y": 0 }
]
}
On a new map, this adds a room behind the right-hand wall of the starter room
and places a shotgun in it. Replace 12 with the revision from your last
read.
- Each entry of
editsuses the arguments of its own operation. Entries do not carry arevision. - The entries run in order. An index in a later entry refers to the map as it is after the earlier entries.
- If any entry fails, the whole batch is dropped and nothing changes. The message names the entry that failed.
- A successful batch is one revision and one undo step.
- A batch is never merged with other people’s edits. If the map changed since the given revision, the batch is refused.
Properties for set
set changes the listed properties and leaves the others alone. Every name
must be one of those below and every value must be a whole number in range.
Otherwise nothing is changed.
| Kind | Property names |
|---|---|
sector | floor_z, ceiling_z, floor_tile, ceiling_tile, floor_flags, ceiling_flags, floor_slope, ceiling_slope, floor_shade, ceiling_shade, floor_palette, ceiling_palette, floor_pan_x, floor_pan_y, ceiling_pan_x, ceiling_pan_y, visibility, lotag, hitag, extra |
wall | tile, overlay_tile, flags, shade, palette, repeat_x, repeat_y, pan_x, pan_y, lotag, hitag, extra |
sprite | z, tile, flags, angle, shade, palette, repeat_x, repeat_y, offset_x, offset_y, clip_distance, status, lotag, hitag, extra |
start | angle, z |
For example, this darkens the floor of sector 2:
{
"revision": 13,
"operation": "set",
"kind": "sector",
"index": 2,
"properties": { "floor_shade": 16 }
}
The positions of walls and sprites are not properties. Use move_vertex,
move_sprite and start to change them.
A good working order for an assistant
- Call
editor_statusto check the connection and see who else is there. - Call
editor_inspectwithkindset tomap, then read the sectors and walls of the area to work on. - Call
editor_presenceto point at that area, so people can see where the assistant is about to work. - Call
editor_editwith the latestrevision. - If the edit is refused, read the map again before trying again.
- Read the changed records to confirm the result. In the game, run
editor_checkand try the map witheditor_controland the actionplaytest. - Call
editor_presencewithclearset totruewhen the work is done.
Classic Build tools
NNBuild also contains the original-style Build editor, with the Mapster32 tools for Duke Nukem 3D maps. The program calls it the native Build tools. It has its own 2D and 3D modes and is driven mostly from the keyboard.
The modern editor is meant for everyday work. The classic tools are there for the jobs it does not cover. A map can move from the modern editor to the classic tools and back.
When to use the classic tools
- For operations the modern editor does not have, such as splitting and joining sectors, extra wall loops, detailed wall alignment, sprite ornamenting, and Mapster32 scripts.
- To repair a map that the map check reports as damaged.
- When you already know Build or Mapster32 and prefer its keys.
The classic tools are part of builds that use SDL2 on Windows, Linux, macOS and BSD. In other builds the menu entry is missing.
Open the classic tools from the modern editor
- Choose File → Open Build tools.
- The classic editor opens in its own window. It holds a copy of your map as it is now, including unsaved changes.
- Do your work there.
- Save the map in the classic editor.
- Close the classic editor.
Back in the modern editor, the status line says “Applied edits from the native Build tools”. The whole visit is one undo step.
Good to know:
- While the classic tools are open, the status line of the modern editor reminds you: “Save the map and exit the native Build tools to apply your edits.”
- File → Open Build tools is greyed out until you close the classic editor.
- If you close the classic editor without saving, nothing changes.
- Be in the modern editor, not in a playtest, at the moment you close the classic editor. Otherwise the result is not applied. See When the result is not applied.
How the map moves between the two
The modern editor writes your map to a temporary file and starts the classic editor on that file. When the classic editor closes, the modern editor reads the file again.
The modern editor reads classic version 7 maps only. Keep the map within the map limits while you work in the classic tools, and do not use features that need a newer map format.
What happens next depends on whether the modern map changed while the classic tools were open.
| Modern map since you opened the classic tools | Result |
|---|---|
| Not changed | The classic result replaces the map. |
| Changed, and both sides only changed properties or positions of existing objects | The two sets of changes are merged, object by object. |
| Changed, and either side added or removed sectors, walls or sprites | Not applied |
| Changed, and both sides changed the same object in different ways | Not applied |
In practice: if you plan to add, join or delete anything in the classic tools, leave the modern editor alone until you are back.
When the result is not applied
Your classic work is not lost. The status line shows where the file is:
The native draft is available at /tmp/.vibemap-AbC123/draft.map
The path on your machine will differ. You can open that file with File → Open map… and save it under a name of your own.
In a live session
During a live session, the classic tools work on your own copy of the shared map. The other participants keep editing.
- When you come back, your result is sent to the session as one edit.
- Edits that the others made in the meantime have changed the modern map. The table above applies. Changes to different objects merge. If something conflicts, the status line gives the path of your saved classic draft.
- For work that adds, joins or deletes things, agree with the others that they wait until you are back.
Open the classic tools from the command line
Use --build-editor, with a map file if you like. This opens the classic
tools directly, without the modern editor.
./vibebuild32 --build-editor "My Map.map"
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --build-editor "My Map.map"
To continue in the modern editor later, save the map as a classic version 7 map and open it there:
./vibebuild32 -gamegrp /path/to/DUKE3D.GRP --editor "My Map.map"
A build without the classic tools answers --build-editor with “This build
has no native Build tools.”
Control by an AI assistant
The classic tools can be driven through MCP. See AI and MCP.
- Start them with
--build-editorand--mcp-http PORTor--mcp-stdio. The toolsgame_status,console_execute,console_outputandui_inputare available.game_statusreports the modebuild_tools. - From the modern editor, the tool
editor_controlwith the actionbuild_toolsopens the classic tools. Give it aportto make the classic editor offer its own MCP address on that TCP port. Choose a port that the game itself does not use. - The console command
saveboardsaves the map in the classic editor. An assistant sends it withconsole_executebefore closing the classic editor.
Modding overview
NNBuild can be modded in four ways. You can combine them.
The executable is called
vibebuild32. Older texts and some messages call the program “VibeBuild32”. It is the same program.
Kinds of mods
| Kind | What it is | Use it when |
|---|---|---|
| Script mod | .js or .ts files run by the built-in QuickJS JavaScript engine. | You want new game logic, HUD text, file or network access, without editing the game’s own script files. |
| Classic mod | CON scripts, GRP/ZIP/PK3 archives, DEF files and user maps, loaded the way EDuke32 loads them. | You play an existing mod, or you already write CON. |
| Editor project | A folder or ZIP made with the map editor: maps, art, sounds and optional scripts attached to map objects. A stand-alone project also ships its own game data. | You build levels, or a complete small game. |
| Server script | A script mod that runs on a multiplayer host or dedicated server. | You run a server and want chat commands, announcements or automatic map changes. |
Script mods (JavaScript and TypeScript)
A script mod is a folder with an index.ts or index.js file. The game loads it at startup. Node.js is not needed to run it: TypeScript files are converted by the game itself.
Scripts talk to the game through the vb module. They can also use a small set of Node-style modules (fs, dgram, net), fetch, and timers.
- Quick start: create and run your first mod.
- Project layout: how scripts are found, how
importworks, what TypeScript is supported. - API reference: every function of the
vbmodule. - Events: every event you can listen to.
- Components: class-based components for sprites and nodes.
- Built-in modules:
fs,dgram,net,cvar,fetch, timers. - TypeScript examples: short complete mods.
- Debugging with VS Code: breakpoints, DevTools, error reports.
Classic CON, GRP and ZIP mods
Classic mods keep working. Pass the files on the command line:
./vibebuild32 mymod.grp MYGAME.CON
./vibebuild32 --grp mymod.zip --con MYGAME.CON
A bare file name ending in .grp, .zip, .pk3, .con, .def, .map or .rts is loaded as that kind of file. See Launch options for the full list.
A script mod can work together with a classic mod. It can read and write CON gamevars and listen to CON events. See Events and API reference.
Editor projects and stand-alone games
The map editor stores a project as a folder with a vibebuild.project.json file. A project can be played, edited, or exported as a ZIP. See Projects and stand-alone games.
A project with Modern Mode turned on can attach scripts to sprites, sectors and walls. These scripts use a different, simpler model than normal script mods. See Map script components.
Server scripts
Any script mod can run on a multiplayer host or on a headless dedicated server. On a server a script can also register !commands that players type into chat. See Server scripts.
Which games run scripts
| Game | Script support |
|---|---|
| Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM, WWII GI | Full. These games share the Duke runtime. Every API in this section works. |
| Shadow Warrior | Core only. Scripts load and receive start, frame and shutdown. log, timers, fs, dgram, net and fetch work. Functions that read or change game state throw an error. |
| Blood, Redneck Rampage, Exhumed | Scripts are not loaded. |
Pages in this section mark an API as Duke runtime when it only works in the first group.
Words used in this section
- Tile: a numbered picture in the game’s art files. Every kind of object is identified by its tile number.
- Sprite: an object in the map, such as an enemy, an item, a projectile or a player. A sprite has an index number. The number is reused after the sprite is removed.
- Actor: a sprite that runs game logic.
- Sector: an area of the map with a floor and a ceiling. A wall is one edge of a sector.
- CON: the game’s original scripting language (
GAME.CONand related files). - CON event: a hook named
EVENT_…that the engine calls at a fixed point, for exampleEVENT_JUMP. - Gamevar: a named integer variable of the CON system. It can be global, per player or per actor.
- Console: the in-game command line. A script can run console commands.
Things to know before you start
- Scripts are loaded once, when the game starts. Restart the game to load a changed script.
- An error that your script does not catch closes the game and shows the error text. See how errors are reported.
- A script runs only on the computer that loaded it. In multiplayer, a change that only one computer makes to the game world breaks synchronization. See Server scripts.
Quick start
This page creates a script mod with the built-in generator, runs it, and explains the edit-run loop.
1. Generate a project
Open a terminal in the folder you start the game from. Run one of these:
./vibebuild32 --gen-ts my-mod # TypeScript starter
./vibebuild32 --gen-js my-mod # JavaScript starter
Short forms: -gts my-mod and -gjs my-mod. The name can also be attached with =, for example --gen-ts=my-mod.
The program creates the project, prints its location, and exits. No game window opens.
Created TypeScript project: /home/me/games/autojs/my-mod
Rules for the name:
- Only letters, digits,
-and_are allowed. - If you leave the name out, the generator picks the first free name
mod-1,mod-2, … - An existing folder is never overwritten. If
autojs/my-modalready exists, the generator stops withCould not create JavaScript project.
The project is always created in autojs/<name>/ inside the folder you ran the command from.
2. What the generator creates
autojs/
└── my-mod/
├── index.ts the entry point; the only file the game loads by itself
├── vb.d.ts type declarations for your editor
├── tsconfig.json settings for your editor and for tsc
├── package.json optional type check: npm run check
└── .vscode/
├── launch.json
├── tasks.json
├── README.md
├── vibebuild32-debug-adapter.js
└── vibebuild32-start-debug-adapter.js
With --gen-js you get index.js and jsconfig.json instead of index.ts and tsconfig.json. Everything else is the same.
The .vscode files are explained in Debugging with VS Code. The other files are explained in Project layout.
The TypeScript starter
index.ts:
// VibeBuild32 auto-loads only index.ts (or index.js) from this project.
// Optional debug-only launch args, for example:
// /// vbd.params="-gm duke -g ~/games/duke3da/duke3d.grp -sc"
import { on, log } from 'vb';
let frames = 0;
on('start', () => {
log('TypeScript mod loaded.');
});
on('frame', () => {
const breakpointProbe = `TypeScript frame ${++frames}`;
if (frames % 60 === 0) log(breakpointProbe);
});
tsconfig.json:
{
"compilerOptions": {
"target": "ES2020", "lib": ["ES2020"], "module": "ESNext",
"moduleResolution": "Bundler", "allowImportingTsExtensions": true, "strict": true,
"noEmit": true, "skipLibCheck": true
},
"include": ["*.ts", "vb.d.ts"]
}
package.json:
{
"name": "vbjs-mod",
"private": true,
"version": "0.1.0",
"description": "VibeBuild32 auto-loaded JavaScript mod",
"types": "./vb.d.ts",
"scripts": { "check": "tsc --noEmit -p tsconfig.json" },
"devDependencies": { "typescript": "^5.0.0" }
}
The JavaScript starter
index.js:
// VibeBuild32 auto-loads only index.js (or index.ts) from this project.
// Optional debug-only launch args, for example:
// /// vbd.params="-gm duke -g ~/games/duke3da/duke3d.grp -sc"
// @ts-check
/** @type {typeof import('vb').default} */
const vb = require('vb');
let frames = 0;
vb.on('start', () => {
vb.log('JavaScript mod loaded.');
});
vb.on('frame', () => {
const breakpointProbe = `JavaScript frame ${++frames}`;
if (frames % 60 === 0) vb.log(breakpointProbe);
});
jsconfig.json:
{
"compilerOptions": { "target": "ES2020", "lib": ["ES2020"], "checkJs": true, "allowJs": true, "noEmit": true, "strict": true },
"include": ["*.js", "vb.d.ts"]
}
The JavaScript package.json is the same as the TypeScript one, except that the check script is tsc --noEmit -p jsconfig.json.
What the starter does:
startruns once, after the script has been loaded. The starter writes one line to the log.frameruns on every drawn frame. The starter writes a line every 60 frames.- The third comment line shows the optional
vbd.paramsdirective. It is inactive as generated, because it starts with// ///. See Debugging with VS Code.
3. How the game finds and loads it
You do not register the mod anywhere. At startup the game looks for a folder named autojs in the folder you started it from. For every sub-folder it loads index.ts. If there is no index.ts, it loads index.js.
Scripts are not loaded at the very first instant. The game loads them during its first frames, on the title screen or in the level you launched into. Then it fires start.
More ways to load scripts are listed in Project layout.
4. Run it
Start the game from the same folder, the one that contains autojs/:
./vibebuild32 --game duke --grp /path/to/duke3d.grp
The game log shows these lines. The log is the file vibebuild32.log and the in-game console.
[js] loaded /home/me/games/autojs/my-mod/index.ts
[js] TypeScript mod loaded.
[js] TypeScript frame 60
[js] TypeScript frame 120
Scripts run fully in the Duke runtime games and partly in Shadow Warrior. See Which games run scripts.
5. The edit-run loop
- Edit
index.tsorindex.jsin any editor. - Start the game again. Scripts are read once per launch. There is no reload while the game runs.
- Read the log. Use
log()orconsole.log()to print values.
If a script has a syntax error or throws an error that nothing catches, the game shows the error text in a dialog and closes. Fix the script and start again. See how errors are reported.
Try a first change. Replace the start handler with this and restart:
import { on, log, drawText } from 'vb';
on('start', () => {
log('TypeScript mod loaded.');
drawText(1, 8, 8, 'My first mod');
});
My first mod now stays in the top-left corner of the screen.
6. Optional: check types with Node.js
The game does not check types. It only removes them. To get real type errors, install Node.js and run this inside the project folder:
npm install
npm run check
This runs the TypeScript compiler without producing files. Your editor shows the same errors if it understands tsconfig.json.
Two things to keep in mind:
- The game’s own TypeScript support is limited. Code that passes
npm run checkcan still fail in the game. Read TypeScript support and its limits before you write much TypeScript. - The generated
vb.d.tsdiffers from the game in a few details. See the list.
Without the generator
The generator is a convenience. A mod is only a folder with an entry file:
autojs/hello/index.js
vb.on('start', () => vb.log('hello'));
You can also load one file directly with --js:
./vibebuild32 --js ./hello.js
Project layout
This page explains how the game finds scripts, how import and require find other files, which TypeScript the game understands, and what the generated configuration files are for.
How a script gets loaded
| Way | Example | Notes |
|---|---|---|
| Auto-loaded project | autojs/my-mod/index.ts | Loaded at every start. No option needed. |
--js <file> | ./vibebuild32 --js mods/test.js | Short form -js. Can be given several times. --js=<file> also works. |
| Bare path | ./vibebuild32 ./server.ts | A command-line word that does not start with - and ends in .js, .ts, .mjs, .mts, .cjs or .cts. Duke runtime only; use --js for Shadow Warrior. |
| Script attached to a map object | Scripts/Station.js in an editor project | A different model with its own hooks. See Map script components. |
Auto-loaded projects
At startup the game scans the folder autojs. It looks exactly one level deep:
autojs/<name>/index.tsis loaded if it exists.- Otherwise
autojs/<name>/index.jsis loaded. - If both exist, only
index.tsis loaded. - Folders whose name starts with
.are skipped. - Files directly inside
autojs/, and files in deeper folders, are not loaded by themselves. Your entry file mustimportthem.
The game scans autojs in two places:
- The folder you started the program from.
- The folder the game runs in, if it is a different one. The game switches to the folder of the game data it selected. A stand-alone editor project runs inside its own project folder.
The second scan is skipped when you play an editor project from a ZIP file and did not pass --allow-project-scripts.
Files given on the command line
A relative --js path is resolved against the folder you started the program from.
After a -net option, a bare path is only treated as a script if the file exists. Put script paths before -net, or use --js.
Load order and limits
- Scripts from
--jsand bare paths are loaded first, in command-line order. Auto-loaded projects follow, in the order the operating system lists the folders. Do not rely on the order between two auto-loaded mods. - A file is loaded only once, even if it is named twice.
- At most 64 entry scripts are loaded.
- All scripts run in one JavaScript runtime. They share the global object, the
vbevent handlers and the HUD text ids. Each entry file is its own module, so top-levelconstandletnames do not collide. - Scripts are loaded once per launch. There is no hot reload.
Scripts in an editor project
An editor project can contain scripts in two forms:
- Script components attached to sprites, sectors and walls. They are listed in the map’s settings file (
<map>.vbmap.json) and need Modern Mode. See Map script components. - An
autojs/folder inside a stand-alone project. It is scanned as described above.
When the project is a folder, both forms run without extra options. When the project is a ZIP, scripts are treated as untrusted and do not run unless you pass --allow-project-scripts:
./vibebuild32 --allow-project-scripts --project "/path/to/My Project.zip"
Only pass this option for projects you trust. A script can read and write files and open network connections.
Entry files are ES modules
Every entry file is loaded as an ES module. This applies to all extensions, including .cjs.
importandexportwork.- The code runs in strict mode.
- These globals exist without an import:
vb,cvar,console,fetch,require,setTimeout,setInterval,clearTimeout,clearInterval. fs,dgramandnetare not globals. Import or require them.
Module resolution
Built-in modules
These names always refer to built-in modules:
vb, cvar, fs, node:fs, fs/promises, node:fs/promises, dgram, node:dgram, net, node:net
Each has named exports and a default export:
import { on, log } from 'vb'; // named
import vb from 'vb'; // default: one object with everything
import fs from 'fs';
See API reference and Built-in modules.
import of your own files
import { clamp } from './util.ts';
import { table } from '../shared/table.js';
- A path is resolved against the folder of the file that contains the
import. - Write the complete file name with its extension. The game does not try
.js,.tsorindexfiles for you. - A name that is not a built-in module is always treated as a file path. There is no
node_moduleslookup.import x from 'lodash'looks for a file namedlodashnext to your script. - Absolute paths work.
- Files ending in
.ts,.mtsor.ctsare converted from TypeScript. All other files are read as JavaScript. - A module is identified by its path text. Import a file with the same spelling everywhere, or it is loaded twice.
require
require is a global function.
const vb = require('vb');
const fs = require('fs');
const util = require('./util.js');
- For built-in names it returns an object with the module’s functions.
- For files it works like CommonJS: the file gets
exports,moduleandrequire, andrequirereturnsmodule.exports. The result is cached per path. - Write the complete file name with its extension.
- A relative path is resolved against the folder of the entry script that was loaded last. It is not resolved against the file that calls
require.
Because of the last rule:
- Call
requirefor your own files only at the top level of your entry file, while it is being loaded. Arequirethat runs later, for example inside an event handler, can look in another mod’s folder. - A file loaded with
requirecannot reliablyrequirefiles from its own sub-folder. - In map script components, use
import.
Prefer import for your own files. It does not have these problems.
TypeScript support and its limits
The game does not contain the TypeScript compiler. A small built-in converter removes type syntax and passes the rest to the JavaScript engine. It does not check types and it does not understand all of TypeScript.
The converter works on text patterns. Some valid TypeScript is converted wrongly. Read this section before you write a larger mod in TypeScript. If you want no surprises, write JavaScript with // @ts-check and JSDoc types, as the JavaScript starter does.
What is handled
| Feature | Example |
|---|---|
Type annotations on variables at the top level, in function bodies, in class bodies and methods, and in if/for/while blocks | const n: number = 1; |
| Parameter types, optional parameters, rest parameters, destructured parameters | (e: ActorEvent, n?: number, ...rest: string[]) |
| Return types | function f(): void {}, (x: number): number => x * 2 |
interface declarations | interface P { x: number; y: number } |
Simple type aliases | type Id = number | string; |
import type … on one line, and export type … on one line with no ; before its end | import type { ActorEvent } from 'vb'; |
as casts, as const, non-null ! after a name, ) or ] | value as string, list[0]!.name |
public, private, protected, readonly, override on class members, and abstract class | private readonly max = 3; |
| Class fields with types, optional fields | count: number = 0; hp?: number; |
Type arguments on calls and new, generic function declarations | new Map<string, number>(), function id<T>(v: T): T |
enum with number or string members, also export enum | enum Color { Red, Green = 5 } |
catch (e: unknown) |
An enum becomes a plain object: enum Color { Red, Green = 5 } becomes const Color = { Red:0, Green:5 }. There is no reverse lookup from number to name.
What is not handled
These produce a syntax error when the game loads the file, unless noted.
| Not supported | Use instead |
|---|---|
A type annotation on const or let directly inside an arrow function body: () => { const n: number = 1; } | Leave the annotation out, use a cast, or use a function. Annotations in the parameter list and in nested blocks are fine. |
switch statements: the : after case x and default is taken for a type. Statement labels have the same problem. | if / else if |
import * as name from … | A default import: import vb from 'vb'; |
import { type X, y } | A separate import type { X } line |
export interface …, and export type … that spans lines or contains ; | Do not export types. Keep them in the file that uses them, or in a .d.ts file. |
A type alias whose object type contains a function type followed by more members | An interface, or method syntax: reply(text: string): void |
const enum | enum |
declare … statements | A .d.ts file |
Function overload signatures, abstract methods | One implementation |
implements, generic classes (class Box<T>), generic arrow functions (<T>(x: T) => x) | Plain classes and function declarations |
satisfies, casts written <T>value, namespace, decorators, JSX | |
Constructor parameter properties: constructor(private x: number). No error, but the field is not created. | Declare the field and assign it in the constructor. |
TypeScript keywords used as variable names, property names or object keys: interface, enum, public, private, protected, readonly, abstract, declare, override. For example { public: true }. | Other names. |
The name type directly followed by another word, for example for (const type of list). { type: 'x' } and e.type === 'x' are fine. | Another name, such as kind. |
Code that is converted wrongly without an error
These are the dangerous cases. The file loads, but it does something else than you wrote.
| You write | The game runs | Write this instead |
|---|---|---|
return !ok; | return ok; | return (!ok); |
return { a: 1, b: 2 }; | return { a, b }; | return ({ a: 1, b: 2 }); |
const { a: b } = obj; | const { a } = obj; | const b = obj.a; |
import { on as listen } from 'vb'; | import { on } from 'vb'; | Import on and use that name. |
/^(\w+):(.*)$/ | /^(\w+)$/ | new RegExp('^(\\w+):(.*)$') |
a < b && c > (d) | a (d) | c > (d) && a < b, or leave out the parentheses after > |
The first rule covers every ! that directly follows a keyword such as return, typeof, case, throw or await. Wrap the expression in parentheses.
The second and third rules exist because the converter decides from the previous word whether { starts an object or a block. After =, (, ,, : and ? it is an object. After a keyword or a name it is a block, and key: value inside is taken for a type annotation.
Rules that keep you safe
- End every statement with
;. - Never start a
returnvalue with!or{. Wrap it in(). - Do not annotate local variables inside arrow function bodies.
- Use
if/else if, notswitch. - Rename in two steps instead of with
asorkey: namepatterns. - Keep types simple and on one line where you can.
- Use default imports for modules:
import fs from 'fs';.
Line numbers
The converter keeps the line structure of your code, so line numbers in error messages and breakpoints match your source. There is one exception. An interface, a type alias or a type annotation that spans several lines is removed together with its line breaks. Every line after it is then reported with a lower number. Keep types on one line, or put multi-line declarations at the end of the file, or in a .d.ts file.
The configuration files
None of these files is read by the game. They exist for your editor and for the optional type check.
| File | Role |
|---|---|
vb.d.ts | Type declarations for the vb module, the built-in modules, the globals, and map script components. Your editor uses it for completion and type errors. |
tsconfig.json | TypeScript projects. Tells the editor and tsc to check *.ts and vb.d.ts, to target ES2020, and to produce no output (noEmit). allowImportingTsExtensions lets you write import './util.ts', which the game requires. |
jsconfig.json | JavaScript projects. Turns on type checking of .js files (checkJs) against vb.d.ts. |
package.json | Lets you run npm install and npm run check. Only needed for the type check. |
.vscode/ | Debugger setup. See Debugging with VS Code. |
Both configuration files only include files in the project folder itself (*.ts or *.js). If you put code in sub-folders, add them to include.
Where vb.d.ts differs from the game
vb.d.ts is written by the generator. It is a copy of a text stored in the game. It declares the vb module, the built-in modules, fetch, the timers, and the types for map script components (MapComponentContext and MapComponentModule).
In a few details the declarations do not match what the game does:
vb.d.ts says | The game does |
|---|---|
| 112 CON event names are known. | All 165 names work. For the other 53 the type check gives the handler an untyped argument. See Events. |
VBNode.activeSelf is read-only. | It can be assigned. Assigning it is the same as calling SetActive. In TypeScript call SetActive. |
new VBPrefab() takes no arguments. | new VBPrefab(tile, ...components) works. Use createPrefab, which is declared correctly. |
getSector, setSector, getWall, setWall and the projectile and tile data functions accept an extra parm2 argument. | The argument is ignored for these functions. Only actor, player and userdef members use it. |
require is typed for 'vb', 'fs', 'dgram', 'net' and 'cvar'. | 'fs/promises' and the node: names also work, but the type check sees their result as unknown. Use import for them. |
API reference: the vb module
The vb module is the link between a script and the game. This page lists every export, grouped by task.
Using the module
import { on, log, drawText } from 'vb'; // named imports
import vb from 'vb'; // default import: one object with everything
vb.log('hello');
const vb = require('vb'); // CommonJS style
A global object named vb with the same functions also exists, so short scripts need no import at all.
In TypeScript files use the first or second form. import * as vb from 'vb' does not work there. See TypeScript support and its limits.
The module exports functions and three classes. It exports no constants. Use define() to look up the game’s named constants, such as tile numbers.
Availability
Functions marked Duke work only in the Duke runtime games: Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM and WWII GI. In Shadow Warrior these functions exist but throw ReferenceError: This vb API is not supported by the active game.
Only on, off, log and breakpoint work in every game that runs scripts.
General rules
- Numbers are integers. Every numeric argument is converted to a 32-bit integer. Fractions are cut off. A value that is not a number becomes
0. - Unknown names give
undefined. A getter returnsundefinedwhen the member, gamevar or constant name does not exist. A setter with an unknown name does nothing. - Indices are not checked.
getActor,getSector,getWall,getPlayerand the other struct functions pass your index straight to the engine. An index that is out of range, such as-1, reads or writes memory that does not belong to the object. The game can crash. Check an index before you use it. - Too few arguments throw. Most functions throw a
TypeErrorwhen a required argument is missing. - Changes are local. A script changes the game only on the computer it runs on. See Keeping the game in sync.
Logging
| Function | Returns | Description |
|---|---|---|
log(...values) | undefined | Writes one line to the game log and console, prefixed with [js]. |
- Each value is converted to a string. The values are joined with single spaces.
- Objects print as
[object Object]. UseJSON.stringify(value)to see their content. - A line is cut off after 1023 characters.
console.log,console.info,console.warnandconsole.errorare the same function.
Events
| Function | Returns | Description |
|---|---|---|
on(name, handler) | undefined | Calls handler every time the event name fires. |
off(name) | undefined | Removes all handlers of the event name. |
nameis a string. The event names are listed in Events.handleris a function. Most events pass one event object. Some pass nothing.- You can register several handlers for one event. They run in the order you registered them.
- For CON events the
EVENT_prefix is optional and the name is not case-sensitive.on('jump', …)andon('EVENT_JUMP', …)are the same. onthrows aTypeErrorifhandleris not a function.offcannot remove a single handler. It also removes handlers that other mods and the component system registered for that event. Avoidoff('frame')andoff('actorDestroyed')if you use components.
import { on, log } from 'vb';
on('actorSpawned', (e) => {
log(`sprite ${e.sprite} spawned with tile ${e.tile}`);
});
HUD text
Duke.
| Function | Returns | Description |
|---|---|---|
drawText(id, x, y, text, pal?, shade?) | undefined | Shows a line of text on the screen, or replaces the line with the same id. |
clearText(id?) | undefined | Removes the line with this id. Without an argument it removes all lines. |
id: any integer you choose. It names the line. CallingdrawTextagain with the sameidreplaces the text.x,y: position of the text in a 320 × 200 screen.0, 0is the top-left corner.text: the string to show. At most 191 characters are kept.pal: palette number that colors the text. Default0.shade: brightness.0is normal, negative values are brighter, positive values are darker. Default0.
A line stays on screen until you clear or replace it. You do not need to draw it again every frame. Lines are shown during play and on the title and menu screens.
There are 64 lines in total, shared by all loaded scripts. When all 64 are in use, a new id is ignored. Pick ids that other mods are unlikely to use.
Spawning and actors
Duke.
| Function | Returns | Description |
|---|---|---|
spawn(tile, x?, y?, z?, owner?) | sprite index, or -1 | Creates an actor of tile tile and initializes it like a normal game actor. |
A_Spawn(spriteNum, tileNum) | sprite index | The engine’s spawn routine. Creates an actor of tile tileNum at the position of the existing sprite spriteNum, which becomes its owner. |
A_InsertSprite(whatsect, s_x, s_y, s_z, s_pn, s_s, s_xr, s_yr, s_a, s_ve, s_zv, s_ow, s_ss) | sprite index | The engine’s low-level insert. Creates a raw sprite without running actor setup. |
getActor(sprite, member, parm2?) | number, or undefined | Reads a member of a sprite. |
setActor(sprite, member, value, parm2?) | undefined | Writes a member of a sprite. |
shoot(sprite, tile) | number | Makes the sprite fire the projectile or weapon with tile tile. Returns the engine’s result, or -1 if sprite is out of range. |
getProjectile(tile, member) | number, or undefined | Reads a setting of the projectile type defined for tile. |
setProjectile(tile, member, value) | undefined | Writes a setting of the projectile type defined for tile. |
getActiveProjectile(sprite, member) | number, or undefined | Reads a setting of one flying projectile sprite. |
setActiveProjectile(sprite, member, value) | undefined | Writes a setting of one flying projectile sprite. |
getTileData(tile, member) | number, or undefined | Reads data of a tile, such as its size. |
setTileData(tile, member, value) | undefined | Writes data of a tile. |
spawn
tile: tile number. An invalid number returns-1.x,y,z: map position. If all three are0or missing, the actor appears at the local player’s position.owner: optional sprite index. Its sector is used as the starting point to find the sector ofx,y. Without it the local player’s sector is used.- Returns
-1when no sector can be found, for example when no game is running. - The new actor fires
actorSpawned.
In multiplayer do not call spawn. Use the synchronized console command instead: run('spawn <tile> <player>'). See Server scripts.
A_Spawn and A_InsertSprite
These are the engine’s own functions with their original names and argument order. They are for people who know the engine.
A_Spawn(spriteNum, tileNum): whenspriteNumis-1, the second argument is not a tile. It is the index of an existing sprite that is then set up as an actor.A_InsertSpritearguments, in order: sector, x, y, z, tile, shade, x-repeat, y-repeat, angle, velocity, z-velocity, owner sprite, status list number. All 13 are required.- If the map has no free sprite left, the game exits.
Actor members
member is the name CON uses for the field. Names are not case-sensitive. Common ones:
x, y, z, ang, sectnum, statnum, picnum (tile), cstat, shade, pal, xrepeat, yrepeat, xvel, yvel, zvel, owner, lotag, hitag, extra (health for most actors)
parm2 is an extra index that a few members need. Most members ignore it.
Tile data members: xsize, ysize, animframes, xoffset, yoffset, animspeed, animtype, gameflags.
Players
Duke.
| Function | Returns | Description |
|---|---|---|
player() | { sprite, x, y, z } | The local player’s sprite index and position. sprite is -1 and the position is 0 when there is no player. |
getPlayer(player, member, parm2?) | number, or undefined | Reads a member of a player. |
setPlayer(player, member, value, parm2?) | undefined | Writes a member of a player. |
getInput(player, member) | number, or undefined | Reads the player’s current input. |
setInput(player, member, value) | undefined | Writes the player’s current input. |
addAmmo(player, weapon, amount) | undefined | Adds ammo for weapon number weapon, up to the weapon’s maximum. |
addWeapon(player, weapon, switchTo?) | undefined | Gives the weapon. switchTo defaults to 1: the player switches to it. Pass 0 to keep the current weapon. |
playeris the player index. In a single-player game it is0.addAmmoandaddWeapondo nothing when the player index is invalid. They do not check the weapon number.- Common player members:
posx,posy,posz,ang,cursectnum,i(the player’s sprite index),curr_weapon,ammo_amount(needsparm2= weapon number),gotweapon(needsparm2= weapon number),on_ground,dead_flag,max_player_health,timebeforeexit. - Input members:
avel,q16avel,horz,q16horz,fvel,svel,bits,extbits.
import { getPlayer, player, getActor } from 'vb';
const me = player();
if (me.sprite >= 0) {
const health = getActor(me.sprite, 'extra');
const ammoOfWeapon1 = getPlayer(0, 'ammo_amount', 1);
}
Sectors and walls
Duke.
| Function | Returns | Description |
|---|---|---|
getSector(sector, member) | number, or undefined | Reads a member of a sector. |
setSector(sector, member, value) | undefined | Writes a member of a sector. |
getWall(wall, member) | number, or undefined | Reads a member of a wall. |
setWall(wall, member, value) | undefined | Writes a member of a wall. |
Common sector members: ceilingz, floorz, ceilingpicnum, floorpicnum, ceilingshade, floorshade, ceilingpal, floorpal, ceilingstat, floorstat, visibility, lotag, hitag, extra, wallptr, wallnum.
Common wall members: x, y, point2, nextwall, nextsector, cstat, picnum, overpicnum, shade, pal, xrepeat, yrepeat, xpanning, ypanning, lotag, hitag, extra.
Heights (z values) get smaller as you go up.
Gamevars and CON data
Duke.
| Function | Returns | Description |
|---|---|---|
getGamevar(name, sprite?, player?) | number, or undefined | Reads a CON gamevar. undefined if no gamevar has this name. |
setGamevar(name, value, sprite?, player?) | undefined | Writes a CON gamevar. Does nothing if no gamevar has this name. |
define(name) | number, or undefined | Returns the value of a CON constant created with define, such as a tile name. |
getUserdef(member, parm2?) | number, or undefined | Reads a member of the game’s global settings structure (userdef in CON). |
setUserdef(member, value, parm2?) | undefined | Writes a member of the game’s global settings structure. |
- Gamevar names and
definenames are case-sensitive. spriteandplayerselect which copy to use for per-actor and per-player gamevars. For global gamevars leave them out. Both default to-1.getUserdefandsetUserdeftake the member name first. They have no index argument.- Common userdef members:
god,multimode,level_number,volume_number,player_skill,eog,pause_on.
import { define, getGamevar, setGamevar, getUserdef } from 'vb';
const trooper = define('LIZTROOP'); // a tile number in Duke Nukem 3D
const gravity = getGamevar('gravitationalconstant');
setGamevar('gravitationalconstant', 88);
const players = getUserdef('multimode');
Sounds and weapons
Duke.
| Function | Returns | Description |
|---|---|---|
sound(num, sprite?) | undefined | Plays sound number num. With a valid sprite index the sound comes from that sprite. Without it the sound is not positioned. |
shoot(sprite, tile) | number | See Spawning and actors. |
addAmmo(player, weapon, amount) | undefined | See Players. |
addWeapon(player, weapon, switchTo?) | undefined | See Players. |
Sound numbers are the ones the game’s CON files define. If the CON files give a sound a name, define('<NAME>') returns its number.
Menus
Duke.
| Function | Returns | Description |
|---|---|---|
setMenuText(original, replacement) | undefined | Whenever the menu draws a string that is exactly original, it draws replacement instead. |
setMenuBackground(tile) | undefined | Uses tile tile as the full-screen picture behind the menu when no game is shown. Pass null to restore the default. |
currentMenu() | number | The id of the menu page that is current. |
openMenu(menuId) | undefined | Switches the menu system to the page menuId. |
setMenuRoute(menuId, itemIndex, destination) | undefined | Redirects a menu item to another page. |
menuSelection() | number | The index of the highlighted menu item. |
setMenuSelection(index) | undefined | Highlights the menu item with this index. |
- Menu ids are the game’s internal page numbers. Page
0is the main menu. setMenuTextaffects text drawn with the game’s large menu font. Replacements stay until the game exits.setMenuBackgroundignores tiles that do not exist. A CON handler forEVENT_GETMENUTILEcan still override your tile.setMenuRoute(menuId, itemIndex, destination): when the player is on pagemenuId, has itemitemIndexhighlighted, and the game changes page, the game goes todestinationinstead.itemIndex-1matches every item of that page that has no route of its own.destination-1keeps the current page.-2closes the menu.destinationnullremoves the route.
- Use the menu events to learn page ids: log
e.menufrom amenuChangedhandler.
Session and multiplayer
Duke.
| Function | Returns | Description |
|---|---|---|
session() | object | A snapshot of the current game session. |
The returned object is a copy. It does not change later. Call session() again for fresh values.
| Field | Type | Meaning |
|---|---|---|
started | boolean | true while a level is being played. |
skill | number | Skill level, starting at 1. |
episode | number | Episode number, starting at 1. |
level | number | Level number inside the episode, starting at 1. |
episodeName | string or undefined | Name of the episode. |
levelName | string or undefined | Name of the level. |
userMap | string or undefined | File name of the user map, when one is loaded. |
localPlayer | number | Index of the player on this computer, or -1. |
hostPlayer | number or undefined | Index of the hosting player. |
hostName | string or undefined | Name of the hosting player. |
serverAddress | string or undefined | On a client that joined through an address: that address. undefined on the host. |
players | array | One entry per player slot. |
Each entry of players:
| Field | Type | Meaning |
|---|---|---|
index | number | Player index. Use it with getPlayer, addAmmo and similar functions. |
name | string | Player name. |
sprite | number | The player’s sprite index, or -1. |
isLocal | boolean | true for the player on this computer. |
isHost | boolean | true for the hosting player. |
Chat and server commands
| Function | Returns | Description |
|---|---|---|
sendMessage(text) | undefined | Duke. Sends a chat message. |
registerCommand(name, handler) | undefined | Duke, server only. Registers a !name chat command. |
sendMessage
- On the host of a multiplayer game the message goes to every player and is shown as
Server: <text>. - Otherwise it is sent as a normal chat line from the local player:
<name>: <text>. - An empty string is ignored.
- The message does not fire
chatMessageon the computer that callssendMessage. The other computers receive it as achatMessage. - Be careful with a handler that answers every
chatMessagewithsendMessage. If two computers run such a script, they keep answering each other.
registerCommand
- It throws a
TypeErrorunless this computer is hosting a multiplayer game in master/slave mode. It throws in single-player games and on clients. namemay start with!. It may contain only letters, digits,_and-, at most 32 characters. It is not case-sensitive.- Registering the same name again replaces the earlier handler.
- When a player types
!name some textin chat, the handler receives one object.vb.d.tscalls its typeCommandRequest:
| Field | Type | Meaning |
|---|---|---|
player | number | Index of the player who sent the command. |
command | string | The command name, in lower case, without !. |
args | string | Everything after the command name, with leading spaces removed. One string, not split. |
reply(text) | function | Sends text to that player only. |
- If the handler returns a string, the string is sent to that player, like
reply.
See Server scripts for details and a complete example.
Console
| Function | Returns | Description |
|---|---|---|
run(command) | undefined | Duke. Runs a console command, for example run('map e1l2'). |
- A leading
/is allowed and ignored. - The command does not run immediately. It is put in a queue and runs after your code returns, the next time the game loop passes. This works during play and at the title menu.
- You cannot read a command’s output from the script.
runis the same ascvar.runfrom thecvarmodule.
Debugging
| Function | Returns | Description |
|---|---|---|
breakpoint() | undefined | When DevTools is enabled, pauses script activity after the current function returns. Does nothing otherwise. |
Components, nodes and prefabs
Duke. These exports are explained in Components. This is the summary.
| Export | Returns | Description |
|---|---|---|
VBComponent | class | Base class for your components. |
VBNode | class | An empty object that can hold components. new VBNode() creates one. |
VBPrefab | class | A tile plus a list of component classes. Create it with createPrefab. |
attach(entity, component) | the component | Attaches a component to a sprite index or a VBNode. component is a class or an instance. |
detach(entity, component) | boolean | Removes one component. true if it was attached. |
getComponent(entity, type) | component, or undefined | The first attached component that is an instance of type. |
getComponents(entity, type?) | array | All attached components, or only those of type. |
setComponentEnabled(component, enabled) | undefined | Turns a component on or off. Same as assigning component.enabled. |
createNode(...components) | VBNode | Creates a node and attaches the given components. |
destroyNode(node) | boolean | Destroys a node and all its components. false if it was already destroyed. |
createPrefab(tile, ...components) | VBPrefab | Describes an actor tile together with component classes. |
spawnPrefab(prefab, x?, y?, z?, owner?) | sprite index, or -1 | Calls spawn for the prefab’s tile and attaches its components to the new sprite. |
Alphabetical list
All 58 exports:
A_InsertSprite, A_Spawn, addAmmo, addWeapon, attach, breakpoint, clearText, createNode, createPrefab, currentMenu, define, destroyNode, detach, drawText, getActiveProjectile, getActor, getComponent, getComponents, getGamevar, getInput, getPlayer, getProjectile, getSector, getTileData, getUserdef, getWall, log, menuSelection, off, on, openMenu, player, registerCommand, run, sendMessage, session, setActiveProjectile, setActor, setComponentEnabled, setGamevar, setInput, setMenuBackground, setMenuRoute, setMenuSelection, setMenuText, setPlayer, setProjectile, setSector, setTileData, setUserdef, setWall, shoot, sound, spawn, spawnPrefab, VBComponent, VBNode, VBPrefab
Events
A script reacts to the game by listening to events.
import { on } from 'vb';
on('levelChanged', () => {
// a level has been loaded
});
on('actorSpawned', (e) => {
// e is { sprite, owner, tile }
});
on(name, handler) adds a handler. off(name) removes all handlers of that event. Both are described in the API reference.
All events on this page except start, frame and shutdown exist only in the Duke runtime games. Shadow Warrior fires only those three.
How handlers run
- Handlers run on the game’s main thread. While a handler runs, the game waits. Keep handlers short, especially
framehandlers. - Handlers of one event run in the order they were registered.
- If a handler throws an error that it does not catch, the game shows the error and closes. See how errors are reported.
- Events that fire before your script has been loaded are not repeated later. Scripts are loaded a moment after the game starts. See Events you can miss.
Lifecycle events
These events pass no event object.
| Event | Fires when |
|---|---|
start | Once, right after all scripts have been loaded. |
frame | On every drawn frame, on the title screen, in menus and during play. Also on a headless server, which draws nothing but still runs its loop. |
gameStarted | A game session begins: the first level of a new game has finished loading. It does not fire again for the following levels. It fires again for the next game after leftGame. |
levelChanged | A level has finished loading. |
levelFinished | The player reached the end of a level, before the score screen. |
leftGame | The game goes back from a running game to the menu. Also when a single-player game ends after its last level. |
playerDied | A player dies. It fires for every player, not only the local one. |
beforeQuit | The game is about to exit. |
shutdown | The script runtime is being closed. It follows beforeQuit at exit. It also fires before the program restarts itself for a content pack change in multiplayer. |
Notes:
- When the first level of a game loads,
gameStartedfires first andlevelChangeddirectly after it. For every later level onlylevelChangedfires. playerDiedhas no event object, so the handler cannot tell which player died. Check the players yourself, for example withgetPlayer(index, 'dead_flag').
Events you can miss
Scripts are loaded during the first frames of the game loop. A level that started before that has already fired its events.
This happens when the game starts directly in a level:
- with
-map,-land-v, or a saved game slot on the command line, - when you play an editor project with
--project.
It can also happen in a multiplayer game started from the command line, including a dedicated server.
In these cases your script does not receive gameStarted or levelChanged for that first level. It still receives start. To cover both cases, do your setup in a function and call it from start when a game is already running:
import { on, session } from 'vb';
function setup() {
// level-dependent setup
}
on('start', () => {
if (session().started) setup();
});
on('levelChanged', setup);
When the game starts on the title screen, scripts are loaded there, before any level.
For setup that belongs to a level, prefer levelChanged over gameStarted. gameStarted fires only once per session and is easier to miss.
Menu events
The event object is { menu, previousMenu }.
menu: number. The id of the menu page that is current now.previousMenu: number, orundefinedwhen there is none.
| Event | Fires when | previousMenu |
|---|---|---|
menuOpened | The menu became visible. Detected once per frame. | The page id seen on the previous frame. |
menuClosed | The menu was closed. Detected once per frame. | The page id seen on the previous frame. |
menuChanged | The menu switched to a different page. | The page that was current before. |
escapeMenuOpened | The player opened the menu with the Escape key. | undefined |
Menu ids are the game’s internal page numbers. Log e.menu to find the id of a page.
Actor events
The event object is { sprite, owner, tile }.
sprite: index of the sprite.tile: the sprite’s tile number. Use it to filter.owner: see the table.
| Event | Fires when | owner |
|---|---|---|
actorSpawned | The engine has finished setting up an actor. This covers actors created during play and the sprites of a map when a level loads. | Index of the sprite that spawned it, or -1 when there is none. Map sprites and actors created with spawn() report -1. |
actorDestroyed | An actor is about to be removed. The sprite still exists inside the handler, so you can read its members. | The sprite’s owner member. |
actorDestroyed does not fire for the sprites of a level that is replaced by loading another level. The old sprites disappear without events.
actorSpawned fires very often while a level loads. Filter by tile first and do little work.
import { on, define, log } from 'vb';
let trooper: number | undefined;
on('start', () => {
trooper = define('LIZTROOP');
});
on('actorDestroyed', (e) => {
if (e.tile === trooper) log(`trooper sprite ${e.sprite} removed`);
});
Chat events
The event object is { player, text }.
text: the complete line as it is shown, including the sender’s name and color codes.^followed by two digits is a color code.player: a player index, or-1. See the table.
chatMessage fires in exactly three situations. A chat line fires it once per computer.
| Situation | player | text looks like |
|---|---|---|
| The local player sends a chat message to all players from the chat box. | The local player’s index. | Name^07: hello |
| A chat message from another player arrives on this computer. | On the host: the sender’s index. On every other computer: -1, because the host passes the message on. | Name^07: hello |
A message from the server arrives on a client. That is a sendMessage call on the host, or the reply to a !command. | The host’s player index. | ^07Server: hello |
What does not fire chatMessage:
- Other lines in the on-screen message area, such as kill messages.
sendMessage, on the computer that calls it. The other computers receive the message and fire the event there.- Server messages, on the host itself.
- A private chat message, on the computer that sends it. It fires on the computer of the player it is addressed to.
- A chat line that starts with
!in a master/slave multiplayer game. It goes to the server’s command handlers. See Server scripts.
On a client, player is -1 for chat from other players. If you need the sender there, read the name at the start of text.
Be careful with a handler that answers every chatMessage with sendMessage. If two computers run such a script, they keep answering each other.
CON events
CON is the game’s original scripting language. The engine calls CON events at fixed points, for example when a player jumps. A script can listen to every one of them.
import { on, setGamevar } from 'vb';
// Cancel every jump.
on('EVENT_JUMP', (e) => {
setGamevar('RETURN', 1, e.sprite, e.player);
});
Names
- Use the CON name, for example
EVENT_JUMP. - The
EVENT_prefix is optional and the name is not case-sensitive.on('jump', …)is the same.
The event object
The event object is { sprite, player, dist }. These are the three values the engine passes to the CON event.
sprite: the sprite the event is about, or-1.player: the player index the event is about, or-1.dist: a distance where the event has one, otherwise-1or0.
Their exact meaning depends on the event. It is the same as for the CON event of that name.
The RETURN gamevar
Many CON events use the gamevar RETURN to pass a value in or to take a decision back. Read and write it with the event’s own sprite and player:
const value = getGamevar('RETURN', e.sprite, e.player);
setGamevar('RETURN', 1, e.sprite, e.player);
Order
Your handlers run before the CON code of the same event. If the loaded CON files also handle the event, they can overwrite what you put in RETURN.
Cost
When you listen to a CON event, the engine starts calling it even if no CON code uses it. Some events fire extremely often. EVENT_GAME fires for every sprite on every game tick. Listen to such events only if you need them.
Examples of CON events
These were checked in the game’s source.
| Event | Fires when | sprite, player, dist | RETURN |
|---|---|---|---|
EVENT_WORLD | Once per game tick. | -1, -1, 0 | Not used. |
EVENT_GAME | Once per game tick for every sprite. | The sprite, the nearest player, the distance to that player. | Not used. |
EVENT_SPAWN | An actor has been spawned. | The new sprite, the nearest player, the distance to that player. | Not used. |
EVENT_KILLIT | A sprite is about to be removed. | The sprite, the nearest player, the distance to that player. | Set it to a non-zero value to keep the sprite. |
EVENT_JUMP | A player starts a jump. | The player’s sprite, the player index, -1. | Set it to a non-zero value to cancel the jump. |
EVENT_USE | A player presses the Use key. | The player’s sprite, the player index, -1. | Set it to a non-zero value to ignore the key press. |
EVENT_ENTERLEVEL | A level has loaded. Fires for the first player. | The player’s sprite, the player index, -1. | Starts at 0. If it is non-zero afterwards, the event also fires for the next player. |
EVENT_DISPLAYSBAR | Every frame, before the status bar is drawn. | The viewed player’s sprite, the viewed player, -1. | Set it to a non-zero value to hide the status bar. |
EVENT_DISPLAYREST | Every frame, while the HUD is drawn. | The viewed player’s sprite, the viewed player, -1. | Not used. |
EVENT_CHANGEMENU | The menu is about to switch page. | The viewed player’s sprite, the viewed player, -1. | Holds the id of the page the game wants to open. Write another id to redirect, -1 to stay, -2 to close the menu. |
All CON event names
The engine registers 165 events:
EVENT_ACTIVATECHEAT EVENT_ACTIVATESWITCH EVENT_AIMDOWN EVENT_AIMUP EVENT_ALTFIRE
EVENT_ALTWEAPON EVENT_ANIMATESPRITES EVENT_BOTGETSPRITESCORE EVENT_CAPIR EVENT_CHANGEMENU
EVENT_CHANGEWEAPON EVENT_CHEATGETBOOT EVENT_CHEATGETFIRSTAID EVENT_CHEATGETHEAT
EVENT_CHEATGETHOLODUKE EVENT_CHEATGETJETPACK EVENT_CHEATGETSCUBA EVENT_CHEATGETSHIELD
EVENT_CHEATGETSTEROIDS EVENT_CHECKFLOORDAMAGE EVENT_CHECKTOUCHDAMAGE
EVENT_CONTINUELEVELMUSICSLOT EVENT_CROUCH EVENT_CUTSCENE EVENT_DAMAGECEILING EVENT_DAMAGEFLOOR
EVENT_DAMAGESPRITE EVENT_DAMAGEWALL EVENT_DISPLAYACCESS EVENT_DISPLAYBONUSSCREEN
EVENT_DISPLAYBORDER EVENT_DISPLAYCROSSHAIR EVENT_DISPLAYCURSOR EVENT_DISPLAYEND
EVENT_DISPLAYFIST EVENT_DISPLAYINACTIVEMENU EVENT_DISPLAYINACTIVEMENUREST EVENT_DISPLAYKNEE
EVENT_DISPLAYKNUCKLES EVENT_DISPLAYLEVELSTATS EVENT_DISPLAYLOADINGSCREEN EVENT_DISPLAYMENU
EVENT_DISPLAYMENUREST EVENT_DISPLAYOVERHEADMAPPLAYER EVENT_DISPLAYOVERHEADMAPTEXT
EVENT_DISPLAYPOINTER EVENT_DISPLAYREST EVENT_DISPLAYROOMS EVENT_DISPLAYROOMSCAMERATILE
EVENT_DISPLAYROOMSEND EVENT_DISPLAYSBAR EVENT_DISPLAYSCUBA EVENT_DISPLAYSPIT EVENT_DISPLAYSTART
EVENT_DISPLAYTIP EVENT_DISPLAYWEAPON EVENT_DOFIRE EVENT_DOQUAKE EVENT_DRAWWEAPON EVENT_EGS
EVENT_ENDLEVELSCREEN EVENT_ENTERLEVEL EVENT_EXITGAMESCREEN EVENT_EXITPROGRAMSCREEN
EVENT_FAKEDOMOVETHINGS EVENT_FIRE EVENT_FIREWEAPON EVENT_FRAGGED EVENT_GAME
EVENT_GETAUTOAIMANGLE EVENT_GETBONUSTILE EVENT_GETLOADTILE EVENT_GETMENUTILE EVENT_GETSHOTRANGE
EVENT_HOLODUKEOFF EVENT_HOLODUKEON EVENT_HOLSTER EVENT_INCURDAMAGE EVENT_INIT
EVENT_INITCOMPLETE EVENT_INVENTORY EVENT_INVENTORYLEFT EVENT_INVENTORYRIGHT EVENT_JUMP
EVENT_KILLIT EVENT_LASTWEAPON EVENT_LOADACTOR EVENT_LOADGAME EVENT_LOGO EVENT_LOOKDOWN
EVENT_LOOKLEFT EVENT_LOOKRIGHT EVENT_LOOKUP EVENT_MAINMENUSCREEN EVENT_MENUCURSORLEFT
EVENT_MENUCURSORRIGHT EVENT_MENUCURSORSHADE EVENT_MENUSHADESELECTED EVENT_MOVEBACKWARD
EVENT_MOVEEFFECTORS EVENT_MOVEFORWARD EVENT_MOVESECTOR EVENT_NEWGAME EVENT_NEWGAMECUSTOM
EVENT_NEWGAMESCREEN EVENT_NEXTWEAPON EVENT_OPENMENUSOUND EVENT_OPERATEACTIVATORS
EVENT_PLAYLEVELMUSICSLOT EVENT_POSTDAMAGESPRITE EVENT_POSTSAVEGAME EVENT_POSTUPDATEANGLES
EVENT_POSTWEAPONSHOOT EVENT_PREACTORDAMAGE EVENT_PRECUTSCENE EVENT_PREGAME EVENT_PRELEVEL
EVENT_PRELOADGAME EVENT_PRESSEDFIRE EVENT_PREUPDATEANGLES EVENT_PREVIOUSWEAPON
EVENT_PREWEAPONSHOOT EVENT_PREWORLD EVENT_PROCESSINPUT EVENT_QUICKKICK EVENT_RECOGSOUND
EVENT_RESETGOTPICS EVENT_RESETINVENTORY EVENT_RESETPLAYER EVENT_RESETWEAPONS
EVENT_RETURNTOCENTER EVENT_SAVEGAME EVENT_SCREEN EVENT_SELECTWEAPON EVENT_SETDEFAULTS
EVENT_SKIPCUTSCENE EVENT_SOARDOWN EVENT_SOARUP EVENT_SOUND EVENT_SPAWN EVENT_STRAFELEFT
EVENT_STRAFERIGHT EVENT_SWIMDOWN EVENT_SWIMUP EVENT_TURNAROUND EVENT_TURNLEFT EVENT_TURNRIGHT
EVENT_UPDATESCREENAREA EVENT_USE EVENT_USEJETPACK EVENT_USEMEDKIT EVENT_USENIGHTVISION
EVENT_USESTEROIDS EVENT_VALIDATESTART EVENT_WEAPKEY1 EVENT_WEAPKEY2 EVENT_WEAPKEY3
EVENT_WEAPKEY4 EVENT_WEAPKEY5 EVENT_WEAPKEY6 EVENT_WEAPKEY7 EVENT_WEAPKEY8 EVENT_WEAPKEY9
EVENT_WEAPKEY10 EVENT_WORLD
A name on this list is accepted by on(). Whether and when the event fires depends on the game and on what happens in it.
Names missing from vb.d.ts
The generated vb.d.ts knows 112 of these names. The other 53 work at run time, but the type check treats them as unknown event names and gives the handler an untyped argument:
EVENT_ACTIVATECHEAT EVENT_CAPIR EVENT_CHANGEMENU EVENT_CHECKFLOORDAMAGE
EVENT_CONTINUELEVELMUSICSLOT EVENT_CUTSCENE EVENT_DAMAGEWALL EVENT_DISPLAYBORDER
EVENT_DISPLAYCURSOR EVENT_DISPLAYEND EVENT_DISPLAYFIST EVENT_DISPLAYINACTIVEMENU
EVENT_DISPLAYINACTIVEMENUREST EVENT_DISPLAYKNEE EVENT_DISPLAYKNUCKLES
EVENT_DISPLAYOVERHEADMAPPLAYER EVENT_DISPLAYOVERHEADMAPTEXT EVENT_DISPLAYPOINTER
EVENT_DISPLAYROOMSCAMERATILE EVENT_DISPLAYROOMSEND EVENT_DISPLAYSCUBA EVENT_DISPLAYSPIT
EVENT_ENDLEVELSCREEN EVENT_EXITGAMESCREEN EVENT_EXITPROGRAMSCREEN EVENT_GETBONUSTILE
EVENT_INITCOMPLETE EVENT_LOADGAME EVENT_MAINMENUSCREEN EVENT_MENUCURSORLEFT
EVENT_MENUCURSORRIGHT EVENT_MENUCURSORSHADE EVENT_MENUSHADESELECTED EVENT_MOVEEFFECTORS
EVENT_MOVESECTOR EVENT_NEWGAMECUSTOM EVENT_NEWGAMESCREEN EVENT_OPENMENUSOUND
EVENT_OPERATEACTIVATORS EVENT_PLAYLEVELMUSICSLOT EVENT_POSTSAVEGAME EVENT_POSTUPDATEANGLES
EVENT_PREACTORDAMAGE EVENT_PRECUTSCENE EVENT_PRELOADGAME EVENT_PREUPDATEANGLES EVENT_RECOGSOUND
EVENT_RESETGOTPICS EVENT_SAVEGAME EVENT_SCREEN EVENT_SKIPCUTSCENE EVENT_UPDATESCREENAREA
EVENT_VALIDATESTART
For these, give the argument its type yourself:
import { on } from 'vb';
on('EVENT_DAMAGEWALL', (event) => {
const e = event as ConEvent;
});
Event summary
| Event | Event object |
|---|---|
start, frame, gameStarted, levelChanged, levelFinished, leftGame, playerDied, beforeQuit, shutdown | none |
menuOpened, menuClosed, menuChanged, escapeMenuOpened | { menu: number, previousMenu?: number } |
actorSpawned, actorDestroyed | { sprite: number, owner: number, tile: number } |
chatMessage | { player: number, text: string } |
| any CON event | { sprite: number, player: number, dist: number } |
Components
A component is a class that holds behavior for one thing: a sprite, or an empty object called a node. The game calls the component’s methods at fixed moments. If you have used Unity, the model will look familiar.
Components are part of the vb module and work only in the Duke runtime games.
NNBuild has two things called components. This page describes the class-based components you create in code. Scripts that the map editor attaches to map objects are a different feature with different hooks. See Map script components.
A first component
import { VBComponent, createNode, log } from 'vb';
class Hello extends VBComponent {
start() {
log('Hello component started');
}
update(dt: number) {
// called every frame; dt is the time since the last frame, in seconds
}
}
createNode(Hello);
- Write a class that extends
VBComponent. - Override the methods you need.
- Attach it to a sprite with
attach(sprite, Hello), or create a node for it withcreateNode(Hello).
Lifecycle methods
Override any of these. All are optional.
| Method | Called |
|---|---|
awake() | When the component is attached. First call. |
onEnable() | When the component becomes active: right after awake() if it is enabled, and every time it is enabled again later. |
onSpawn() | When the component is attached, after onEnable(). |
start() | When the component is attached, after onSpawn(). |
fixedUpdate(step) | In fixed steps of 1/60 second, zero or more times per frame. step is always 1/60. |
update(dt) | Once per frame. dt is the time since the previous frame in seconds. |
lateUpdate(dt) | Once per frame, after every component’s update. |
onDisable() | When the component stops being active: it was disabled, its node was deactivated, or it is being destroyed. |
onDestroy() | When the component is removed: detached, destroyed, or its sprite was removed. Last call. |
Attaching calls awake, onEnable, onSpawn and start immediately, in that order, before attach returns.
A component is active when it is enabled and, if it sits on a node, the node is active and not destroyed. Only active components receive the three update calls.
How the update calls are timed
The update calls are driven by the frame event.
- They run on every drawn frame. That includes the title screen, menus and a paused game.
dtis measured with the computer’s clock. It is0on the first frame and never larger than0.25.fixedUpdateruns as often as needed to keep up with real time, in steps of 1/60 second, at most 4 steps per frame. It is not tied to the game’s own simulation tick.- The update loop is installed the first time you attach a component that overrides
update,fixedUpdateorlateUpdate.
Properties and methods of a component
| Member | Meaning |
|---|---|
sprite | The sprite index the component is attached to, or -1. |
node | The VBNode the component is attached to, or null. |
gameObject | Same as node. |
transform | The node’s transform, or undefined for a component on a sprite. |
enabled | true or false. Assign it to turn the component on or off. |
isActiveAndEnabled | true when the component is active. Read-only. |
GetComponent(type) | Another component on the same sprite or node. undefined if there is none. |
GetComponents(type?) | All components on the same sprite or node, optionally filtered by class. |
AddComponent(type) | Attaches another component to the same sprite or node and returns it. |
Destroy() | Removes this component. Returns true on success. |
Attaching to sprites
import { attach, detach, getComponent, getComponents } from 'vb';
const pulse = attach(spriteIndex, Pulse); // create and attach
const same = getComponent(spriteIndex, Pulse);
const all = getComponents(spriteIndex);
detach(spriteIndex, pulse);
attach(entity, component)takes a sprite index or a node.componentis a class, or an instance you created withnew. It returns the component instance.- A sprite can have several components, also several of the same class.
attachthrows whenentityis not a non-negative whole number or a node, when the class does not extendVBComponent, or when the instance is already attached somewhere.attachdoes not check that the sprite exists.- After
detachorDestroy()an instance can be attached again.
When the sprite goes away
When a sprite is removed during play, all its components are destroyed automatically: onDisable if they were active, then onDestroy. Inside onDestroy the sprite still exists and this.sprite is still set.
This cleanup depends on the actorDestroyed event. Two things follow:
- Level changes do not destroy components. Loading another level replaces all sprites without firing
actorDestroyed. A component stays attached to its index, and that index now belongs to a different sprite. Guard against this as the worked example below does, or detach your components yourself. - Do not call
off('actorDestroyed')oroff('frame').offremoves every handler of an event, including the ones the component system uses.
Nodes
A node is an empty object that is not part of the map. Use it for behavior that does not belong to one sprite, such as a HUD element or a game rule.
import { createNode, destroyNode } from 'vb';
const node = createNode(Scoreboard, Timer); // a node with two components
node.name = 'match rules';
node.SetActive(false); // components get onDisable
node.SetActive(true); // components get onEnable
destroyNode(node); // components get onDisable, onDestroy
| Member | Meaning |
|---|---|
id | A unique number, assigned in creation order starting at 1. |
name | Free text. Starts as Node <id>. |
tag | Free text. Starts as Untagged. |
transform | { position, rotation, scale }, each { x, y, z }. Plain numbers for your own use. The game does not read them. |
activeSelf | true or false. Assigning it is the same as SetActive. vb.d.ts marks it read-only, so in TypeScript call SetActive. |
activeInHierarchy | true when the node is active and not destroyed. Read-only. |
destroyed | true after the node was destroyed. |
SetActive(active) | Activates or deactivates the node. Enabled components get onEnable or onDisable. |
AddComponent(type) | Attaches a component and returns it. |
GetComponent(type), GetComponents(type?) | Look up components on the node. |
Destroy() | Same as destroyNode(node). |
new VBNode() also creates a node, without components. A destroyed node cannot take new components.
Prefabs
A prefab is a recipe: a tile number and the component classes that every spawned copy gets.
import { createPrefab, spawnPrefab, define } from 'vb';
const pulsingTrooper = createPrefab(define('LIZTROOP') ?? 0, Pulse);
const sprite = spawnPrefab(pulsingTrooper); // at the local player
const other = spawnPrefab(pulsingTrooper, x, y, z); // at a map position
createPrefab(tile, ...components)returns aVBPrefabwith the fieldstileandcomponents.new VBPrefab(tile, ...components)does the same, butvb.d.tsdoes not declare its arguments. UsecreatePrefab.spawnPrefab(prefab, x?, y?, z?, owner?)callsspawnwith the prefab’s tile. If that succeeds, it attaches a new instance of each component class to the new sprite. It returns the sprite index, or-1.- Pass classes, not instances, to
createPrefab. An instance can only be attached once.
These prefabs exist only in code. The map editor has its own prefab assets (
.vbprefabfiles), which are saved groups of sprites. The two are unrelated.
Worked example: pulsing enemies
This mod makes every trooper slowly grow and shrink. It shows a component on a sprite, per-instance state, cleanup, and the guard for level changes.
import { VBComponent, attach, on, define, getActor, setActor, log } from 'vb';
class Pulse extends VBComponent {
tile = -1;
time = 0;
onSpawn() {
this.tile = getActor(this.sprite, 'picnum') ?? -1;
log(`Pulse attached to sprite ${this.sprite}`);
}
update(dt: number) {
// The sprite slot now holds something else (for example after a level change).
if (getActor(this.sprite, 'picnum') !== this.tile) {
this.Destroy();
return;
}
this.time += dt;
const size = 40 + Math.round(8 * Math.sin(this.time * 6));
setActor(this.sprite, 'xrepeat', size);
setActor(this.sprite, 'yrepeat', size);
}
onDestroy() {
log(`Pulse removed from sprite ${this.sprite}`);
}
}
let trooper: number | undefined;
on('start', () => {
trooper = define('LIZTROOP');
});
on('actorSpawned', (e) => {
if (e.tile === trooper) attach(e.sprite, Pulse);
});
How it works:
define('LIZTROOP')looks up the trooper’s tile number in the game’s CON constants. It runs instart, when the constants are available.actorSpawnedfires for every actor. The handler attaches a newPulseto each trooper.onSpawnremembers which tile the sprite had.updateruns every frame. It first checks that the sprite still has that tile. If not, the index was reused, and the component removes itself. Otherwise it changes the sprite’s size.- When the trooper’s sprite is removed by the game,
onDestroyruns automatically.
time and tile are normal class fields. Every attached instance has its own copy.
Worked example: a node with a lifecycle
import { VBComponent, createNode, destroyNode, log } from 'vb';
class Ticker extends VBComponent {
seconds = 0;
awake() { log('awake'); }
onEnable() { log('onEnable'); }
onSpawn() { log('onSpawn'); }
start() { log('start'); }
fixedUpdate(step: number) {
this.seconds += step;
}
onDisable() { log('onDisable'); }
onDestroy() { log(`onDestroy after ${this.seconds.toFixed(1)} s`); }
}
const node = createNode(Ticker); // logs: awake, onEnable, onSpawn, start
node.transform.position = { x: 0, y: 0, z: 0 };
setTimeout(() => node.SetActive(false), 5000); // logs: onDisable
setTimeout(() => node.SetActive(true), 6000); // logs: onEnable
setTimeout(() => destroyNode(node), 10000); // logs: onDisable, onDestroy
The ticker counts only while its node is active, so the final log shows about 9 seconds.
Limits and pitfalls
- An error thrown inside a lifecycle method closes the game, like any uncaught script error.
- Inside
update,fixedUpdateandlateUpdate, a component may destroy itself. Do not destroy components of other sprites or nodes from inside these methods. Do it later, for example withsetTimeout(() => other.Destroy(), 0). - Components are local to the computer that runs the script. A component that changes the game world in multiplayer must run identically on every computer. See Keeping the game in sync.
- In TypeScript, keep to the supported subset. Class fields, typed method parameters and
extendswork.implements, generic classes and constructor parameter properties do not. See TypeScript support and its limits.
Map script components
A map script component is a script file that the map editor attaches to an object in a map: a sprite, a sector or a wall. When the level runs, the game calls functions that the file exports.
Use this model when behavior belongs to a place or an object in a level: a door, a hazard, a pickup, a terminal.
This is not the class-based component system. That one lives in code and uses
VBComponentclasses. See Components. The two models are separate. A map script component is a module with exported functions, not a class.
Requirements
- An editor project: a folder with a
vibebuild.project.jsonfile. See Projects and stand-alone games. - Modern Mode turned on, for the project or for the map.
- Script files inside the project folder. Allowed extensions:
.js,.ts,.mjs,.mts. - A Duke runtime game.
Attaching a script in the editor
- Turn on Modern Mode: File → Project → Enable Modern Mode, and confirm the compatibility warning. A single map can override this in File → Map settings… with Inherit, Off or On.
- Select a sprite, a sector or a wall.
- In the Inspector, open Script components and click Add Component.
- Pick a script that is already in the project. Or choose New TypeScript component… or New JavaScript component…, enter a project path such as
Scripts/Door.ts, and click Create and Attach.
Each attached script is listed under Script components with a Remove button.
- One object can have several components.
- One script file can be attached to many objects.
- A map can hold up to 1,024 attachments.
The template
New JavaScript component… creates this file:
export function onAttach(component) {
// Initialize component.state for this instance.
}
export function onUpdate(component, deltaSeconds) {
// Update visuals each frame.
}
export function onFixedUpdate(component, deltaSeconds) {
// Update gameplay each simulation tick.
}
New TypeScript component… creates the same file with types:
type ComponentContext = { kind: string; index: number; map: string; state: Record<string, unknown> };
export function onAttach(component: ComponentContext) {
// Initialize component.state for this instance.
}
export function onUpdate(component: ComponentContext, deltaSeconds: number) {
// Update visuals each frame.
}
export function onFixedUpdate(component: ComponentContext, deltaSeconds: number) {
// Update gameplay each simulation tick.
}
The TypeScript template declares its own ComponentContext type, so it works in a project that has no declaration file.
Types in vb.d.ts
The vb.d.ts file that the mod generator writes also declares types for map script components:
declare type MapComponentContext = {
kind: 'sprite' | 'sector' | 'wall';
index: number;
map: string;
state: Record<string, any>;
};
declare type MapComponentModule = {
onAttach?(component: MapComponentContext): void | (() => void);
onUpdate?(component: MapComponentContext, deltaSeconds: number): void;
onFixedUpdate?(component: MapComponentContext, deltaSeconds: number): void;
onDetach?(component: MapComponentContext): void;
};
MapComponentContext is the object every hook receives. MapComponentModule describes the functions a component file may export.
The editor does not add vb.d.ts to a project. If you want these types in your code editor, copy vb.d.ts from a generated mod project into your project and include it in your editor’s TypeScript settings. The game does not need the file.
Hooks
A module can export any of these four functions. All are optional.
| Hook | Called | Use it for |
|---|---|---|
onAttach(component) | Once, when the level has loaded and the component becomes active. | Setting up component.state. It may return a cleanup function. |
onUpdate(component, deltaSeconds) | On every drawn frame while the level is being played. Not in menus and not while paused. | Visuals and HUD. |
onFixedUpdate(component, deltaSeconds) | Once per game tick, after the world has moved. Not while paused. | Game logic. |
onDetach(component) | When the component ends: the level is unloaded, the game returns to the menu, a playtest stops, the game exits, or the component’s sprite is removed. | Undoing what the component set up. |
Details:
- The game simulates 30 ticks per second.
deltaSecondsofonFixedUpdateis always1/30. deltaSecondsofonUpdateis the real time since the previousonUpdate, at most0.25. It is0for the first call after the level starts and after a pause or a menu.- If
onAttachreturns a function, the game calls it without arguments when the component ends, just beforeonDetach. - Components end in the reverse order of their attachment.
The context object
Every hook receives the same object for one attachment. The template calls it component.
| Field | Type | Meaning |
|---|---|---|
kind | string | "sprite", "sector" or "wall". |
index | number | The index of the sprite, sector or wall in the map. Use it with getActor, getSector or getWall. |
map | string | The path of the map file. In an editor playtest of a map that was never saved, the map’s title. |
state | object | An empty object, new for each attachment. Store this attachment’s own values here. |
You may add your own fields to the context object. It stays the same object for all hooks of the attachment.
Per-attachment state and shared state
A script file is loaded once per level. All attachments of that file share one module.
- Variables at the top of the file are shared by all attachments of the file.
component.statebelongs to one attachment.
This is useful. One file can serve several objects that work together through shared variables. The example below does this.
What a component can use
- The global
vbobject, orimport { … } from 'vb'. The wholevbAPI is available. - The other built-in modules and globals:
fs,cvar,fetch, timers. See Built-in modules. importof other files in the project with relative paths, for exampleimport { clamp } from './lib/math.js'. Write the full file name.- TypeScript, within the supported subset.
Rules:
- The module must finish loading immediately. Do not use
awaitat the top level of the file. A module that does is skipped with a log message. - Use
import, notrequire, for your own files. Seerequire. - An error that a hook does not catch closes the game and shows the error.
Reloading during a playtest
In the editor, press F5 to playtest and F5 again to return. Every playtest loads the component files again from disk, together with the files they import. Edit a script, save it, and start the next playtest to see the change. The editor does not need to be restarted.
Variables at the top of the file start fresh in every playtest and for every level.
Normal script mods (autojs/…) are different: they are loaded once when the game starts.
When a sprite is removed
If the sprite of a component is removed during play, the component ends. Its cleanup function and onDetach run on the next update, and no further hooks are called.
A sprite that the game removes while the level is still being set up never gets its component. The log notes this.
How attachments are stored
The editor saves attachments in a settings file next to the map, named <map>.vbmap.json:
{
"target": "inherit",
"scripts": [
{ "kind": "sector", "script": "Scripts/Station.js", "index": 29 },
{ "kind": "sprite", "script": "Scripts/Station.js", "index": 15 }
],
"version": 1
}
script is a path relative to the project folder. Modern Mode is stored as "modern": true in vibebuild.project.json, or as "modern": true or false in the map’s settings file when the map overrides it.
Playing a project with components
./vibebuild32 --project examples/ashline-relay
./vibebuild32 --editor --project examples/ashline-relay
Components of a project folder run without further options.
Components of an exported project ZIP do not run unless the player allows scripts:
./vibebuild32 --allow-project-scripts --project "/path/to/Ashline Relay.zip"
Without the option the level loads, but no component is attached. Only allow scripts from projects you trust.
Example: Ashline Relay
The repository contains a small stand-alone game, examples/ashline-relay. Its whole mission logic is one file, Scripts/Station.js, attached to four sectors and four sprites. The player collects a power cell from a coolant pool, a seal opens, and the player transmits from a terminal.
One file, several roles
The file is attached to different kinds of objects. onAttach finds out what each object is and stores a role in state:
function identify(component) {
if (component.kind === "sector") {
switch (vb.getSector(component.index, "hitag")) {
case 20201: return "seal";
case 20202: return "coolant";
}
} else if (component.kind === "sprite") {
switch (vb.getActor(component.index, "picnum")) {
case 3860: return "relay";
case 3850: return "cell";
case 3872: return "indicator";
case 3876: return "uplink";
}
}
return "unknown";
}
export function onAttach(component) {
const role = identify(component);
component.state.role = role;
component.state.elapsed = 0;
component.state.phase = 0;
component.state.z = component.kind === "sprite" ? vb.getActor(component.index, "z") : 0;
if (role === "relay") vb.log("Ashline Relay online");
}
- A sector is recognized by its
hitag, a number the level designer typed into the sector in the editor. - A sprite is recognized by its tile number (
picnum). - The script uses the global
vbobject, so it needs no import.
This file is JavaScript. switch is fine here. In a .ts file use if / else if, because the game’s TypeScript converter does not handle case labels.
Shared mission state
The progress of the mission is kept in one object at the top of the file. All eight attachments see the same object:
const mission = {
cell: false,
gateOpen: false,
transmitted: false,
message: "",
messageTime: 0,
coolantTimer: 0,
};
Values that belong to one object, such as its role and its original height, are in component.state.
Game logic in onFixedUpdate
onFixedUpdate runs once per game tick for each attachment. It advances the attachment’s own clock and then runs the code for its role:
export function onFixedUpdate(component, dt) {
component.state.elapsed += dt;
switch (component.state.role) {
case "relay": updateRelay(component, dt); break;
case "coolant": updateCoolant(component); break;
case "seal": updateSeal(component); break;
case "cell": updateCell(component); break;
case "indicator":
if (mission.gateOpen && component.state.phase === 0) {
vb.setActor(component.index, "picnum", 3878);
component.state.phase = 1;
}
break;
case "uplink": updateUplink(component); break;
}
}
The power cell is a sprite. Until it is collected it floats up and down. When the player comes close, the script marks the cell as collected for everyone, hides the sprite, plays two sounds and shows a message:
function playerNear(sprite, distance) {
if (vb.getPlayer(0, "cursectnum") !== vb.getActor(sprite, "sectnum")) return false;
const dx = vb.getActor(sprite, "x") - vb.getPlayer(0, "posx");
const dy = vb.getActor(sprite, "y") - vb.getPlayer(0, "posy");
return dx * dx + dy * dy < distance * distance;
}
function updateCell(component) {
if (mission.cell) return;
if (playerNear(component.index, 600)) {
mission.cell = true;
vb.setActor(component.index, "cstat", 32768);
vb.sound(CELL_PICKUP);
vb.sound(SEAL_RELEASE);
signal("BLUE CELL ONLINE / UPLINK SEAL OPENING", 3.2);
vb.log("Ashline Relay: blue cell recovered");
} else {
vb.setActor(component.index, "z", component.state.z + Math.round(620 * Math.sin(component.state.elapsed * 5)));
}
}
cstat32768makes a sprite invisible.component.state.zis the height saved inonAttach. The sprite moves around it.
The seal is a sector. Another attachment of the same file watches mission.cell and raises the sector’s ceiling a little on every tick until it is open:
function updateSeal(component) {
if (!mission.cell || mission.gateOpen) return;
const index = component.index;
const current = vb.getSector(index, "ceilingz");
const next = Math.max(OPEN_CEILING, current - 832);
vb.setSector(index, "ceilingz", next);
if (next === OPEN_CEILING) {
mission.gateOpen = true;
vb.log("Ashline Relay: uplink seal open");
}
}
Heights get smaller as they go up, so subtracting raises the ceiling.
The other roles follow the same pattern:
- coolant (sector): cycles the floor picture with
setSector(index, "floorpicnum", …). When the player stands in the sector, it lowers the health of the player’s sprite (extra) at most once every 0.55 seconds and plays a sound. - relay (sprite): animates its tile and height. It also counts down the shared timers, because there is exactly one relay.
The uplink terminal is a sprite. It ends the mission:
function updateUplink(component) {
if (mission.transmitted || !mission.gateOpen || !playerNear(component.index, 860)) return;
signal("USE THE UPLINK TERMINAL TO TRANSMIT", 0.35);
if (!(vb.getInput(0, "bits") & USE)) return;
mission.transmitted = true;
vb.setActor(component.index, "picnum", 3875);
vb.sound(TRANSMIT);
signal("TRANSMISSION COMPLETE", 3);
vb.setPlayer(0, "customexitsound", -1);
vb.setUserdef("eog", 1);
vb.setPlayer(0, "timebeforeexit", 90);
vb.log("Ashline Relay: transmission complete");
}
- It does nothing until the seal is open and the player is close.
vb.getInput(0, "bits")reads the keys player 0 holds.USEis1 << 29, the bit of the Use key.vb.setUserdef("eog", 1)marks this level as the end of the game. After the level the game returns to the menu.vb.setPlayer(0, "timebeforeexit", 90)starts the countdown that ends the level.
The HUD in onUpdate
onUpdate runs every frame. Only the relay attachment draws, so the text is drawn once:
export function onUpdate(component) {
if (component.state.role !== "relay") return;
const health = Math.max(0, vb.getActor(vb.player().sprite, "extra"));
const ammo = vb.getPlayer(0, "ammo_amount", 1);
const objective = mission.transmitted ? "RELAY LINK ESTABLISHED"
: mission.cell ? "02 / REACH THE UPLINK AND TRANSMIT"
: "01 / RECOVER THE BLUE CELL IN COOLANT";
vb.drawText(710, 9, 23, objective, 0, -12);
vb.drawText(711, 9, 187, "SUIT " + health + " PULSE " + ammo, 0, -12);
if (mission.messageTime > 0) vb.drawText(712, 9, 35, mission.message, 0, -14);
else vb.clearText(712);
}
Cleanup in onDetach
HUD text stays on screen until it is cleared. The relay removes its three lines when the level ends:
export function onDetach(component) {
if (component.state.role !== "relay") return;
for (const id of [710, 711, 712]) vb.clearText(id);
}
What to take from the example
- Decide the role of an object from data the level designer controls: a tag or a tile.
- Keep per-object values in
component.stateand shared progress at the top of the file. - Put rules in
onFixedUpdateand drawing inonUpdate. - Clear HUD text and undo changes in
onDetach. - The example is single-player. It reads player
0everywhere.
Example: a cleanup function in TypeScript
This component makes a sector’s floor blink. onAttach returns a function that restores the original brightness.
import { getSector, setSector } from 'vb';
export function onAttach(component: MapComponentContext) {
if (component.kind !== 'sector') return;
component.state.timer = 0;
component.state.original = getSector(component.index, 'floorshade') ?? 0;
// Runs when the component ends, just before onDetach.
return () => setSector(component.index, 'floorshade', component.state.original);
}
export function onFixedUpdate(component: MapComponentContext, dt: number) {
if (component.kind !== 'sector') return;
component.state.timer += dt;
const dark = Math.floor(component.state.timer * 2) % 2 === 1;
setSector(component.index, 'floorshade', dark ? 24 : component.state.original);
}
MapComponentContext comes from vb.d.ts. The game removes the type when it loads the file, so the script also runs in a project without vb.d.ts.
The kind check matters. component.index is a sector number only when the script is attached to a sector.
Limits
- Components run on the computer that plays the level. They are not synchronized between players. See Keeping the game in sync.
- The struct functions do not check indices. Use
component.indexonly with the function that matchescomponent.kind. - HUD text ids are shared with all other scripts. Pick ids that are unlikely to collide.
Built-in modules
Besides vb, scripts can use a few modules and global functions that look like their Node.js or browser counterparts.
This is not Node.js. Only the functions listed on this page exist. A function that Node.js has and this page does not list is not available.
| Name | Kind | Import | Purpose |
|---|---|---|---|
fs | module | fs, node:fs | Files and folders |
fs/promises | module | fs/promises, node:fs/promises | Promise versions of the file functions |
dgram | module | dgram, node:dgram | UDP sockets |
net | module | net, node:net | Outgoing TCP connections |
cvar | module and global | cvar | Console commands |
fetch | global | HTTP and HTTPS requests | |
| Timers | globals | setTimeout, setInterval, … | |
console | global | Logging | |
require | global | CommonJS-style loading |
All of these work in every game that runs scripts, except cvar, which needs the Duke runtime.
How callbacks are scheduled
The JavaScript engine runs on the game’s main thread. Callbacks do not interrupt your code. The game runs them once per frame, in this order:
- UDP messages, TCP events, finished
fetchrequests. fscallbacks.- The
frameevent. - Timers that are due.
- Promise continuations (code after
await,.thenhandlers).
So a timer or a network callback is never more exact than one frame. On a headless server the loop still runs, and all of this works.
An error that a callback does not catch closes the game. See how errors are reported.
Promises and errors
A promise that is rejected at a moment when no handler is attached to it closes the game with an “unhandled promise rejection” error. The game does not wait to see whether you attach a handler later.
This has practical consequences:
- An
asyncfunction that throws before its firstawaitends the game, even when the caller usestry/catchor.catch(). Put atry/catchinside theasyncfunction. - The functions of
fs.promisesreject immediately when the operation fails. Such a failure ends the game. Use the…Syncfunctions withtry/catch, or check withexistsSyncfirst. response.json()rejects immediately when the body is not valid JSON. UseJSON.parse(await response.text())insidetry/catch.await fetch(…)insidetry/catchis safe. The request fails later, when the handler is already attached.
fs
import fs from 'fs';
import { readFileSync, writeFileSync } from 'fs';
A relative path is relative to the folder the game runs in. That is usually the folder of the selected game data, not the folder of your script. Use absolute paths if the location matters.
Synchronous functions
| Function | Returns | Description |
|---|---|---|
readFileSync(path, options?) | Uint8Array or string | Reads a whole file. |
writeFileSync(path, data) | undefined | Creates or replaces a file. |
appendFileSync(path, data) | undefined | Appends to a file. Creates it if needed. |
existsSync(path) | boolean | true if the file can be opened for reading. |
unlinkSync(path) | undefined | Deletes a file. |
renameSync(oldPath, newPath) | undefined | Renames or moves a file. |
mkdirSync(path) | undefined | Creates one folder. No error if it already exists. |
readdirSync(path) | array of strings | The names in a folder, without . and ... |
statSync(path) | object | { size, isFile(), isDirectory() }. Named FSStats in vb.d.ts. |
- Text or bytes.
readFileSync(path)returns aUint8Array. To get a string, pass an encoding:readFileSync(path, 'utf8')orreadFileSync(path, { encoding: 'utf8' }). The file is always read as UTF-8, whatever encoding name you pass. datais text.writeFileSyncandappendFileSyncconvertdatato a string. AUint8Arrayis written as its text form (1,2,3), not as bytes. Binary writing is not supported.- Errors. A failed operation throws an error, for example
fs.readFile: cannot open file. Catch it withtry/catch.existsSyncnever throws. mkdirSyncdoes not create parent folders. Options are ignored.readdirSyncandstatSyncignore their options argument.
Callback functions
| Function | Callback receives |
|---|---|
readFile(path, callback) or readFile(path, options, callback) | (error, data) |
writeFile(path, data, callback) | (error) |
appendFile(path, data, callback) | (error) |
exists(path, callback) | (exists) |
unlink(path, callback) | (error) |
rename(oldPath, newPath, callback) | (error) |
errorisnullon success.- The file operation itself happens immediately. Only the callback is delayed until the next frame.
- Without a callback these functions behave exactly like their
…Syncversions and return the result directly.
fs.promises
fs.promises is an object with six functions. Each returns a promise.
readFile(path, options?), writeFile(path, data), appendFile(path, data), exists(path), unlink(path), rename(oldPath, newPath)
The same object is the module fs/promises:
import promises from 'fs/promises';
import { on, log } from 'vb';
on('start', async () => {
await promises.writeFile('notes.txt', 'hello');
const text = await promises.readFile('notes.txt', 'utf8');
log(`notes.txt contains: ${text}`);
});
Read the warning under Promises and errors: a failing call ends the game. Use these functions only where failure is not expected.
Not implemented
Everything else from Node’s fs, including: open/read/write/close on file handles, streams, copyFile, rm, rmdir, readdir and stat in callback or promise form, watch, access, chmod, recursive mkdir, file descriptors, Buffer.
dgram
UDP sockets.
import dgram from 'dgram';
const socket = dgram.createSocket('udp4');
socket.on('message', (message, rinfo) => {
// message is a Uint8Array; rinfo is { address, port, family, size }
});
socket.bind(40123, '0.0.0.0', () => {
// ready to receive
});
socket.send('hello', 40123, '127.0.0.1');
| Function | Returns | Description |
|---|---|---|
dgram.createSocket(type, onMessage?) | socket | type is 'udp4' or 'udp6'. An optional function is added as a message listener. |
socket.on(event, listener) | the socket | Adds a listener. |
socket.bind(port, callback?) | the socket | Starts receiving on port, on the loopback address only. |
socket.bind(port, address, callback) | the socket | Starts receiving on port at address. |
socket.send(message, port, address?, callback?) | undefined | Sends one datagram. message is a string or a Uint8Array. |
socket.close(callback?) | undefined | Closes the socket. |
socket.address() | { address, port, family } | The local address. Throws if the socket is closed. |
Events:
| Event | Listener receives | When |
|---|---|---|
message | (message, rinfo) | A datagram arrived. message is a Uint8Array. rinfo is { address, port, family, size }. family is 'IPv4' or 'IPv6'. |
listening | nothing | bind succeeded. |
close | nothing | The socket was closed. |
error | (error) | Receiving failed. |
Things to know:
bind(port)listens on loopback only. Without an address the socket accepts datagrams only from the same computer. To receive from other computers, pass an address and a callback:socket.bind(port, '0.0.0.0', () => {}). The address argument is ignored when no callback follows it.sendwithout an address sends to the same computer.sendthrows if the datagram cannot be sent. With a callback, the callback is called first with an error, or withnull.- Sockets are checked once per frame. Up to 65,536 bytes of a datagram are received.
- Keep the socket in a variable that stays alive, for example at the top of your file. A socket that is no longer referenced is closed when it is garbage-collected.
- To turn received bytes into text, use
String.fromCharCode(...message)for plain ASCII. - Host names are resolved while your code waits. A slow lookup pauses the game.
Not implemented: once, off/removeListener, connect, setBroadcast, addMembership and the other multicast functions, ref/unref, send with offset and length.
net
Outgoing TCP connections. There is no TCP server.
import net from 'net';
const socket = net.createConnection(8080, '127.0.0.1', () => {
socket.write('hello\n');
});
socket.on('data', (data) => {
// data is a Uint8Array
});
socket.on('close', (hadError) => {
// the connection is gone
});
| Function | Returns | Description |
|---|---|---|
net.createConnection(port, host?, onConnect?) | socket | Starts connecting. host defaults to 127.0.0.1. The optional function is added as a connect listener. |
net.connect(…) | socket | Same function. |
socket.on(event, listener) | the socket | Adds a listener. |
socket.write(data, callback?) | boolean | Sends data (string or Uint8Array). true if the send succeeded. |
socket.end(data?, callback?) | the socket | Optionally sends data, then closes the sending side. |
socket.destroy() | the socket | Closes the connection immediately. |
socket.setNoDelay(noDelay?) | the socket | Turns off send buffering in the operating system. Default true. |
Events:
| Event | Listener receives | When |
|---|---|---|
connect | nothing | The connection is established. |
data | (data) | Bytes arrived, as a Uint8Array. |
end | nothing | The other side closed the connection. close follows. |
error | (error) | Connecting, sending or receiving failed. close follows for connection and receive errors. |
close | (hadError) | The socket is closed. hadError is true after an error. |
Things to know:
portmust be between 1 and 65535. OtherwisecreateConnectionthrows aRangeError.createConnectionthrows if the host name cannot be resolved. The lookup happens while your code waits.- Wait for
connectbefore you callwrite. Awriteon a socket that is not connected fails: it returnsfalseand fireserror. writesends at once and does not queue. Keep messages small.writeon a closed socket throws.- The
writecallback is called immediately, whether or not the send succeeded. - Keep the socket in a variable that stays alive.
Not implemented: createServer and everything about listening, new net.Socket(), setEncoding, pause/resume, once, off, setTimeout, setKeepAlive, address properties, TLS.
cvar
Duke runtime. Runs console commands. It is a module and also a global object.
import cvar from 'cvar';
cvar.run('map e1l2');
cvar.set('r_maxfps', 60);
| Function | Description |
|---|---|
cvar.run(command) | Runs one console command line. |
cvar.set(name, value) | Short for cvar.run(name + ' ' + value). |
- Commands are queued. They run after your code returns, on the next pass of the game loop, during play and at the title menu. See
run. vb.runis the same function ascvar.run.- You cannot read the value of a console variable, and you get no result back.
- In Shadow Warrior the functions exist, but the commands are never executed.
fetch
fetch(url, options?) returns a promise for a response object. The request runs on a background thread. The promise settles on a later frame. fetch is a global function. It needs no import.
Options:
| Option | Type | Meaning |
|---|---|---|
method | string | For example 'POST'. Default GET. |
headers | object | Header names and string values. |
body | string or Uint8Array | The request body. Set method as well when you send a body. |
The response object:
| Member | Meaning |
|---|---|
status | The HTTP status code. |
ok | true for status 200 to 299. |
url | The final URL, after redirects. |
headers.get(name) | The value of a response header, or null. The name is not case-sensitive. |
text() | Promise for the body as a string. |
json() | Promise for the body parsed as JSON. |
arrayBuffer() | Promise for the body as an ArrayBuffer. |
Things to know:
- An HTTP error status such as 404 does not reject the promise. Check
response.ok. - A network failure rejects the promise with an
Error. - Use
try/catcharoundawait fetch(…). Read Promises and errors before you usejson(). - You can read the body as often as you like. It is fully downloaded before the promise resolves. There is no streaming.
import { on, log } from 'vb';
on('start', async () => {
try {
const response = await fetch('https://example.com/api', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ hello: 'world' }),
});
const text = await response.text();
log(`status ${response.status}: ${text.length} characters`);
} catch (err) {
log(`request failed: ${err}`);
}
});
Platform notes:
- macOS uses libcurl.
- Linux uses the system’s libcurl, loaded on the first
fetchcall (libcurl.so.4orlibcurl-gnutls.so.4). If it is not installed, the promise is rejected withfetch: libcurl is not installed on this system. - Windows uses the HTTP client built into Windows. Name lookup and connecting time out after 10 seconds, sending and receiving after 30 seconds.
- With libcurl, redirects are followed and connecting times out after 10 seconds. There is no limit on the total duration of a request.
Not implemented: Request, Response and Headers constructors, AbortController and signal, statusText, blob(), formData(), streaming bodies, iterating over headers, the options redirect, credentials, mode and cache.
Timers
| Function | Returns | Description |
|---|---|---|
setTimeout(callback, ms?, ...args) | timer id (number) | Calls callback(...args) once, after at least ms milliseconds. |
setInterval(callback, ms?, ...args) | timer id (number) | Calls callback(...args) repeatedly, every ms milliseconds. |
clearTimeout(id) | undefined | Cancels a timer. |
clearInterval(id) | undefined | Cancels a timer. Same function as clearTimeout. |
callbackmust be a function. A string of code is not accepted.- The shortest delay is 1 millisecond. A missing or smaller
msbecomes 1. - Timers are checked once per frame, after the
frameevent. A timer never fires earlier than the next frame. - An interval that falls behind does not catch up. The next call is scheduled from the moment the previous one ran.
- Timers use real time. They keep running in menus, while the game is paused, and across level changes.
- All timers are removed when the game shuts down.
Not implemented: setImmediate, timer.unref(), timer.refresh().
console
console.log, console.info, console.warn and console.error all do the same as vb.log: they write one line to the game log. There are no log levels.
Not implemented: console.table, console.time, console.assert, console.trace and the rest.
require
require(name) loads a built-in module or a file in CommonJS style.
const fs = require('fs');
const helpers = require('./helpers.js');
Built-in names: vb, cvar, fs, node:fs, fs/promises, node:fs/promises, dgram, node:dgram, net, node:net.
For the rules that apply to your own files, see require. There is no module, exports, __dirname or __filename at the top level of an entry file, because entry files are ES modules. A file loaded through require does receive module and exports.
What else is missing
There is no process, no Buffer, no path, os, http, https, child_process, crypto or events module, and no node_modules lookup. The standard JavaScript language itself is complete: Promise, Map, Set, typed arrays, JSON, Math, Date, regular expressions, classes, async/await.
Server scripts
A server script is a normal script mod that runs on the computer hosting a multiplayer game. It can run on a player’s own machine when that player hosts, or on a dedicated server without a screen.
On a server a script can do things that make no sense elsewhere: answer !commands that players type into chat, make announcements, and change maps on a schedule.
Everything on this page needs the Duke runtime.
Starting a server with a script
Give the script on the command line, like any other script:
./vibebuild32 --headless --startnow --js ./server.ts -net /p23513 /n0:8
--headlessstarts a dedicated server with no window, graphics or sound.--startnowbegins the match immediately and keeps the other slots open.--js ./server.tsloads the script. A bare path (./server.ts) also works if it comes before-net.-net /p23513 /n0:8hosts on port 23513 in master/slave mode with 8 slots.
A script in autojs/<name>/ is loaded as well. See Dedicated server for the server options and Project layout for the ways to load scripts.
What is different on a headless server
- The script runtime runs normally. The
frameevent, timers,fs,dgram,net,fetchand promises all work. - Nothing is drawn.
drawTextand the menu functions have no visible effect. soundplays nothing.logwrites to the server’s log.- The server starts directly in a level, before scripts are loaded. Your script does not get
gameStartedorlevelChangedfor the first map. See Events you can miss. - A script runs only on the computer that loaded it. It is not sent to the players.
Chat commands
A player types a line that starts with ! into the normal chat box, for example !help. In a master/slave multiplayer game such a line is not shown as chat. It is sent to the server and handled there.
Register a handler with registerCommand:
import { registerCommand } from 'vb';
registerCommand('help', ({ reply }) => {
reply('Commands: !help, !rules');
});
registerCommand('rules', () => 'Play the objective and keep chat friendly.');
The handler receives one object. In vb.d.ts its type is named CommandRequest:
| Field | Type | Meaning |
|---|---|---|
player | number | Index of the player who typed the command. |
command | string | The command name in lower case, without the !. |
args | string | The rest of the line, with leading spaces removed. It is one string. Split it yourself. |
reply(text) | function | Sends text to that player only. |
- Returning a string from the handler is the same as calling
replywith it. - A reply appears on the player’s screen as
Server: <text>. Other players do not see the command or the reply. replycan be called later, for example from a timer. It is ignored if the player has left in the meantime.
Rules and limits:
- A command name may contain letters, digits,
_and-, up to 32 characters. Case does not matter:!Helpruns thehelphandler. - A command line can be at most 120 characters long.
- If no handler is registered for a command, the player gets
Unknown server command. - The host’s own
!lines are handled the same way. - In a single-player game, and in peer-to-peer mode, a line starting with
!is ordinary chat.
registerCommand only works on the server
registerCommand throws an error when the computer is not hosting a multiplayer game in master/slave mode. An error that nothing catches closes the game. If your script may also be loaded in single-player, on a client, or in a peer-to-peer game, catch the error:
import { registerCommand, log } from 'vb';
try {
registerCommand('rules', () => 'Play the objective and keep chat friendly.');
} catch (err) {
log(`chat commands are off: ${err}`);
}
If the first registerCommand succeeds, the computer is the server. The complete example below uses this to decide whether to start its timers.
Messages to players
sendMessage(text) on the host sends text to every player. It is shown as Server: <text>.
import { sendMessage } from 'vb';
sendMessage('Welcome. Type !help for commands.');
To talk to one player, use reply inside a command handler.
sendMessage does not fire the chatMessage event on the server itself. The players’ computers receive the message as a chatMessage from the host. See Chat events.
Timers
setTimeout and setInterval work on a server as everywhere else. They use real time and keep running across map changes.
import { sendMessage } from 'vb';
const minute = 60_000;
setInterval(() => {
sendMessage('Remember: type !rules for the server rules.');
}, 15 * minute);
See Timers.
Console commands from a script
run(command) runs a line as if the server operator had typed it into the console. cvar.run is the same function.
import { run } from 'vb';
run('nextmap'); // advance to the next map of the rotation
run('monsters off'); // remove all monsters
run('spawn 1680 2'); // spawn tile 1680 next to player 2
- The command runs a moment later, after your code has returned.
- The script cannot read the command’s output. It goes to the server log.
- See Server administration and Console commands for the commands.
Keeping the game in sync
Multiplayer in NNBuild is deterministic. Every computer simulates the same game from the same inputs. The game checks constantly that all computers still agree. If one computer changes the game world and the others do not, the game is out of sync.
A server script runs on one computer only. So it must not change the game world directly.
Safe on a server:
- Chat:
sendMessage,registerCommand,reply. - Timers, files, network:
setTimeout,setInterval,fs,fetch,dgram,net. - Reading game state:
session(),getPlayer,getActor,getGamevarand the other getters. - Host console commands that the server sends to all players and applies on every computer at the same moment.
spawn,monstersandnextmapare commands of this kind.
Not safe on a server:
spawn(),A_Spawn(),A_InsertSprite(),spawnPrefab().- Every setter:
setActor,setPlayer,setInput,setSector,setWall,setGamevar,setUserdef,setProjectile,setActiveProjectile,setTileData. addAmmo,addWeapon,shoot.- Changing
RETURNor anything else from a CON event handler.
Replace direct changes with the synchronized console commands:
| Instead of | Use |
|---|---|
spawn(tile, x, y, z) | run('spawn <tile> <x> <y> <z>') or run('spawn <tile> <player>') |
| Removing or restoring monsters with setters | run('monsters off'), run('monsters on'), run('monsters <skill>') |
The spawn console command takes a tile number or a tile name from the game’s CON files. The second form places the actor in front of a player. The player is given by index or by name.
A script that changes the world is still possible in multiplayer if every computer loads the same script and the script makes the same changes at the same moment on all of them, for example from a CON event. That is a mod that all players install, not a server script.
Errors stop the server
An error that your script does not catch closes the game. On a server that ends the match for everyone. Keep these habits:
- Wrap code that can fail in
try/catch: file access, parsing player input, network replies. - Put a
try/catchinside everyasyncfunction. See Promises and errors. - Treat
argsas untrusted text. Players can type anything.
Restarts
When the server changes to a different content pack, the server program restarts itself with the same command line. The script receives shutdown and is then loaded again from the beginning. Variables and timers are lost. Store anything that must survive in a file.
A complete server script
// server.ts
// ./vibebuild32 --headless --startnow --js ./server.ts -net /p23513 /n0:8
import { log, run, sendMessage, registerCommand, session } from 'vb';
import fs from 'fs';
const MINUTE = 60_000;
const ATOMIC_HEALTH = 100; // Duke Nukem 3D tile number
const NOTES_FILE = 'server-notes.txt';
function playerName(index: number): string {
const found = session().players.find((p) => p.index === index);
return found ? found.name : `player ${index}`;
}
let hosting = false;
try {
// Chat commands. Only the player who typed the command sees the answer.
registerCommand('help', () => 'Commands: !help, !rules, !players, !gift, !note <text>');
registerCommand('rules', () => 'Play the objective and keep chat friendly.');
registerCommand('players', ({ reply }) => {
const names = session().players.map((p) => p.name).filter((name) => name.length > 0);
reply(`${names.length} online: ${names.join(', ')}`);
});
// World changes go through a synchronized host console command.
registerCommand('gift', ({ player, reply }) => {
run(`spawn ${ATOMIC_HEALTH} ${player}`);
reply('A gift is on its way.');
});
// File access works on a headless server too.
registerCommand('note', ({ player, args }) => {
if (args.length === 0) return 'Usage: !note <text>';
try {
fs.appendFileSync(NOTES_FILE, `${playerName(player)}: ${args}\n`);
return 'Noted.';
} catch (err) {
log(`could not write ${NOTES_FILE}: ${err}`);
return 'Sorry, the note could not be saved.';
}
});
hosting = true;
} catch (err) {
// registerCommand throws when this computer is not the server.
log(`server script is idle: ${err}`);
}
if (hosting) {
// A repeating announcement, then a map change one minute later.
setInterval(() => {
sendMessage('The map changes in one minute.');
setTimeout(() => run('nextmap'), MINUTE);
}, 10 * MINUTE);
log('server script ready');
}
What it does:
- The first
registerCommandthrows when this computer is not the server. Thecatchlogs that and leaveshostingatfalse, so nothing else happens. !helpand!rulesreturn a string. The string is sent to the player who asked.!playersanswers with the names fromsession().!giftspawns an item in front of the player. It uses thespawnconsole command, which is applied on every computer, so the game stays in sync.!note some textappends a line to a file. A failed write is caught, logged and reported to the player. It does not stop the server.- Every ten minutes the server announces a map change and runs
nextmapone minute later.nextmapneeds a map rotation. See Server administration.
TypeScript examples
Each example is a complete index.ts. Put it in autojs/<name>/index.ts, or generate a project first with ./vibebuild32 --gen-ts <name> and replace the generated index.ts. See Quick start.
All examples keep to the TypeScript that the game can convert. See TypeScript support and its limits.
Examples 5, 9 and 10 use only on, log and built-in modules. They also run in Shadow Warrior. The other examples need a Duke runtime game.
All examples pass the type check (npm run check) against the generated vb.d.ts.
1. Hello, HUD
Shows a fixed line of text and a frame counter that updates every 30 frames.
import { on, drawText } from 'vb';
let frames = 0;
on('start', () => {
drawText(1, 8, 8, 'Hello from my mod');
});
on('frame', () => {
frames++;
if (frames % 30 === 0) drawText(2, 8, 18, `frames: ${frames}`);
});
Text stays on screen until it is replaced or cleared, so the first line is drawn only once.
2. Reacting to actor spawns
Counts every trooper the engine spawns and shows the count. This includes troopers that are part of a map when a level loads.
import { on, define, drawText, log } from 'vb';
let trooper: number | undefined;
let seen = 0;
on('start', () => {
trooper = define('LIZTROOP');
if (trooper === undefined) log('LIZTROOP is not defined by this game');
});
on('actorSpawned', (e) => {
if (e.tile !== trooper) return;
seen++;
drawText(10, 8, 8, `Troopers spawned: ${seen}`);
});
define('LIZTROOP') asks the game for the tile number behind the name. The name comes from Duke Nukem 3D’s CON files. In another game the lookup returns undefined and the mod only logs a message.
3. A custom chat command
Adds two commands that players type into chat on a server: !players lists who is online, !roll 20 rolls a die.
import { registerCommand, session, log } from 'vb';
try {
registerCommand('players', () => {
const names = session().players.map((p) => p.name).join(', ');
return `Online: ${names}`;
});
registerCommand('roll', ({ args, reply }) => {
const sides = Math.max(2, parseInt(args, 10) || 6);
reply(`You rolled ${1 + Math.floor(Math.random() * sides)} (d${sides})`);
});
} catch (err) {
log(`chat commands are not available: ${err}`);
}
registerCommand throws when the game is not a multiplayer server. The try/catch keeps the mod harmless in single-player. A handler can answer by returning a string or by calling reply. See Server scripts.
4. A timed announcement that changes the map
Every ten minutes the host announces a map change and switches to the next map of the rotation one minute later.
import { sendMessage, run, session } from 'vb';
const minute = 60_000;
function isHost() {
const s = session();
return s.players.length > 1 && s.localPlayer === s.hostPlayer;
}
setInterval(() => {
if (!isHost()) return;
sendMessage('The map changes in one minute.');
setTimeout(() => run('nextmap'), minute);
}, 10 * minute);
run('nextmap') runs the host’s nextmap console command, which changes the map for all players together. The isHost() check makes the timer do nothing on other computers.
5. Reading and writing a file
Counts how often the mod has been started and keeps the number in a text file.
import fs from 'fs';
import { on, log } from 'vb';
const file = 'my-mod-launches.txt';
on('start', () => {
let launches = 0;
if (fs.existsSync(file)) {
launches = parseInt(fs.readFileSync(file, 'utf8') as string, 10) || 0;
}
launches++;
fs.writeFileSync(file, String(launches));
log(`This mod has been started ${launches} time(s)`);
});
The 'utf8' argument makes readFileSync return a string. Without it you get bytes. The file is created in the folder the game runs in.
6. Reading and setting a gamevar
Halves the gravity that pulls sprites down, and logs the old and the new value.
import { on, getGamevar, setGamevar, log } from 'vb';
const LOW_GRAVITY = 88;
function applyGravity() {
const before = getGamevar('gravitationalconstant');
if (before === undefined) return;
setGamevar('gravitationalconstant', LOW_GRAVITY);
log(`gravity ${before} -> ${getGamevar('gravitationalconstant')}`);
}
on('start', applyGravity);
on('levelChanged', applyGravity);
gravitationalconstant is a gamevar that the game itself provides. Its value is normally 176. The function is called from start and from levelChanged, so it also covers a game that starts directly in a level. It sets a fixed value, so calling it more than once does no harm. This mod changes the game world. In multiplayer every player needs it.
7. A class-based component
Shows a frames-per-second counter. The logic lives in a component on a node.
import { VBComponent, createNode, drawText, clearText } from 'vb';
class FpsCounter extends VBComponent {
frames = 0;
elapsed = 0;
update(dt: number) {
this.frames++;
this.elapsed += dt;
if (this.elapsed < 1) return;
drawText(20, 8, 38, `${this.frames} fps`);
this.frames = 0;
this.elapsed = 0;
}
onDestroy() {
clearText(20);
}
}
const hud = createNode(FpsCounter);
hud.name = 'fps counter';
update runs once per drawn frame with the time since the last frame. After one second the component shows how many frames it counted. See Components.
8. A CON event listener
Stops a player from jumping while that player’s health is below 25.
import { on, getActor, setGamevar } from 'vb';
on('EVENT_JUMP', (e) => {
const health = getActor(e.sprite, 'extra') ?? 0;
if (health < 25) setGamevar('RETURN', 1, e.sprite, e.player);
});
The engine fires EVENT_JUMP when a player starts a jump. e.sprite is that player’s sprite and extra is its health. Setting the gamevar RETURN to a non-zero value tells the engine to cancel the jump. See CON events. This mod changes the game world. In multiplayer every player needs it.
9. A fetch call
Downloads a web page when the mod starts and logs the status code and the length of the body.
import { on, log } from 'vb';
on('start', async () => {
try {
const response = await fetch('https://example.com/');
const body = await response.text();
log(`HTTP ${response.status}, ${body.length} characters`);
} catch (err) {
log(`request failed: ${err}`);
}
});
The try/catch is inside the async function on purpose. A rejected promise that nothing handles closes the game. See Promises and errors.
10. A UDP socket
Opens a UDP socket on the local computer, sends itself one datagram and logs what arrives.
import dgram from 'dgram';
import { log } from 'vb';
const PORT = 40123;
const socket = dgram.createSocket('udp4');
socket.on('message', (message, rinfo) => {
const text = String.fromCharCode(...message);
log(`UDP ${rinfo.address}:${rinfo.port} says: ${text}`);
});
socket.bind(PORT, '127.0.0.1', () => {
socket.send('ping', PORT, '127.0.0.1');
});
message is a Uint8Array. String.fromCharCode(...message) turns plain ASCII bytes into a string. The socket is stored in a top-level constant so that it stays open. To receive from other computers, bind to '0.0.0.0' instead of '127.0.0.1'. See dgram.
11. A player list on the HUD
Shows the index and name of up to eight players while a level is being played.
import { on, session, drawText, clearText } from 'vb';
const FIRST_ID = 100;
const MAX_LINES = 8;
on('frame', () => {
const s = session();
for (let i = 0; i < MAX_LINES; i++) clearText(FIRST_ID + i);
if (s.started === false) return;
s.players.slice(0, MAX_LINES).forEach((p, i) => {
const tag = p.isHost ? ' (host)' : '';
drawText(FIRST_ID + i, 8, 50 + i * 9, `${p.index}: ${p.name}${tag}`);
});
});
session() returns a fresh snapshot each time it is called. The example clears its eight text ids every frame and draws the current players again, so the list follows players who join and leave.
Debugging with VS Code
Script mods can be debugged with real breakpoints. The mod generator writes everything VS Code needs into the project’s .vscode folder.
This page covers the VS Code setup, the game’s debug options, the in-game DevTools, and how script errors are reported.
What you need
- A project made with
--gen-tsor--gen-js. See Quick start. - Visual Studio Code.
- Node.js on your
PATH. The debug adapter is a small Node.js program. The game itself does not need Node.js. - A normal desktop build of the game (SDL2 with OpenGL). Other builds have no debug connection.
Open the project folder in VS Code, for example autojs/my-mod. Do not open the folder above it.
Platforms
- Linux: the complete flow on this page is verified: generate a project, launch through the adapter, stop at a breakpoint in
index.ts, read the stack and the variables, evaluate, continue, disconnect. - macOS: the debugger was first written for macOS.
- Windows: the debug connection is built into the Windows version too, but debugging is not yet tested on Windows.
The files in .vscode
| File | Purpose |
|---|---|
launch.json | Two debug configurations: launch the game, or attach to a running game. |
tasks.json | One task that starts the debug adapter before a debug session. |
vibebuild32-debug-adapter.js | The debug adapter. It translates between VS Code and the game. |
vibebuild32-start-debug-adapter.js | Starts the adapter in the background and waits until it is ready. |
README.md | A short guide. |
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch VibeBuild32",
"type": "node",
"request": "launch",
"debugServer": 4714,
"preLaunchTask": "VibeBuild32: Start VS Code debug adapter",
"gameExecutable": "${workspaceFolder}/../../vibebuild32",
"cwd": "${workspaceFolder}/../..",
"debugPort": 8501
},
{
"name": "Attach to running VibeBuild32",
"type": "node",
"request": "attach",
"debugServer": 4714,
"preLaunchTask": "VibeBuild32: Start VS Code debug adapter",
"debugPort": 8501
}
]
}
debugServer: 4714tells VS Code to talk to a debug adapter that is already listening on port 4714.preLaunchTaskstarts that adapter first.gameExecutableis the program to start. The default points two folders up from the project, because a generated project lives in<folder>/autojs/<name>/and the game is expected in<folder>. Change it if your executable is somewhere else.cwdis the folder the game is started in. It must be the folder that containsautojs/, or the game will not find your mod.debugPort: 8501is the port of the game’s debug connection.
tasks.json
{
"version": "2.0.0",
"tasks": [{
"label": "VibeBuild32: Start VS Code debug adapter",
"type": "process",
"command": "node",
"args": ["${workspaceFolder}/.vscode/vibebuild32-start-debug-adapter.js", "--port", "4714"],
"options": { "env": { "NODE_OPTIONS": "" } }
}]
}
The task runs node. If Node.js is not installed, the task fails and the debug session does not start.
The debug adapter
- The start script checks whether an adapter already answers on port 4714. If not, it starts
vibebuild32-debug-adapter.jsas a background process and waits until it accepts connections. Then the task ends and VS Code continues. - The adapter has no dependencies. There is nothing to
npm install. - The adapter serves one debug session and then exits. If no session starts within 60 seconds, it exits too.
- The adapter listens only on the local computer.
Ports
| Port | Used for | Where it is set |
|---|---|---|
| 4714 | VS Code ↔ debug adapter | --port in tasks.json and debugServer in launch.json. Both must be the same number. |
| 8501 | Debug adapter ↔ game | debugPort in launch.json, and the port of the game’s --debug option. |
Both connections are local (127.0.0.1). If another program uses port 4714, the task fails with VibeBuild32 DAP adapter did not start on port 4714. Choose another port and change it in both files.
The two debug configurations
Launch VibeBuild32
- Set breakpoints.
- Choose Launch VibeBuild32 in Run and Debug and press F5.
The adapter starts the game with the single option -dbg and waits for its debug connection. VS Code then sends your breakpoints. Only after that does the game load your scripts. Breakpoints in top-level code and in start handlers therefore work.
Pressing Stop ends the game.
The game is started with -dbg and nothing else. To choose a game, data files or a map, use the vbd.params directive.
Attach to running VibeBuild32
- Start the game yourself with
--debug(or--devtools). - Choose Attach to running VibeBuild32 and press F5.
Attach within the first few seconds after the game starts if you want breakpoints in top-level code or in start handlers. The game holds your scripts back for about five seconds to give you that chance. See When scripts start in debug mode. If you attach later, debugging works, but that code has already run.
Stop or Disconnect ends the debug session and leaves the game running. Continue the game first if it is paused.
Game options for debugging
| Option | Effect |
|---|---|
--debug, -dbg | Opens the debug connection on port 8501. Skips the game picker and the startup window. Scripts start later than usual, see below. |
--debug <port>, -dbg <port>, -dbg<port> | The same on another port. Change debugPort in launch.json to match. A custom port is read by the Duke runtime games. |
--devtools, -dt | Everything --debug does, plus the in-game DevTools. Forces windowed mode. |
When scripts start in debug mode
Without --debug, the game loads scripts 30 frames after it starts.
With --debug or --devtools, the game gives a debugger time to connect:
- If the VS Code debug adapter contacts the game, the game waits until VS Code has sent your breakpoints and finished its setup. Then it loads the scripts. There is no time limit for this step.
- If no adapter contacts the game, the scripts are loaded after 300 frames. That is about five seconds at 60 frames per second.
- If VS Code attaches after the scripts were loaded, you can still debug. Top-level code and
starthandlers have run by then.
There is no reason to add --debug to a normal launch. It delays your scripts and opens a local debug port.
Launch arguments: the vbd.params directive
The Launch VibeBuild32 configuration cannot pass game arguments. Put them into your entry file instead, as a special comment near the top:
/// vbd.params="--game duke --grp ~/games/duke3d/duke3d.grp --skip-cinema"
import { on, log } from 'vb';
When the game is started in debug mode, it reads this line and adds the arguments to its own command line.
Rules:
-
The line starts with three slashes:
/// vbd.params=…. -
It must be in the comment block at the top of the file. Only
//comment lines and empty lines may come before it. It must be within the first 32 lines. -
The value is split into arguments at spaces. The quotes around the whole value are optional. Use inner quotes for an argument that contains spaces:
/// vbd.params="--game sw --grp '/home/me/Shadow Warrior/SW.GRP'" -
A backslash keeps the next character as it is.
-
An argument that starts with
~/gets your home folder. -
The arguments are not run through a shell. Variables and wildcards are not expanded.
-
The directive is only read when the game starts with
--debug,-dbg,--devtoolsor-dt. In a normal launch it is an ordinary comment. -
The game reads it from
index.ts(orindex.js) of every project in theautojsfolder of the folder it was started in. It is not read from files given with--js.
The generated starter contains the directive as an inactive example:
// /// vbd.params="-gm duke -g ~/games/duke3da/duke3d.grp -sc"
Remove the leading // and adjust the paths to activate it.
Setting breakpoints
Click in the gutter left of a line, as in any VS Code project.
Breakpoints work in entry files: index.ts, index.js, and files loaded with --js. They currently do not stop in:
- files loaded with a relative
importorrequire, such asimport './util.ts'. The game keeps the./in the path it records for the file, so the path is not the one VS Code sends. You can still step into such a file from a breakpoint in the entry file. - map script components.
Further rules:
- A breakpoint stops the game when the line is about to run. While it is stopped, the whole game is frozen.
- A breakpoint on a line that has no code of its own stops on the line directly below it.
- Only plain line breakpoints exist. A condition, a hit count or a log message is ignored: the breakpoint always stops.
- VS Code shows every breakpoint as confirmed, even on a line that never runs.
- The file path must be exactly the path the game loaded. The game resolves links to the real location. If you open the project through a symbolic link, breakpoints may not stop.
- Limits: breakpoints in up to 64 files, up to 128 per file.
- In TypeScript files, line numbers after a multi-line
interfaceortypedeclaration are shifted. See Line numbers.
Stepping and inspecting
While the game is stopped at a breakpoint:
| Action | Supported |
|---|---|
| Continue, Step Over, Step Into, Step Out | Yes |
| Call stack with function name, file and line | Yes |
| Variables in three scopes: Local, Closure, Global | Yes, as text |
| Hover over a variable name | Yes |
| Watch expressions and the Debug Console input | Limited, see below |
| Pause a running game | No |
| Stop on exceptions | No |
| Changing a variable’s value | No |
How variables are shown:
- Each value is shown as text. Objects and arrays appear in JSON form and cannot be expanded.
- Functions and variables whose value is
undefinedare not listed. - Closure lists the outer variables that the current function uses, such as top-level
letandconstof your module.
How expressions are evaluated:
- A single name, such as
frames, is looked up in the Local and Closure variables of the selected stack frame. This is what hovering uses. - Any other expression is evaluated as global code. It cannot see local variables or the top-level variables of your module.
vb.player()works.frames + 1does not.
Other things to know:
log()output does not appear in VS Code. Read the game log,vibebuild32.log.- When the game exits, the debug session ends.
In-game DevTools
Start the game with --devtools (or -dt) to open a DevTools view next to the game.
--devtools includes --debug. You can use DevTools without VS Code: the scripts then start about five seconds after the game. You can also attach VS Code at the same time. See When scripts start in debug mode.
What the view is depends on the platform:
| Platform | DevTools view |
|---|---|
| Linux, Windows | A second window, VibeBuild32 JavaScript DevTools. |
| macOS | A page in a Google Chrome app window. Google Chrome must be installed. |
| Builds without OpenGL | A read-only console panel drawn over the game. |
The DevTools window (Linux and Windows)
- A status line: Running, or PAUSED at … with a Resume button.
- Console tab: the 12 most recent log lines, and an Evaluate field with a Run button.
- Scope tab: short hints.
- Closing the window hides it for the rest of the session.
The Evaluate field runs an expression as global code and shows the result as JSON text. For example vb.player() or globalThis.myValue. It cannot see the top-level variables of your modules. Store a value on globalThis if you want to inspect it.
An expression that throws an error is treated like any other script error: the game shows the error and closes. Type carefully.
The DevTools page (macOS)
- A list of the loaded entry scripts. Click one to see its source with line numbers.
- Click the circle left of a line to set or clear a breakpoint.
- Continue, Step over, Step into, Step out.
- The paused location, the call stack and the variables of the selected frame.
- The most recent log lines.
- A field to evaluate an expression.
Press Command+Option+I in the game window to bring the page to the front.
The breakpoint() function
breakpoint() is a function of the vb module. It pauses your scripts from code:
import { on, breakpoint, log } from 'vb';
on('levelChanged', () => {
log('pausing scripts');
breakpoint();
});
- It only works when the game was started with
--devtools. Otherwise it does nothing. - It does not freeze the game, and it does not stop in the middle of a function. The current function runs to its end.
- After that, no events, timers,
fscallbacks, promise continuations or component updates are delivered. Network results still arrive: socket listeners keep running. - The DevTools window shows PAUSED at vb.breakpoint(). Click Resume to continue.
The Resume button is part of the DevTools window on Linux and Windows. The DevTools page on macOS has no such button. On macOS use breakpoints in the source instead.
How errors are reported
A script error that nothing catches is fatal. This applies to:
- a syntax error, or an error at the top level of a file while it is loaded,
- an error thrown in an event handler, a timer, a socket listener, an
fscallback, a chat command handler or a component method, - a rejected promise that has no handler. See Promises and errors.
When that happens, the game:
- Writes the message and the stack trace to the game log, prefixed with
[js]. - Copies the full text to the clipboard.
- Shows a dialog titled VibeBuild32 JavaScript Error with the message and the stack trace.
- Exits after you close the dialog.
The message names the place, for example failed to load /…/index.ts, uncaught exception in frame handler #1 (disabled) or unhandled promise rejection. The stack trace lists file names and line numbers.
Notes:
- Despite the word
(disabled)in the message for event handlers, the game does not switch the handler off and carry on. It always exits. Usetry/catchwhere an error is acceptable. - A script file that cannot be read is only logged (
could not read …). The game continues without it. - For TypeScript files, a syntax error is reported by the JavaScript engine after the types have been removed. If the message makes no sense, the cause is often a construct the converter does not handle. See TypeScript support and its limits.
- On a server, a script error stops the server. See Errors stop the server.
Launch options
Launch options are the words you add after the program name when you start NNBuild. This page lists them by purpose.
vibebuild32 --game duke --skip-menu --volume 1 --level 3
How options are read
NNBuild reads options in two steps.
- The launcher runs first. It is the same for every game. It picks the game, handles the options marked All below, and rewrites a few options so that every game understands them.
- The runtime of the chosen game reads the rest. A runtime is the part of NNBuild that runs one game or one family of games. Each runtime has its own options.
The tables use these names for the runtimes:
| Name in the tables | Games |
|---|---|
| Duke | Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM, WWII GI |
| SW | Shadow Warrior |
| Blood | Blood |
| RR | Redneck Rampage |
| Exhumed | Exhumed / PowerSlave |
| All | Handled by the launcher, for every game |
Writing options
- Long names start with two dashes (
--game). Short names start with one (-gm). - A value follows its option as the next word:
--game duke. You can also write--game=duke. - Some short options accept the value attached:
-l3,-v1,-g/path/file.grp,-res1280x720. Where this works, the table says so. - A value can be attached to a long name only when it is a number or a path:
--level1,--grp/path/file.grp. Anything else needs a space or=. - Give full paths for files and folders. NNBuild changes folder before the game starts, so a path relative to where you typed the command may not be found.
- Put
-netlast. Everything after-netbelongs to the network setup. See The-netblock. - Use the spelling shown in the tables. Many options have older spellings, but not all of them are understood by every game.
Help
| Option | Runtime | What it does |
|---|---|---|
-?, -help, --help | Duke, Exhumed | Shows the option list of that runtime. Depending on the game and the system it appears in a message box or in the log. |
-?, -h, -help | SW, Blood, RR | The same, for these runtimes. |
-debughelp | Duke, RR | Shows the developer options. |
NNBuild picks the game before any help is shown, so add --game <name> to get
the help of a particular runtime.
Choosing the game
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--game | -gm, -game | game name | All | Chooses the game. Names are listed in Supported games. The value may be attached to -gm (-gmduke). |
--skip-menu | -sm | All | Skips the game picker and the startup window. | |
--no-game-menu | -ngm, -nogamemenu | All | Skips only the game picker. The first installed game is used. | |
--menu | -m, -setup | All | Shows the startup window even when it would be skipped. | |
-nosetup | All | Skips the startup window. --skip-menu adds this for you. | ||
--skip-cinema | -sc, -nologo | All | Skips the logos and intro movie. | |
-quick | SW, Blood, Exhumed | Skips the intro screens. |
What these do step by step is described in First launch.
Game data and mods
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--gamegrp | -gamegrp | file | Duke, SW, RR, Exhumed | Names the main data file of the game. Also used to pick the game. |
--grp | -grp, -g | file | All | Loads a data file. Also used to pick the game. The value may be attached to -g. See the notes below. |
--game-dir | -game_dir | folder | Duke, SW, Blood, RR | Names the game’s data folder. Also used to pick the game. In Duke, Blood and RR it becomes the folder for custom content. |
--search-path | --path, -j | folder | All | Adds a folder to search for files. Also used to pick the game. The value may be attached to -j. |
--rff | -rff | file | Blood | Uses another main .rff archive. |
--ini | -ini | file | Blood | Uses another episode .ini file. |
-snd | file | Blood | Uses another sound .rff archive. | |
-art | file | Blood | Uses another base art file name. | |
--con | -x | file | Duke, RR | Loads another main CON script. CON is the script language of these games. |
-mx | file | Duke, RR | Loads an additional CON script module. | |
--def | file | Duke, RR | Loads another definitions (.def) file. | |
-h<file> | attached | Duke, SW, RR | The same as --def, with the file name attached: -hmy.def. | |
-h | file | Exhumed | Loads another definitions file. | |
-mh | file | Blood, RR, Exhumed | Loads an additional definitions module. In SW attach the name: -mhextra.def. | |
-rts | file | Duke, RR | Loads another Remote Ridicule (.rts) sound bank. | |
-noautoload | Duke, Blood, RR, Exhumed | Does not load files from the autoload folder. | ||
-addon0, -addon1, -addon2 | SW | Starts Shadow Warrior, Wanton Destruction or Twin Dragon. | ||
-addon | number | RR | Selects a numbered add-on. | |
-kex | folder | Exhumed | Turns on KEX mode and names the PowerSlave Exhumed install folder. | |
-nam, -napalm, -ww2gi | Duke | Older way to switch the runtime to NAM, NAPALM or WWII GI. Prefer --game. |
Notes on --grp:
- When the file is the main data file of World Tour, Ion Fury, NAM, NAPALM,
WWII GI, Redneck Rampage or Exhumed, the launcher treats it like
--gamegrp. - When the file belongs to a different game than the one running, it is not loaded as game data. It is kept as a source of levels and art. See Playing one game’s levels in another.
- In Blood, a
.rfffile is passed on as--rffand a.inifile as--ini. - In the Duke runtime, a file given with
--grpthat is not recognised game data is a mod pack. In multiplayer it is offered to the players who join. Recognised game data, such asDUKE3D.GRPor an official add-on, is never offered: every player needs their own copy. - To start an official add-on, name its data file with
--gamegrp.
Playing one game’s levels in another
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--game.levels | -gm.lvls | game name | All | The game the levels come from. Used by the Duke and SW runtimes. |
--game.items | -gm.its | game name | All | The game whose item pickups to use. |
--game.weapons | -gm.wpns | game name | All | The game whose weapon and ammo pickups to use. |
Video
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--window | -wnd | Duke | Starts in a window. | |
--fullscreen | -fscr | Duke | Starts full screen. | |
--resolution | -res | WIDTHxHEIGHT | Duke | Sets the resolution, from 320x200 to 8192x4320. The value may be attached: -res1280x720. |
These options override the saved video settings for this run. In the other games, set the video mode in the game’s own options menu.
Starting a level
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--level | -l | number | Duke, SW, RR | Starts at that level. The value may be attached: -l3. |
--volume | -v, --episode, -e | number | Duke, RR | Starts in that episode. The value may be attached: -v1. |
-level | episode and level | Blood | Starts at that level: -level 1 3. | |
-<n> | Exhumed | Jumps to level n: -3. | ||
-<n> | Duke | Loads the saved game in slot n (0 to 9). Single player only. | ||
-map | file | Duke, SW, Blood, RR, Exhumed | Loads a map file. Not available with shareware data in Duke and SW. | |
--skill | -s<n> | number | Duke, RR | Sets the skill level. |
-s<n> | attached | SW | Skill, 1 to 4. | |
-s | number | Blood | Difficulty, 0 to 4. | |
--monsters | -mnst | number | Duke, Blood | 0 turns monsters off. 1 or more turns them on and sets the skill to that number minus one. In RR only --monsters 0 is supported. |
-monst | SW | No monsters. | ||
-nodudes | Blood | No monsters. | ||
-nocreatures | Exhumed | No enemies. | ||
-name | name | Duke, SW, Blood, RR, Exhumed | Your player name. Blood also accepts -pname. |
Game rules (Duke runtime)
| Option | Other spellings | Argument | What it does |
|---|---|---|---|
-c<n> | --coop | number | Multiplayer game mode: 1 Dukematch, 2 Co-op, 3 Team Dukematch. Attach the number: -c2. |
-t<n> | --respawn | 1, 2, 3 or x | Respawn: 1 monsters, 2 items, 3 inventory, x all. Attach the value: -t2. |
-y<n> | number | Frag limit. Attach the number: -y20. | |
-u<digits> | --weapons | digits | Your preferred weapon order: -u3425689071. |
-wstay | Weapons stay after pickup. | ||
-noffire | Friendly fire off. | ||
-allowvisibility | Allows visibility adjustment in multiplayer. |
-c on its own is a different option: see --cmd below. RR accepts -c<n>,
-t<n> and -u<digits> as well.
Sound, settings and startup commands
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
-nosound | -ns | Duke | Sound effects off. RR accepts -ns. Exhumed accepts -nosound. | |
-nomusic | -nm | Duke | Music off. RR accepts -nm. Exhumed accepts -nomusic. | |
-cfg | file | Duke, Blood, RR, Exhumed | Uses another settings file. | |
-usecwd | All runtimes | Keeps settings in the folder the game runs from and skips the search for installed copies. | ||
--cmd | -c | text | Duke | Runs console commands when the game is ready. Put several commands in one quoted argument, one per line, or repeat the option. |
--cmd-file | -cf | file | Duke | Reads startup console commands from a text file, one per line. Lines that start with # are ignored. |
-cachesize | size in kB | Duke, Blood, RR, Exhumed | Sets the size of the file cache. |
vibebuild32 --game duke --cmd "skin 6" --cmd "echo Ready"
Console commands are listed in Console commands.
Recording and playing demos
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--record | -r | Duke, RR | Records a demo. | |
--playback | -pb | file, optional | Duke | Plays a demo file. .dmo is added when the name has no extension. |
-d<file> | --demo | file | Duke, RR | Plays a demo file. |
--record, --playback | file for playback | SW | Records or plays a demo. -dr<file> and -dp<file> do the same with the file name attached. | |
-record, -playback | Exhumed | Records to or plays from the file DATA.VCR. |
Multiplayer with -net
The Duke, SW and Exhumed runtimes start network games with -net.
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
-net | --net | network words | Duke, SW, Exhumed | Starts a network game. See The -net block. |
--startnow | -sn, -nowait | Duke | Host: start at once with whoever is present, even alone. The other slots stay open and players can join at any time. | |
--startnow | -sn | Exhumed | Host: start with the players who are present. | |
--latejoin | -lj | Duke, Exhumed | Host: let players join while the match is running. | |
--async | -as | Duke | Host: never make everyone wait for one slow player. Only that player feels the delay. Without it, all players wait for each other. | |
--zeroping | Duke | Shows your own shots at once instead of waiting for the server. Each player sets this for themselves. | ||
--nplayers | -np | number | Exhumed, RR | Number of players to wait for before the match starts. The default is 2. |
--netfile | -nf | file | Exhumed, RR | Host: send this file to players who join. Blood accepts --netfile only. |
Rules for the Duke runtime:
--startnowincludes--latejoin.- A host that only gives
-netwaits until every slot is filled. - Mod packs given with
--grpand map files are sent to joining players automatically. There is no--netfilein this runtime.
The -net block
Everything after -net describes the connection. The words can start with /
or -.
| Word | Meaning |
|---|---|
/n0 | Host-and-clients mode: one computer is the host and the others connect to it. |
/n0:<count> | Host in that mode with count player slots, for example /n0:4. |
/n1 | Peer-to-peer mode: every computer connects to every other. |
/n1:<count> | Peer-to-peer with count slots, leaving room for late joiners. |
/p<port> | The UDP port this computer uses, for example /p23513. It must be between 1025 and 65534. The default is 23513. |
| address | A computer to connect to. Any word that is not one of the above is an address. |
An address can be written as:
192.0.2.10or192.0.2.10:23513(IPv4, with or without port),[2001:db8::1]:23513(IPv6 with port) or2001:db8::1(IPv6 alone),host.example.orgorhost.example.org:23513(a name).
Without a port, 23513 is used. An address with no /n word means /n0.
# Host four slots on the default port and start at once
vibebuild32 --game duke --startnow -net /n0:4
# Host on another port
vibebuild32 --game duke --startnow -net /p23600 /n0:4
# Join a host
vibebuild32 --game duke -net /n0 192.0.2.10:23513
# Join when your own port has to differ from the host's (same computer)
vibebuild32 --game duke -net /p23514 /n0 127.0.0.1:23513
In host-and-clients mode the host lists no addresses, and each client lists the host.
In peer-to-peer mode each player lists the addresses of the other players.
All players use the same player order, and the place where /n1 stands among
the addresses is your own place in that order. With three players at
192.0.2.2, 192.0.2.100 and 192.0.2.4:
first player: -net /n1 192.0.2.100 192.0.2.4
second player: -net 192.0.2.2 /n1 192.0.2.4
third player: -net 192.0.2.2 192.0.2.100 /n1
On Linux and macOS you can instead give every player the same list, with all addresses including their own, in any order. NNBuild finds its own address in the list.
In the Duke runtime the slot count includes a dedicated server. A dedicated
server started with /n0:4 has room for three players.
Multiplayer in Blood and Redneck Rampage
These two games do not use -net.
Blood
| Option | Argument | What it does |
|---|---|---|
-server | players | Starts a server for that many players (1 to 8). |
-client | host | Connects to a server. |
-port | number | The server’s port. The default is 23513. |
-clientport | number | The local port a client uses. |
-netretry | Client: keep trying to connect. Hold Escape to stop. | |
-auto | Starts the network game automatically. Also skips the intro. | |
-broadcast, -masterslave | Selects the packet mode. | |
-mp_mode | 0 to 2 | Game mode: 0 co-op, 1 Bloodbath, 2 teams. |
-mp_level | episode and level | Level for the match: -mp_level 1 3. |
-mp_map | file | Map file for the match. |
-mp_mapclient | file | Client: use another map file than the one the server names. |
-mp_diff | 0 to 4 | Difficulty. |
-mp_dudes | 0 to 2 | Monsters: 0 none, 1 spawn, 2 respawn. |
-mp_weaps | 0 to 3 | Weapons: 0 do not respawn, 1 permanent, 2 respawn, 3 respawn with markers. |
-mp_items | 0 to 2 | Items: 0 do not respawn, 1 respawn, 2 respawn with markers. |
-mp_spawn | 0 to 2 | Spawn location: 0 random, 1 smart random, 2 by distance. |
-mp_protect | 0 to 3 | Length of spawn protection. |
-mp_secwind | 0 or 1 | Second wind. |
-mp_score | 1 to 255 | Score or lives limit. |
-mp_time | 1 to 60 | Time limit. |
-mp_noexit | Disables the exit button. | |
-mp_noflag | Removes the flag in teams mode. | |
-mp_chaseview | Allows chase view. | |
-mp_holstering | Allows holstering. | |
-mp_spectating | Allows spectating. |
Blood stops with an “Invalid argument” error when it is given an option it does not know. Only use options listed for Blood on this page.
Redneck Rampage
| Option | Argument | What it does |
|---|---|---|
-server | Starts a server. | |
-connect | host or host:port | Connects to a server. |
-port | number | The port to host on or connect to. The default is 23513. |
-password | text | The server password. |
--startnow | Server with a window: start the match automatically when enough players are in. | |
--wait | Server without a window: do not start the match automatically. |
Dedicated server
A dedicated server is a copy of the game that only hosts. It has no window, graphics or sound.
| Option | Other spellings | Runtime | What it does |
|---|---|---|---|
--dedicated | -dd | Duke, RR, Exhumed | Runs as a server without a window. |
--headless | -hl, --console | Duke, RR, Exhumed | The same. |
--wait | -w | RR, Exhumed | Do not start the match automatically. |
- Duke. The server reads console commands typed in its terminal. It takes
one of the player slots but does not appear in the match. Combine it with
--startnowand-net. See Dedicated server. - Exhumed. The server starts the match by itself. On Linux and macOS it reads console commands typed in its terminal.
- RR. The server waits for players and starts the match by itself. It has no console in the terminal.
vibebuild32 --game duke --dedicated --startnow -name Server -net /p23513 /n0:8
Lobby server
A lobby server keeps a list of games that players can join. NNBuild can list a game on a lobby server, read the list, and be the lobby server.
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
-masterserver | port, optional | All | Runs NNBuild as a lobby server and nothing else. No game is chosen and no game data is needed. The default UDP port is 23519. | |
--advertise | -ad | address | Duke, SW, RR, Exhumed | Host: list this game on the lobby server at that address. Blood accepts --advertise only. In RR it also starts a server. |
--lobbylist | -ll | address | SW, Blood, RR, Exhumed | Writes the games listed on that lobby server to the log, then continues starting. Blood accepts --lobbylist only. |
--joinlobby | -jl | address | SW, Blood, RR, Exhumed | Joins the first game listed on that lobby server. SW and Blood accept --joinlobby only. |
-masteraddr | address | SW, Exhumed | The lobby server to use for connection help and, in SW, for the server list in the menu. | |
-punchto | address | SW, Exhumed | Client: the host to ask the lobby server for connection help with. |
A lobby address is a host name or IP address, optionally followed by :port.
Without a port, 23519 is used.
# Run a lobby server on the default port
vibebuild32 -masterserver
# The same on another port, on a computer without a display
vibebuild32 --headless -masterserver 24000
# Host a Duke Nukem 3D match and list it
vibebuild32 --game duke --startnow --advertise lobby.example.org -net /n0:4
Notes:
- Write
-masterserverwith one dash. --advertisehas to come before-net.- In the Duke runtime, players find listed games in the Multiplayer menu
or with the
serverlistconsole command. The address the menu asks is the console settingcl_masterserver. See Console commands. - The name shown in the list is the host’s player name (
-name).
Script mods
These options belong to the JavaScript and TypeScript mod system. Mods run in the Duke and SW runtimes. See Modding.
| Option | Other spellings | Argument | Runtime | What it does |
|---|---|---|---|---|
--js | -js | file | Duke, SW | Loads a script file (.js or .ts). Works anywhere on the command line. |
| script file | Duke | A file name ending in .js, .ts, .mjs, .mts, .cjs or .cts, given without an option, is loaded as a script. | ||
--gen-ts | -gts | name, optional | All | Creates a TypeScript mod starter in autojs/<name>/ and exits. No game is started. |
--gen-js | -gjs | name, optional | All | The same for JavaScript. |
--debug | -dbg | port, optional | Duke, SW | Turns on the script debugger connection for VS Code. The default port is 8501. Also skips the menus. The port can be attached (-dbg8600) and is honoured by the Duke runtime. |
--devtools | -dt | Duke, SW | Opens the script DevTools window. Includes --debug. In the Duke runtime it also forces windowed mode. |
Mods in autojs/<name>/index.ts or index.js are loaded automatically. The
autojs folder is looked for in the folder you start NNBuild from. When a name
is left out of --gen-ts or --gen-js, the next free name of the form mod-1,
mod-2 is used.
The index.ts or index.js of a mod in autojs can carry extra launch
options for debugging, in a comment at its top. They are used only when NNBuild
is started with --debug or --devtools:
/// vbd.params="--game duke --gamegrp /home/you/games/duke3d/DUKE3D.GRP"
Map editor and projects
These options belong to the Duke runtime. See Map editor.
| Option | Argument | What it does |
|---|---|---|
--editor | map file, optional | Opens the built-in map editor, with that map if one is named. |
--build-editor | map file, optional | Opens the classic Build editing tools. |
--project | folder or ZIP | Plays a project. With --editor, opens it for editing. |
--project-map | map path inside the project | Chooses which map of the project to play or edit. |
--allow-project-scripts | Lets the script files inside a project ZIP run. They do not run otherwise. |
A project ZIP given without an option is played as a project. This is what happens when you drop the ZIP onto the program.
vibebuild32 --game duke --gamegrp ~/games/duke3d/DUKE3D.GRP --editor
vibebuild32 "/home/you/projects/My Project.zip"
vibebuild32 "/home/you/projects/My Project.zip" --project-map "Maps/Outpost.map"
vibebuild32 --game duke -j ~/games/duke3d --editor --project "/home/you/projects/My Project"
Write these options exactly as shown, with two dashes.
MCP
MCP is an open standard that lets an AI assistant control a program. These options belong to the Duke runtime. See AI assistants and MCP.
| Option | Argument | What it does |
|---|---|---|
--mcp-stdio | Lets an MCP client control this game, server or editor through the program’s standard input and output. | |
--mcp-http | port | The same through a local web address, http://127.0.0.1:<port>/mcp. Only this computer can reach it. |
--editor-mcp | host or host:port, optional | Joins a live map-editing session as an MCP participant instead of starting a game. No game is chosen and no game data is needed. The default host is this computer. Everything after this option belongs to it. |
After --editor-mcp you can give --name <name> for the participant’s label
and --mcp-http <port> to offer it over the local web address instead of
standard input and output.
vibebuild32 --game duke --dedicated --startnow --mcp-http 8787 -net /n0:4
vibebuild32 --editor-mcp 127.0.0.1:23514 --name "Layout Assistant"
Two environment variables protect the web address. When VIBEBUILD_MCP_TOKEN
is set, a client must send that value as a bearer token. VIBEBUILD_MCP_ORIGIN
names one extra web origin that is allowed to connect.
Files given without an option
A file name without an option in front of it is handled by its ending. This is also what happens when you drop a file onto the program.
The launcher looks at such a file first, to work out the game. Then the runtime uses it:
| Runtime | Ending | What happens |
|---|---|---|
| Duke | .map | The map is loaded. |
| Duke | .grp, .zip, .pk3 | Loaded as a data file. A ZIP that is a project is played as a project. |
| Duke | .con | Loaded as the main CON script. |
| Duke | .def | Loaded as the definitions file. |
| Duke | .rts | Loaded as the Remote Ridicule sound bank. |
| Duke | .js, .ts, .mjs, .mts, .cjs, .cts | Loaded as a script mod. |
| Blood | .map, or no ending | The map is loaded. |
| Blood | .grp, .zip, .pk3, .pk4 | Loaded as a data file. |
| Blood | .def | Loaded as the definitions file. |
| RR | .map | The map is loaded. |
| RR | .grp, .zip, .pk3, .pk4 | Loaded as a data file. |
| RR | .con, .def, .rts | Loaded as the main script, definitions file or sound bank. |
| SW, Exhumed | any | Not used by the runtime. Use -map, --grp and -j. |
More options of single runtimes
Shadow Warrior
| Option | Argument | What it does |
|---|---|---|
-nodemo | No demos at the title screen. | |
-nometers | Hides the air and boss meter bars. | |
-nopredict | Turns off network prediction. | |
-f2, -f4, -f8 | Packet duplication in network games. | |
-autonet | ten numbers separated by commas | Starts a network game with preset rules: rules, level, enemies, markers, team play, hurt teammate, kill limit, time limit, colour, nuke. |
--color | colour name or #rrggbb | Your player colour in a network game. Names: brown, gray, purple, red, yellow, olive, green, blue. A #rrggbb value picks the closest of these. |
-movescale, -turnscale | number | Movement and turning scale. 256 means one unit. |
-extcompat | Controller compatibility mode. | |
-nocontroller | Turns controller support off. |
Blood
| Option | Argument | What it does |
|---|---|---|
-nodemo | No demos. | |
-noaim | Turns auto-aim off. | |
-skill | 0 to 4 | Player handicap. This is not the difficulty. |
-setupfile | file | The same as -cfg. |
Redneck Rampage
| Option | Argument | What it does |
|---|---|---|
--players | number | Fake multiplayer with that many players, for testing. |
-rotatesprite-no-widescreen | Stretches screen drawing from scripts to the full screen. | |
-nocontroller | Turns controller support off. |
Exhumed
| Option | Argument | What it does |
|---|---|---|
-color | 0 to 7 | Your player colour in a network game. |
-t<n> | attached number | Time setting for network games. |
Developer options
These are for testing and for the program’s own use.
| Option | Runtime | What it does |
|---|---|---|
-q<n>, --players <n> | Duke | Fake multiplayer with n players on one computer. |
-a | Duke | Simple computer control for the other players in fake multiplayer. |
-w | Duke | Shows your coordinates. |
-condebug, -z<n> | Duke, RR | CON script compile debugging. |
-nD | Duke | Writes the default script variables to a file. |
-unstable | Duke | Turns off the safety checks of the CON script system. |
-stun | Duke | Older UDP hole-punching mode for -net. |
-noinstancechecking | All runtimes | Windows: do not ask when NNBuild is already running. |
-punchtarget, -masteraddr, -joinerror | Duke | Added by NNBuild when it restarts itself to join a game from the menu. |
--content-probe, --content-rejoin, --server-resume | Duke | Added by NNBuild when a server changes its mod pack. |
-validate, -robust, -noresend | Blood | Compatibility test and network checking switches. |
-short, -cheat, -allsync, -cam | SW | Test switches. |
Environment variables
| Variable | What it does |
|---|---|
DUKE3DGRP | Duke runtime: the main data file to use when none is named on the command line. |
DUKE3DDEF | Duke runtime: the definitions file to use when none is named. |
SWGRP | Shadow Warrior: the main data file to use when none is named. |
BLOODDEF | Blood: the definitions file to use when none is named. |
VIBEBUILD_MCP_TOKEN, VIBEBUILD_MCP_ORIGIN | See MCP. |
EDUKE32_LOGSTDOUT | Set to TRUE to write the program’s console output to stdout.txt. |
Console commands
This page lists the console commands and settings that NNBuild adds. The
commands the games already had, such as bind, god or vidmode, are still
there and are not repeated here.
Unless a section says otherwise, everything on this page belongs to the Duke Nukem 3D runtime: Duke Nukem 3D, World Tour, Ion Fury, NAM, NAPALM and WWII GI.
How to enter commands
-
In the game: open the console and type the command.
-
On a dedicated server: type the command in the terminal the server runs in, and press Enter.
-
At startup: give the command with
--cmd, or put commands in a text file and name it with--cmd-file. See Launch options.vibebuild32 --game duke --dedicated --startnow \ --cmd "sv_maprotation 1" -net /n0:8 -
From a script or an AI assistant: see Server scripts and AI assistants and MCP.
A setting (also called a cvar) is a named value. Type its name alone to see the value. Type the name and a new value to change it.
Put quotes around a file name or path that contains spaces.
Who may run a command
Many commands are for the host: the computer that hosts the match. On a
dedicated server that is the server itself. Some commands need the match to be
in host-and-clients mode, which is what -net /n0 starts and what the
Multiplayer menu uses.
| Command or setting | Who may run it | Purpose |
|---|---|---|
listplayers | Anyone in a network game | List the players. |
kick | Host | Remove a player. |
ban | Host | Remove a player and block their address. |
unban | Whoever keeps the ban list | Remove a ban. |
listban | Anyone | Show the ban list. |
map, changemap | Host, for everyone. Otherwise for yourself. | Change level. |
mod | Host, host-and-clients mode | Change mod pack and level. |
nextmap | Host | Go to the next map of the rotation. |
mapcycle | Anyone to view, host to change | View or edit the map rotation. |
maplist | Anyone | View the map rotation. |
sv_maprotation | Host | Turn automatic rotation on or off. |
sendfile | Host | Send a file to all players. |
monsters | Host, or yourself in single player | Remove or allow monsters. |
spawn | Host, or yourself in single player | Add an enemy or item. |
serverlist | Anyone | Print the games listed on a lobby server. |
cl_masterserver | Each player | Which lobby server the menus use. |
cl_preferipv6 | Each player | Prefer IPv6 addresses in the game list. |
skin | Each player | Appear as an enemy in multiplayer. |
cl_mousesmooth | Each player | Smooth the mouse. |
cl_joysmoothing | Each player | Smooth the controller. |
cl_swapjoysticks | Each player | Swap the two controller sticks. |
wt_commentary | Each player | World Tour developer commentary. |
Players
listplayers
listplayers
Shows every connected player with slot number, name and network address. The host is marked. It only works in a network game.
listplayers
Players:
0: Server (this machine) [host]
1: Maya 192.0.2.44:23530
kick
kick <name|slot>
Removes a player from the match. Only the host can use it. Give the slot
number shown by listplayers, or the name. The start of a name is enough, and
upper and lower case do not matter. The host cannot kick itself.
kick 1
kick maya
ban
ban <name|slot|ip>
Removes a player and adds their IP address to the ban list. Only the host can use it. A banned address is refused when it tries to connect.
You can also give an IP address directly. This works before the player connects, and even before you start hosting.
ban maya
ban 192.0.2.44
About the ban list:
- It is saved in the file
banlist.txtand loaded again the next time you host. - It holds up to 256 entries.
- Bans work on IPv4 addresses. A player who is connected over IPv6 cannot be
banned. Use
kickfor that player. - Addresses on your own computer (
127.x.x.x) are never banned.
banlist.txt is a text file with one entry per line: the address, then
optionally the player’s name. Lines that start with # are ignored.
# NNBuild ban list - one entry per line: <ip> <name>
192.0.2.44 Maya
198.51.100.7
unban
unban <ip|name>
Removes entries from the ban list and prints how many were removed. Give the IP address, or the name that was saved with the ban. The start of the name is enough.
unban 192.0.2.44
unban maya
listban
listban
Shows the ban list.
Levels and mod packs
A pack is a file with game content: maps, art, sounds or scripts. Packs
can be .grp, .zip, .pk3, .pk4 or .ssi files. In these commands, the
word base means “the base game with no pack”, and current means “the pack
in use now”.
A level is written either as episode and level, such as E1L3, or as the path
of a map file, such as maps/arena.map.
map and changemap
map <E#L#|map path> [pack|base]
changemap <E#L#|map path> [pack|base]
The two names do the same thing.
- Host of a host-and-clients match: changes the level for everyone. With a second word, it also changes the pack, as described in When the pack changes.
- Single player: loads that level. With no arguments it lists the map files it can find.
- A player who is not the host: starts a vote for the level.
map E1L3
map "maps/User Arena.map"
map "maps/User Arena.map" "packs/arena.pk3"
changemap E2L1 base
When the level is a map file, the host sends it to the players who do not have
it, and the match goes on without a restart. Files that belong to the map go
with it: a map hack file (.mhk), music and map art with the same name as the
map. Players keep them in their netcache folder.
These commands are not available with shareware data.
mod
mod <pack|base> [E#L#|map path]
Switches the server to another pack and starts a level of it. Without a level,
E1L1 is used. Only the host of a host-and-clients match can use it.
mod "packs/arena.pk3" E2L1
mod "packs/arena.pk3" "maps/User Arena.map"
mod base E1L1
mod base goes back to the base game with no pack.
When the pack changes
A pack change can come from mod, from the pack word of map or changemap,
or from a mapcycle entry that names another pack. The same
steps follow in each case.
On the server:
- The server checks the new pack and the level in a separate process. The running match continues meanwhile. The check can take up to a minute.
- If the check fails, the server prints
Could not activate the requested pack and leveland nothing else changes. When the change came from the map rotation at the end of a level, the current level is started again. - If the check passes, the server tells the players, restarts itself with the new pack on the same address and port, and starts the level.
The restarted server keeps the map rotation and its position, the value of
sv_maprotation, the game mode, the skill, the frag limit and the other game
rules. Startup commands that had not run yet are run after the restart. The
server accepts players at any time after the restart, as if it had been
started with --startnow. Script mods start again from the beginning.
For the players:
- The game leaves the match and restarts itself about two seconds later. The player does not have to do anything.
- It connects to the same server again and compares packs with it.
- A pack the player does not have is downloaded. The screen shows
Downloading <file> (1 of 2)with a progress figure. - The player enters the new match.
Downloaded packs are kept in a folder named netcache, next to the settings
file, and are reused next time. A pack is not downloaded when the player
already has a file with the same name and the same content in netcache, in a
folder the game searches, or anywhere below the folder that holds netcache.
Rules for packs:
- A pack is a
.grp,.zip,.pk3,.pk4or.ssifile. - Give its full path, or a path inside a folder the game searches.
- The base game’s own data file cannot be used as a pack and is never sent. Every player needs their own copy of the edition the server runs. A player without that edition cannot join, and the log says that the server uses different base game data.
nextmap
nextmap
Goes to the next entry of the map rotation right away. Only the host can use
it. See mapcycle for how the rotation is filled.
mapcycle
mapcycle
mapcycle list
mapcycle add [pack|base|current] <E#L#|map path>
mapcycle clear
mapcycle reload
Views or edits the map rotation, the list of levels a server plays one after another.
| Form | What it does | Who |
|---|---|---|
mapcycle or mapcycle list | Shows the rotation and marks the current entry. | Anyone |
mapcycle add <level> | Adds a level of the current pack. | Host |
mapcycle add <pack> <level> | Adds a level of another pack, of base, or of current. | Host |
mapcycle clear | Empties the rotation. | Host |
mapcycle reload | Reads maplist.txt again. | Host |
mapcycle add base E1L1
mapcycle add "packs/arena.pk3" E2L1
mapcycle add "packs/arena.pk3" "maps/User Arena.map"
mapcycle list
The rotation holds up to 64 entries. Changes made with this command last until the server is shut down, and they survive a pack change. Editing is possible only in a host-and-clients match, and not while a level change is in progress.
When the rotation reaches an entry that names another pack, the server changes pack as described in When the pack changes.
To keep a rotation between sessions, write it in a text file named
maplist.txt in a folder the game searches, for example the folder the game
runs from. Each line is one entry:
# One level of the current pack
E1L1
E1L2
# Pack first, then level
base E2L1
"packs/arena.pk3" "maps/User Arena.map"
current E3L1
Lines that start with # or ; are ignored.
maplist
maplist
Shows the map rotation. It is the same as mapcycle list.
sv_maprotation
sv_maprotation <0|1|2>
A setting that controls what happens when a level ends in a network game.
| Value | Meaning |
|---|---|
0 | Off. This is the default. |
1 | Play the rotation in order. |
2 | Pick a random entry of the rotation. |
Only the host can change it. The other players are told the new value.
sv_maprotation 1
sendfile
sendfile <name>
Sends a file to every connected player. Only the host can use it. Players keep
received files in their netcache folder. A player who already has an
identical copy does not download it again. Base game data is refused.
sendfile "extras/readme.txt"
Changing the match
These two commands change the level that is running, for all players at the same moment. In a network game only the host can use them. They also work in single player. You have to be in a level.
monsters
monsters off
monsters on [skill]
monsters <skill>
monsters offremoves every monster from the level and keeps monsters switched off.monsters onswitches monsters back on. With a skill number it also sets the skill. It does not put removed monsters back into the level that is running.monsters <skill>is short formonsters on <skill>.
Skill numbers start at 1.
monsters off
monsters on 3
spawn
spawn <tile> <player>
spawn <tile> <x> <y> [z]
Adds an enemy, weapon or item to the level.
<tile>is a tile number, or a name defined by the game’s scripts, such asLIZTROOPorSHOTGUNSPRITE.<player>is a player’s name or slot number. The object appears a short distance in front of that player.<x> <y> [z]are map coordinates. Withoutzthe object is placed just above the floor.
spawn LIZTROOP maya
spawn SHOTGUNSPRITE 1
spawn 1680 2048 -4096
Lobby
A lobby server keeps a list of games that players can join. See Lobby server.
serverlist
serverlist [address]
Asks a lobby server for its list and prints one line per game: address,
players, map and name. Without an address it asks the lobby server set in
cl_masterserver.
serverlist
serverlist lobby.example.org
cl_masterserver
cl_masterserver <host[:port]>
A setting with the address of the lobby server the menus use. Join Game
reads its list from this address, and Host Internet Game lists your game
there. The default is 127.0.0.1. Without a port, 23519 is used.
cl_masterserver lobby.example.org
cl_masterserver lobby.example.org:24000
cl_preferipv6
cl_preferipv6 <0|1>
A setting for the game list. When a game is listed with both an IPv4 and an
IPv6 address, 1 connects over IPv6 and 0 over IPv4. The default is 0.
Player appearance
skin
skin <0-9>
A setting that chooses how other players see you in multiplayer. It changes your looks, not how you play.
| Value | Skin |
|---|---|
0 | Duke |
1 | Assault Trooper |
2 | Assault Captain |
3 | Octabrain |
4 | Assault Commander |
5 | Enforcer |
6 | Pig Cop |
7 | Alien Beast |
8 | Lo Wang |
9 | Shelly |
If the art for a skin is not in the loaded game data, you appear as Duke. The Alien Beast, for example, is not part of the 1.3D data. Lo Wang and Shelly need the data of their own games to be loaded.
skin 6
To set a skin when you start the game:
vibebuild32 --game duke --cmd "skin 6"
Input
These three settings exist in every game of NNBuild, not only in the Duke
Nukem 3D runtime. Each is 0 (off, the default) or 1 (on).
cl_mousesmooth
cl_mousesmooth <0|1>
Smooths mouse movement by averaging each movement with the one before it.
cl_joysmoothing
cl_joysmoothing <0|1>
Smooths looking and turning with a controller.
cl_swapjoysticks
cl_swapjoysticks <0|1>
Swaps the left and right sticks of a game controller.
cl_swapjoysticks 1
World Tour
wt_commentary
wt_commentary <0|1>
A setting that shows and enables the developer commentary markers of World
Tour. The default is 0. It has an effect only when the game is World Tour.
wt_commentary 1
Other runtimes
say (Exhumed)
say <text>
Sends a chat message to the other players. It exists while a network game of Exhumed / PowerSlave is running. A server without a window uses it to talk to its players.
say The next level starts in one minute
KEX control names (Exhumed)
In KEX mode, the console accepts
the control names used by the PowerSlave Exhumed remaster, so that key
bindings written with those names work: automap, jump, strafeleft,
backward, +use, forward, straferight, +weapprev, +weapnext,
mapzoomout, inventoryscreen, mapzoomin, turnleft, turnright,
attack, weaponwheel and weapon.
saveboard (classic Build tools)
saveboard
Saves the map that is open in the classic Build editing tools. See Classic Build tools.
Building from source
NNBuild is built with GNU Make. The target is named vibebuild32, after the
project’s earlier name, and produces a program file of the same name.
git clone https://github.com/aabluedragon/nnbuild.git
cd nnbuild
make -j8 vibebuild32
A plain make vibebuild32 builds every game runtime into the one program. To
leave one out, pass WITH_SW=0, WITH_BLOOD=0, WITH_RR=0 or
WITH_EXHUMED=0.
The release builds are produced by the workflow in
.github/workflows/build.yml, which is the reference for the exact commands
on each platform.
Linux
Install the compiler and libraries. On Debian or Ubuntu:
sudo apt install build-essential nasm pkg-config \
libsdl2-dev libflac-dev libogg-dev libvpx-dev libcurl4-openssl-dev \
libgl1-mesa-dev libglu1-mesa-dev libasound2-dev
Then build:
make -j"$(nproc)" vibebuild32
Useful options:
| Option | Effect |
|---|---|
HAVE_FLAC=0 | Build without FLAC audio support; the FLAC library is then not needed. |
USE_LIBVPX=0 | Build without VP8 video support; the VPX library is then not needed. |
FLAC_LIBS="-l:libFLAC.a -l:libogg.a" | Link FLAC statically, so the program runs on distributions that ship a different FLAC version. |
VPX_LIBS="-l:libvpx.a" | The same for VPX. |
RELEASE=0 | Debug build. |
The curl library is only needed for building. At run time it is loaded when a
script first calls fetch; without it, fetch reports an error and everything
else works.
Windows
The Windows builds are cross-compiled on Linux with MinGW-w64. The libraries
they need are already in the repository under platform/Windows.
On Ubuntu, for the 64-bit build:
sudo apt install make nasm g++-mingw-w64-x86-64-posix
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
make -j"$(nproc)" PLATFORM=WINDOWS CROSS=x86_64-w64-mingw32- vibebuild32
For the 32-bit build, use g++-mingw-w64-i686-posix and
CROSS=i686-w64-mingw32-. Give each build its own object directory if you
build both from one checkout, for example obj=obj-win32.
The POSIX-threads flavour of MinGW (the -posix packages) is required.
macOS
Install the Xcode command line tools and the libraries with Homebrew:
xcode-select --install
brew install sdl2 flac libogg libvpx
make -j"$(sysctl -n hw.ncpu)" vibebuild32
The build also creates an application bundle next to the program file.
Packaging
platform/package.sh assembles a release archive from a finished build:
sh platform/package.sh linux-x64
Targets are linux-x64, linux-arm64, windows-x64, windows-x86,
macos-arm64 and macos-x64. The archive is written to dist/. On macOS the
script needs dylibbundler (brew install dylibbundler) to carry the
libraries inside the application bundle.
The documentation site
This site is in the docs/ directory and is built with
mdBook:
mdbook serve docs # preview at http://localhost:3000
mdbook build docs # write the site to docs/book
How several games fit in one program
Each extra game (Shadow Warrior, Blood, Redneck Rampage, Exhumed) is compiled on its own and then prelinked into a single object file. Any symbol that an earlier game also defines is made private to that object, so the games do not interfere with each other. A small launcher picks the game at start-up and routes the engine’s callbacks to it.
The prelink step differs by platform: macOS uses its linker’s
-unexported_symbols_list; Linux uses a relocatable link followed by
objcopy --localize-symbols; Windows does the same and additionally renames
some sections (see platform/pe-private-sections.sh). Because this step needs
real machine code, link-time optimisation is switched off for this target
everywhere except macOS.