From bbb84ec7d14d27536be99408fcea22e51d2534b8 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Sun, 28 Feb 2016 20:50:28 -0300 Subject: [PATCH] Move the tourniquet loop to handleUnitVitals. Makes the tourniquet pain compatible with swapping localities --- .../functions/fnc_handleUnitVitals.sqf | 13 +++++++++++ .../fnc_treatmentTourniquetLocal.sqf | 23 +------------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 6159351cc9..d161bbb385 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -110,6 +110,19 @@ if (GVAR(level) >= 2) then { }; }; + // Handle toruniquets + private _tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; + { + private _appliedTime = _x; + if (_appliedTime > 0) then { + // There's a tourniquet applied at time _appliedTime + if (CBA_missionTime - _appliedTime > 120) then { + // Increase pain at a rate of 0.001 units/s + _unit setVariable [QGVAR(pain), (_unit getVariable [QGVAR(pain), 0]) + 0.001]; + }; + } + } forEach _tourniquets; + // Set the vitals _heartRate = (_unit getVariable [QGVAR(heartRate), 80]) + (([_unit] call FUNC(getHeartRateChange)) * _interval); _unit setVariable [QGVAR(heartRate), _heartRate max 0, _syncValues]; diff --git a/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf b/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf index 3b181b2387..b8acc27c74 100644 --- a/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf +++ b/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf @@ -23,26 +23,5 @@ _part = [_selectionName] call FUNC(selectionNameToNumber); // Place a tourniquet on the bodypart _tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; -_applyingTo = (_tourniquets select _part) + 1 + round(random(100)); -_tourniquets set[_part, _applyingTo]; +_tourniquets set [_part, CBA_missionTime]; _target setVariable [QGVAR(tourniquets), _tourniquets, true]; - -[{ - params ["_args", "_idPFH"]; - _args params ["_target", "_applyingTo", "_part", "_time"]; - - if (!alive _target) exitWith { - [_idPFH] call CBA_fnc_removePerFrameHandler; - }; - - _tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; - if !((_tourniquets select _part) == _applyingTo) exitWith { - // Tourniquet has been removed - [_idPFH] call CBA_fnc_removePerFrameHandler; - }; - if (ACE_time - _time > 120) then { - _target setVariable [QGVAR(pain), (_target getVariable [QGVAR(pain), 0]) + 0.005]; - }; -}, 5, [_target, _applyingTo, _part, ACE_time] ] call CBA_fnc_addPerFrameHandler; - -true