diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index c95db059df..0715f79e0e 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -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; }; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 321f6dbd62..3877faf85d 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -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 {};