Move the tourniquet loop to handleUnitVitals. Makes the tourniquet pain compatible with swapping localities

This commit is contained in:
esteldunedain 2016-02-28 20:50:28 -03:00
parent 085860c770
commit bbb84ec7d1
2 changed files with 14 additions and 22 deletions

View File

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

View File

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