Planning to plan: Setting up your development environment
Introduction
Setting up your Quake modding for DarkPlaces development environment (or any development pipeline) is one of the first crucial steps in any project and this is simply getting the source code compiling, the game running and the ability to create test levels.
Also be sure to check out other resources available on setting up a basic Quake mod, such as this one which provides links to other source bases and provides additional information about some of the differences between said codebases.
What you’ll need
Unless you’re going completely from scratch, you’ll need the Quake 1 game content to get started. Aside from the base game, we’ll need to gather some more things:
-
Some base code to build from like this codebase by NumberSix which provides a more cleaned up and modern version of the original codebase, however it can be a bit advanced, otherwise as mentioned in the previously linked article, there is the original progs 1.06 codebase.
-
FTEQCC download page and docs to compile QuakeC code. FTEQCC is basically the ‘industry standard’ QuakeC compiler (imho). There’s another one called GMQCC another article that goes more in depth on that. I’ve not used GMQCC, so I have nothing to say about it as I’ve only ever used FTEQCC.
I would like to note that engines like DarkPlaces and FTE have support for 3 self contained modules known as:
NOTE: At time of writing it should be pointed out that FTE is a lot more robust in terms of CSQC.
-
progs.dat which is the compiled game code, this is considered server side or SSQC (as was only supported by the original game).
-
csprogs.dat (CSQC) which runs separately on the client.
-
menu.dat which overrides the built in menu contained in the executable.
You’ll also need:
-
A text editor of choice, I’ve found Notepad++ with C syntax highlighting works just fine for QC, but it’s up to you.
-
Shaders were introduced with Quake 3: Arena and are simple text files used by both the tools as well as the engine to define how a surface behaves and appears in the game. This is everything from animations to transparency to even defining surface information for footstep sounds and impacts. At the very least you’ll need the common ones which provide clipping, setting origins on some brush entities and even some more advanced stuff like terrain blending. There are also some fun built-in shader keywords in DarkPlaces for doing advanced rendering like reflective and refractive water, controlling gloss exponent and cubemap reflection mapping for shiny surfaces (see the shader section below on getting this set up).
Don’t forget to grab some optional code bases if you want your own client and menu modules:
-
You can follow this guide for getting your own basic client module set up or this and this.
-
OPTIONAL Menu QC this is a basic menu (and I think optional client module as well) similar to the original Quake menu but also comes with mouse support!
NOTE: I don’t have a lot of CSQC or Menu experience so pretty much all of the tutorials on this site pertain to SSQC. But I wanted to make sure something was included here for now.
- A level editor (see below).
Installation
This is focused on Windows but should hopefully translate to other OS’s.
After a clean installation of Quake under a directory like C:\Quake your folder structure should look something like this (we’ll get to the NetRadiant/TrenchBroom stuff later)…
C:\Quake
├── id1
├── NetRadiant/Trechbroom
├── Q3Map2Build/Q3Map2
├── Yourmod
│ └── src
│ └── src/client (optional)
│ └── src/menu (optional)
└── Darkplaces.exe, etc...
Common shaders
As mentioned above, in order to take advantage of Q3BSP, you’ll needs to add some common map editing shaders.
For starters you’ll need this file
NOTE: These files were taken from the NetRadiant Q3 package and slightly modified for use in a DP mod (although should work for anything using Q3BSP). Also note that not all of these shaders might apply to DP but were included anyway.
Unzip this file into the root of the yourmod folder so it looks like this:
C:\Quake
├── Yourmod
│ └── textures/common
│ └── scripts
└── Darkplaces.exe, etc...
Inside the scripts folder you should see a file called shaderlist.txt. This file lists the .shader files used by Q3Map2, in this case only common.shader is loaded, which will tell the tools how certain textures used in levels should behave during compile, like clips, etc…
I plan to eventually do a more in depth article on shaders at a later date (at time of writing).
Additional models
The entities.ent file makes reference to a few models that are distributed with NetRadiant-Custom (.bsp based models), included here for convenience. Drop the .pak into your yourmod folder.
Making Levels
Before you set up any map editing tools for a custom mod you’ll need a few items:
- Ibuprofen or acetylsalicylic acid.
- Glass of water.
There are a few popular options for making levels, any Quake 3 level editor will work however here are 2 that are quite popular at the time of writing:
NOTE: At the time of writing, TrenchBroom doesn’t support curved surfaces, opinions are divided about whether they’re worth even using at all. I personally find them very useful for doing things like pipes and railings, rocky terrain surfaces etc… But it’s up to you.
NetRadiant is based on the long line of Radiant editors but it’s not the easiest to use.
For beginners I would recommend the more recent Trechbroom which is more user friendly and well supported within the Quake community. Check out Dumptruck_ds’s Quake mapping tutorials to get started using Trechbroom. These tutorials will focus on using the Quake 1 map format but having this down will make using other formats much easier to jump into since the basics of editing geometry and entities are the same.
NOTE: You can also skip all this Q3BSP stuff and just use Quake 1 maps but Q3BSP offers a lot more in terms of advantages (performance, arbitrary collision hulls, surface flags).
NOTE: DarkPlaces supports many different map (or BSP) formats. Quake 1, 2, 3, Half-Life. So, you can optionally stick with those formats and forego any Q3BSP stuff. Some DarkPlaces specific shaders will still work regardless of map format.
- OPTIONAL Q3Map2Build Windows based map compiler GUI.
If you’re not using Windows or just prefer to skip Q3Map2Build, you can always compile maps via batch files. Or bash scripts (or whatever the alternative command script is in your OS of choice).
Map editing with NetRadiant-Custom
If you grabbed NetRadiant, you can download a starter kit here
Extract the archive into your NetRadiant folder so that it looks like this:
C:\NetRadiant
├── NetRadiant/NetRadiant
│ └── games/q1.game
│ └── games/q3.game
│ └── games/etc...
│ └── games/yourmod.game
│ └── q1.game
│ └── q3.game
│ └── etc...
│ └── yourmod.game
And edit the file yourmod.game accordingly to where ever you installed Quake such as:
enginepath_win32="C:/Quake/"
As well as editing anything that says “yourmod” or “your awesome mod” etc… within the yourmod.game folder.
Run NetRadiant and select Yourmod (or whatever you renamed it to) as the game of choice and hopefully it works fingers crossed.
In order to add entities to NetRadiant that you may add to your mod, edit the file yourmod.game/yourmod/entities.ent.
Troubleshooting:
NOTE: If for any reason you messed up on the engine path, NetRadiant will keep that original path. It saves this information within settings/1.5.0/yourmod.game inside local.pref with this little ditty:
<epair name="EnginePath">D:/path/to/Quake/</epair>
So, you can either delete the entire settings/1.5.0/yourmod.game or just update that one entry.
When you start up NetRadiant, you may or may not see any entities, i.e, right clicking will only show worldspawn and there will be no textures. This is becuase we’ve stacked youmod on top if Id1 as a mod, similar to how Team Arena is recognised when setting up Quake 3 for mapping. To remedy this simply go to File->Project Setting and change “Quake id1” to “Your awesome mod” (or whatever you called it). Restart NetRadiant and select Your awesome mod as the starup game. If all went well, you should have entities to choose from and some common/ textures.
Map editing with TrechBroom
Similar to NetRadiant you’ll need to create a custom game that will support your mod with TrenchBroom:
-
Make a copy of the folder TB/games/Quake3 and rename it to TB/games/yourmod
-
Edit TB/games/yourmod/GameConfig.cfg to reflect yourmod, such as name, searchpath, etc… Maybe make a nice icon.png to go along with it.
-
TrenchBroom can load the same XML entities file as NetRadiant-Custom, download it separately here and replace the Quake 3 one in your TB/games/yourmod folder.
-
Launch TB and see if Yourmod shows up. You may not have any textures but this is a start.
Making a test map
With either editor, make a basic empty room and texture it with editor/grid256 (included with the common shaders), place a light entity and an info_player_start and for testing later, add a weapon_rocketlauncher pickup.
NOTE: Without an info_player_start entity the level will crash as the game won’t know where to spawn the player.
Save the map to yourmod/maps/test.map.
Compiling your maps
To compile a Q3BSP that the engine can load go to your Q3Map2Build folder and open ‘q3compile.exe’ and configure it.
Alternatively, you can set up paths and compile via batch files which would look something like this:
In your yourmod/maps folder, make a file and call it compile_test.bat and paste the following inside:
"C:\[PATH_TO_Q3Map2]\q3map2.exe" -fs_basepath "C:\QUAKE" -fs_game "Yourmod" -v -meta "C:\QUAKE\Yourmod\maps\[mapname].map"
"C:\[PATH_TO_Q3Map2]\q3map2.exe" -fs_basepath "C:\QUAKE" -fs_game "Yourmod" -vis -v -saveprt "C:\QUAKE\Yourmod\maps\[mapname].bsp"
"C:\[PATH_TO_Q3Map2]\q3map2.exe" -fs_basepath "C:\QUAKE" -fs_game "Yourmod" -light -v "C:\QUAKE\Yourmod\maps\[mapname].bsp"
pause
Make sure to edit the paths accordingly and save. You’ll be able to run this script by double clicking it, or making a handy shortcut to it. Pause is optional, but is always nice to have in order to go over the output to see if there were any problems.
That should be it for the initial map editing setup. Now onto the source code.
Compiling the source code
Inside Yourmod/src should be where the QuakeC files go. These files can be edited in notepad although I’d recommend using Notepad++ or something with C syntax highlighting. Use language->C in Notepad++ (like I do). Or you can use CodeBlocks following this tutorial. You can also use FTEQCC’s GUI compiler.
First, compile the code and see if there are any issues. You can create a batch file inside /src that looks like this:
fteqcc.exe -srcfile progs.src
pause
NOTE: progs.src is a listing of all the files that will be compiled, in order. The compiler essentially sees it as one large file.
After compiling, check inside the root Yourmod folder just above /src to see if a progs.dat was produced (or alternatively you can just see if it spit out any errors).
Launching your mod
If all goes well and there is a newly created progs.dat in your Yourmod folder.
Run your mod using a shortcut:
darkplaces.exe -game Yourmod +map test
After that, try changing something simple like changing the speed of a projectile to make sure everything is working.
Your first QuakeC mod
Open w_weapons.qc and scroll down to:
/*
================
W_FireRocket
================
*/
void() W_FireRocket =
And change:
missile.velocity = aim(self, 1000);
missile.velocity = missile.velocity * 1000;
To:
missile.velocity = aim(self, 10);
missile.velocity = missile.velocity * 10;
10 should be a bit slower than 1000. Save and compile. Then test the map again and fire the rocket launcher to see if that did the trick. If all went well, the rocket should be moving at a much slower speed.
If that didn’t seem to work, retrace your steps. Otherwise, congratulations on your first QuakeC mod!
Taking advantage of some DarkPlaces features
Okay, so what sets DP apart from Quake aside from the above mentioned file formats. Well, you can get a good sense for features within a little file called dpextentions.qc some are documented here. It’s often included in your progs.src right after defs.qc (or you can cherry pick a smaller custom version).
Like any API, it’s good practice to read it over and take note of all the cool stuff you can take advantage of. Like Weird Al says in the song Hardware Store… “would you look at all that stuff!”
We’ll take advantage of some of it in other tutorials on this site, like EF_LOWPRECISION, used to make objects more multiplayer more optimized for objects the server shouldn’t spend as much worry on.
Pre-rolled Quake for DP Starter Kit
If that REALLY didn’t seem to work just download the entire starter kit here.
Starter kit includes:
- Base yourmod folder (shaders, textures and models included)
- Editor files for NetRadiant-custom and Trenchbroom
- Cleaned progs 1.06 source code and FTEQCC
- Basic CSQC and Menu QC
- Batch files for running the game and compiling source code
Links to files mentioned above for convenience:
- Common shader pack
- NetRadiant mod starter files
- Entities.ent for TrechBroom
- NetRadiant Quake1 models
Building and Packaging
Building your mod for distribution is covered in a separate article on build systems.
Additional (and recommended) reading:
I would also recommend learning C (at least just the basics). Knowing some basic C like variables, functions, and different types of data structures like arrays will go a long way in your QuakeC endeavors.
If you’re feeling adventurous you can check out more advanced QuakeC:
That should be it for getting set up. Happy modding!