====== Modding quick tutorial ====== Mirror of [[http://gregs-blog.com/2008/01/24/how-to-make-a-quake-3-arena-mod/|this article]]. ===== Introduction ===== You’ll need to be at least somewhat familiar with C programming in order to make a mod. Quake III doesn’t do what is typically done by other games these days – which is wrap all game modding into some form of scripting language (such as Lua) or abstract things to the point where you don’t need to be a game programmer or familiar with the entire codebase in order to make simple behavioral changes. ===== The Two Types of Mods ===== The first thing you’ll need to know is that there are two types of Quake III mods: - QVM mods - DLL mods It doesn’t matter which type of mod you make. A QVM mod will have the same effect in the game as a DLL mod. The only difference is how these mods are executed at runtime. QVM mods are created by compiling your source into a QVM file. These files are very similar to Java bytecode – they contain instructions that the Quake III engine interprets at runtime. DLL mods are created by compiling your source into a Windows DLL. These DLL’s are no different from any other Win32 DLL – the operating system executes these DLL’s as native machine code whenever the Quake III engine needs to call a function contained within them. Due to the extreme difficulty I experienced trying to load a QVM mod (as explained in [[http://gregs-blog.com/2008/01/15/how-to-install-a-quake-3-mod-common-problems-and-solutions/|a previous Quake III mod post]]), I’m going to focus on the creation of DLL mods for this post. In my opinion this method is the easier of the two anyway. ===== Get the Source Code ===== The first thing you’ll need to do is get the source code for Quake III Arena. You can download it from the following link : [[ftp://ftp.idsoftware.com/idstuff/source/quake3-1.32b-source.zip|Q3A 1.32b native C Source (original Id Software code with VS 2003 project files)]] If you must use the original native codebase for some special reason, but only have Visual Studio 2008, send me an email through my Contact page and I’ll send you my upgrade checklist – a list of steps I did to convert the original VS 2003 project to VS 2008 while keeping the native C settings intact (once you know what the steps are, it actually only takes about 20 minutes to convert). I’m really glad Microsoft still supports ANSI C in the compiler. You will need a retail copy of Quake 3 Arena to run mods, it will not work with the shareware demo version. I know what you’re thinking – “but I have the source code, why can’t I circumvent the license check?!” The license check isn’t the problem. The problem is that there are a few big differences between the structure of a demo PK3 data file and a retail PK3 data file (specifically related to the UI interpreted bytecode instructions). The public source only includes code for reading a retail version’s PK3 data. If you try and force the code to read a demo data file (and believe me, I’ve tried), the game crashes half the time; the other half of the time it will run but with no menu options. Besides, it’s not worth getting around the license – these days you can buy all three Quake games (Quake I, II, and Quake III Arena) for $20 bucks in the Ultimate Quake collection. I got mine at Fry’s Electronics for $19.95; I’d recommend you get it from a discount electronics store too since buying it from Id Software’s site will cost a little more ($30 bucks at the time of this writing). //Note : No need since IoQuake3 added a CVar to set the engine in standalone mode : [[quake3:tools|Download IoQuake3]]// ===== Game Project Structure ===== There are eight project files included in the source. You’ll only need to focus on three of them: - The cgame project. - The game project. - The quake3 project. These projects build as Win32 DLL’s. However, you must change where the compiler saves them. Open their project settings and set the output directory to the “baseq3″ folder of your Quake III installation (i.e. on my computer it is “c:\quake3\baseq3″). ===== Modify the Code ===== We’re going to change one line of code that will make the rocket launcher repeat-fire at a faster rate. Open the source file, bg_pmove.c, under the game project and look for a function called PM_Weapon. Once in this function scroll close to the bottom of it where you should see a switch statement that looks like: switch( pm->ps->weapon ) { In the switch statement look for the case of WP_ROCKET_LAUNCHER; it is 125 lines below the start of the function. In that case block the variable “addTime” is being set to 800 – change this to 100. So instead of: case WP_ROCKET_LAUNCHER: addTime = 800; break; Now the code should look like: case WP_ROCKET_LAUNCHER: addTime = 100; // for rapid fire break; Under the build configuration drop-down of Visual Studio select “Debug.” You could have selected “Release” but running in debug mode will give you better diagnostic information in the event something crashes. Now compile the source – select “Build->Rebuild Solution” from the menu. I recommend a full rebuild instead of a regular build just in case some stray binaries were accidentally left in the original source tree. ===== Installing and Running the Mod ===== Now it’s time to take the compiled DLL’s and have Quake III use them as a mod. By now you should have modified the three DLL projects to output their binaries to “c:\quake3\baseq3″ (or whatever you chose as your Quake III installation). Open that directory in Explorer and check for the following DLL’s: - cgamex86.dll - qagamex86.dll - uix86.dll If those DLL’s are present, you’re ready to run your mod! Simply start Quake III with the following command line: ”quake3.exe +set sv_pure 0 +set vm_game 0 +set vm_cgame 0 +set vm_ui 0” When the Quake III menu options load, select a single player game and run an instance without any bots (so you won’t get distracted). After you’re inside the map, press tilde (”~”) to drop down the Quake 3 console. Here you’ll see a ton a status text. Use the and keys to scroll through everything line by line. You’ll want to look for status messages saying your DLL’s were loaded OK. The status text for qagamex86 is quite a few pages up, while the status of cgamex86 and uix86 are near the bottom. These lines look like, “LoadLibrary qagamex86.dll ok.” When you see the DLL’s were loaded successfully, you’re done! Now try picking up the rocket launcher and see how fast it fires!! A good map for getting the rocket launcher right away is q3dm1 accessible under Squirmish mode. ===== More Fun ===== Here’s something extra you can do to make the rocket launcher feel and act more like a rapid fire weapon. You see, when we changed the firing rate of the rocket launcher above, we really only changed the trigger rate (the minimum amount of time that you have to wait between rocket fires), but didn’t touch the speed at which the rockets travel. It will feel better and you’ll get more frags if the weapon has a faster muzzle velocity. In order to do this, open up g_missile.c under the game project and search for a function called “fire_rocket.” Once there, you’ll notice that the function is very small and most of what it’s doing is setting projectile properties. You’re interested in the following line near the bottom: VectorScale( dir, 900, bolt->s.pos.trDelta ); Change this line to: VectorScale( dir, 1800, bolt->s.pos.trDelta ); So you’re really just changing the “900″ to an “1800.” Anything less than 900 will give you a slower rocket, and anything more than 900 will give you a faster rocket. But beware! Just as you can now fire faster rockets, this also means the bots can do so as well. ===== Conclusion ===== Coming up with your own complex mods that require more than editing two lines of code will require some study of the Quake III codebase. You can learn quickly by simply playing around with the code and stepping through it with a debugger. -Greg Dolley