Improvements made to heart rate effects

This commit is contained in:
Glowbal 2015-03-01 14:06:44 +01:00
parent 91a52a4b76
commit d5e5ab24f2
2 changed files with 69 additions and 65 deletions

View File

@ -1,37 +1,37 @@
class CfgSounds {
class ACE_heartbeat_fast_1 {
name = "ACE_heartbeat_fast_1";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_1.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_1.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_fast_2 {
name = "ACE_heartbeat_fast_2";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_2.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_2.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_fast_3 {
name = "ACE_heartbeat_fast_3";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_3.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\fast_3.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_norm_1 {
name = "ACE_heartbeat_norm_1";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\norm_1.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\norm_1.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_norm_2 {
name = "ACE_heartbeat_norm_2";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\norm_2.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\norm_2.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_slow_1 {
name = "ACE_heartbeat_slow_1";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\slow_1.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\slow_1.wav)), "db+1", 1};
titles[] = {};
};
class ACE_heartbeat_slow_2 {
name = "ACE_heartbeat_slow_2";
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\slow_2.wav)), "db-1", 1};
sound[] = {QUOTE(PATHTOF(sounds\heart_beats\slow_2.wav)), "db+1", 1};
titles[] = {};
};
};

View File

@ -4,10 +4,9 @@
if (!hasInterface) exitwith{};
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3", "ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
GVAR(heartBeatSounds_Fast) = ["ACE_heartbeat_fast_1", "ACE_heartbeat_fast_2", "ACE_heartbeat_fast_3"];
GVAR(heartBeatSounds_Normal) = ["ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2", "ACE_heartbeat_norm_1", "ACE_heartbeat_norm_2"];
GVAR(playingHeartBeatSound) = false;
GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
["Medical_treatmentCompleted", FUNC(onTreatmentCompleted)] call ace_common_fnc_addEventHandler;
["medical_propagateWound", FUNC(onPropagateWound)] call ace_common_fnc_addEventHandler;
@ -131,6 +130,7 @@ GVAR(effectTimeBlood) = time;
GVAR(lastHeartBeat) = time;
GVAR(lastHeartBeatSound) = time;
// @todo, remove once parameters are set up
if (isNil QGVAR(level)) then {
@ -142,10 +142,10 @@ if (isNil QGVAR(level)) then {
_heartRate = ACE_player getVariable [QGVAR(heartRate), 70];
if (GVAR(level) == 0) then {
_heartRate = 60 + 40 * (ACE_player getVariable [QGVAR(pain), 0]);
_heartRate = _heartRate min 120;
};
_interval = 60 / _heartRate;
if (time < GVAR(lastHeartBeat) + _interval) exitWith {};
if (_heartRate <= 0) exitwith {};
_interval = 60 / (_heartRate min 50);
if (time > GVAR(lastHeartBeat) + _interval) then {
GVAR(lastHeartBeat) = time;
// Pain effect
@ -197,16 +197,20 @@ if (isNil QGVAR(level)) then {
GVAR(effectPainCC) ppEffectEnable false;
};
};
};
if (GVAR(level) > 0) then {
if (GVAR(level) > 0 && {_heartRate > 0}) then {
_minTime = 60 / _heartRate;
if (time - GVAR(lastHeartBeatSound) > _minTime) then {
GVAR(lastHeartBeatSound) = time;
// Heart rate sound effect
if (_heartRate < 60) then {
_sound = GVAR(heartBeatSounds_Slow) select (random((count GVAR(heartBeatSounds_Slow)) -1));
_sound = GVAR(heartBeatSounds_Normal) select (random((count GVAR(heartBeatSounds_Normal)) -1));
playSound _sound;
} else {
if (_heartRate > 120) then {
_sound = GVAR(heartBeatSounds_Fast) select (random((count GVAR(heartBeatSounds_Fast)) -1));
playSound _sound;
if (_heartRate > 150) then {
playSound "ACE_heartbeat_fast_2";
};
};
};
};