From: MirceaKitsune Date: Sun, 27 Feb 2011 01:41:15 +0000 (+0200) Subject: Health and armor regen sounds. Taken from Xonotic X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=23ab5e8e6726b9d38a0d21d7e46c71d230ac6880;p=voretournament%2Fvoretournament.git Health and armor regen sounds. Taken from Xonotic --- diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index dcafed6c..4570ae2d 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -1854,7 +1854,8 @@ float CalcRot(float current, float stable, float rotfactor, float rotframetime) return max(stable, current + (stable - current) * rotfactor * rotframetime); } -float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit) +.float regen_soundtime; +float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit, string regensound) { if(current > rotstable) { @@ -1870,6 +1871,17 @@ float CalcRotRegen(float current, float regenstable, float regenfactor, float re { current = CalcRegen(current, regenstable, regenfactor, regenframetime); current = min(regenstable, current + regenlinear * regenframetime); + + if(regensound != "") + { + if(self.regen_soundtime < time) + { + msg_entity = self; + if(clienttype(msg_entity) == CLIENTTYPE_REAL) + soundto(MSG_ONE, self, CHAN_AUTO, regensound, VOL_BASE, ATTN_NONE); + } + self.regen_soundtime = time + 1; // only replay the sound if regen was paused for one second + } } } @@ -1909,8 +1921,8 @@ void player_regen (void) if (!g_ca && (!g_lms || cvar("g_lms_regenerate"))) { - 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); - 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); + 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"); + 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"); // if player rotted to death... die! if(self.health < 1) @@ -1918,7 +1930,7 @@ void player_regen (void) } if not(self.items & IT_UNLIMITED_WEAPON_AMMO) - 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); + 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, ""); } float zoomstate_set; diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 561631e5..60cdad05 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1419,6 +1419,8 @@ void precache() precache_sound ("player/lava.wav"); precache_sound ("player/slime.wav"); precache_sound ("player/digest.wav"); + precache_sound ("misc/health_regen.ogg"); + precache_sound ("misc/armor_regen.ogg"); if (g_jetpack) precache_sound ("misc/jetpack_fly.wav"); diff --git a/data/sound/misc/armor_regen.ogg b/data/sound/misc/armor_regen.ogg new file mode 100644 index 00000000..6f0538a1 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 index 00000000..a98ce140 Binary files /dev/null and b/data/sound/misc/health_regen.ogg differ