PAGE_CONTENT = other_viewer.php
Home > Other content > myfirstmod

Tutorial: My First Quake III Arena Mod

If all went well, Quake 3 has now started up, loaded your mod dll's and loaded the q3dm1 map. That's a good start, but we can't actually see a difference with the original game yet since we haven't made any changes to the source code. Before we get to that, there's one last thing that remains to be done. While we have been able to compile dll files, to actually run them requires a manual change in q3config.cfg, which we don't want to do. Also, dll files will only work on Windows based computers and since Quake 3 is available for Mac and Linux as well, we want them to be able to play our mod too.

This is where qvm files come in. These are so-called bytecode files. They aren't exactly fully compiled binaries like dll or executable files are but they are instructions for Quake 3's built in run-time environment. This means that Quake 3's own executable (quake3.exe in the case of Windows) is capable of interpreting the instructions in the qvm files by itself, independent of the operating system it's running on. This allows us to release one set of files for all three systems. It's supposedly more secure as well, since dll files could potentially contain instructions that are harmful for your computer. Compiling qvm files is not hard but ofcourse it requires some additional work to set things up correctly.

Setting up the qvm compiler

Fortunately, id Software has set up some bat files for us to use when compiling qvm files. You can find these batch files in these locations:

These files only need to be tweaked slightly before they work correctly. Starting off with cgame.bat, open this file in a text editor and find the following line:

set cc=lcc -DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1

Change this into the following line:

set cc=..\..\..\bin\lcc -DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui %1

You'll notice that the path to lcc (which is lcc.exe) has been changed to be a relative path. Also, the last include (-I..\..\ui) has been changed to include q3_ui instead of ui. The same must be done for the game.bat file as well.

The q3_ui.bat file requires some more work. First there's the "set cc=lcc" line we found in cgame.bat and game.bat as well. Change the path to lcc here as well. This file already refers to q3_ui as it's last include, so that doens't need to be changed. Finally, all the individual files are called independently by the lcc compiler, so the whole file is littered with lines like these:

lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_main.c

Simply prefix all these lines with ..\..\..\ and you're good to go. Here's an example of the above line after it's been changed:

..\..\..\bin\lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\q3_ui ../ui_main.c

There are a number of these lines that are starting with "rem". These lines can be ignored.

To wrap this up, go to the \bin folder. You'll see that this folder contains 4 exe files: lcc.exe, q3asm.exe, q3cpp.exe, q3rcc.exe. Copy all of these files (except for lcc.exe) to the code\cgame\vm, code\game\vm and code\q3_ui\vm folders. These "vm" folders may not exist yet. In that case, create them. By running the three bat files, the qvm files for their respective projects will be built. The output will be stored in a "\quake3\baseq3\vm" folder on the same harddisk as where the batch file is located.

To get this running as a mod, go back to your testmod folder. Remove the dll files here and create a folder named "vm". Copy all the vm files from the \quake3\baseq3\vm folder to your testmod\vm folder. Open q3config again, and set the vm_ settings back to their original value. Start quake 3 the same way as we did with the DLL's and now your qvm files should be loaded.

NEXT: Getting your hands dirty >>