Thunder Grenades

InsideQC tutorials kleskby 0 631
Author: Dr DooMer
Source: https://www.insideqc.com/qctut/qctut-58.shtml

The grenade launcher may not be your favorite weapon right now, and after completing this tutorial it still might not be. But anyway, I'll show you how to make a nice effect that utilises the power of the temporary entities! So, open up weapons.qc and proceed to:

STEP 1

Scroll down about half way until you find W_FireGrenade. Search for it's "missile.nextthink" line and change it to:

missile.nextthink = time + 0.1;

And change it's "missile.think" line into:

missile.think = GrenadeZap;

Now, all we have done here is to tell the grenade that it should next think in 0.1 seconds time, and when it does think, to call the function GrenadeZap.

STEP 2

Now scroll up a bit and add this function just above W_FireGrenade:

void() GrenadeZap =
{
    local vector    org;

    self.count = self.count + 1;    // This bit is here to count
    if (self.count > 40)        // how long the grenade
    {               // has been lingering.
        GrenadeExplode();   // After forty 1/10 second
        return;         // counts, the grenade
    }               // just goes boom normally

    sound (self.owner, CHAN_VOICE, "weapons/lhit.wav", 1, ATTN_NORM);
    self.nextthink = time + 0.1;
    self.think = GrenadeZap;        // Repeat the function

    org = self.origin + '0 0 3';
    traceline (org, self.owner.origin + '0 0 10', TRUE, self);

    WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
    WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
    WriteEntity (MSG_BROADCAST, self);
    WriteCoord (MSG_BROADCAST, org_x);
    WriteCoord (MSG_BROADCAST, org_y);
    WriteCoord (MSG_BROADCAST, org_z);
    WriteCoord (MSG_BROADCAST, trace_endpos_x);
    WriteCoord (MSG_BROADCAST, trace_endpos_y);
    WriteCoord (MSG_BROADCAST, trace_endpos_z);
// Now, all this complicated bit of code does is draw
// a beam of lightning from one place to another

    LightningDamage (org, trace_endpos + v_forward*5, self.owner, 15);
// This is standard lightning gun code, and 15 the the amount of damage done.
};

Well, that's it! If you've done all that right, compile, run, and have fun! Try shooting grenades over a monster, and if you feel especially nasty, up the damage!



Tags: tutorial, quakec, qc, insideqc, weapon

Comments


captcha


No comments yet. Be the first!
Owned by kleskby#1837
Close

You have no new notifications.

SHOUTBOX
Open chat to load…
Log in to chat