Replaced injuredCollection array for separate PFH for each unit.

This commit is contained in:
Glowbal 2015-02-08 11:34:20 +01:00
parent 3be442c31a
commit 633037c1b4
2 changed files with 18 additions and 27 deletions

View File

@ -1,28 +1,6 @@
#include "script_component.hpp"
[{
{
if (!alive _x || !local _x) then {
GVAR(injuredUnitCollection) set [ _forEachIndex, ObjNull];
} else {
[_x] call FUNC(handleUnitVitals);
private "_pain";
_pain = _X getvariable [QGVAR(pain), 0];
if (_pain > 45) then {
if (random(1) > 0.6) then {
// [_X] call FUNC(setUnconsciousState);
};
//[_X] call FUNC(playInjuredSound);
};
};
}foreach GVAR(injuredUnitCollection);
GVAR(injuredUnitCollection) = GVAR(injuredUnitCollection) - [ObjNull];
}, 1, [] ] call CBA_fnc_addPerFrameHandler;
if (!hasInterface) exitwith{};
//45 cutRsc [QGVAR(ScreenEffectsBlack),"PLAIN"];

View File

@ -21,9 +21,22 @@ if !(_unit getvariable[QGVAR(addedToUnitLoop),false]) then{
};
if ([_unit] call FUNC(hasMedicalEnabled)) then {
if (isnil QGVAR(injuredUnitCollection)) then {
GVAR(injuredUnitCollection) = [];
};
if (_unit in GVAR(injuredUnitCollection)) exitwith {};
GVAR(injuredUnitCollection) pushback _unit;
[{
private "_unit";
_unit = (_this select 0) select 0;
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 {
// [_unit] call FUNC(setUnconsciousState);
};
//[_unit] call FUNC(playInjuredSound);
};
};
}, 1, [_unit]] call CBA_fnc_addPerFrameHandler;
};