Inside3D tutorials.
Created By: SHaDoW.STaLKeR (Evan)
eMail: evan@patriot.net
Difficulty Scale: Medium


Step 1
This tutorial will teach you how to modify the rocket launcher to shoot 3 rockets instead of 1. This weapon is powerful! To begin open the file weapons.qc and scroll down to about line 375 which should read:
void() W_FireRocket =

Step 2
This step is very simple. First you must declare two entities: missile2 and missile3 (They can actually have any names you choose). Next you need to modify the amount of ammo taken from each shot. Since you will be shooting 3 rockets, I suggest you have 3 subtracted from your rocket supply. The code in blue is what was modified or added in this section.
void() W_FireRocket =
{
	local	entity missile, mpuff;
	local	entity missile2, missile3;   //Declaration of two entities

	self.currentammo = self.ammo_rockets = self.ammo_rockets - 3;

Step 3
Now scroll down a little bit to the end of this function. The end of a function looks like };. Add the following code right above the ending. This code is will fire missile2 to the right of missile. This isn't original code. It is almost exactly the same code as the code already in the function that fires the missile in the center. Just copy it and then add the portions in blue. You also most change every occurance of missile to missile2. Both portions of code in blue move the rocket fired slightly to the right.
//missile2
	sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
	missile2 = spawn ();
	missile2.owner = self;
	missile2.movetype = MOVETYPE_FLYMISSILE;
	missile2.solid = SOLID_BBOX;
	missile2.classname = "missile";

// set missile2 speed

	makevectors (self.v_angle - '0 1 0');
	missile2.velocity = aim(self, 1000);
	missile2.velocity = missile2.velocity * 1000;
	missile2.angles = vectoangles(missile2.velocity);

	missile2.touch = T_MissileTouch;

// set missile2 duration
	missile2.nextthink = time + 5;
	missile2.think = SUB_Remove;

	setmodel (missile2, "progs/missile.mdl");
	setsize (missile2, '0 0 0', '0 0 0');
	setorigin (missile2, self.origin + v_forward*8 + v_right*8 +'0 0 16');

Step 4
This step is almost exactly the same as STEP 3. Just copy the missile2 and change every occurance of missile2 to missile3. This way you are initializing the missile3 entity. Also the blue code below must be changed as well. The only differences between the portions in blue are the minus (-) signs. This will move the missile3 entity slightly to the left.
//missile3
	sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
	missile3 = spawn ();
	missile3.owner = self;
	missile3.movetype = MOVETYPE_FLYMISSILE;
	missile3.solid = SOLID_BBOX;
	missile3.classname = "missile";

// set missile3 speed

	makevectors (self.v_angle + '0 1 0');
	missile3.velocity = aim(self, 1000);
	missile3.velocity = missile3.velocity * 1000;
	missile3.angles = vectoangles(missile3.velocity);

	missile3.touch = T_MissileTouch;

// set missile3 duration
	missile3.nextthink = time + 5;
	missile3.think = SUB_Remove;

	setmodel (missile3, "progs/missile.mdl");
	setsize (missile3, '0 0 0', '0 0 0');
	setorigin (missile3, self.origin + v_forward*8 + v_right*-8 +'0 0 16');


Step 5
You will now fire 3 rockets instead of one, but there is one more thing you must edit. The function below can be found at around line 487 under the "W_BestWeapon" function. The code in blue should be added so that when you don't have 3 rockets and try to fire the tri-rocket launcher it switchs weapons. It should be pretty easy to understand. The first statement says "if you have more than 3 ammo and you are using the rocket launcher then go back to playing (you have enough ammo). The second statement says "if you have ammo and your using some other weapon then go back to the game."
float() W_CheckNoAmmo =
{
        if ((self.currentammo > 3) && (self.weapon == IT_ROCKET_LAUNCHER))
                return TRUE;

        if ((self.currentammo > 0) && (self.weapon != IT_ROCKET_LAUNCHER))
                return TRUE;
        
	if (self.weapon == IT_AXE)
		return TRUE;
	
	self.weapon = W_BestWeapon ();

	W_SetCurrentAmmo ();
	
// drop the weapon down
	return FALSE;
};

Step 6
That's it. Compile it, run it, and have fun. Your rocket launcher will now shoot 3 rockets instead of 1.