2015-02-08 12:06:44 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Enabled the vitals loop for a unit.
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
2015-02-08 12:06:44 +00:00
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit <OBJECT>
|
|
|
|
*
|
|
|
|
* ReturnValue:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-02-08 12:06:44 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-02-08 09:01:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit", ["_force", false]];
|
2015-02-08 09:01:32 +00:00
|
|
|
|
2015-03-08 16:50:06 +00:00
|
|
|
if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
|
2015-03-22 16:04:42 +00:00
|
|
|
|
2015-11-30 16:14:05 +00:00
|
|
|
if !(local _unit) exitWith {
|
2015-03-08 16:50:06 +00:00
|
|
|
[[_unit, _force], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
2015-03-05 17:42:08 +00:00
|
|
|
};
|
2015-03-07 12:06:50 +00:00
|
|
|
|
2015-11-30 16:27:09 +00:00
|
|
|
if ((_unit getVariable[QGVAR(addedToUnitLoop),false] || !alive _unit) && !_force) exitWith{};
|
|
|
|
_unit setVariable [QGVAR(addedToUnitLoop), true, true];
|
2015-02-08 09:01:32 +00:00
|
|
|
|
2015-02-28 18:28:05 +00:00
|
|
|
[{
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_args", "_idPFH"];
|
|
|
|
_args params ["_unit", "_interval"];
|
|
|
|
_interval = ACE_time - _interval;
|
2015-05-21 16:42:44 +00:00
|
|
|
(_this select 0) set [1, ACE_time];
|
2015-08-22 14:25:10 +00:00
|
|
|
|
2015-02-08 10:34:20 +00:00
|
|
|
if (!alive _unit || !local _unit) then {
|
2015-08-22 14:25:10 +00:00
|
|
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
2015-03-08 12:56:24 +00:00
|
|
|
if (!local _unit) then {
|
|
|
|
if (GVAR(level) >= 2) then {
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(heartRate), _unit getVariable [QGVAR(heartRate), 80], true];
|
|
|
|
_unit setVariable [QGVAR(bloodPressure), _unit getVariable [QGVAR(bloodPressure), [80, 120]], true];
|
2015-03-08 12:56:24 +00:00
|
|
|
};
|
2015-11-30 16:27:09 +00:00
|
|
|
_unit setVariable [QGVAR(bloodVolume), _unit getVariable [QGVAR(bloodVolume), 100], true];
|
2015-03-08 12:56:24 +00:00
|
|
|
};
|
2015-02-08 10:34:20 +00:00
|
|
|
} else {
|
2015-05-15 07:15:03 +00:00
|
|
|
[_unit, _interval] call FUNC(handleUnitVitals);
|
2015-02-08 10:34:20 +00:00
|
|
|
|
|
|
|
private "_pain";
|
2015-11-30 16:27:09 +00:00
|
|
|
_pain = _unit getVariable [QGVAR(pain), 0];
|
|
|
|
if (_pain > (_unit getVariable [QGVAR(painSuppress), 0])) then {
|
2015-09-05 10:20:40 +00:00
|
|
|
// This introduces wierd unconscious behaviour for basic medical and possibly also advanced.
|
|
|
|
// TODO This is disabled as it's considered non critical code.
|
|
|
|
// We will need to decide if we want unconscious triggered on high pain levels or if we can get rid of this entirely.
|
|
|
|
/*if (_pain > 0.7 && {random(1) > 0.6}) then {
|
2015-02-08 12:06:44 +00:00
|
|
|
[_unit] call FUNC(setUnconscious);
|
2015-09-05 10:20:40 +00:00
|
|
|
};*/
|
2015-03-08 14:13:32 +00:00
|
|
|
|
2015-03-08 12:56:24 +00:00
|
|
|
[_unit, _pain] call FUNC(playInjuredSound);
|
2015-02-08 10:34:20 +00:00
|
|
|
};
|
|
|
|
};
|
2015-05-21 16:42:44 +00:00
|
|
|
}, 1, [_unit, ACE_time]] call CBA_fnc_addPerFrameHandler;
|
2015-02-08 09:01:32 +00:00
|
|
|
};
|