From 41a134a1957b7aa78e74697a7c4264f5776493a5 Mon Sep 17 00:00:00 2001 From: De-Seppe <71447857+De-Seppe@users.noreply.github.com> Date: Mon, 27 Sep 2021 12:56:22 +0200 Subject: [PATCH 1/3] 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/game/g_main.c | 1 + src/game/header/local.h | 1 + src/game/player/weapon.c | 5 +++-- src/game/savegame/savegame.c | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game/g_main.c b/src/game/g_main.c index 666d825d..aa003c2e 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -86,6 +86,7 @@ cvar_t *sv_maplist; cvar_t *gib_on; 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/game/header/local.h b/src/game/header/local.h index e82c2182..7d9bc33b 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -549,6 +549,7 @@ extern cvar_t *flood_waitdelay; extern cvar_t *sv_maplist; extern cvar_t *aimfix; +extern cvar_t *machinegun_norecoil; #define world (&g_edicts[0]) diff --git a/src/game/player/weapon.c b/src/game/player/weapon.c index 25eb4a03..75495d40 100644 --- a/src/game/player/weapon.c +++ b/src/game/player/weapon.c @@ -1249,7 +1249,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++; @@ -1258,7 +1258,8 @@ Machinegun_Fire(edict_t *ent) ent->client->machinegun_shots = 9; } } - + + /* get start / end positions */ VectorAdd(ent->client->v_angle, ent->client->kick_angles, angles); AngleVectors(angles, forward, right, NULL); diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index d0a68b38..b25733b1 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -273,6 +273,7 @@ InitGame(void) /* others */ aimfix = gi.cvar("aimfix", "0", CVAR_ARCHIVE); + machinegun_norecoil = gi.cvar("machinegun_norecoil", "0", CVAR_ARCHIVE); /* items */ InitItems(); From c1e0372366594521b50a5dd78f7f686726cc4fd0 Mon Sep 17 00:00:00 2001 From: De-Seppe <71447857+De-Seppe@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:06:58 +0200 Subject: [PATCH 2/3] Add new cvar to the documentation --- doc/040_cvarlist.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 08bcb64f..a4260264 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -48,6 +48,12 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` * **aimfix**: Fix aiming. When set to to `0` (the default) aiming is slightly inaccurate, bullets and the like have a little drift. When set to `1` they hit exactly were the crosshair is. + +* **machinegun_norecoil**: Disable machine gun recoil in single player. + By default this is set to `0`, this keeps the original machine gun + recoil in single player. When set to `1` the recoil is disabled in + single player, the same way as in multiplayer. + This cvar only works if the game.dll implements this behaviour. * **busywait**: By default this is set to `1`, causing Quake II to spin in a very tight loop until it's time to process the next frame. This From b471578c3e86d9fbff74bc9a345cf0843ac7d790 Mon Sep 17 00:00:00 2001 From: De-Seppe <71447857+De-Seppe@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:29:37 +0200 Subject: [PATCH 3/3] 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 --- doc/040_cvarlist.md | 2 +- src/game/g_main.c | 2 +- src/game/header/local.h | 2 +- src/game/player/weapon.c | 3 +-- src/game/savegame/savegame.c | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index a4260264..fda8a048 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -49,7 +49,7 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` slightly inaccurate, bullets and the like have a little drift. When set to `1` they hit exactly were the crosshair is. -* **machinegun_norecoil**: Disable machine gun recoil in single player. +* **g_machinegun_norecoil**: Disable machine gun recoil in single player. By default this is set to `0`, this keeps the original machine gun recoil in single player. When set to `1` the recoil is disabled in single player, the same way as in multiplayer. diff --git a/src/game/g_main.c b/src/game/g_main.c index aa003c2e..b2939a68 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -86,7 +86,7 @@ cvar_t *sv_maplist; cvar_t *gib_on; 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/game/header/local.h b/src/game/header/local.h index 7d9bc33b..a96683c5 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -549,7 +549,7 @@ extern cvar_t *flood_waitdelay; extern cvar_t *sv_maplist; extern cvar_t *aimfix; -extern cvar_t *machinegun_norecoil; +extern cvar_t *g_machinegun_norecoil; #define world (&g_edicts[0]) diff --git a/src/game/player/weapon.c b/src/game/player/weapon.c index 75495d40..99f49ced 100644 --- a/src/game/player/weapon.c +++ b/src/game/player/weapon.c @@ -1249,7 +1249,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++; @@ -1259,7 +1259,6 @@ Machinegun_Fire(edict_t *ent) } } - /* get start / end positions */ VectorAdd(ent->client->v_angle, ent->client->kick_angles, angles); AngleVectors(angles, forward, right, NULL); diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index b25733b1..06c652ff 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -273,7 +273,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();