
As requested, here is how to have different
weapons appear when you press the same number multiple times. The code here is
using only the weapons which are in the basic game and because of that there is
the minor problem that if you select a weapon in a chain the normal way (i.e.
press 4 to select the machinegun) and then press the number allocated to a
chain which the machinegun appears in, the weapon after the machine gun ,in the
chain, will be selected. If you are using this code for your own weapons then
this shouldn't be a problem.
All the changes are made in a single function in
G_cmds.c. the function is Cmd_Use_f Then new code is marked with
// Begin multiweapon select. Copy this code block for multiple weapon chains
and
// End of multiweapon select
If you want more than one chain, then just copy
that code in again and change the weapons marked in it. Make sure that you are
using the pickup names of the weapons in the comparisons. (the pickup names are
defined in g_items.c)
Here is the modified Cmd_Use_f function.
void Cmd_Use_f (edict_t *ent){ int index; gitem_t *it; char *s; s = gi.args(); it = FindItem (s); // Begin multiweapon select. Copy this code block for multiple weapon chains if (!Q_strcasecmp(s, "Blaster")) // begin multi select for blaster { if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Blaster")) // do you have the blaster selected? it=FindItem ("Rocket Launcher"); // select the next in the weapon chain else if (!Q_strcasecmp(ent->client->pers.weapon->pickup_name,"Rocket Launcher")) // do you have the blaster selected? it=FindItem ("Machinegun"); // select the next in the weapon chain } // End of multiweapon select if (!it) { gi.cprintf (ent, PRINT_HIGH, "unknown item: %s\n", s); return; } if (!it->use) { gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n"); return; } index = ITEM_INDEX(it); if (!ent->client->pers.inventory[index]) { gi.cprintf (ent, PRINT_HIGH, "Out of item: %s\n", s); return; } it->use (ent, it);}
All the code does is check to see if you are
selecting the first weapon in the chain and then finding the current location
in the chain, then selecting the next weapon in the chain. As it stands at the
moment if you don't have the next weapon in the chain (or no ammo for it) you
cant progress through the chain. I should get round to fixing this, but it'll
probably change the code a fair bit. (i'm planning to use arrays)