Synchronizing of vital values across the net every 10-25 seconds

This commit is contained in:
Glowbal 2015-03-08 13:56:24 +01:00
parent 2e07aabd41
commit 784a5e9fcb
3 changed files with 26 additions and 11 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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];
};
};
};