diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 7a3c3882ca..7a3606adf9 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -240,5 +240,6 @@ if (isMultiplayer) then { {(((_this select 0) getvariable [QGVAR(bloodVolume), 0]) < 65)}, {(((_this select 0) getvariable [QGVAR(pain), 0]) > 48)}, {(((_this select 0) call FUNC(getBloodLoss)) > 0.25)}, - {((_this select 0) getvariable [QGVAR(inReviveState), false])} + {((_this select 0) getvariable [QGVAR(inReviveState), false])}, + {((_this select 0) getvariable ["ACE_isDead", false])} ] call FUNC(addUnconsciousCondition); diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index 68cff4c3f5..128544c96a 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -34,16 +34,24 @@ if ([_unit] call FUNC(hasMedicalEnabled)) then { _unit = (_this select 0) select 0; if (!alive _unit || !local _unit) then { [_this select 1] call CBA_fnc_removePerFrameHandler; + if (!local _unit) then { + if (GVAR(level) >= 2) then { + _unit setvariable [QGVAR(heartRate), _unit getvariable [QGVAR(heartRate), 0], true]; + _unit setvariable [QGVAR(bloodPressure), _unit getvariable [QGVAR(bloodPressure), [0, 0]], true]; + }; + _unit setvariable [QGVAR(bloodVolume), _unit getvariable [QGVAR(bloodVolume), 0], true]; + }; + GVAR(InjuredCollection) = GVAR(InjuredCollection) - [_unit]; } else { [_unit] call FUNC(handleUnitVitals); private "_pain"; _pain = _unit getvariable [QGVAR(pain), 0]; - if (_pain > 45) then { - if (random(1) > 0.6) then { + if (_pain > 0) then { + if (_pain > 0.7 && {random(1) > 0.6}) then { [_unit] call FUNC(setUnconscious); }; - [_unit] call FUNC(playInjuredSound); + [_unit, _pain] call FUNC(playInjuredSound); }; }; }, 1, [_unit]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 6702a14cfd..6a5b94b46d 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -13,14 +13,20 @@ #include "script_component.hpp" -private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus"]; +private ["_unit", "_heartRate","_bloodPressure","_bloodVolume","_painStatus", "_lastTimeValuesSynced", "_syncValues"]; _unit = _this select 0; +_lastTimeValuesSynced = _unit getvariable [QGVAR(lastMomentValuesSynced), 0]; +_syncValues = time - _lastTimeValuesSynced >= (10 + floor(random(10))); +if (_syncValues) then { + _unit setvariable [QGVAR(lastMomentValuesSynced), time]; +}; + _bloodVolume = (_unit getvariable [QGVAR(bloodVolume), 0]) + ([_unit] call FUNC(getBloodVolumeChange)); if (_bloodVolume <= 0) then { _bloodVolume = 0; }; -_unit setvariable [QGVAR(bloodVolume), _bloodVolume]; +_unit setvariable [QGVAR(bloodVolume), _bloodVolume, _syncValues]; // Set variables for synchronizing information across the net if (_bloodVolume < 90) then { @@ -68,26 +74,26 @@ if ([_unit] call EFUNC(common,isAwake)) then { }; // handle advanced medical, with vitals -if (GVAR(level) >= 2) exitwith { +if (GVAR(level) >= 2) then { // Set the vitals _heartRate = (_unit getvariable [QGVAR(heartRate), 0]) + ([_unit] call FUNC(getHeartRateChange)); - _unit setvariable [QGVAR(heartRate), _heartRate]; + _unit setvariable [QGVAR(heartRate), _heartRate, _syncValues]; _bloodPressure = [_unit] call FUNC(getBloodPressure); - _unit setvariable [QGVAR(bloodPressure), _bloodPressure]; + _unit setvariable [QGVAR(bloodPressure), _bloodPressure, _syncValues]; // Handle airway if (GVAR(setting_allowAirwayInjuries)) then { _airwayStatus = _unit getvariable [QGVAR(airwayStatus), 100]; if (((_unit getvariable [QGVAR(airwayOccluded), false]) || (_unit getvariable [QGVAR(airwayCollapsed), false])) && !((_unit getvariable [QGVAR(airwaySecured), false]))) then { if (_airwayStatus >= 0.5) then { - _unit setvariable [QGVAR(airwayStatus), _airwayStatus - 0.5]; + _unit setvariable [QGVAR(airwayStatus), _airwayStatus - 0.5, _syncValues]; }; } else { if !((_unit getvariable [QGVAR(airwayOccluded), false]) || (_unit getvariable [QGVAR(airwayCollapsed), false])) then { if (_airwayStatus <= 98.5) then { - _unit setvariable [QGVAR(airwayStatus), _airwayStatus + 1.5]; + _unit setvariable [QGVAR(airwayStatus), _airwayStatus + 1.5, _syncValues]; }; }; };