Quake 2: Mods


      Compiling with LCC
      A tutorial for LCC win 32 for Quake 2

      Installing LCC to compile quake 2 is no longer as easy as it once was. The first problem being that windows NT based systems (xp) no longer read the autoexec.bat information at start up, so running the traditional make commands in a dos prompt is a little more complicated than it used to be.

      The first thing you need to do is get the quake 2 source code (all downloads are at the bottom of the page). The next is that you need Fuzzy Steve's make file and the lcchack.c file. We are enternally grateful to him for helping us poor people to make mods. And finally you'll need to spend about 1 hour fidgiting with the lcc project configurations.

      So install the latest version of LCC. At this point it's basically all win32 style with the compiler being best uitilized through the gui menus in Wedit. Older versions of lcc had little use for the Wedit gui, now it's pretty useful. We'll discuss it's quirks later.

      Extract your source to c:\quake2\modname. This will create the folder c:\quake2\modname\quake3-21-full or something similar depending on the version of the code you installed. If you are working with 3.20 src as opposed to 3.21 src then it will probably default to c:\quake2\modname\src. If you are working with 3.21 source then the only code you're interested in for deathmatch mods is in c:\quake2\modname\quake3-21-full\game. Remember to use your current quake 2 directory if it differs from the default c:\quake2 and to use a different name than modname.

      Once the code is extracted, then put the makefile and lcchack.c into that same source folder as the code. (whether your source be c:\quake2\modname\quake3-21-full\game or just c:\quake2\modname\src).

      Now the fun part with lcc. Open Wedit. A shortcut should have been placed in your start bar, otherwise it's under your bin folder. The bin folder is in c:\lcc\bin. If you are new to programming, the location of the bin folder is important to remember because you may often need to go directly to your bin folder for other projects.

      Once Wedit is open press file->new->project. One of the quirks of lcc is that it stores every project name in a central location and the same project name cannot be moved over. The reason why this is a problem is that the final product is going to match your project name. For our mod we want to product a file called gamex86.dll. If you name your project gamex86 and specifiy a dll then it will create a correctly named file when it compiles. However you can only name one project this, so if you create a second mod you are out of luck as far as naming goes. So go ahead and name the project the same as your mod name just to keep a point of reference. We'll fix the naming problem latter.

      Once you enter your project name you will see the label "sources" and "working directory" followed by a text box and immediatly after that text box is a browse button. Press the brows button. Now find your mod source. This will be the c:\quake2\modname\src or c:\quake2\modname\quake3-21-full\game that we extracted earlier. Finally at the bottom select the Dynamic Link Library (dll) radio button and press create. You should see a window that asks to create a generic or base file. Tell it no. We have all the base files we need already.

      This will probably open up an empty window or 2. You do not need them an can close them. If none open then do not worry. Also if it asks you if you would like to automatically generate a makefile, say NO. Never overwrite the current makefile. if you accidentally overwrite the current makefile you can also copy the one that you downloaded first back over, but incorrect makefiles cause wierd errors that are not as easy to determine. So just avoid overwriting the file to begin with to avoid problems.

      So now that we have a project, we need to include files. So press project->add new files. A dialog box will appear showing all the files currently included in your project. There's probably none, so click add new file and a browse dialog box will apear pointing to your project directory. Here you should see the source code.

Add all of the following files. (you'll have to change "files of type" to "all")

game.def, makefile, lcchack.c
game.h, g_ai.c, g_chase.c, g_cmds.c, g_combat.c, g_func.c, g_items.c,
g_local.h g_main.c g_misc.c g_monster.c g_phys.c g_save.c,
g_spawn.c g_svcmds.c g_target.c g_trigger.c g_turret.c g_utils.c,
g_weapon.c Lcchack.c makefile m_actor.c m_actor.h m_berserk.c m_berserk.h,
m_boss2.c, m_boss2.h, m_boss3.c, m_boss31.c, m_boss31.h, m_boss32.c, m_boss32.h,
m_brain.c, m_brain.h, m_chick.c, m_boss32.c, m_boss32.h, m_brain.c, m_brain.h,
m_chick.c, m_chick.h, m_flash.c, m_flipper.c, m_flipper.h, m_float.c, m_float.h,
m_flyer.c, m_flyer.h, m_gladiator.c, m_gladiator.h, m_gunner.c, m_gunner.h,
m_hover.c, m_hover.h, m_infantry.c, m_infantry.h, m_insane.c, m_insane.h, m_medic.c,
m_medic.h, m_move.c, m_mutant.c, m_mutant.h, m_parasite.c, m_parasite.h, m_player.h,
m_rider.h, m_soldier.c, m_soldier.h, m_supertank.c, m_supertank.h, m_tank.c, m_tank.h,
p_client.c, p_hud.c, p_trail.c, p_view.c, p_weapon.c, q_shared.c, q_shared.h

Once your done open game.def and make sure it has this exactly:

EXPORTS
	GetGameAPI=GetGameAPI

Also open game.h and near the top at line 23 you should see:

// game.h -- game dll information visible to server

#define	GAME_API_VERSION	3

Make sure that your version of the source code has either a 2 or a 3 here.

      Finally we get to change the project configuration. The goal here is to create the proper file name so that we do not have to rename it later. So click project->configuration then click the linker tab. You should see a text box that says Output fine name. It will read c:\quake2\modname\src\lcc\projectname.dll (depending on your project path so yours my differ). Change the projectname.dll to gamex86.dll. Then press the Debugger tab and do the same thing to the Executable to start text box. Now press ok. Oddly enough these changes don't seem to take affect immediatly. I recommend you restart your computer.

      So once your computer comes back up open wedit again. Your last project should open up automatically. If it doesn't then click project->open and select yours from the list. All (about 90) of your source files will probably open up as well so just minimize or close them. Open p_weapon.c (just to have a file open, most editing begins here anyway) and press compiler->make. This should work. If not we have forums because there is no way in jello to address all possible errors here. If you have a problem, try placing Fuzzy Steve's makefile back into your source. If you still get an error try creating a new project again the same way.

      Assuming everything compiled correctly, a gamex86.dll will be created in your source directory. It will be sitting there as c:\quake2\modname\src\lcc\gamex86.dll. Copy that file into your mod dirctory (c:\quake2\modname\gamex86.dll). Then open quake 2 and type game modname. Now start a new single player game using the menu or deathmatch game using f5. You won't see any changes immediatly so go back to the code and do something rediculous to make sure it's working. Like put blaster damage at 10000. Remember every time you compile you'll have to copy the gamex86.dll over again. Now go have some fun.

P.S. if you compile successful and still do not see a gamex86.dll, it may still be using the project name for some wierd reason. In that case copy projectname.dll to your mod directory and then rename it to gamex86.dll. This can be streamlined using by creating a MSDOS batch file.

get lcc here: http://www.cs.virginia.edu/~lcc-win32/
makefile: Fuzzy Steve's makefile
lcchack.c: lcchack.c