From 633037c1b43c1309b0109ceb4af9998161d7b1d1 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 8 Feb 2015 11:34:20 +0100 Subject: [PATCH] Replaced injuredCollection array for separate PFH for each unit. --- addons/medical/XEH_postInit.sqf | 22 ------------------ .../functions/fnc_addToInjuredCollection.sqf | 23 +++++++++++++++---- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 9eced7ef9f..a0550fa308 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -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"]; diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index f82e0fd5e4..064b62bb5a 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -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; };