From a94e9dca81b6fb07da32763a2bcb4f96fc70c0fc Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Thu, 29 Jun 2023 11:14:58 -0400 Subject: [PATCH] Snappier "g_swap_speed" behaviour Player is no longer forced to go through the last frame of activation or deactivation of a weapon before changing its state. --- doc/040_cvarlist.md | 2 +- src/game/player/weapon.c | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 5261d0ae..f7ccd667 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -224,7 +224,7 @@ Set `0` by default. * **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 4 + the triple... up until the max of `8`, since there are at least 2 frames of animation that will be played compulsorily, on every weapon. Cheat-protected, has to be a positive integer. As with the last one, will only work if the game.dll implements this behaviour. diff --git a/src/game/player/weapon.c b/src/game/player/weapon.c index 3875fa7b..173fc763 100644 --- a/src/game/player/weapon.c +++ b/src/game/player/weapon.c @@ -619,7 +619,7 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, if (ent->client->weaponstate == WEAPON_DROPPING) { - if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST) + if (ent->client->ps.gunframe >= FRAME_DEACTIVATE_LAST - change_speed + 1) { ChangeWeapon(ent); return; @@ -636,16 +636,12 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, } ent->client->ps.gunframe += change_speed; - if (ent->client->ps.gunframe > FRAME_DEACTIVATE_LAST) - { - ent->client->ps.gunframe = FRAME_DEACTIVATE_LAST; - } return; } if (ent->client->weaponstate == WEAPON_ACTIVATING) { - if (ent->client->ps.gunframe == FRAME_ACTIVATE_LAST) + if (ent->client->ps.gunframe >= FRAME_ACTIVATE_LAST - change_speed + 1) { ent->client->weaponstate = WEAPON_READY; ent->client->ps.gunframe = FRAME_IDLE_FIRST; @@ -653,10 +649,6 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, } ent->client->ps.gunframe += change_speed; - if (ent->client->ps.gunframe > FRAME_ACTIVATE_LAST) - { - ent->client->ps.gunframe = FRAME_ACTIVATE_LAST; - } return; }