Author: John Rittenhouse
Let's Do It...
Okay open up "g_weapon.c" now add at the end this code.
This site, and all content and graphics displayed on it,
Difficulty: Easy
Alright now open up "p_view.c" and goto "void SV_CalcViewOffset (edict_t *ent)" add this at the top of it.
/*
===========================
Concussion Grenades
===========================
*/
void Concussion_Explode (edict_t *ent)
{
vec3_t offset,v;
edict_t *target;
float Distance, DrunkTimeAdd;
// Move it off the ground so people are sure to see it
VectorSet(offset, 0, 0, 10);
VectorAdd(ent->s.origin, offset, ent->s.origin);
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)
DrunkTimeAdd = 20; //completely drunk
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)
target->DrunkTime = DrunkTimeAdd+level.time;
else
target->DrunkTime += DrunkTimeAdd;
}
// Blow up the grenade
BecomeExplosion1(ent);
}
void fire_concussiongrenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, float timer, float damage_radius)
{
edict_t *grenade;
vec3_t dir;
vec3_t forward, right, up;
vectoangles (aimdir, dir);
AngleVectors (dir, forward, right, up);
grenade = G_Spawn();
VectorCopy (start, grenade->s.origin);
VectorScale (aimdir, speed, grenade->velocity);
VectorMA (grenade->velocity, 200 + crandom() * 30.0, up, grenade->velocity);
VectorMA (grenade->velocity, crandom() * 10.0, right, grenade->velocity);
VectorSet (grenade->avelocity, 300, 300, 300);
grenade->movetype = MOVETYPE_BOUNCE;
grenade->clipmask = MASK_SHOT;
grenade->solid = SOLID_BBOX;
grenade->s.effects |= EF_GRENADE;
VectorClear (grenade->mins);
VectorClear (grenade->maxs);
grenade->s.modelindex = gi.modelindex ("models/objects/grenade/tris.md2");
grenade->owner = self;
grenade->touch = Grenade_Touch; //Stuff for cluster grenades when they explode
grenade->nextthink = level.time + timer;
grenade->think = Concussion_Explode; //stuff for cluster grenades exploding
grenade->dmg = damage;
grenade->dmg_radius = damage_radius;
grenade->classname = "concussion";
VectorSet(grenade->mins, -3, -3, 0);
VectorSet(grenade->maxs, 3, 3, 6);
grenade->mass = 2;
grenade->health = 10;
grenade->die = Grenade_Die;
grenade->takedamage = DAMAGE_YES;
grenade->monsterinfo.aiflags = AI_NOSTEP;
gi.linkentity (grenade);
}
ALright now go below the code
edict_t *Bub;
float bob;
and add this now.
if (bobcycle & 1)
delta = -delta;
angles[ROLL] += delta;
Now goto the end of the sub "void G_SetClientEffects (edict_t *ent)" and add this.
//add angles based on drunkness
if (ent->DrunkTime > level.time)
{
bubble = bubble + 1;
if (bubble == 10)
{
Bub = G_Spawn();
Bub->movetype = MOVETYPE_NOCLIP;
Bub->clipmask = MASK_SHOT;
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);
gi.linkentity(Bub);
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;
}
Okay this should work. I hope all the bugs are out of this.
if (ent->DrunkTime>level.time)
ent->client->ps.rdflags |= RDF_UNDERWATER;
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