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:
|
|
|
|
* <NIL>
|
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-02-08 09:01:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
private "_unit";
|
|
|
|
_unit = _this select 0;
|
|
|
|
if !(local _unit) exitwith{
|
2015-02-28 12:17:17 +00:00
|
|
|
[[_unit], QUOTE(DFUNC(addToInjuredCollection)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */
|
2015-02-08 09:01:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if !(_unit getvariable[QGVAR(addedToUnitLoop),false]) then{
|
|
|
|
_unit setvariable [QGVAR(addedToUnitLoop),true, true];
|
|
|
|
};
|
|
|
|
|
|
|
|
if ([_unit] call FUNC(hasMedicalEnabled)) then {
|
2015-02-28 18:28:05 +00:00
|
|
|
[{
|
|
|
|
private "_unit";
|
|
|
|
_unit = (_this select 0) select 0;
|
2015-02-08 10:34:20 +00:00
|
|
|
if (!alive _unit || !local _unit) then {
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
} else {
|
|
|
|
[_unit] call FUNC(handleUnitVitals);
|
|
|
|
|
|
|
|
private "_pain";
|
|
|
|
_pain = _unit getvariable [QGVAR(pain), 0];
|
|
|
|
if (_pain > 45) then {
|
|
|
|
if (random(1) > 0.6) then {
|
2015-02-08 12:06:44 +00:00
|
|
|
[_unit] call FUNC(setUnconscious);
|
2015-02-08 10:34:20 +00:00
|
|
|
};
|
2015-02-08 12:18:08 +00:00
|
|
|
[_unit] call FUNC(playInjuredSound);
|
2015-02-08 10:34:20 +00:00
|
|
|
};
|
|
|
|
};
|
2015-02-28 18:28:05 +00:00
|
|
|
}, 1, [_unit]] call CBA_fnc_addPerFrameHandler;
|
2015-03-01 11:33:05 +00:00
|
|
|
|
|
|
|
if (isNil QGVAR(InjuredCollection)) then {
|
|
|
|
GVAR(InjuredCollection) = [];
|
|
|
|
};
|
|
|
|
GVAR(InjuredCollection) pushback _unit;
|
2015-02-08 09:01:32 +00:00
|
|
|
};
|