Poison Axe

1996-06-22 InsideQC tutorials kleskby 0 155 Edit
Author: ShockMan
Source: https://www.insideqc.com/qctut/lesson-34.shtml

Step 1
Ok.. in this tutorial we are gonna make a Poison Axe... Thanx to the guy's that did TF, for the idea, but NOT for the code... this is totaly my own code... but thanx anyways...

First open up weapons.qc, search for the W_FireAxe function and replace it with this:


void() W_FireAxe =
{
    local   vector  source;
    local   vector  org;

    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;
        GetPoisoned(trace_ent);            // I added this...
        SpawnBlood (org, '0 0 0', 20);
        T_Damage (trace_ent, self, self, 10); // changed the last number to 10
                                              // instead of 20 to make the axe 
                                              // not do so much damage...
    }
    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 2
Now add this code before the W_FireAxe function:

void() OnPoisonThink =
{
    if (self.waterlevel >= 2) // if you get to water it stops
    {
        remove(self);
        return;
    }
    T_Damage (self.owner, self, self, 5); // do damage
    self.nextthink = time + 1; 
};      

void(entity ent) GetPoisoned =
{
    local   entity poison;

    poison = spawn (); 
    poison.owner = ent; 
    poison.movetype = MOVETYPE_NONE;
    poison.solid = SOLID_NOT;
        
    setmodel (poison, "");
    setsize (poison, '0 0 0', '0 0 0');             
    setorigin (poison, '0 0 0');
        
    poison.nextthink = time + 1;
    poison.think = OnPoisonThink;
};


Step 3
Now it shall war both in multiplayer and in single :)

Tags: tutorial, quakec, qc, insideqc, weapon
Owned by kleskby#1837
Telegram
Close

You have no new notifications.


You have no new messages.