Created By: Kryten
eMail: kryten@inside3d.com
Difficulty Scale: Medium


In this tutorial you can learn how to make monsters become gibbable corpses after they die.
I will show you how to make a the grunts into gibbable corpses, then you can just apply what
you learned to other monsters.

First you need to open your soldier.qc file and find these lines:

void()  army_die3       =[      $death3,        army_die4]
{self.solid = SOLID_NOT;self.ammo_shells = 5;DropBackpack();};

Now replace the "self.solid = SOLID_NOT;" with "become_corpse();", so you should now have:

void()  army_die3       =[      $death3,        army_die4]
{become_corpse(); self.ammo_shells = 5;DropBackpack();};

Do the same for army_cdie3 so it looks like this:

void()  army_cdie3      =[      $deathc3,       army_cdie4      ]
{become_corpse(); self.ammo_shells = 5;DropBackpack();ai_back(4);};

Now go down to:

        setmodel (self, "progs/soldier.mdl");

        setsize (self, '-16 -16 -24', '16 16 40');
        self.health = 30;

And before this add:

        self.headmdl = "progs/h_guard.mdl";

The .headmdl will be used to know what head to throw when you gib the corpse. You should have
this line for each monster with the correct head for the headmdl. Now you should have a good
idea of what to do when making other monsters become gibbable corpses when they die too. The
next thing you need to do is make the code that will turn monsters into gibbable corpses. To do
this create a new file and call it corpse.qc, in that new file add this:

void () corpse_touch = 
{ 
        self.velocity = '0 0 0';

        if ((!other.flags & FL_ONGROUND) && (other.health) && (other.flags & FL_CLIENT))
                other.flags = other.flags + FL_ONGROUND;
};


The above code fixes a problem in Quake, normally you slide when on top of corpses, this fixes
that problem. Now add this code after that above code:

.string headmdl;
void () corpse_die =

{
        sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM); //gib sound
        if (self.headmdl) //do we have a head? if not you must have forgotten that.
                ThrowHead (self.headmdl, self.health);
        ThrowGib ("progs/gib1.mdl", self.health);
        ThrowGib ("progs/gib2.mdl", self.health);
        ThrowGib ("progs/gib3.mdl", self.health);

        if (!self.headmdl) //if no head then this is needed!
                remove (self);
};

void () become_corpse =

{
        self.health = 30;

        self.takedamage = DAMAGE_AIM;
        self.solid = SOLID_SLIDEBOX;
        self.movetype = MOVETYPE_STEP;
        self.flags = self.flags & (!FL_MONSTER);

        //make shamblers bigger
        if (self.classname == "monster_shambler")
                setsize (self, '-32 -32 -24', '32 32 -14');
        else
                setsize (self, '-32 -32 -24', '32 32 -19');

        self.classname = "monster_corpse";

        self.origin_z = self.origin_z + 3; //less likely to fall into ground

//target stuff: if a monsters death sets off a trigger then dont let the corpses
//death do the same
        self.use = SUB_Null;
        self.target = string_null;
        self.killtarget = string_null;
        self.targetname = string_null;

        self.th_die = corpse_die;
	self.th_stand = SUB_Null;
	self.th_walk = SUB_Null;
	self.th_run = SUB_Null;
	self.th_missile = SUB_Null;
	self.th_melee = SUB_Null;
	self.th_pain = SUB_Null;
        self.touch = corpse_touch;
};

Now save and close the corpse.qc file and open the progs.src file. In the progs.src file
find this line:

ogre.qc

ABOVE that line add this line:

corpse.qc

Save changes and exit. Now all you need to do is compile and after you kill a grunt you can gib
his corpse! Have fun!

I would like to thank MaNiAc for the sliding fix.



Tutorial html coding by legion.