Inside3D tutorials.
Created By: A. George Corrigan
eMail: corrigan@voyager.net
Difficulty Scale: Medium


Step 1
This is a cute little patch, which gives you the flame thrower, instead of the Grenade launcher! Ok now, let's get started. Open up weapons.qc file, and scroll down to the "W_FireGrenade" part. Now, comment it ALL OUT! (Using "//" or "/*" and "*/")

Step 2
When that's done, take all the code shown below, and add it just above the stuff you just commented out.
void(vector org) Flame_Burn =
{
        local entity flame;

        flame = spawn ();
        flame.owner = self;
        flame.classname = "fire";
        flame.movetype = MOVETYPE_FLYMISSILE;
        flame.solid = SOLID_NOT;
        flame.origin = org;
        flame.velocity = '0 0 75';
        setmodel (flame, "progs/s_explod.spr");
        setsize (flame, '0 0 0', '0 0 0');
        flame.nextthink = time + 0.01;
        flame.think = s_explode1;
};

void() Flame_Touch =
{
        local float r;
        local vector org;

        if (other.takedamage)
        {
                org = other.origin;
                org_z = self.origin_z;
                Flame_Burn (org);
                T_Damage (other, self, self.owner, 8);  // the amount of damage
                remove (self);
        }
};

void() W_FireGrenade =
{
        local entity flame;
        
        self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;

        sound (self, CHAN_WEAPON, "hknight/hit.wav", 1, ATTN_NORM);
        flame = spawn ();
        flame.owner = self;
        flame.movetype = MOVETYPE_FLYMISSILE;
        flame.solid = SOLID_BBOX;
        flame.classname = "fire";
        makevectors (self.v_angle);
        flame.velocity = aim (self, 100000);
        flame.velocity = flame.velocity * 500;
        flame.touch = Flame_Touch;
        setmodel (flame, "progs/s_explod.spr");
        setsize (flame, '0 0 0', '0 0 0');
        setorigin (flame, self.origin + (v_forward * 16) + '0 0 16');
        flame.think = s_explode1;
        flame.nextthink = time + 0.25;    // how far away from barrel before it flames up
        // W_Attack, self.attack_finished - Would control how how close together they come out
};

Step 3
Quite easy, eh? So.. you wanna have the flame to burn yer enemies? Ok, then follow this last big. Be warned, though, that this will make the game slower, since the EF_DIMLIGHT doesn't want to go away. Still want it?? Follow me!! Just add the 2 new functions, and re-place the old Flame_Touch!
void() Flame_Think = // New...
{
        local float r;

        if (self.enemy.waterlevel == 3 || self.enemy.health <= 0)
        {
                // Make hiss sound...
                BecomeExplosion ();
                return;
        }
        self.origin = self.enemy.origin + '0 0 25';
        if (r < 0.3)// how often they get hurt/scream...
                T_Damage (self.enemy, self, self.owner, 1);// how much it burns...
        self.nextthink = time + 0.01;
// NOTE: you must keep the .nextthink fast, otherwise the flame won't keepup with player.
};

void(vector org, entity e) Flame_Onfire = // New...
{
        local entity flame;

        flame = spawn ();
        flame.owner = self.owner;
        flame.enemy = e;
        flame.classname = "fire";
        flame.movetype = MOVETYPE_NONE;
        flame.solid = SOLID_NOT;
        flame.origin = org;
        flame.velocity = '0 0 0';
        setmodel (flame, "progs/flame2.mdl");    // Don't forget to precache this
        setsize (flame, '0 0 -15', '0 0 0');
        flame.nextthink = time + 0.01;
        flame.think = Flame_Think;
        flame.effects = flame.effects | EF_DIMLIGHT;
};

void() Flame_Touch = // remake of old Flame_Touch... Re-place the old one.
{
        local float r;
        local vector org;

        if (other.takedamage)
        {
                org = other.origin;
                org_z = self.origin_z;
                Flame_Burn (org);
                T_Damage (other, self, self.owner, 8);
                remove (self);
                r = random ();
                if (r < 0.2)// how often they get on-fire...
                {
                        if ((other.classname == "player"))
                        {
                                centerprint (other,"You are on fire!\n- Find WATER fast -");
                                stuffcmd (other,"bf\n");
                        }
                        Flame_Onfire (org, other);
                }
        }
};

Step 4
Now, that wasn't too hard, was it?? Compile, and load it up the usual way. Now, try the grenade launcher. Cool, eh? "I love the smell of fried sodiers in the morning" ;)