Author: John Rittenhouse
Difficulty: Easy

Let's Do It...

Alright here is those concussion grenades from Team Fortress with some things added in. This code is not taken from the Team Fortress source code at all and is total written new by me, John Rittenhouse. SO here we go. Also make notice I set my grenades up so they can be killed so make sure you do that tutorial I forget who did that one but thanx.

Okay open up "g_weapon.c" now add at the end this code.

```/*
===========================
===========================
*/
void Concussion_Explode (edict_t *ent)
{
vec3_t      offset,v;
edict_t *target;
// Move it off the ground so people are sure to see it
VectorSet(offset, 0, 0, 10);

if (ent->owner->client)
PlayerNoise(ent->owner, ent->s.origin, PNOISE_IMPACT);

target = NULL;
while ((target = findradius(target, ent->s.origin, 520)) != NULL)
{
if (!target->client)
continue;       // It's not a player
if (!visible(ent, target))
continue;       // The grenade can't see it
// Find distance
VectorSubtract(ent->s.origin, target->s.origin, v);
Distance = VectorLength(v);
// Calculate drunk factor
if(Distance < 520/10)
else
DrunkTimeAdd = 1.5 * 20 * ( 1 / ( ( Distance - 520*2 ) / (520*2) - 2 ) + 1 ); //partially drunk
if ( DrunkTimeAdd < 0 )
DrunkTimeAdd = 0; // Do not make drunk at all.

// Increment the drunk time
if(target->DrunkTime < level.time)
else
}

BecomeExplosion1(ent);
}

void fire_concussiongrenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius)
{
vec3_t	dir;
vec3_t	forward, right, up;

vectoangles (aimdir, dir);
AngleVectors (dir, forward, right, up);

}
```
Alright now open up "p_view.c" and goto "void SV_CalcViewOffset (edict_t *ent)" add this at the top of it.
```	edict_t *Bub;
float		bob;
```
ALright now go below the code
```	if (bobcycle & 1)
delta = -delta;
angles[ROLL] += delta;
```
```		//add angles based on drunkness
if (ent->DrunkTime > level.time)
{
bubble = bubble + 1;
if (bubble == 10)
{
Bub = G_Spawn();
Bub->movetype = MOVETYPE_NOCLIP;
Bub->solid = SOLID_NOT;
VectorClear (Bub->mins);
VectorClear (Bub->maxs);
VectorSet (Bub->velocity,0,0,10);
Bub->s.modelindex = gi.modelindex ("sprites/s_bubble.sp2");
Bub->nextthink = level.time + 2;
Bub->think = G_FreeEdict;
VectorCopy(ent->s.origin,Bub->s.origin);
bubble = 0;
}
ent->client->ps.rdflags |= RDF_UNDERWATER;
if(YDirection)
ent->DizzyYaw += random()*6;
else
ent->DizzyYaw -= random()*6;
if(PDirection)
ent->DizzyPitch += random()*5;
else
ent->DizzyPitch -= random()*5;
if(RDirection)
ent->DizzyRoll += random()*3;
else
ent->DizzyRoll -= random()*3;
if (ent->DizzyYaw < -35)
YDirection = 1;
if (ent->DizzyYaw > 35)
YDirection = 0;
if (ent->DizzyPitch < -25)
PDirection = 1;
if (ent->DizzyPitch > 25)
PDirection = 0;
if (ent->DizzyRoll < -25)
RDirection = 1;
if (ent->DizzyRoll > 25)
RDirection = 0;
angles[YAW] += ent->DizzyYaw;
angles[PITCH] += ent->DizzyPitch;
angles[ROLL] += ent->DizzyRoll;
}
```
Now goto the end of the sub "void G_SetClientEffects (edict_t *ent)" and add this.
```	if (ent->DrunkTime>level.time)
ent->client->ps.rdflags |= RDF_UNDERWATER;
```
Okay this should work. I hope all the bugs are out of this.

 This site, and all content and graphics displayed on it, are ©opyrighted to the Quake DeveLS team. All rights received.Got a suggestion? Comment? Question? Hate mail? Send it to us!Oh yeah, this site is best viewed in 16 Bit or higher, with the resolution on 800*600.Thanks to Planet Quake for their great help and support with hosting. Best viewed with Netscape 4