Faster "weapprev" and "weapnext" behavior

Allows to skip the "previous" or "next" weapon, by constantly tapping
the bound key (or scrolling the mouse wheel).
This commit is contained in:
Jaime Moreira 2023-12-07 23:45:46 -03:00
parent c3968e2534
commit 15ac078a88
4 changed files with 26 additions and 17 deletions

View file

@ -728,12 +728,20 @@ Cmd_WeapPrev_f(edict_t *ent)
cl = ent->client;
if (!cl->pers.weapon)
if (g_quick_weap->value && cl->newweapon)
{
it = cl->newweapon;
}
else if (cl->pers.weapon)
{
it = cl->pers.weapon;
}
else
{
return;
}
selected_weapon = ITEM_INDEX(cl->pers.weapon);
selected_weapon = ITEM_INDEX(it);
/* scan for the next valid one */
for (i = 1; i <= MAX_ITEMS; i++)
@ -748,12 +756,7 @@ Cmd_WeapPrev_f(edict_t *ent)
it = &itemlist[index];
if (!it->use)
{
continue;
}
if (!(it->flags & IT_WEAPON))
if (!it->use || !(it->flags & IT_WEAPON))
{
continue;
}
@ -783,14 +786,22 @@ Cmd_WeapNext_f(edict_t *ent)
cl = ent->client;
if (!cl->pers.weapon)
if (g_quick_weap->value && cl->newweapon)
{
it = cl->newweapon;
}
else if (cl->pers.weapon)
{
it = cl->pers.weapon;
}
else
{
return;
}
selected_weapon = ITEM_INDEX(cl->pers.weapon);
selected_weapon = ITEM_INDEX(it);
/* scan for the next valid one */
/* scan for the next valid one */
for (i = 1; i <= MAX_ITEMS; i++)
{
/* prevent scrolling through ALL weapons */
@ -803,12 +814,7 @@ Cmd_WeapNext_f(edict_t *ent)
it = &itemlist[index];
if (!it->use)
{
continue;
}
if (!(it->flags & IT_WEAPON))
if (!it->use || !(it->flags & IT_WEAPON))
{
continue;
}

View file

@ -76,6 +76,7 @@ cvar_t *g_disruptor;
cvar_t *aimfix;
cvar_t *g_machinegun_norecoil;
cvar_t *g_quick_weap;
cvar_t *g_swap_speed;
void SpawnEntities(char *mapname, char *entities, char *spawnpoint);

View file

@ -635,6 +635,7 @@ extern cvar_t *g_disruptor;
extern cvar_t *aimfix;
extern cvar_t *g_machinegun_norecoil;
extern cvar_t *g_quick_weap;
extern cvar_t *g_swap_speed;
/* this is for the count of monsters */

View file

@ -260,6 +260,7 @@ InitGame(void)
/* others */
aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE);
g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "0", CVAR_ARCHIVE);
g_quick_weap = gi.cvar("g_quick_weap", "0", CVAR_ARCHIVE);
g_swap_speed = gi.cvar("g_swap_speed", "1", 0);
/* items */