add addPain function, cap pain

This commit is contained in:
commy2 2016-10-10 16:44:03 +02:00
parent 3521bca00b
commit 2ad7c4c4ea
4 changed files with 33 additions and 12 deletions

View File

@ -27,4 +27,5 @@ PREP(handleUnitVitals);
PREP(handleMedications);
// PREP(handleStateRevive);
PREP(addPain);
PREP(setUnconscious);

View File

@ -0,0 +1,28 @@
/*
* Author: commy2
* Adds pain to unit and plays a scream sound.
*
* Arguments:
* 0: Argument Name <TYPE>
* 0: Argument Name <TYPE>
*
* Return Value:
* Return Name <TYPE>
*
* 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);

View File

@ -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);

View File

@ -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);