]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Health and armor regen sounds. Taken from Xonotic
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 27 Feb 2011 01:41:15 +0000 (03:41 +0200)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 27 Feb 2011 01:41:15 +0000 (03:41 +0200)
data/qcsrc/server/cl_client.qc
data/qcsrc/server/miscfunctions.qc
data/sound/misc/armor_regen.ogg [new file with mode: 0644]
data/sound/misc/health_regen.ogg [new file with mode: 0644]

index dcafed6c26cf942b9a722695bb48f0aa0fb0fc36..4570ae2d99023cc0864355f0e3f27e5de5a6f12f 100644 (file)
@@ -1854,7 +1854,8 @@ float CalcRot(float current, float stable, float rotfactor, float rotframetime)
                return max(stable, current + (stable - current) * rotfactor * rotframetime);\r
 }\r
 \r
-float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit)\r
+.float regen_soundtime;\r
+float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit, string regensound)\r
 {\r
        if(current > rotstable)\r
        {\r
@@ -1870,6 +1871,17 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re
                {\r
                        current = CalcRegen(current, regenstable, regenfactor, regenframetime);\r
                        current = min(regenstable, current + regenlinear * regenframetime);\r
+\r
+                       if(regensound != "")\r
+                       {\r
+                               if(self.regen_soundtime < time)\r
+                               {\r
+                                       msg_entity = self;\r
+                                       if(clienttype(msg_entity) == CLIENTTYPE_REAL)\r
+                                               soundto(MSG_ONE, self, CHAN_AUTO, regensound, VOL_BASE, ATTN_NONE);\r
+                               }\r
+                               self.regen_soundtime = time + 1; // only replay the sound if regen was paused for one second\r
+                       }\r
                }\r
        }\r
 \r
@@ -1909,8 +1921,8 @@ void player_regen (void)
 \r
        if (!g_ca && (!g_lms || cvar("g_lms_regenerate")))\r
        {\r
-               self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregenarmor_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita);\r
-               self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith);\r
+               self.armorvalue = CalcRotRegen(self.armorvalue, mina, cvar("g_balance_armor_regen"), cvar("g_balance_armor_regenlinear"), regen_mod * frametime * (time > self.pauseregenarmor_finished), maxa, cvar("g_balance_armor_rot"), cvar("g_balance_armor_rotlinear"), rot_mod * frametime * (time > self.pauserotarmor_finished), limita, "misc/armor_regen.ogg");\r
+               self.health = CalcRotRegen(self.health, minh, cvar("g_balance_health_regen"), cvar("g_balance_health_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished), maxh, cvar("g_balance_health_rot"), cvar("g_balance_health_rotlinear"), rot_mod * frametime * (time > self.pauserothealth_finished), limith, "misc/health_regen.ogg");\r
 \r
                // if player rotted to death...  die!\r
                if(self.health < 1)\r
@@ -1918,7 +1930,7 @@ void player_regen (void)
        }\r
 \r
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
-               self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, cvar("g_balance_fuel_regen"), cvar("g_balance_fuel_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished) * (self.items & IT_FUEL_REGEN != 0), maxf, cvar("g_balance_fuel_rot"), cvar("g_balance_fuel_rotlinear"), rot_mod * frametime * (time > self.pauserotfuel_finished), limitf);\r
+               self.ammo_fuel = CalcRotRegen(self.ammo_fuel, minf, cvar("g_balance_fuel_regen"), cvar("g_balance_fuel_regenlinear"), regen_mod * frametime * (time > self.pauseregenhealth_finished) * (self.items & IT_FUEL_REGEN != 0), maxf, cvar("g_balance_fuel_rot"), cvar("g_balance_fuel_rotlinear"), rot_mod * frametime * (time > self.pauserotfuel_finished), limitf, "");\r
 }\r
 \r
 float zoomstate_set;\r
index 561631e5e5f05de4b69c31dbcef86969fd32b000..60cdad05e3874bd47b1a1b359051558f34593e42 100644 (file)
@@ -1419,6 +1419,8 @@ void precache()
     precache_sound ("player/lava.wav");\r
     precache_sound ("player/slime.wav");\r
     precache_sound ("player/digest.wav");\r
+       precache_sound ("misc/health_regen.ogg");\r
+       precache_sound ("misc/armor_regen.ogg");\r
 \r
     if (g_jetpack)\r
         precache_sound ("misc/jetpack_fly.wav");\r
diff --git a/data/sound/misc/armor_regen.ogg b/data/sound/misc/armor_regen.ogg
new file mode 100644 (file)
index 0000000..6f0538a
Binary files /dev/null and b/data/sound/misc/armor_regen.ogg differ
diff --git a/data/sound/misc/health_regen.ogg b/data/sound/misc/health_regen.ogg
new file mode 100644 (file)
index 0000000..a98ce14
Binary files /dev/null and b/data/sound/misc/health_regen.ogg differ