From 6ef86de77790cd35861e634b0d745db84428d699 Mon Sep 17 00:00:00 2001
From: Mario <mario.mario@y7mail.com>
Date: Tue, 14 Jan 2020 02:49:20 +1000
Subject: [PATCH] Add g_buffs_randomize_teamplay setting (on by default) to
 control whether buffs are randomized in teamplay modes (g_buffs_randomize
 still acts as a master switch), useful for modes with bases where symmetry
 may be desired

---
 mutators.cfg                                    | 3 ++-
 qcsrc/common/mutators/mutator/buffs/sv_buffs.qc | 4 ++--
 qcsrc/common/mutators/mutator/buffs/sv_buffs.qh | 1 +
 qcsrc/server/g_world.qc                         | 1 +
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mutators.cfg b/mutators.cfg
index 14289d8c8..b6ad3468e 100644
--- a/mutators.cfg
+++ b/mutators.cfg
@@ -309,7 +309,8 @@ set g_buffs_effects 1 "show particle effects from carried buffs"
 set g_buffs_waypoint_distance 1024 "maximum distance at which buff waypoint can be seen from item"
 set g_buffs_pickup_anyway 0 "instantly respawn the buff when it is picked up, instead of waiting for the player to drop it"
 set g_buffs_pickup_delay 0.7 "cooldown before player can pick up another buff after dropping one"
-set g_buffs_randomize 1 "randomize buff type when player drops buff"
+set g_buffs_randomize 1 "randomize buff type when player drops the buff, only applies to teamplay gamemodes if g_buffs_randomize_teamplay is enabled"
+set g_buffs_randomize_teamplay 1 "in teamplay gamemodes, randomize buff type when player drops the buff, requires g_buffs_randomize"
 set g_buffs_random_lifetime 30 "re-spawn the buff again if it hasn't been touched after this time in seconds"
 set g_buffs_random_location 0 "randomize buff location on start and when reset"
 set g_buffs_random_location_attempts 10 "number of random locations a single buff will attempt to respawn at before giving up"
diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
index 5789b6e4c..f1a149166 100644
--- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
+++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
@@ -272,7 +272,7 @@ void buff_Think(entity this)
 	{
 		buff_SetCooldown(this, autocvar_g_buffs_cooldown_respawn + frametime);
 		this.owner = NULL;
-		if(autocvar_g_buffs_randomize)
+		if(autocvar_g_buffs_randomize && (!teamplay || autocvar_g_buffs_randomize_teamplay))
 			buff_NewType(this);
 
 		if(autocvar_g_buffs_random_location || (this.spawnflags & 64))
@@ -316,7 +316,7 @@ void buff_Waypoint_Reset(entity this)
 
 void buff_Reset(entity this)
 {
-	if(autocvar_g_buffs_randomize)
+	if(autocvar_g_buffs_randomize && (!teamplay || autocvar_g_buffs_randomize_teamplay))
 		buff_NewType(this);
 	this.owner = NULL;
 	buff_SetCooldown(this, autocvar_g_buffs_cooldown_activate);
diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh
index 671a524f9..88efc94eb 100644
--- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh
+++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qh
@@ -9,6 +9,7 @@ float autocvar_g_buffs_waypoint_distance;
 bool autocvar_g_buffs_pickup_anyway = false;
 float autocvar_g_buffs_pickup_delay = 0.7;
 bool autocvar_g_buffs_randomize;
+bool autocvar_g_buffs_randomize_teamplay = true;
 float autocvar_g_buffs_random_lifetime;
 bool autocvar_g_buffs_random_location;
 int autocvar_g_buffs_random_location_attempts;
diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index aed2d2ef5..c3dc5be39 100644
--- a/qcsrc/server/g_world.qc
+++ b/qcsrc/server/g_world.qc
@@ -330,6 +330,7 @@ void cvar_changes_init()
 		BADCVAR("g_balance_kill_delay");
 		BADCVAR("g_buffs_pickup_anyway");
 		BADCVAR("g_buffs_randomize");
+		BADCVAR("g_buffs_randomize_teamplay");
 		BADCVAR("g_campcheck_distance");
 		BADCVAR("g_ca_point_leadlimit");
 		BADCVAR("g_ca_point_limit");
-- 
2.39.5