Quake Style - Quake 3 Tutorials Weapon Mods - Cluster Grenades! Converts the grenade launcher so it fires cluster grenades. |
void G_ExplodeCluster( gentity_t *ent ); gentity_t *fire_clustergrenade (gentity_t *self, vec3_t start, vec3_t dir);
void G_ExplodeCluster( gentity_t *ent ) { vec3_t dir; vec3_t origin; //Gerbil! vec3_t grenade1; vec3_t grenade2; vec3_t grenade3; vec3_t grenade4; BG_EvaluateTrajectory( &ent->s.pos, level.time, origin ); SnapVector( origin ); G_SetOrigin( ent, origin ); // we don't have a valid direction, so just point straight up dir[0] = dir[1] = 0; dir[2] = 10; ent->s.eType = ET_GENERAL; G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) ); ent->freeAfterEvent = qtrue; // splash damage if ( ent->splashDamage ) { if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, NULL , ent->splashMethodOfDeath ) ) { g_entities[ent->r.ownerNum].client->ps.persistant[PERS_ACCURACY_HITS]++; } } //Gerbil! VectorSet(grenade1, 25, 25, 30); VectorSet(grenade2, -25, 25, 30); VectorSet(grenade3, 25, -25, 30); VectorSet(grenade4, -25, -25, 30); fire_clustergrenade (ent, origin, grenade1); fire_clustergrenade (ent, origin, grenade2); fire_clustergrenade (ent, origin, grenade3); fire_clustergrenade (ent, origin, grenade4); trap_LinkEntity( ent ); }
bolt = G_Spawn(); bolt->classname = "grenade"; bolt->nextthink = level.time + 2500; // Gerbil! bolt->think = G_ExplodeCluster; bolt->s.eType = ET_MISSILE; bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
gentity_t *fire_clustergrenade (gentity_t *self, vec3_t start, vec3_t dir) { gentity_t *bolt; VectorNormalize (dir); bolt = G_Spawn(); bolt->classname = "grenade"; bolt->nextthink = level.time + 2000; bolt->think = G_ExplodeMissile; bolt->s.eType = ET_MISSILE; bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN; bolt->s.weapon = WP_GRENADE_LAUNCHER; bolt->s.eFlags = EF_BOUNCE_HALF; bolt->r.ownerNum = self->s.number; bolt->parent = self; bolt->damage = 100; bolt->splashDamage = 100; bolt->splashRadius = 150; bolt->methodOfDeath = MOD_GRENADE; bolt->splashMethodOfDeath = MOD_GRENADE_SPLASH; bolt->clipmask = MASK_SHOT; bolt->s.pos.trType = TR_GRAVITY; bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame VectorCopy( start, bolt->s.pos.trBase ); //Gerbil! lower the velocity from 700 to 400 VectorScale( dir, 400, bolt->s.pos.trDelta ); SnapVector( bolt->s.pos.trDelta ); // save net bandwidth VectorCopy (start, bolt->r.currentOrigin); return bolt; }