Created By: Pastor
eMail: marklacroix@qtm.net
Difficulty Scale: Medium


Step 1
Ever wanted to use that fancy sword that the Hell Knight has? We're going to make that right now, but with the axe instead. Go ahead and open the weapons.qc file.


Step 2
Right before the W_FireAxe function, add all this new code. I'll explain as we go along... Note the star in one of the later comments. For some odd reason, when you look up, the shots go down. This line merely fixes that problem.
//actually this is just a modified knight_spike from hknight.qc
void() AxeSpikes =
{
        local vector    org, vec;
        local float             num_shots;

        num_shots = (ceil(random() * 50) / 5);  //random amount of shots
                                        //mutiplying by 50 and dividing by five will result in more 
                                        //mid-range shots.  Like the dice in D&D

        org = self.origin + self.mins + self.size*0.5 + v_forward * 20; //start just in front

// set missile speed
        vec = normalize (v_forward);
        vec_z = 0 - vec_z + (random() - 0.5)*0.1;
        
        do      //well this is easy to understand... 
        {
                launch_spike (org, vec);        //really is just a spike with a different model
                newmis.classname = "knightspike";
                setmodel (newmis, "progs/k_spike.mdl");
                setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
                newmis.velocity = vec * 300;    //speed up
                newmis.velocity_x = newmis.velocity_x + ((random() - 0.5) * 128); //random spread
                newmis.velocity_y = newmis.velocity_y + ((random() - 0.5) * 128); //random spread
                newmis.velocity_z = newmis.velocity_z - (2 * newmis.velocity_z); //fixes strange bug*
                sound (self, CHAN_WEAPON, "hknight/attack1.wav", 1, ATTN_NORM);
                num_shots = num_shots - 1;      //hmm...
        } while (num_shots > 0);
};

/*
================
W_FireAxe
================
*/


Step 3
OK now in the W_FireAxe function, add the new code in blue.
/*
================
W_FireAxe
================
*/
void() W_FireAxe = {
        local vector    source;
        local vector    org;

 AxeSpikes ();   //shoot hell knight spike 

        makevectors (self.v_angle);

        source = self.origin + '0 0 16';
        traceline (source, source + v_forward*64, FALSE, self);
        if (trace_fraction == 1.0)
                return;

        org = trace_endpos - v_forward*4;

        if (trace_ent.takedamage)
        {
                trace_ent.axhitme = 1;
                SpawnBlood (org, '0 0 0', 20);
                T_Damage (trace_ent, self, self, 20);
        }
        else
        {       // hit wall
                sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
                WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
                WriteByte (MSG_BROADCAST, TE_GUNSHOT);
                WriteCoord (MSG_BROADCAST, org_x);
                WriteCoord (MSG_BROADCAST, org_y);
                WriteCoord (MSG_BROADCAST, org_z);
        }
};


Step 4
It would be all done right now...but we have to precache the damn sounds and models! Again, new code is in blue...


// called by worldspawn
void() W_Precache =
{
        precache_sound ("weapons/r_exp3.wav");  // new rocket explosion
        precache_sound ("weapons/rocket1i.wav");        // spike gun
        precache_sound ("weapons/sgun1.wav");
        precache_sound ("weapons/guncock.wav"); // player shotgun
        precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
        precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
        precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
        precache_sound ("weapons/spike2.wav");  // super spikes
        precache_sound ("weapons/tink1.wav");   // spikes tink (used in c code)
        precache_sound ("weapons/grenade.wav"); // grenade launcher
        precache_sound ("weapons/bounce.wav");          // grenade bounce
        precache_sound ("weapons/shotgn2.wav"); // super shotgun

//-----------new precaches----------
        precache_sound ("hknight/attack1.wav"); // sound 
        precache_model("progs/k_spike.mdl");    // model
};


Step 3
Hope you caught all that. I think by now you know how to use QuakeC patches, so I won't insult your intelligence. Have fun...