Use PFEH array instead of setVariable

This commit is contained in:
PabstMirror 2015-05-15 02:15:03 -05:00
parent 8dbca1d3de
commit 39bc7d06be
2 changed files with 8 additions and 10 deletions

View File

@ -27,8 +27,11 @@ if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
_unit setvariable [QGVAR(addedToUnitLoop), true, true];
[{
private "_unit";
private ["_unit", "_lastTime"];
_unit = (_this select 0) select 0;
_interval = time - ((_this select 0) select 1);
(_this select 0) set [1, time];
if (!alive _unit || !local _unit) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (!local _unit) then {
@ -39,7 +42,7 @@ if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
_unit setvariable [QGVAR(bloodVolume), _unit getvariable [QGVAR(bloodVolume), 100], true];
};
} else {
[_unit] call FUNC(handleUnitVitals);
[_unit, _interval] call FUNC(handleUnitVitals);
private "_pain";
_pain = _unit getvariable [QGVAR(pain), 0];
@ -51,5 +54,5 @@ if ([_unit] call FUNC(hasMedicalEnabled) || _force) then {
[_unit, _pain] call FUNC(playInjuredSound);
};
};
}, 1, [_unit]] call CBA_fnc_addPerFrameHandler;
}, 1, [_unit, time]] call CBA_fnc_addPerFrameHandler;
};

View File

@ -13,14 +13,9 @@
#include "script_component.hpp"
private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus", "_lastTimeValuesSynced", "_syncValues", "_airwayStatus", "_blood", "_bloodPressureH", "_bloodPressureL", "_interval", "_lastMomentVitalsHandled"];
private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus", "_lastTimeValuesSynced", "_syncValues", "_airwayStatus", "_blood", "_bloodPressureH", "_bloodPressureL", "_interval"];
_unit = _this select 0;
_lastMomentVitalsHandled = _unit getVariable [QGVAR(lastMomentVitalsHandled), -1];
_unit setVariable [QGVAR(lastMomentVitalsHandled), time];
//If QGVAR(lastMomentVitalsHandled) is undefined then assume 1 second interval:
_interval = if (_lastMomentVitalsHandled == -1) then {1} else {time - _lastMomentVitalsHandled};
_interval = _this select 1;
if (_interval == 0) exitWith {};