mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-31 21:30:36 +00:00
Merge pull request #1031 from protocultor/g_swap_speed
Cheat to speed up "weapon change" animations
This commit is contained in:
commit
cb317f2cd3
6 changed files with 49 additions and 28 deletions
|
@ -222,6 +222,13 @@ Set `0` by default.
|
|||
single player, the same way as in multiplayer.
|
||||
This cvar only works 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
|
||||
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.
|
||||
|
||||
* **g_disruptor (Ground Zero only)**: This boolean cvar controls the
|
||||
availability of the Disruptor weapon to players. The Disruptor is
|
||||
a weapon that was cut from Ground Zero during development but all
|
||||
|
|
|
@ -686,6 +686,7 @@ cheatvar_t cheatvars[] = {
|
|||
{"cl_kickangles", "1"},
|
||||
{"g_footsteps", "1"},
|
||||
{"g_machinegun_norecoil", "0"},
|
||||
{"g_swap_speed", "1"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ cvar_t *gib_on;
|
|||
|
||||
cvar_t *aimfix;
|
||||
cvar_t *g_machinegun_norecoil;
|
||||
cvar_t *g_swap_speed;
|
||||
|
||||
void G_RunFrame(void);
|
||||
|
||||
|
|
|
@ -551,6 +551,7 @@ extern cvar_t *sv_maplist;
|
|||
|
||||
extern cvar_t *aimfix;
|
||||
extern cvar_t *g_machinegun_norecoil;
|
||||
extern cvar_t *g_swap_speed;
|
||||
|
||||
#define world (&g_edicts[0])
|
||||
|
||||
|
|
|
@ -570,6 +570,31 @@ Drop_Weapon(edict_t *ent, gitem_t *item)
|
|||
ent->client->pers.inventory[index]--;
|
||||
}
|
||||
|
||||
/*
|
||||
* Client (player) animation for changing weapon
|
||||
*/
|
||||
static void
|
||||
Change_Weap_Animation(edict_t *ent)
|
||||
{
|
||||
if (!ent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ent->client->anim_priority = ANIM_REVERSE;
|
||||
|
||||
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
||||
{
|
||||
ent->s.frame = FRAME_crpain4 + 1;
|
||||
ent->client->anim_end = FRAME_crpain1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ent->s.frame = FRAME_pain304 + 1;
|
||||
ent->client->anim_end = FRAME_pain301;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A generic function to handle
|
||||
* the basics of weapon thinking
|
||||
|
@ -580,6 +605,7 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
|||
int *fire_frames, void (*fire)(edict_t *ent))
|
||||
{
|
||||
int n;
|
||||
const unsigned short int change_speed = (g_swap_speed->value > 0)?(unsigned short int)g_swap_speed->value:1;
|
||||
|
||||
if (!ent || !fire_frames || !fire)
|
||||
{
|
||||
|
@ -593,41 +619,36 @@ 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;
|
||||
}
|
||||
else if ((FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe) == 4)
|
||||
else if ( (FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) >= (4 * change_speed) )
|
||||
{
|
||||
ent->client->anim_priority = ANIM_REVERSE;
|
||||
|
||||
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
||||
unsigned short int remainder = FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe;
|
||||
// "if (remainder == 4)" at change_speed == 1
|
||||
if ( ( remainder <= (4 * change_speed) )
|
||||
&& ( remainder > (3 * change_speed) ) )
|
||||
{
|
||||
ent->s.frame = FRAME_crpain4 + 1;
|
||||
ent->client->anim_end = FRAME_crpain1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ent->s.frame = FRAME_pain304 + 1;
|
||||
ent->client->anim_end = FRAME_pain301;
|
||||
Change_Weap_Animation(ent);
|
||||
}
|
||||
}
|
||||
|
||||
ent->client->ps.gunframe++;
|
||||
ent->client->ps.gunframe += change_speed;
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
||||
ent->client->ps.gunframe++;
|
||||
ent->client->ps.gunframe += change_speed;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -636,20 +657,9 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
|||
ent->client->weaponstate = WEAPON_DROPPING;
|
||||
ent->client->ps.gunframe = FRAME_DEACTIVATE_FIRST;
|
||||
|
||||
if ((FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < 4)
|
||||
if ( (FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) < (4 * change_speed) )
|
||||
{
|
||||
ent->client->anim_priority = ANIM_REVERSE;
|
||||
|
||||
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
||||
{
|
||||
ent->s.frame = FRAME_crpain4 + 1;
|
||||
ent->client->anim_end = FRAME_crpain1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ent->s.frame = FRAME_pain304 + 1;
|
||||
ent->client->anim_end = FRAME_pain301;
|
||||
}
|
||||
Change_Weap_Animation(ent);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -246,6 +246,7 @@ InitGame(void)
|
|||
/* others */
|
||||
aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE);
|
||||
g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "0", CVAR_ARCHIVE);
|
||||
g_swap_speed = gi.cvar("g_swap_speed", "1", 0);
|
||||
|
||||
/* items */
|
||||
InitItems();
|
||||
|
|
Loading…
Reference in a new issue