Table Of ContentFocus on Mod
Programming
for Quake
III
Arena
This page intentionally left blank
Focus on Mod
Programming
for Quake
III
Arena
Shawn Holmes
© 2002 by Premier Press, a division of Course Technology. All rights reserved. No part
of this book may be reproduced or transmitted in any form or by any means, elec-
tronic or mechanical, including photocopying, recording, or by any information stor-
age or retrieval system without written permission from Premier Press, except for the
inclusion of brief quotations in a review.
The Premier Press logo, top edge printing, and related trade dress are trade-
marks of Premier Press, Inc. and may not be used without written permis-
sion. All other trademarks are the property of their respective owners.
Publisher:Stacy L. Hiquet
Marketing Manager: Heather Hurley
Managing Editor:Sandy Doell
Acquisitions Editor:Emi Smith
Series Editor:André LaMothe
Project Editor:Estelle Manticas
Editorial Assistant:Margaret Bauer
Technical Reviewer:Robi Sen
Technical Consultant: Jared Larson
Copy Editor: Kate Welsh
Interior Layout:Marian Hartsough
Cover Design:Mike Tanamachi
Indexer:Katherine Stimson
Proofreader:Jennifer Davidson
All trademarks are the property of their respective owners.
Important:Premier Press cannot provide software support. Please contact the appro-
priate software manufacturer’s technical support line or Web site for assistance.
Premier Press and the author have attempted throughout this book to distinguish
proprietary trademarks from descriptive terms by following the capitalization style
used by the manufacturer.
Information contained in this book has been obtained by Premier Press from sources
believed to be reliable. However, because of the possibility of human or mechanical
error by our sources, Premier Press, or others, the Publisher does not guarantee the
accuracy, adequacy, or completeness of any information and is not responsible for any
errors or omissions or the results obtained from use of such information. Readers
should be particularly aware of the fact that the Internet is an ever-changing entity.
Some facts may have changed since this book went to press.
ISBN: 1-931841-56-X
Library of Congress Catalog Card Number: 2001099836
Printed in the United States of America
02 03 04 05 RI 10 9 8 7 6 5 4 3 2 1
Premier Press, a division of Course Technology
2645 Erie Avenue, Suite 41
Cincinnati, Ohio 45208
To Ariel and Hunter,
who love to play games
almost as much as their Dad
And to Dave Kirsch,
for inspiring me, and many others,
to create
Acknowledgements
T
his is my first book, and it was both challenging and a constant
learning process from start to finish. Because of the unusual cir-
cumstances that led to my becoming the author, I have many impor-
tant people to thank; without them I surely wouldn’t have been able
to pull this off. The first of these people are Emi Smith and Estelle
Manticas, two patient ladies who held my hand as I stumbled blindly.
Many of the tutorials in this book are based on the hard work of dedi-
cated Quake III Arena fans, who took their own personal time to write
up what they had discovered. My thanks go to Chris Hilton, Karl
Pauls, Arthur “Calrathan” Tomlin, and Ian “HypoThermia” Jefferies at
Code3Arena for their extensive help and knowledge. As well, thanks to
my favorite 3D modeler and friend Dave Wolfe for his contribution in
the modeling department. My passion for C programming would not
exist if it weren’t for the support of Dave Sausville, and so I have him
to thank as well. I need to thank Thaxton Beesely, too, for it was his
laptop on which a great deal of this book was written.
Special thanks go to Robi Sen, my technical editor, for believing in me
enough to get me on this project. Jared Larsen provided detailed
information on Q3’s code, shaders, and wrote the Flag Indicator &
Dynamic Spawn generating functions (all after having just welcomed a
baby!), so thanks very much to him. Many thanks also to Andy Smith
for providing introductory content in Chapter 2. Also, special thanks
to Anthony Jacques, for providing the source to his “Domination”
mod for Q3, which formed the basis of the Defend the Flag modifica-
tion, handled in the last section of this book. Thanks also go to the
team back at Breckenridge Communications, who dared me to write a
book.
And finally, thanks especially to my wife, Julie, for her support and
patience during this exciting and unpredictable project.
About the Author
SHAWN HOLMES is a gaming addict, period. Born in the recesses of the
Great White North, Shawn grew up in the small town of Parksville,
British Columbia, with dreams of one day becoming a professional
video-game developer. He first tinkered with an Apple computer back
in 1985, and wrote his first game for a Computer Science project in
1990. Today, Shawn is Senior Programmer at Breckenridge
Communications, an Internet-applications company in Denver,
Colorado, and lives with his wife Julie and their two children, Ariel
and Hunter. He can be reached at sholmes@breckcomm.com.
Shawn has played a role in several game modifications; in 1997 he
headed up The CTF Expansion Project to increase the number of quality
CTF maps available for Quake. In 1999, his Decay! mod for Heretic II
was named “Mod of the Month” by an Australian gaming magazine,
PC Powerplay. As long as video and computer games exist, Shawn will
continue to push his development experience to new levels in his
quest to create the next exciting game.
Contents
Letter from the Series Editor . . . . . . . xiv
Introduction. . . . . . . . . . . . . . . . . . . xvii
Introduction to
CHAPTER 1
Programming Mods . . . . . . . . . . . 1
What Is a Mod?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Why Create a Mod Instead of Just Writing a Game?. . . . . . . . . . . . . . . . . . . . . . . 3
The Tools of the Trade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Using C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Using the VC++ Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
What Mods Are Currently Available?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Urban Terror. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Rocket Arena Q3A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Quake III Fortress (Q3F) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Painkeep Arena. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Rune Quake . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
C Programming
CHAPTER 2
in Quake III . . . . . . . . . . . . . . . 13
The History of Quake and Its Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
The Move from DOS to Win32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Hello Quake III,Goodbye DLL! (Sort Of). . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Getting Set Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Installing Q3 and the Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Source Directory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Using Visual C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Contents ix
Building the Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Compiling the Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Loading Up Your Mod. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Looking at the Quake III Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
On Your Marks,Get Set .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
The Q3 Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
A Simple Mod:The Homing Missile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
I Think,Therefore I NextThink .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Entities:Building Blocks in Q3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Changing the Missile’s Behavior. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Smoothing the Missile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
A Final Note. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
More
CHAPTER 3
Weaponry Work. . . . . . . . . . . . 49
Understanding Weapon Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Modifying the Shotgun. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Understanding the Top-Down Approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Knowing the Shotgun Inside and Out. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
The Physics of Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Intricacies of Damage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Adjusting the Shotgun’s Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
The Shotgun’s Dirty Secret. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Synchronicity in the Client Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Adding Polish:Shooting While Moving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Modifying Grenades:The Cluster Grenade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Further g.weapon.c Detective Work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Why a Grenade Bounces (and Rockets Don’t). . . . . . . . . . . . . . . . . . . . . . . 74
Using What You Know:think and nextthink. . . . . . . . . . . . . . . . . . . . . . . . . . 76
Making the Cluster Grenade Behave. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Description:You've seen the cool mods that other developers have created for games like Quake. Now you're ready to try it for yourself. All you need to dive in and start designing is a copy of Quake III, a creative idea, and this book! Master the fundamental skills you'll need as you start with the basics of mo