PAGE_CONTENT = other_viewer.php
Home > Other content > myfirstmod

Tutorial: My First Quake III Arena Mod

So, we've loaded our mod as qvm files. That's good, but it's not really exciting. Right now we've made no actual changes to the source code, so what you're playing now is just plain old vanilla Quake 3. So let's dig in and make our first changes to the game.

So lets see, what are the things that our mod needs. I'll list them here:

Those are the basics, but lets explore the details a little further: Now that we've outlined the goals we wish to achieve, we can start looking at the code.

Taking a closer look at the code

So far we've seen that there are 3 relevant projects in here: cgame, game and q3_ui. The cgame project deals with all things that are related to the client. In other words: it contains code that is specific for one player in the match and this is executed on the player's own computer.
The game project is code that runs on the server. It contains code for tracking and updating gamestate.
Finally there's the q3_ui project which contains code related to the in-game menus. In this tutorial, we won't be doing anything with the q3_ui project, but cgame and game are edited.

Last but not least, it helps a bit to get a general idea of what the filename prefixes are for. Most obvious one are these prefixes:

Removing weapons from the playing field

Our first task is to remove all weapons and ammo from the levels. We don't want players to pick up any ammo or weapons because they should stick strictly to the weapon the are currently using. Stopping ammo and weapons from spawning is rather easy. Check out the file g_items.c in the game project. You'll find the G_SpawnItem function here. It takes an (empty) as input and an item definition. It applies the correct properties to the entity based on the item definition that's passed and spawns it. What we can simply do here is check if the item definition defines a weapon or ammo box and simply skip the entire function if this is the case. This is done by simply adding the following line right at the top of the function:

	if (item->giType != IT_WEAPON && item->giType != IT_AMMO)

IT_WEAPON and IT_AMMO are enum values defined in bg_public.h. Ofcourse the rest of the code must be closed within curly brackets: { and }. The result is that whenever the game tries to spawn a weapon or an ammo box, this code makes sure it doesn't happen. Obviously this is not the ideal way to do this, because right now, we have an entity in the server's memory that holds up space while it's not visible or used in the game. In other words: it's a waste of resources. It's not as bad as I make it sound though: in a normal game of Q3A these enitites are there as well, so it doens't degrade performance. In a future update of the mod, we might be looking more closely at this to optimize things like this. Compile the game again (either as dll's or qvm's. Remember to use the right vm_ settings in q3config.cfg). Check out the map and see how all weapon and ammo pickups are gone.

NEXT: Weapon progression>>