Created By: Kryten
eMail: kryten@inside3d.com
Difficulty Scale: Easy


Instead of having the shotgun firing normal buckshot you can make it fire explosive buckshot. In this tut I will show you how to do that. You will need a new explosion sprite, a smaller one, I am giving you a smaller version of id's exposion sprite, but I recomend making your own.

Step One: Download the sprite from here. Or make your own (If you know how then it would be better).

Step Two: Open the weapons.qc, you need to precache the sprite so add this line to the bottom of the W_Precache function.

precache_model ("progs/sm_expld.spr"); //small explosion

(if using your own sprite then precache that instead).

Step Three: Now go down till you see something like this:

/*
============================================================

BULLETS

============================================================
*/

directly after that you want to add these lines:

/*
================
ShotgnExpld -- For Explosive Shotgun
================
*/
void () s_explode1; //this function is later in weapons.qc
void () sm_expld =
{
	setmodel (self, "progs/sm_expld.spr");
	particle (self.origin, self.oldorigin*0.05, 235, 16);
	sound (self, CHAN_BODY, "weapons/r_exp3.wav", 0.5, ATTN_NORM);
	s_explode1 ();
};

The function you just added sets the buckshot to the explosion, throws some particles, makes an explosion sound, and then animates the explosion. The self.oldorigin has nothing to do with the old origin but instead in has to do with the velocity the particles should be thrown at. The 0.5 in the sound is the volume the sound should play at, 1 is full (don't ever set over 1). You should be able to understand everything else.

Step Four: Add this function just after the last one you added:

void (vector org, vector vel) ShotgnExpld =
{
	local entity expld;
	expld = spawn();
	setorigin (expld, org);
	setsize (expld, '0 0 0', '0 0 0');
	expld.oldorigin = vel;
	expld.movetype = MOVETYPE_NONE;
	expld.solid = SOLID_NOT;
	expld.think = sm_expld;
	expld.nextthink = time + random()*0.4;
	T_RadiusDamage (expld, self, 80, world);
};

What this function does is it makes a new entity where the buckshot should be. It will then call the other function you made just above it. Some of you may be wondering what the random()*0.4 is for in the nextthink, what that does it it make the explosions happen at slightly different times, it just looks cool. The T_RadiusDamage is set to 80 for larger area only, we will modify that function to do less damage.

Step Five: Now go down just a little ways down to the TraceAttack function. You need to add this:

	if (self.weapon == IT_SHOTGUN || self.weapon == IT_SUPER_SHOTGUN)
	{
		ShotgnExpld (org, vel*0.2);
		if (trace_ent.takedamage) //even out damage & for doors & triggers
			T_Damage (trace_ent, self, self, 2);
	}
	else if (trace_ent.takedamage)

just above this line and then delete this line:

if (trace_ent.takedamage)

This has been set up so only players can use the explosive shotguns

Step Six: You're almost done, save and close that file and open the combat.qc. Go down to T_RadiusDamage function, in that function just after these lines:

	if (head == attacker)
		points = points * 0.5;

you need to add these lines:

	if (attacker.weapon == IT_SHOTGUN || attacker.weapon == IT_SUPER_SHOTGUN)
		points = points*0.015; //less damage

And thats it!