mirror of
https://github.com/yquake2/xatrix.git
synced 2025-02-22 11:51:26 +00:00
Cheat cvar "g_swap_speed" implemented
Allows to skip frames of "putting down weapon" and "raising weapon" animations, speeding them up.
This commit is contained in:
parent
4a04cf8afd
commit
a43de22013
4 changed files with 47 additions and 26 deletions
|
@ -68,6 +68,7 @@ cvar_t *gib_on;
|
||||||
|
|
||||||
cvar_t *aimfix;
|
cvar_t *aimfix;
|
||||||
cvar_t *g_machinegun_norecoil;
|
cvar_t *g_machinegun_norecoil;
|
||||||
|
cvar_t *g_swap_speed;
|
||||||
|
|
||||||
void SpawnEntities(char *mapname, char *entities, char *spawnpoint);
|
void SpawnEntities(char *mapname, char *entities, char *spawnpoint);
|
||||||
void ClientThink(edict_t *ent, usercmd_t *cmd);
|
void ClientThink(edict_t *ent, usercmd_t *cmd);
|
||||||
|
|
|
@ -542,6 +542,7 @@ extern cvar_t *sv_maplist;
|
||||||
|
|
||||||
extern cvar_t *aimfix;
|
extern cvar_t *aimfix;
|
||||||
extern cvar_t *g_machinegun_norecoil;
|
extern cvar_t *g_machinegun_norecoil;
|
||||||
|
extern cvar_t *g_swap_speed;
|
||||||
|
|
||||||
#define world (&g_edicts[0])
|
#define world (&g_edicts[0])
|
||||||
|
|
||||||
|
|
|
@ -493,6 +493,31 @@ Think_Weapon(edict_t *ent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make the weapon ready if there is ammo
|
* Make the weapon ready if there is ammo
|
||||||
*/
|
*/
|
||||||
|
@ -660,6 +685,7 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
||||||
int *fire_frames, void (*fire)(edict_t *ent))
|
int *fire_frames, void (*fire)(edict_t *ent))
|
||||||
{
|
{
|
||||||
int n;
|
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)
|
if (!ent || !fire_frames || !fire)
|
||||||
{
|
{
|
||||||
|
@ -678,23 +704,22 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
||||||
ChangeWeapon(ent);
|
ChangeWeapon(ent);
|
||||||
return;
|
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;
|
unsigned short int remainder = FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe;
|
||||||
|
// "if (remainder == 4)" at change_speed == 1
|
||||||
if (ent->client->ps.pmove.pm_flags & PMF_DUCKED)
|
if ( ( remainder <= (4 * change_speed) )
|
||||||
|
&& ( remainder > (3 * change_speed) ) )
|
||||||
{
|
{
|
||||||
ent->s.frame = FRAME_crpain4 + 1;
|
Change_Weap_Animation(ent);
|
||||||
ent->client->anim_end = FRAME_crpain1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ent->s.frame = FRAME_pain304 + 1;
|
|
||||||
ent->client->anim_end = FRAME_pain301;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->client->ps.gunframe++;
|
ent->client->ps.gunframe += change_speed;
|
||||||
|
if (ent->client->ps.gunframe > FRAME_DEACTIVATE_LAST)
|
||||||
|
{
|
||||||
|
ent->client->ps.gunframe = FRAME_DEACTIVATE_LAST;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,7 +732,11 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent->client->ps.gunframe++;
|
ent->client->ps.gunframe += change_speed;
|
||||||
|
if (ent->client->ps.gunframe > FRAME_ACTIVATE_LAST)
|
||||||
|
{
|
||||||
|
ent->client->ps.gunframe = FRAME_ACTIVATE_LAST;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,20 +745,9 @@ Weapon_Generic(edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST,
|
||||||
ent->client->weaponstate = WEAPON_DROPPING;
|
ent->client->weaponstate = WEAPON_DROPPING;
|
||||||
ent->client->ps.gunframe = FRAME_DEACTIVATE_FIRST;
|
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;
|
Change_Weap_Animation(ent);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -251,6 +251,7 @@ InitGame(void)
|
||||||
/* others */
|
/* others */
|
||||||
aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE);
|
aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE);
|
||||||
g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "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 */
|
/* items */
|
||||||
InitItems ();
|
InitItems ();
|
||||||
|
|
Loading…
Reference in a new issue