QuakeMap Documentation
New Monsters


A practical example of turning a monster found on the Internet into a QuakeMap add-on

This document does not discuss how to make your own new monster. It focuses on converting an already existing monster into a QuakeMap add-on.

As an example, I'll tell you how you can convert the Goblin Monster, by Jim Rowley. Download it first, and unzip it.


Description of the Goblin archive

Progs.dat file
Forget it. You don't need it. It's only the compiled equivalent of the QuakeC file whose source is available in the Progs subdirectory. If the source was not available, we would have to use this Progs.dat, but avoid it if you can.
Progs subdirectory
It is the common place for the monster's model (.MDL) file. Here, there are several ones : the goblin itself, but also the arrow thrown by the goblin, its bag, and so on. In our case, you also find here the source QuakeC code (.QC).
Sound subdirectories
Usually in sub-subdirectories, you will find any new sounds that are used by the monster.

Creating the QuakeMap file

Start QuakeMap. You get an empty QuakeMap Explorer window in which we are going to put various entries containing the Goblin's datas. When you save your work, name it GOBLIN.QME. Open the Import Wizard : New, Import Wizard.If you want, try clicking on the question marks to learn more.

Let's start with the easier part : the model and sound files. They must be imported into QuakeMap. This means that you are going to copy them into file GOBLIN.QME.

Click on the button near the text Import a file, and select one of the .MDL files in the Progs subdirectory. This will import the file. QuakeMap tells you that the file is being put in the Progs subdirectory, which is correct. Do the same operation for all 4 .MDL files.

Next, we must import the sound files. It's a bit tedious, but not complicated. Do the same for all the .WAV files found in subdirectories Sound. The only complication is that you must change the path of the imported files : change the File name within Quake search path to the path where you found the file. For example, for the file Sound\Goblin\death1.wav, you must enter sound/goblin/death1.wav instead of sound/death1.wav.

Let's come to the delicate point. We must import the QuakeC code. Usually, all the monster's AI is found in a single file. In our case, it is Progs\Goblin.qc. Use the Import Wizard again, but now click on the button near the text Import a .qc file. Select Goblin.qc. That's all ! Note that there might have been some other changes in some of id Software's original .QC files, but they are usually minor. More about it later.

Let's test it now. First, click on the QuakeC entry and try to compile it, by clicking on the first button in the toolbar. Damn. It crashes. Wrong operand types. This is a known problem of QuakeMap with functions with a Vector result. In the highlighted line, you will see a call to the function normalize, which gives a Vector result. The workaround is to move the function call outside the expression. This means, replace this line :

   org = self.origin + vec * 20 + normalize(v_right) * 12 + '0 0 8';

with these two:

   org = normalize(v_right);
   org = self.origin + vec * 20 + org * 12 + '0 0 8';

Try compiling again. This time it should be O.K.

The Goblin , like any monster,is supposed to be placed in your own maps, with classname monster_goblin. Note that some other monsters found on the 'net are supposed to replace existing monsters, like the soldiers or the dogs. As this is usually not what you want when creating your own new maps, you can change it as follows : if, say, a monster is supposed to replace the soldiers, you will find in its QuakeC code a function monster_army, as monster_army is the classname of the soldiers. Simply change this name in the code to something else, like monster_mynewone. And what if you want to test the monster in some existing map ? With QuakeMap, you can open any .BSP file and edit its entities as if it were a normal map; this means that you can add new monsters in any .BSP, even in id Software's original maps.

The last thing to add to your Goblin file is a New entity definition, so that QuakeMap knows there is a monster_goblin entity that can be added in maps. Choose New, New entities, and Open QuakeMap Editor. The window that opens is the usual map editor, although it doesn't look the same. The only difference is that the entity list is in full-screen mode. To convince yourself, choose View, Full-screen list. Convinced ?

Choose Edit, New Item and add any already existing monster, like a monster_dog. Then, click on 'New entity' wizard and enter, as Classname, your monster's classname - in our case, monster_goblin. Save your work and close the map editor.

That's all ! You have made a QuakeMap add-on. It's time to test your work. Create a new, empty file (File, New). Then, choose New, Make file link and select file Goblin.qme.

If you get an error You can only create file links in the current directory, it means that you must first switch to the directory where Goblin.qme is. Choose File, Open and select Goblin.qme, then choose File, New and try making the file link again.

If all went right, you can now create a new map, add monster_goblins in it, and test it !The monster_goblin is available from the New item window, at the bottom of the list.

Even if everything went right, you will get an error in Quake as soon as you kill the goblin : no precache: progs/bag.mdl. Blame Jim, not me. The error is that every Model file, as well as sound files, must be precached from the QuakeC code, and he probably did this operation in another .QC file that he didn't distribute. Anyway, file precaching is a single line of code that should be added in the spawn function, i.e. in the monster_goblin function. In file Goblin.qme, in entry QuakeC, at the end, you will find a lot of precache_sound and precache_model, but not one for progs/bag.mdl. So add this line, anywhere with the other ones :

  precache_model("progs/bag.mdl");

The above change will fix the problem. Try it.


Enhancements in QuakeC

There is a last thing you can do. Maybe you noticed in Quake that the goblin is strangely silent when it sees you : no grrr!. The code that does this is found in file Progs\ai.qc from the Goblin archive. But don't put the whole code in QuakeMap. File AI.QC has been made by id Software, and this file, here, is only a slightly modified version. You need to figure out which changes have been made. Open the file with any text editor, and search for the text "Jim". You will find :

// Goblin modification by Jim Rowley
  else if (self.classname == "monster_goblin") 
  {
    if (random() < 0.5) 
       sound (self, CHAN_VOICE, "goblin/sight1.wav", 1, ATTN_NORM);
    else
       sound (self, CHAN_VOICE, "goblin/sight2.wav", 1, ATTN_NORM);
  }
// end goblin mod

The above is found in the function void() SightSound. Come back to Goblin.qme, choose New, QuakeC, and enter the following code :

void() SightSound =
{
// Goblin modification by Jim Rowley
  if (self.classname == "monster_goblin") 
  {
    if (random() < 0.5) 
       sound (self, CHAN_VOICE, "goblin/sight1.wav", 1, ATTN_NORM);
    else
       sound (self, CHAN_VOICE, "goblin/sight2.wav", 1, ATTN_NORM);
  }
// end goblin mod
  else inherited ();
};

We have overriden the function SightSound. We first check whether the monster that saw the player is a Goblin, and if it is, we play the corresponding sounds. This is Jim's code. If the monster is not a Goblin, we use Quake's default behaviour by calling the inherited SightSound function. See the idea ?

We can do the same for the text displayed when the player is killed by a Goblin. This time we must override the function ClientObituary, which is called when someone or something kills a player. Here is the code, add it either to the same QuakeC entry as the previous code or in a new one :

void(entity targ, entity attacker) ClientObituary =
{
  if (targ.classname == "player" && attacker.classname == "monster_goblin")
  {
      bprint (targ.netname);
      bprint (" was killed by a Goblin\n");
  }
  else inherited ();
};

For more about it, see how to use QuakeC with QuakeMap.


Conclusion

A sample file where the above operations have been done is available : GoblinQM.zip. Monsters and other add-ons already made for QuakeMap are available at Derrick's QuakeMap Page.

With the author's agreement, distribute your work ! It will be useful for everybody else using QuakeMap. I suggest you to send it to Derrick. Don't forget to put a description (New, Description) specifying the original author's name.


More about it


Back to the main page
Date: 25.01.97, by Armin Rigo