From 6feba10e1819ab46a2491f434fabe45f99c65541 Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@alientrap.org>
Date: Tue, 16 Nov 2010 07:45:54 +0100
Subject: [PATCH] add cvars for electro secondary bouncefactor/bouncestop

---
 balance25.cfg              |  2 ++
 balanceLeeStricklin.cfg    |  2 ++
 balanceNexSVN.cfg          |  2 ++
 balanceSamual.cfg          |  2 ++
 balanceTest.cfg            |  2 ++
 balanceXonotic.cfg         |  2 ++
 balancetZork.cfg           |  2 ++
 qcsrc/client/Main.qc       |  6 ++++--
 qcsrc/client/main.qh       |  6 ++++--
 qcsrc/client/projectile.qc |  6 ++++--
 qcsrc/server/cl_client.qc  | 15 +++++++++++++++
 qcsrc/server/w_electro.qc  |  4 ++--
 12 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/balance25.cfg b/balance25.cfg
index 9a0792012..001572fe5 100644
--- a/balance25.cfg
+++ b/balance25.cfg
@@ -384,6 +384,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 5
 set g_balance_electro_secondary_damageforcescale 4
 set g_balance_electro_secondary_count 1
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 80
 set g_balance_electro_combo_edgedamage 0
 set g_balance_electro_combo_force 200
diff --git a/balanceLeeStricklin.cfg b/balanceLeeStricklin.cfg
index 1e72552ae..62847823f 100644
--- a/balanceLeeStricklin.cfg
+++ b/balanceLeeStricklin.cfg
@@ -395,6 +395,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 10
 set g_balance_electro_secondary_damageforcescale 4
 set g_balance_electro_secondary_count 3
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 70
 set g_balance_electro_combo_edgedamage 0
 set g_balance_electro_combo_force 200
diff --git a/balanceNexSVN.cfg b/balanceNexSVN.cfg
index b17358db7..e4c4a69d1 100644
--- a/balanceNexSVN.cfg
+++ b/balanceNexSVN.cfg
@@ -383,6 +383,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 5
 set g_balance_electro_secondary_damageforcescale 4
 set g_balance_electro_secondary_count 1
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 80
 set g_balance_electro_combo_edgedamage 0
 set g_balance_electro_combo_force 200
diff --git a/balanceSamual.cfg b/balanceSamual.cfg
index 5858ec213..b82fa6632 100644
--- a/balanceSamual.cfg
+++ b/balanceSamual.cfg
@@ -384,6 +384,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 5
 set g_balance_electro_secondary_damageforcescale 4
 set g_balance_electro_secondary_count 3
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 50
 set g_balance_electro_combo_edgedamage 0
 set g_balance_electro_combo_force 200
diff --git a/balanceTest.cfg b/balanceTest.cfg
index 3efe125a7..e9b797ef5 100644
--- a/balanceTest.cfg
+++ b/balanceTest.cfg
@@ -384,6 +384,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 10
 set g_balance_electro_secondary_damageforcescale 2
 set g_balance_electro_secondary_count 3
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 80
 set g_balance_electro_combo_edgedamage 10
 set g_balance_electro_combo_force 150
diff --git a/balanceXonotic.cfg b/balanceXonotic.cfg
index 2f0587dde..de110e3d5 100644
--- a/balanceXonotic.cfg
+++ b/balanceXonotic.cfg
@@ -384,6 +384,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 10
 set g_balance_electro_secondary_damageforcescale 4
 set g_balance_electro_secondary_count 3
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 set g_balance_electro_combo_damage 40
 set g_balance_electro_combo_edgedamage 0
 set g_balance_electro_combo_force 80
diff --git a/balancetZork.cfg b/balancetZork.cfg
index 3ba426487..e1183bc8e 100644
--- a/balancetZork.cfg
+++ b/balancetZork.cfg
@@ -405,6 +405,8 @@ set g_balance_electro_secondary_ammo 2
 set g_balance_electro_secondary_health 10
 set g_balance_electro_secondary_damageforcescale 2
 set g_balance_electro_secondary_count 3
+set g_balance_electro_secondary_bouncefactor 0.5
+set g_balance_electro_secondary_bouncestop 0.075
 
 set g_balance_electro_combo_damage 80
 set g_balance_electro_combo_edgedamage 10
diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc
index d358a59a5..ced8061ba 100644
--- a/qcsrc/client/Main.qc
+++ b/qcsrc/client/Main.qc
@@ -1087,8 +1087,10 @@ void Ent_Init()
 
 	g_weaponswitchdelay = ReadByte() / 255.0;
 
-	g_balance_grenadelauncher_secondary_bouncefactor = ReadCoord();
-	g_balance_grenadelauncher_secondary_bouncestop = ReadCoord();
+	g_balance_grenadelauncher_bouncefactor = ReadCoord();
+	g_balance_grenadelauncher_bouncestop = ReadCoord();
+	g_balance_electro_secondary_bouncefactor = ReadCoord();
+	g_balance_electro_secondary_bouncestop = ReadCoord();
 
 	nex_scope = !ReadByte();
 	campingrifle_scope = !ReadByte();
diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh
index 2294ffd15..625a4ba7b 100644
--- a/qcsrc/client/main.qh
+++ b/qcsrc/client/main.qh
@@ -161,5 +161,7 @@ float calledhooks;
 
 .float ping, ping_packetloss, ping_movementloss;
 
-float g_balance_grenadelauncher_secondary_bouncefactor;
-float g_balance_grenadelauncher_secondary_bouncestop;
+float g_balance_grenadelauncher_bouncefactor;
+float g_balance_grenadelauncher_bouncestop;
+float g_balance_electro_secondary_bouncefactor;
+float g_balance_electro_secondary_bouncestop;
diff --git a/qcsrc/client/projectile.qc b/qcsrc/client/projectile.qc
index fb07b21b8..a2cef7645 100644
--- a/qcsrc/client/projectile.qc
+++ b/qcsrc/client/projectile.qc
@@ -315,6 +315,8 @@ void Ent_Projectile()
 				self.maxs = '0 0 -4';
 				self.move_movetype = MOVETYPE_BOUNCE;
 				self.move_touch = SUB_Null;
+				self.move_bounce_factor = g_balance_electro_secondary_bouncefactor;
+				self.move_bounce_stopspeed = g_balance_electro_secondary_bouncestop;
 				break;
 			case PROJECTILE_ROCKET:
 				loopsound(self, CHAN_PROJECTILE, "weapons/rocket_fly.wav", VOL_BASE, ATTN_NORM);
@@ -330,8 +332,8 @@ void Ent_Projectile()
 				self.maxs = '3 3 3';
 				self.move_movetype = MOVETYPE_BOUNCE;
 				self.move_touch = SUB_Null;
-				self.move_bounce_factor = g_balance_grenadelauncher_secondary_bouncefactor;
-				self.move_bounce_stopspeed = g_balance_grenadelauncher_secondary_bouncestop;
+				self.move_bounce_factor = g_balance_grenadelauncher_bouncefactor;
+				self.move_bounce_stopspeed = g_balance_grenadelauncher_bouncestop;
 				break;
 			case PROJECTILE_MINE:
 				self.mins = '-4 -4 -4';
diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc
index 2a79d6a4a..8168f7fb3 100644
--- a/qcsrc/server/cl_client.qc
+++ b/qcsrc/server/cl_client.qc
@@ -1075,6 +1075,9 @@ void PutClientInServer (void)
 	//	ctf_playerchanged();
 }
 
+.float ebouncefactor, ebouncestop; // electro's values
+// TODO do we need all these fields, or should we stop autodetecting runtime
+// changes and just have a console command to update this?
 float ClientInit_SendEntity(entity to, float sf)
 {
 	WriteByte(MSG_ENTITY, ENT_CLIENT_INIT);
@@ -1099,6 +1102,8 @@ float ClientInit_SendEntity(entity to, float sf)
 	WriteByte(MSG_ENTITY, self.cnt * 255.0); // g_balance_weaponswitchdelay
 	WriteCoord(MSG_ENTITY, self.bouncefactor); // g_balance_grenadelauncher_bouncefactor
 	WriteCoord(MSG_ENTITY, self.bouncestop); // g_balance_grenadelauncher_bouncestop
+	WriteCoord(MSG_ENTITY, self.ebouncefactor); // g_balance_grenadelauncher_bouncefactor
+	WriteCoord(MSG_ENTITY, self.ebouncestop); // g_balance_grenadelauncher_bouncestop
 	WriteByte(MSG_ENTITY, cvar("g_balance_nex_secondary")); // client has to know if it should zoom or not
 	WriteByte(MSG_ENTITY, cvar("g_balance_campingrifle_secondary")); // client has to know if it should zoom or not
 	WriteByte(MSG_ENTITY, serverflags); // client has to know if it should zoom or not
@@ -1128,6 +1133,16 @@ void ClientInit_CheckUpdate()
 		self.bouncestop = cvar("g_balance_grenadelauncher_bouncestop");
 		self.SendFlags |= 1;
 	}
+	if(self.ebouncefactor != cvar("g_balance_electro_bouncefactor"))
+	{
+		self.ebouncefactor = cvar("g_balance_electro_bouncefactor");
+		self.SendFlags |= 1;
+	}
+	if(self.ebouncestop != cvar("g_balance_electro_bouncestop"))
+	{
+		self.ebouncestop = cvar("g_balance_electro_bouncestop");
+		self.SendFlags |= 1;
+	}
 }
 
 void ClientInit_Spawn()
diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc
index 014fc34e5..1600a1c9a 100644
--- a/qcsrc/server/w_electro.qc
+++ b/qcsrc/server/w_electro.qc
@@ -178,8 +178,8 @@ void W_Electro_Attack2()
 	proj.event_damage = W_Plasma_Damage;
 	proj.flags = FL_PROJECTILE;
 	
-	//proj.bouncefactor = cvar("g_balance_electro_secondary_bouncefactor");
-	//proj.bouncestop = cvar("g_balance_electro_secondary_bouncestop");
+	proj.bouncefactor = cvar("g_balance_electro_secondary_bouncefactor");
+	proj.bouncestop = cvar("g_balance_electro_secondary_bouncestop");
 	
 #if 0
 	entity p2;
-- 
2.39.5