Merge remote-tracking branch 'yquake2/master'

This commit is contained in:
Denis Pauk 2023-12-18 12:47:09 +02:00
commit 642aeedc43
5 changed files with 46 additions and 23 deletions

View file

@ -222,6 +222,12 @@ Set `0` by default.
single player, the same way as in multiplayer.
This cvar only works if the game.dll implements this behaviour.
* **g_quick_weap**: If set to `1`, both *weapprev* and *weapnext*
commands will "count" how many times they have been called, making
possible to skip weapons by quickly tapping one of these keys.
By default this cvar is set to `0`, and will only work if the
game.dll implements this behaviour.
* **g_swap_speed**: Sets the speed of the "changing weapon" animation.
Default is `1`. If set to `2`, it will be double the speed, `3` is
the triple... up until the max of `8`, since there are at least 2

View file

@ -866,17 +866,24 @@ 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++)
{
/* prevent scrolling through ALL weapons */
index = (selected_weapon + MAX_ITEMS - i) % MAX_ITEMS;
if (!cl->pers.inventory[index])
@ -886,22 +893,22 @@ 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;
}
it->use(ent, it);
/* prevent scrolling through ALL weapons */
if (cl->newweapon == it)
{
return;
if (g_quick_weap->value)
{
cl->ps.stats[STAT_PICKUP_ICON] = gi.imageindex(cl->newweapon->icon);
cl->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS + ITEM_INDEX(cl->newweapon);
cl->pickup_msg_time = level.time + 0.9f;
}
return; /* successful */
}
}
}
@ -921,17 +928,24 @@ 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 */
index = (selected_weapon + i) % MAX_ITEMS;
if (!cl->pers.inventory[index])
@ -941,22 +955,22 @@ 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;
}
it->use(ent, it);
/* prevent scrolling through ALL weapons */
if (cl->newweapon == it)
{
return;
if (g_quick_weap->value)
{
cl->ps.stats[STAT_PICKUP_ICON] = gi.imageindex(cl->newweapon->icon);
cl->ps.stats[STAT_PICKUP_STRING] = CS_ITEMS + ITEM_INDEX(cl->newweapon);
cl->pickup_msg_time = level.time + 0.9f;
}
return; /* successful */
}
}
}

View file

@ -100,6 +100,7 @@ cvar_t *g_disruptor;
cvar_t *aimfix;
cvar_t *g_machinegun_norecoil;
cvar_t *g_quick_weap;
cvar_t *g_swap_speed;
void G_RunFrame(void);

View file

@ -671,6 +671,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

@ -261,6 +261,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 */