From 73beecec4449ab56fcc6a3ecdceea75fbd1f3193 Mon Sep 17 00:00:00 2001 From: De-Seppe <71447857+De-Seppe@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:14:38 +0200 Subject: [PATCH 1/2] Add cvar machinegun_norecoil Add cvar machinegun_norecoil This cvar allows to disable machinegun recoil in single player. The default value is the original Quake 2 behaviour. --- src/g_main.c | 1 + src/header/local.h | 1 + src/player/weapon.c | 2 +- src/savegame/savegame.c | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/g_main.c b/src/g_main.c index f3e843c..fbe9f53 100644 --- a/src/g_main.c +++ b/src/g_main.c @@ -75,6 +75,7 @@ cvar_t *randomrespawn; cvar_t *g_disruptor; cvar_t *aimfix; +cvar_t *machinegun_norecoil; void SpawnEntities(char *mapname, char *entities, char *spawnpoint); void ClientThink(edict_t *ent, usercmd_t *cmd); diff --git a/src/header/local.h b/src/header/local.h index ef3f102..4d1fe05 100644 --- a/src/header/local.h +++ b/src/header/local.h @@ -634,6 +634,7 @@ extern cvar_t *randomrespawn; extern cvar_t *g_disruptor; extern cvar_t *aimfix; +extern cvar_t *machinegun_norecoil; /* this is for the count of monsters */ #define ENT_SLOTS_LEFT \ diff --git a/src/player/weapon.c b/src/player/weapon.c index 729adf5..8107585 100644 --- a/src/player/weapon.c +++ b/src/player/weapon.c @@ -1475,7 +1475,7 @@ 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 || machinegun_norecoil->value)) { ent->client->machinegun_shots++; diff --git a/src/savegame/savegame.c b/src/savegame/savegame.c index e9b97c1..b1e99d3 100644 --- a/src/savegame/savegame.c +++ b/src/savegame/savegame.c @@ -259,6 +259,7 @@ InitGame(void) /* others */ aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE); + machinegun_norecoil = gi.cvar("machinegun_norecoil", "0", CVAR_ARCHIVE); /* items */ InitItems (); From ea57b889b6ccf35f933d67f19ee78a6726d7ff04 Mon Sep 17 00:00:00 2001 From: De-Seppe <71447857+De-Seppe@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:30:18 +0200 Subject: [PATCH 2/2] Rename variable to conform to naming guidelines Change the name of the cvar machinegun_norecoil to g_machinegun_norecoil to conform to the naming guidelines --- src/g_main.c | 2 +- src/header/local.h | 2 +- src/player/weapon.c | 2 +- src/savegame/savegame.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_main.c b/src/g_main.c index fbe9f53..9ba3b54 100644 --- a/src/g_main.c +++ b/src/g_main.c @@ -75,7 +75,7 @@ cvar_t *randomrespawn; cvar_t *g_disruptor; cvar_t *aimfix; -cvar_t *machinegun_norecoil; +cvar_t *g_machinegun_norecoil; void SpawnEntities(char *mapname, char *entities, char *spawnpoint); void ClientThink(edict_t *ent, usercmd_t *cmd); diff --git a/src/header/local.h b/src/header/local.h index 4d1fe05..ec37ed8 100644 --- a/src/header/local.h +++ b/src/header/local.h @@ -634,7 +634,7 @@ extern cvar_t *randomrespawn; extern cvar_t *g_disruptor; extern cvar_t *aimfix; -extern cvar_t *machinegun_norecoil; +extern cvar_t *g_machinegun_norecoil; /* this is for the count of monsters */ #define ENT_SLOTS_LEFT \ diff --git a/src/player/weapon.c b/src/player/weapon.c index 8107585..bcbbb71 100644 --- a/src/player/weapon.c +++ b/src/player/weapon.c @@ -1475,7 +1475,7 @@ 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 || machinegun_norecoil->value)) + if (!(deathmatch->value || g_machinegun_norecoil->value)) { ent->client->machinegun_shots++; diff --git a/src/savegame/savegame.c b/src/savegame/savegame.c index b1e99d3..3e79ea7 100644 --- a/src/savegame/savegame.c +++ b/src/savegame/savegame.c @@ -259,7 +259,7 @@ InitGame(void) /* others */ aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE); - machinegun_norecoil = gi.cvar("machinegun_norecoil", "0", CVAR_ARCHIVE); + g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "0", CVAR_ARCHIVE); /* items */ InitItems ();