From 2ad7c4c4ea01a0182cb11ad9d418c15dd51d9321 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 10 Oct 2016 16:44:03 +0200 Subject: [PATCH] add addPain function, cap pain --- addons/medical/XEH_PREP.hpp | 1 + addons/medical/functions/fnc_addPain.sqf | 28 +++++++++++++++++++ .../functions/fnc_woundsHandler.sqf | 8 ++---- .../functions/fnc_woundsHandlerSQF.sqf | 8 ++---- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 addons/medical/functions/fnc_addPain.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 87b8159a62..6c48674199 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -27,4 +27,5 @@ PREP(handleUnitVitals); PREP(handleMedications); // PREP(handleStateRevive); +PREP(addPain); PREP(setUnconscious); diff --git a/addons/medical/functions/fnc_addPain.sqf b/addons/medical/functions/fnc_addPain.sqf new file mode 100644 index 0000000000..edf8294682 --- /dev/null +++ b/addons/medical/functions/fnc_addPain.sqf @@ -0,0 +1,28 @@ +/* + * Author: commy2 + * Adds pain to unit and plays a scream sound. + * + * Arguments: + * 0: Argument Name + * 0: Argument Name + * + * Return Value: + * Return Name + * + * Example: + * ["example"] call ace_[module]_fnc_[functionName] + * + * Public: [Yes/No] + */ +#include "script_component.hpp" + +params ["_unit", "_painToAdd"]; + +_painToAdd = _painToAdd min 1; + +private _pain = _unit getVariable [QEGVAR(medical,pain), 0]; +_pain = _pain + _painToAdd * (1 - _pain); + +_unit setVariable [QEGVAR(medical,pain), _pain]; + +[_unit, "hit", PAIN_TO_SCREAM(_painToAdd)] call EFUNC(medical_engine,playInjuredSound); diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 958f7475b9..af99f50b13 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -66,10 +66,6 @@ if (count _woundsCreated > 0) then { _unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true]; }; -// TODO use medical add pain function instead -private _painLevel = _unit getVariable [QEGVAR(medical,pain), 0]; -_unit setVariable [QEGVAR(medical,pain), _painLevel + _painToAdd]; +[_unit, _painToAdd] call EFUNC(medical,addPain); -[_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); +TRACE_5("exit",_unit, _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 dfb4f96293..ea7087d5ed 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -135,10 +135,6 @@ if (count _woundsCreated > 0) then { _unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true]; }; -// TODO use medical add pain function instead -private _painLevel = _unit getVariable [QEGVAR(medical,pain), 0]; -_unit setVariable [QEGVAR(medical,pain), _painLevel + _painToAdd]; +[_unit, _painToAdd] call EFUNC(medical,addPain); -[_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); +TRACE_5("exit",_unit, _painToAdd, _unit getVariable QEGVAR(medical,pain), _unit getVariable QEGVAR(medical,openWounds),_woundsCreated);