Quake 3
Running Quake 3 on OS X
Download and install
Quake 3 version 1.32b, aka 132-AltivecTest2. This package includes everything you need to play Quake 3 on OS X
except the game data file 'pak0.pk3'. You can get this off any Quake 3 CD (Mac or PC). It goes into the baseq3 folder (next to the app) along with the other .pk3 files. You'll need the CD registration number. As far as I can tell this version is only available on the net, and it's the latest (and last official) version of Quake 3 for OS X. It doesn't matter what version is on the CD as you'll only need the pak file. This
how-to was helpful in figuring this out.
Once installed, you can delete the 10.1 folder and the Quake3.app (the non-G4 version, if you don't need it).
Run Quake 3. Play.
Building the Sources
Download and decompress the
Quake 3 1.32b sources. There are a few active development communities on the net with their own versions of the sources (
icculus.org, for example), but I wanted to start with the original code as released by id last August. A few small changes are necessary to get the project to build completely with Xcode 2.1.
The project file is located at quake3-1.32b/code/macosx/Quake3.pbproj. Notice that it's an old-school Project Builder project. The first change you have to make is to open it in Xcode and have Xcode convert it. You can throw out the .pbproj file after that.
The project has seven targets:
Quake3 (Application)
Quake3 G4 (Application)
qagame
cgame
ui
Dedicated Server
Dedicated Server G4
Each target has the two standard build configurations: Development and Deployment. Partly because of changes in Xcode and partly as a result of converting the project, some of the build settings are whacked. Edit the build configurations for all of the targets so that these three settings look like this (there are other settings too, but they're okay as-is):
Development:
OPTIMIZATION_CFLAGS = -O0 -fno-inline -fno-inline-functions
OTHER_CFLAGS = -g -Wall -DMACOS_X -DQGL_CHECK_GL_ERRORS -DMISSIONPACK -DBOTLIB -force_cpusubtype_ALL
ZERO_LINK = NO [We hates Zerolinkses, we does]
Deployment:
OPTIMIZATION_CFLAGS = -O2
OTHER_CFLAGS = -DMACOS_X -DMISSIONPACK -DBOTLIB -force_cpusubtype_ALL -faltivec
ZERO_LINK = NO
Build
Quake3 G4 (Application) using the Development build configuration. You'll see a dozen or so warnings but they're benign. You should be able to run this and play Quake.
Modifying the Sources
Something to understand about how the Quake application is organized: the OS X application is just a shell. The real code guts are stored in the .pk3 files as virtual machine code. The Quake engine includes a virtual machine compiler that targets the native platform. The .pk3 files are actually just zip archives, and if you change the extension you can browse them with Stuffit or any zip application. Inside pak0.pk3 you'll find a folder called 'vm' and within it these three files:
cgame.qvm
qagame.qvm
ui.qvm
cgame.qvm is the client program,
qagame.qvm is the server program and
ui.qvm is the pre-game menu system code. Quake loads and compiles them at runtime. In order to change anything substantial in Quake 3 you have to be able to build these and substitute them for the ones in the pak. There's a command-line compiler available that builds the .qvm binaries from the Quake 3 sources, which you would then stuff into a Zip archive, change the extension to .pk3 and put it in the baseq3 folder. This is how real mods are made and it sounds like a pain. Fortunately for experimentation Quake has a development option that eliminates all of this busywork and uses natively compiled bundles.
This is great, but there are two incompatibilities with 10.4 that must be fixed before this works. Open the source file
macosx_sys.m and make these two changes:
@@ -114 +114 @@
- dllEntry = dlsym( libHandle, "_dllEntry" );
+ dllEntry = dlsym( libHandle, "dllEntry" ); // JOE
@@ -121 +121 @@
- *entryPoint = dlsym( libHandle, "_vmMain" );
+ *entryPoint = dlsym( libHandle, "vmMain" ); // JOE
This fixes the entry points into the native qagame. The underscores are not needed on 10.4 (compare the man pages for dlsym on 10.3 and 10.4).
Finally, add this to the Quake 3 G4 (Application) executable's arguments (Project menu / Edit Active Executable):
+set vm_game 0
Build
qagame with the Development build configuration. If you look in the build directory you'll see the fresh qagame bundle next to the app:
quake3-1.32b/code/macosx/build/Development/
Quake3 G4.app
qagame.bundle
The argument
+set vm_game 0 tells Quake 3 to ignore the qagame.qvm in the pak file and use the native bundle instead. Because the bundle is a native Mac binary you can debug it with Xcode and gdb (this wouldn't be possible with the virtual machine code version).
Run Quake3. In the console log you should see this, indicating that the native bundle was loaded and used:
Loading dll file qagame.
Loading 'qagame.bundle/Contents/MacOS/qagame'.
[It's likely there are similar changes to be made for cgame and ui, but I haven't gotten there yet.]
Now For The Fun
Fun Thing #1 - Make missiles go a lot slower. You can fire them down a hall and outrun them to the other end.
In g_missile.c, fire_rocket():
VectorCopy( start, bolt->s.pos.trBase );
- VectorScale( dir, 900, bolt->s.pos.trDelta );
+ VectorScale( dir, 150, bolt->s.pos.trDelta ); // JOE: was 900
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
Fun Thing #2 - Make the slow-mo missiles last longer. The time is specified in 1000ths of a second.
In g_missile.c, fire_rocket():
bolt->classname = "rocket";
- bolt->nextthink = level.time + 15000;
+ bolt->nextthink = level.time + 35000; // JOE: was 15000
bolt->think = G_ExplodeMissile;
Fun Thing #3 - Make missiles bounce off walls. Go into a large room and fire away!
In g_missile.c, fire_rocket():
bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
bolt->s.weapon = WP_ROCKET_LAUNCHER;
+ bolt->s.eFlags = EF_BOUNCE; // JOE: added
bolt->r.ownerNum = self->s.number;
bolt->parent = self;
Lots more fun things at the
Code3Arena website.
I've attached the app and sources to this page for reference, but
please use the links above to get the files. My school's tin-cans-and-string connection to the internet would appreciate it, and your downloads will go much faster.
Questions or comments?