From 20d00d7cd90ae350ed73fffdfad5e63f22134ca1 Mon Sep 17 00:00:00 2001 From: commy2 Date: Tue, 27 Sep 2016 21:21:44 +0200 Subject: [PATCH] make units scream when they're hit --- addons/medical/script_component.hpp | 2 +- addons/medical_blood/script_component.hpp | 2 +- addons/medical_damage/functions/fnc_woundsHandler.sqf | 2 ++ .../medical_damage/functions/fnc_woundsHandlerSQF.sqf | 2 ++ addons/medical_damage/script_component.hpp | 10 +++++++--- .../medical_engine/functions/fnc_playInjuredSound.sqf | 1 + addons/medical_engine/script_component.hpp | 6 +++--- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/addons/medical/script_component.hpp b/addons/medical/script_component.hpp index 81abb0c462..c008c9e7bd 100644 --- a/addons/medical/script_component.hpp +++ b/addons/medical/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED Medical Core #include "\z\ace\addons\main\script_mod.hpp" -#define DEBUG_MODE_FULL +//#define DEBUG_MODE_FULL #define DISABLE_COMPILE_CACHE #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/medical_blood/script_component.hpp b/addons/medical_blood/script_component.hpp index 015cea6b54..d725749e0c 100644 --- a/addons/medical_blood/script_component.hpp +++ b/addons/medical_blood/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED Medical Blood #include "\z\ace\addons\main\script_mod.hpp" -#define DEBUG_ENABLED_MEDICAL_BLOOD +//#define DEBUG_ENABLED_MEDICAL_BLOOD #define DISABLE_COMPILE_CACHE #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 4def1e0b7a..62c696bbb0 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -72,4 +72,6 @@ if (count _woundsCreated > 0) then { private _painLevel = _unit getVariable [QEGVAR(medical,pain), 0]; _unit setVariable [QEGVAR(medical,pain), _painLevel + _painToAdd]; +[_unit, "hit", PAIN_TO_SCREAM(_painToAdd)] call EFUNC(medical_engine,playInjuredSound); + TRACE_6("exit",_unit, _painLevel, _painToAdd, _unit getVariable QEGVAR(medical,pain), _unit getVariable QEGVAR(medical,openWounds),_woundsCreated); diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 870925317b..6c584565bf 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -136,4 +136,6 @@ if (count _woundsCreated > 0) then { private _painLevel = _unit getVariable [QGVAR(pain), 0]; _unit setVariable [QGVAR(pain), _painLevel + _painToAdd]; +[_unit, "hit", PAIN_TO_SCREAM(_painToAdd)] call EFUNC(medical_engine,playInjuredSound); + TRACE_6("exit",_unit, _painLevel, _painToAdd, _unit getVariable QGVAR(pain), _unit getVariable QGVAR(openWounds),_woundsCreated); diff --git a/addons/medical_damage/script_component.hpp b/addons/medical_damage/script_component.hpp index acbc688414..c0f6967c93 100644 --- a/addons/medical_damage/script_component.hpp +++ b/addons/medical_damage/script_component.hpp @@ -2,9 +2,9 @@ #define COMPONENT_BEAUTIFIED Medical Damage #include "\z\ace\addons\main\script_mod.hpp" -//#define DEBUG_MODE_FULL -//#define DISABLE_COMPILE_CACHE -//#define CBA_DEBUG_SYNCHRONOUS +#define DEBUG_MODE_FULL +#define DISABLE_COMPILE_CACHE +#define CBA_DEBUG_SYNCHRONOUS //#define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_MEDICAL_DAMAGE @@ -22,3 +22,7 @@ #define GET_ARRAY(config,default) (if (isArray (config)) then {getArray (config)} else {default}) #define ALL_BODY_PARTS ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] + +// scale received pain to 0-2 level to select type of scream +// below 0.25: 0, from 0.25 to 0.5: 1, more than 0.5: 2 +#define PAIN_TO_SCREAM(pain) (floor (4 * pain) min 2) diff --git a/addons/medical_engine/functions/fnc_playInjuredSound.sqf b/addons/medical_engine/functions/fnc_playInjuredSound.sqf index b17d3f72d6..aa7ae2dd4d 100644 --- a/addons/medical_engine/functions/fnc_playInjuredSound.sqf +++ b/addons/medical_engine/functions/fnc_playInjuredSound.sqf @@ -21,6 +21,7 @@ #define TIME_OUT 1 params [["_unit", objNull, [objNull]], ["_type", "hit", [""]], ["_severity", 0, [0]]]; +TRACE_3("",_unit,_type,_severity); if (!local _unit) exitWith { ACE_LOGERROR("Unit not local or null"); diff --git a/addons/medical_engine/script_component.hpp b/addons/medical_engine/script_component.hpp index 4f7a9a7c5a..cdaf58b0e5 100644 --- a/addons/medical_engine/script_component.hpp +++ b/addons/medical_engine/script_component.hpp @@ -2,9 +2,9 @@ #define COMPONENT_BEAUTIFIED Medical (Engine) #include "\z\ace\addons\main\script_mod.hpp" -//#define DEBUG_MODE_FULL -//#define DISABLE_COMPILE_CACHE -//#define CBA_DEBUG_SYNCHRONOUS +#define DEBUG_MODE_FULL +#define DISABLE_COMPILE_CACHE +#define CBA_DEBUG_SYNCHRONOUS //#define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_MEDICAL_ENGINE