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.
This commit is contained in:
Jaime Moreira 2023-06-29 11:14:58 -04:00
parent c5e2d51fd7
commit a94e9dca81
2 changed files with 3 additions and 11 deletions

View file

@ -224,7 +224,7 @@ Set `0` by default.
* **g_swap_speed**: Sets the speed of the "changing weapon" animation. * **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 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. frames of animation that will be played compulsorily, on every weapon.
Cheat-protected, has to be a positive integer. As with the last one, Cheat-protected, has to be a positive integer. As with the last one,
will only work if the game.dll implements this behaviour. will only work if the game.dll implements this behaviour.

View file

@ -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->weaponstate == WEAPON_DROPPING)
{ {
if (ent->client->ps.gunframe == FRAME_DEACTIVATE_LAST) if (ent->client->ps.gunframe >= FRAME_DEACTIVATE_LAST - change_speed + 1)
{ {
ChangeWeapon(ent); ChangeWeapon(ent);
return; return;
@ -636,16 +636,12 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
} }
ent->client->ps.gunframe += change_speed; ent->client->ps.gunframe += change_speed;
if (ent->client->ps.gunframe > FRAME_DEACTIVATE_LAST)
{
ent->client->ps.gunframe = FRAME_DEACTIVATE_LAST;
}
return; return;
} }
if (ent->client->weaponstate == WEAPON_ACTIVATING) 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->weaponstate = WEAPON_READY;
ent->client->ps.gunframe = FRAME_IDLE_FIRST; 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; ent->client->ps.gunframe += change_speed;
if (ent->client->ps.gunframe > FRAME_ACTIVATE_LAST)
{
ent->client->ps.gunframe = FRAME_ACTIVATE_LAST;
}
return; return;
} }