in g_cmds:
extern void propExplosion ( gentity_t * ent ) ;
/*
=================
Cmd_Kamikaze_f
=================
*/
void Cmd_Kamikaze_f( gentity_t *ent ) {
int random_num;
char text[4][50] = { "^1G^7et out of here it's gonna ^1BLOW^7!",
"-----^1]^7 Kam^1i^7kaze ^1[^7 ------^7 !!!",
"^3Boom, Boom BOOooo0000m!!",
"^2E^7at ^2T^7his ^8!!!",
}; // each string must be no longer
// than 50 characters, or increase the
// size of the 2nd array value.
static trace_t tr;
gentity_t *traceEnt;
traceEnt = &g_entities[ tr.entityNum ];
// set a random number
srand(time(NULL));
random_num = rand()%4; /*sets random_number to a number between 0 and 3, both included */
ent->timestamp = level.time;
if ( ent->client->pers.kami >= g_kami.integer ) {
trap_SendServerCommand( ent-g_entities, "print \"You have used ^1ALL^7 of your Kamikaze's!.
\"" ); // Kami limiting :O
return;
}
trap_SendServerCommand( -1, va("chat \"Console: %s^7: %s\"", ent->client->pers.netname,text[random_num])); //say something :)
ent->client->pers.kami = ent->client->pers.kami + 1;
G_StartKamikaze (ent); // Make damage around you in a shockwave.
propExplosion (ent); // you explode...
}
thats the g_cmds part…
now to the final part: goto g_weapon.c and somewhere add this:
/*
===============
G_StartKamikaze
===============
*/
void G_StartKamikaze( gentity_t *ent ) {
gentity_t *explosion;
gentity_t *te;
vec3_t snapped;
int kamidamage;
kamidamage = g_kamidamage.integer;
// start up the explosion logic
explosion = G_Spawn();
explosion->s.eType = ET_EVENTS + EV_KAMIKAZE;
explosion->eventTime = level.time;
if ( ent->client ) {
VectorCopy( ent->s.pos.trBase, snapped );
}
else {
VectorCopy( ent->activator->s.pos.trBase, snapped );
}
SnapVector( snapped ); // save network bandwidth
G_SetOrigin( explosion, snapped );
explosion->classname = "kamikaze";
explosion->s.pos.trType = TR_STATIONARY;
explosion->kamikazeTime = level.time;
explosion->think = KamikazeDamage;
explosion->nextthink = level.time + 100; //100
explosion->count = 0;
VectorClear(explosion->movedir);
trap_LinkEntity( explosion );
if (ent->client) {
//
explosion->activator = ent;
//
ent->s.eFlags &= ~EF_KAMIKAZE;
// nuke the guy that used it
//G_Damage( ent, ent, ent, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_KAMIKAZE );
G_Damage( ent, ent, ent, NULL, NULL, kamidamage, DAMAGE_NO_PROTECTION, MOD_KAMIKAZE );
}
else {
if ( !strcmp(ent->activator->classname, "bodyque") ) {
explosion->activator = &g_entities[ent->activator->r.ownerNum];
}
else {
explosion->activator = ent->activator;
}
}
// play global sound at all clients
te = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_CLIENT_SOUND );
te->r.svFlags |= SVF_BROADCAST;
te->s.eventParm = G_SoundIndex( "sound/multiplayer/artillery_exp01");
}