Created By: Kilbert
eMail: kilbert@juno.com
Difficulty Scale: Easy


Intruduction
This tutorial will show you how to make those blood trails that gibs leave even bloodier and/or colorful. This type of thing has been done before,but now you can do it and apply it. This could also be applied to the nails, rockets, or whatever if you just want more smoke, blood, rainbow, or p00p(brown :-) trails. Let's now get cracking w/ this code.


Step 1
Create a document if whatever directory you do these tuts and name the file blood.qc. After the file has been created add it to the progs.src file above the player.qc file. BTW if you add this to weapons and such add some prototypes at the top of the weapons.qc file.


Step 2
Open up the file you just created named blood.qc and add the following:

void() blood =
{
        // Don't spray blood until part of us stops
        if(self.velocity != '0 0 0')
        {
/* The numbers in blue is the number for color as it is in the Quake Palette.
You can also get rainbow blood by changing those numbers to random()*254.*/
                particle(self.origin,'0 0 0',75,30);
                particle(self.origin,'0 0 5',73,30);
                particle(self.origin,'0 0 5',69,30);
	
                self.think = blood;  // The must have to this tut. Makes it so particles keep comin.
                self.nextthink = time + 0.01;
        }
        // or...when we stop
        else
        {
// Check to see if it is a head
                if((self.frame == 0) && (self.view_ofs == '0 0 8'))
                        self.nextthink = -1;
                else
                {
                        self.think = SUB_Remove;
                        self.nextthink = time + 10 + random()*10;
                }
        }
};


Step 3
Ok now open up the player.qc and search for the word gib. The two functions we want are ThrowGib and ThrowHead and paste in these new ones, or you can just add or change the lines that I highlighted for you convience.

void(string gibname, float dm) ThrowGib =
{
        local   entity new;

        new = spawn();
        new.origin = self.origin;
        setmodel (new, gibname);
        setsize (new, '0 0 0', '0 0 0');
        new.velocity = VelocityForDamage (dm);
        new.movetype = MOVETYPE_BOUNCE;
        new.solid = SOLID_NOT;
        new.avelocity_x = random()*600;
        new.avelocity_y = random()*600;
        new.avelocity_z = random()*600;
        new.think = blood;  // Call the function in the blood.qc file
        new.ltime = time;
        new.nextthink = time + 0.01;  // Bleed real soon
        new.frame = 0;
        new.flags = 0;
};

void(string gibname, float dm) ThrowHead =
{
        setmodel (self, gibname);
        self.frame = 0;
        self.think = blood;  // I believe I added this line
        self.nextthink = time + 0.01;  // You're heads been cut and you bleed right then
        self.movetype = MOVETYPE_BOUNCE;
        self.takedamage = DAMAGE_NO;
        self.solid = SOLID_NOT;
        self.view_ofs = '0 0 8';
        setsize (self, '-16 -16 0', '16 16 56');
        self.velocity = VelocityForDamage (dm);
        self.origin_z = self.origin_z - 24;
        self.flags = self.flags - (self.flags & FL_ONGROUND);
        self.avelocity = crandom() * '0 600 0';
};


Step 4
Um...I think that's it. Now compile it, play it, gib something, watch, and wonder in amazement at the shower of blood(or maybe some other type of liquid). Hope you liked this tutorial and if it doesn't work or blows chunks drop me some mail. My box has been empty for awhile, so drop a piece of mail in it. Another note, you may or may not see some more tuts using the particles as the main enhancement.