diff --git a/changelog.txt b/changelog.txt
index a7f7fa30..884f8094 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -9,6 +9,7 @@ Find me a cat!
---------------------
[*] Changelog updates - oh shi-
+[*] Optional heartbeat sound when health reaches a certain level.
// TODO : find a better order for these categories
@@ -191,4 +192,4 @@ I18n / L10n
[*] Client now tries to set the LANG alias if it's not defined.
[*] fixed LANG for windows (breaks Win98/2K compatibility!)
-[*] Float separator set to "." (dot) regardless of locale.
\ No newline at end of file
+[*] Float separator set to "." (dot) regardless of locale.
diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg
index cc304161..d8aba43c 100644
--- a/config/menus_settings.cfg
+++ b/config/menus_settings.cfg
@@ -518,6 +518,7 @@ menuitemcheckbox "Die 1: " "(soundmuted 32)" [ mutesound 32 (! $arg1) ]
menuitemcheckbox "Die 2: " "(soundmuted 33)" [ mutesound 33 (! $arg1) ]
menuitemcheckbox "Gib sounds: " "(soundmuted 48)" [ mutesound 48 (! $arg1) ]
menuitemcheckbox "Tinnitus: " "(soundmuted 62)" [ mutesound 62 (! $arg1) ]
+menuitemcheckbox "Heartbeat: " "(soundmuted 100)" [ mutesound 100 (! $arg1) ]
newmenu "Mute movement sounds"
diff --git a/config/sounds.cfg b/config/sounds.cfg
index 1a1d11c0..7562f190 100755
--- a/config/sounds.cfg
+++ b/config/sounds.cfg
@@ -109,7 +109,8 @@ registersound "voicecom/thanks_1" // 95 : public
registersound "voicecom/thanks_2" // 96 : public
registersound "voicecom/awesome_1" // 97 : public
registersound "voicecom/awesome_2" // 98 : public
-registersound "misc/pickup_helmet" // 99 - S_ITEMHELMET
+registersound "misc/pickup_helmet" // 99 - S_ITEMHELMET
+registersound "player/heartbeat" // 100 - S_HEARTBEAT
// Music
registermusic "pingpong/Ping_Pong_-_Kamikadze" // M_FLAGGRAB
diff --git a/docs/reference.xml b/docs/reference.xml
index b80fceef..a8e8c7fb 100644
--- a/docs/reference.xml
+++ b/docs/reference.xml
@@ -4854,6 +4854,11 @@ Output:
+
+ Defines the health level at or below which a heartbeat sound will be played. A value of 0 (which is the default) disables this feature.
+
+
+
Sets the team display mode.
diff --git a/packages/audio/player/heartbeat.ogg b/packages/audio/player/heartbeat.ogg
new file mode 100755
index 00000000..13bda9d1
Binary files /dev/null and b/packages/audio/player/heartbeat.ogg differ
diff --git a/packages/audio/player/heartbeat.ogg_license.txt b/packages/audio/player/heartbeat.ogg_license.txt
new file mode 100755
index 00000000..543075c4
--- /dev/null
+++ b/packages/audio/player/heartbeat.ogg_license.txt
@@ -0,0 +1,4 @@
+heartbeat.ogg by Lunardrive (http://www.freesound.org/usersViewSingle.php?id=120830)
+ Four Heartbeats HQ_BeatSmith.wav (http://www.freesound.org/samplesViewSingle.php?id=22416)
+
+This file is licensed under the Creative Commons Sampling Plus 1.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/sampling+/1.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp
index 83900c14..a2d17f68 100644
--- a/source/src/audiomanager.cpp
+++ b/source/src/audiomanager.cpp
@@ -532,6 +532,8 @@ void audiomanager::stopsound()
if(gamemusic) gamemusic->reset();
}
+VAR(heartbeat, 0, 0, 99);
+
// main audio update routine
void audiomanager::updateaudio()
@@ -540,7 +542,7 @@ void audiomanager::updateaudio()
alcSuspendContext(context); // don't process sounds while we mess around
- //bool alive = player1->state!=CS_DEAD;
+ bool alive = player1->state!=CS_DEAD;
bool firstperson = camera1==player1 || (player1->isspectating() && player1->spectatemode==SM_DEATHCAM);
// footsteps
@@ -560,6 +562,10 @@ void audiomanager::updateaudio()
bool tinnitus = /*alive &&*/ firstperson && player1->eardamagemillis>0 && lastmillis<=player1->eardamagemillis;
location *tinnitusloc = updateloopsound(S_TINNITUS, tinnitus);
+ // heartbeat
+ bool heartbeatsound = heartbeat && alive && firstperson && player1->health <= heartbeat;
+ updateloopsound(S_HEARTBEAT, heartbeatsound);
+
// pitch fx
const float lowpitch = 0.65f;
bool pitchfx = underwater || tinnitus;
diff --git a/source/src/sound.h b/source/src/sound.h
index 484a2989..1b669832 100644
--- a/source/src/sound.h
+++ b/source/src/sound.h
@@ -70,6 +70,7 @@ enum
S_AWESOME1,
S_AWESOME2,
S_ITEMHELMET, // begin: Sounds for AssaultCube v1.1.0.4 onwards
+ S_HEARTBEAT,
S_NULL
};