Quake 3 Dev Notes
From BenningtonWiki
Contents |
[edit] SPELUNKING
- How do you replace the NIN wannabe background music with something else?
- How are the cvars and commands stored internally? What are the lists like? What functions manipulate the lists (search, add, etc.)?
- How do you make your own level?
- Make the machine gun barrel spin the other direction.
- Notice how the weapon you're holding bobs gently when you're standing still. How does it do that?
- Notice the shot marks your weapon leaves on the surfaces it hits. Is there a limit to how many of these marks there can be in the game at one time? Can you change how long they last?
- Notice how shots can be used to open doors at a distance. Find the code that does that. Change it to require two shots to open.
- From the Dept. of Amazingly Gratuitous Effects: If you fire the shotgun under water it leaves a trail of bubbles. That's just silly. Change it to leave a trail of bubbles in the air, too.
- Find the code where you take damage. Modify it so that you never get hurt. Is there a cvar for this already?
- Some of the options you can turn on or off are considered "cheats" and normally they're not allowed. Find the code that checks for this. (E.g., try "/god" mode during gameplay.)
- More about doors: Notice how they close automatically after a period of time. Find the code that does this. Change the time. Can you make the doors reopen by themselves, so that they're always closing and springing back open?
- A couple of cool special effects happen when you have quad damage. Your shots have this awesome echoey sound, and your gun has this cool blue glow. Find out how these are done.
- Can you make the missiles bounce based on a cvar boolean? That is, create a new variable that the missile code checks, and if it's non-zero they bounce. This way, we can turn on and off the bouncing from the console.
[edit] GETTING STARTED
svn co http://svn.bennington.edu/svn/quake3
[edit] On Windows XP
Step 1: You need Visual C++. If you don't have it:
- Go to Microsoft's website, click on "Developer Tools" and do the Visual C++ 2005 Express Web Install. This will install the VC2005 Express IDE and the Microsoft .NET Framework 2.0.
- Visual C++ 2005 Express has certain limitations compared to the non-free versions.
- There is no Source Control integration (you'll be stuck with the SVN command line tools)
- It does not come with certain Windows API files, one of which is windows.h. To get these files, download another Windows SDK.
- The Windows Server SDK comes with a "Register Environment Variables with Visual Studio" utility, but it didn't work for me. I had to manually add C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\bin, \lib and \include as well as all of their child folders to my VC2005 search paths (Tools -> Options -> Projects and Solutions -> VC++ Directories).
- It does not come with DirectX API files, for example, dinput.h. To get these files, download the DirectX SDK. The DirectX SDK successfully added its own environment variables to my VC++'s search paths.
- Visual C++ 2005 Express has certain limitations compared to the non-free versions.
Step 2: Open the Visual C++ solution file, located at code\quake3.sln.
The following changes have already been made by me, and committed:
- When the IDE loads, it will convert the project file to a VC++ 2005 Express file from its original format, VC++ 7.
- For our purposes, we will be working with DEBUG and not DEBUG_TA, which is what the solution file starts the Active Configuration at. TA is Team Arena and forces DMISSIONPACK to float all over the code. MAKE SURE that your active configuration is DEBUG, not DEBUG_TA, and that ALL projects in the solution are set to DEBUG. You may need to change q3_ui's dependencies and set it to be dependent on ui.
Step 3: Add the paths indicated in README.TXT to your $PATH environment variable.
Step 4: From Command Prompt, run game.bat, cgame.bat and q3_ui.bat indicated in README.TXT.
Step 5: Build and run.
[edit] On Mac OS X
The Xcode project file is at code/macosx/Quake3.xcodeproj. Open it. There are three preferences that you need to set. They may already be set, but if not you only need to do this once:
- Set the active target to App G4 and DLLs or App Intel and DLLs (Project menu / Set Active Target).
- Set the active build configuration to Debug (Project menu / Set Active Build Configuration).
- Set the active executable to Quake3 G4 (Application) or Quake Intel (Application) (Project menu / Set Active Executable). This is what you want Xcode to launch whenever you run the project.
On first run, you'll be asked to locate your original Quake 3 install folder. Select the folder that Quake 3.app and baseq3 are in.
[edit] Tips
- To make changes to qagame, cgame and ui (missile behavior, etc.) you need to force Quake 3 to ignore the DLLs in the pak files and use your versions instead. To do this, you must pass the following command line arguments to the application when it runs:
+set vm_pure 0 +set sv_pure 0 +set vm_game 0 +set vm_cgame 0 +set vm_ui 0
In Xcode, the way to do this is in Project menu / Edit Active Executable, then look under the Arguments tab.
- Turn Full Screen off and set the display size to something smallish like 640x480. This way when Quake runs it'll open into another window and you can switch easily between it and Xcode. When in Quake, the cursor is hijacked and you can't click out of the Quake window; you have to use command-tab. Command-click to drag the window while in another app.
- When we get around to doing symbolic debugging, remember to turn off "Load symbols lazily" in Xcode Preferences / Debugging.
[edit] SOURCE CODE ORGANIZATION
[edit] Files
There are 293,844 lines of code. = 5,877 pages printed.
| Prefix | Description |
|---|---|
| aas_ | Area Awareness System. Used by the bots to find their way around. See van Waveren, "The Quake 3 Arena Bot," p. 24. |
| ai_ | Server AI handling: goals, chat, teams. Built as part of the qagame dll. |
| bg_ | "both games" code (client and server). Some fun stuff: items, jump pad handling, picking up items, movement. |
| be_ai_ | Bot AI header files. |
| cg_ | Client in-game code: weapons, effects, movement, console, scoring, view. Constitutes the cgame dll. |
| cl_ | Client support. |
| g_ | The bulk of the Server code. |
| macosx_ | Mac OS X specific code. Cocoa guts. |
| snd_ | Client sound playback. |
| tr_ | High level control of frame rendering. |
- tr_init.c: init OpenGL, valid screen modes, screen shots
[edit] Configuration
#define DEDICATED // Indicates building the dedicated server. Is not defined when building the client app.
[edit] BINARY ORGANIZATION
Quake3/
Quake3 G4.app/
baseq3/
pak0.pk3
pak1.pk3
pak2.pk3
pak3.pk3
pak4.pk3
pak5.pk3
pak6.pk3
pak7.pk3
pak8.pk3
[edit] Pak3
".pk3" = ".zip"
That is, the format of this file is simply a compressed set of all the data that Quake needs to run: level maps, sound files, etc. in zip format. You can change the extension to ".zip" and open it.
[edit] CODE WALK-THROUGH
[edit] Starting Up
Quake 3 on Mac OS X uses the standard technique of placing an instance of an object class in the nib file and letting Cocoa create and initialize it when the program launches. This object class is called "Q3Controller" and the object instance in the nib file is called (inaccurately) "Q2Controller". To complete the technique, this object is also set as the app's delegate (set in the nib file). This means that as soon as the app launches the class starts getting delegate method calls correlating to the app's goings on. Q3Controller hooks into the "did finish launching" delegate method and that's when Quake 3 starts happening:
Q3Controller.m:
- (void)applicationDidFinishLaunching:(NSNotification *)notification;
{
NS_DURING {
[self quakeMain];
} NS_HANDLER {
Sys_Error("%@", [localException reason]);
} NS_ENDHANDLER;
Sys_Quit();
}
quakeMain is the Q3Controller method that runs the whole show. It doesn't return until the game quits. Its invocation is wrapped in a Cocoa exception handler, which is pretty standard.
- Quake 3 is launched.
- Cocoa creates the Q3Controller instance and hooks it up as the app's delegate.
- As soon as the app is finished launching quakeMain takes over completely.
Com_Init() is the common initialization entry point. It’s called from quakeMain.
[edit] Game Loop
Com_Frame() runs one frame of the game.
while (1) {
Com_Frame();
if ((count & 15)==0) {
// We should think about doing this less frequently than every frame
[pool release];
pool = [[NSAutoreleasePool alloc] init];
}
}
[edit] BOTS
Bots are controlled by the code in ai_dmnet.c and ai_dmq3.c. All of the bots share the same code. What makes them different are their config files inside pak/botfiles/bots/*_c.c.
[edit] Reference
The Quake 3 Arena Bot, J.M.P. van Waveren, University of Technology in Delft the Netherlands (2.2MB, pdf).
[edit] 3D GRAPHICS
[edit] Reference
sgi.com – OpenGL info.
[edit] PHYSICAL MODELING
Origin of Quake3's Fast InvSqrt()
[edit] NETWORKING
[edit] Reference
[edit] SOUND
snd_adpcm So this is the code which I'm pretty sure does the work of parsing the wav files. If not, it might be the brain of the sound prefs. When I know I'll report. -M
[edit] LEVEL BUILDING
Mike wrote up a nice long bit about level building. It's part of the svn project and can be looked at here.
[edit] GtkRadiant Installation
Must install X11 first.
Looks like you can put the editor anywhere. I have:
drwxr-xr-x 3 joe admin 102 May 12 03:48 MacRadiant14.app/ drwxr-xr-x 10 joe admin 340 May 25 17:18 baseq3/ drwxr-xr-x 9 joe admin 306 May 25 17:18 missionpack/
[edit] Opening and Saving
Looks like you’re supposed to open a .map file. baseq3/maps/*.map. Be sure to add the .map suffix when saving.
[edit] Preferences
- Display / 2D Display/Rendering: turn on OpenGL antialiased points, Solid selection boxes, Display size info
- 3D View: turn off: Discrete movement
[edit] Basics
Read the Map Building Basics in the online manual. Go through the “Ten Quick-n-Dirty steps to a SIMPLE room.”
X11 mouse buttons: option-click is center button, command-click is right button.
Use control-tab to switch between 2D views.
[edit] Reference
- qeradiant.com – Q3Radiant manual.
- redsaurus.net – GtkRadiant for mac.
- [1] - Q3Radiant command line tools, usage, etc
[edit] CONSOLE & VARIABLES
Quake 3 has a command line console that you can get to by typing '`' at any time, even during game play. There are a bajillion commands. In addition(!), there are another bajillion variables that you can set and examine.
Quake 3 Commands and Quake 3 Variables
[edit] MISC REFERENCE
- Quake 3 Bugs
- Slashdot article about Quake 3 Source GPL'ed.
- A Quake family tree graphic.
- planetquake – Quake 3 Files.
- gamers.org index of /pub/idgames/idstuff.
- quake3world.com forum.
- quake3world.com – Macintosh discussion forum.
- quakesrc.org News.
