
Posted by Manvak (151.204.199.*) on May 08, 1999 at
10:05:04:
This will simply allow you
to wait until you die to switch classes instead of respawning instantly. This
will prevent some lame-o from respawning with full health and ammo without
loosing frags every time someone hits him. To use this you must have first used
Willi's class-based mod starter, and i suggest that you also use a class menu.
First, in g_cmds.c, replace
this:
else if (Q_stricmp (cmd, "class1") == 0)
{
ent->client->resp.class = 1;
EndObserverMode (ent);
}
With this, for every class command that you have:
else if (Q_stricmp (cmd, "class1") == 0)
{
Cmd_SwitchClass_f(ent, 1);//Manvak
}
In the argument list (ent, 1) the number represents the class index. You need
to change that to the number that you use for each class.
Above that, somewhere
before the say function, use this:
/*
=================
Cmd_SwitchClass_f
Manvak
=================
*/
void Cmd_SwitchClass_f (edict_t *ent, int nclass)
{
if (ent->client->resp.class < 1 || ent->client->resp.class > HIGHEST CLASS # GOES HERE)
{
ent->client->resp.class = nclass;
EndObserverMode (ent);
}
else if (ent->client->resp.class == nclass)
{
gi.cprintf(ent, PRINT_HIGH, "You already are that class.\n");
PMenu_Close(ent);
}
else
{
ent->client->resp.nextclass = nclass;
if (ent->client->resp.nextclass == 1)
gi.cprintf(ent, PRINT_HIGH, "You will become class 1 next time you respawn.\n");
else if (ent->client->resp.nextclass == 2)
gi.cprintf(ent, PRINT_HIGH, "You will become class 2 next time you respawn.\n");
else
gi.cprintf(ent, PRINT_HIGH, "You will become class 3 next time you respawn.\n");
PMenu_Close(ent);
}
}
Good, almost done. Now all that we have to do is perform a check in the respawn
function to see if the dead client is suppose to change classes.
Do this in the respawn function in p_client.c:
//Manvak
if (!self->client->resp.nextclass == 0)
{
self->client->resp.class = self->client->resp.nextclass;
self->client->resp.nextclass = 0;
}
All that is left is to add
the nextclass variable into g_local.h.
Find the spot where you added the class variable(client_respawn_t):
int nextclass;
There, your done!
Remember to give credit where credit is due, and Enjoy!
Manvak