From 82f72cca77e8e57ffedee001dc3f5b3e96dbd149 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Wed, 5 Jul 2023 16:18:13 -0400 Subject: [PATCH] Added Yamagi cheat cvars "g_machinegun_norecoil" and "g_swap_speed" --- src/g_main.c | 3 ++- src/header/local.h | 2 ++ src/player/weapon.c | 20 ++++++++++++-------- src/savegame/savegame.c | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/g_main.c b/src/g_main.c index 88c328f..5cd7036 100644 --- a/src/g_main.c +++ b/src/g_main.c @@ -46,6 +46,8 @@ cvar_t *gamedir; cvar_t *sv_cheats; cvar_t *aimfix; +cvar_t *g_machinegun_norecoil; +cvar_t *g_swap_speed; void SpawnEntities (char *mapname, char *entities, char *spawnpoint); void ClientThink (edict_t *ent, usercmd_t *cmd); @@ -357,4 +359,3 @@ void G_RunFrame (void) // build the playerstate_t structures for all players ClientEndServerFrames (); } - diff --git a/src/header/local.h b/src/header/local.h index fbc6f77..4e7405f 100644 --- a/src/header/local.h +++ b/src/header/local.h @@ -610,6 +610,8 @@ extern cvar_t *grenadeammo; extern cvar_t *bettyammo; extern cvar_t *aimfix; +extern cvar_t *g_machinegun_norecoil; +extern cvar_t *g_swap_speed; #define world (&g_edicts[0]) diff --git a/src/player/weapon.c b/src/player/weapon.c index 4a00cb7..55a4b5e 100644 --- a/src/player/weapon.c +++ b/src/player/weapon.c @@ -499,6 +499,7 @@ A generic function to handle the basics of weapon thinking void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, int FRAME_IDLE_LAST, int FRAME_DEACTIVATE_LAST, int *pause_frames, 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) { @@ -507,35 +508,36 @@ void 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 - FRAME_DEACTIVATE_FIRST) >= 4 ) + else if ( (FRAME_DEACTIVATE_LAST - FRAME_DEACTIVATE_FIRST) >= (4 * change_speed) ) { unsigned short int remainder = FRAME_DEACTIVATE_LAST - ent->client->ps.gunframe; // "if (remainder == 4)" at change_speed == 1 - if (remainder == 4) + if ( ( remainder <= (4 * change_speed) ) + && ( remainder > (3 * change_speed) ) ) { 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; } @@ -543,7 +545,7 @@ void 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) ) { Change_Weap_Animation(ent); } @@ -1184,11 +1186,13 @@ void Machinegun_Fire (edict_t *ent) ent->client->kick_angles[0] = ent->client->machinegun_shots * -1.5; // raise the gun as it is firing - if (!deathmatch->value) + if (!(deathmatch->value || g_machinegun_norecoil->value)) { ent->client->machinegun_shots++; if (ent->client->machinegun_shots > 9) + { ent->client->machinegun_shots = 9; + } } // get start / end positions diff --git a/src/savegame/savegame.c b/src/savegame/savegame.c index 93eb5c2..251e43e 100644 --- a/src/savegame/savegame.c +++ b/src/savegame/savegame.c @@ -236,6 +236,8 @@ 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 (); @@ -1156,4 +1158,3 @@ ReadLevel(const char *filename) } } } -