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:46:43 -04:00
parent 15c531c300
commit 8319109c9f

View file

@ -705,7 +705,7 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int F
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;
@ -722,16 +722,12 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int F
} }
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;
@ -739,10 +735,6 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int F
} }
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;
} }