ACE3/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf

48 lines
1.4 KiB
Plaintext
Raw Normal View History

2015-02-21 20:26:39 +00:00
/*
* Author: Glowbal
* Apply a tourniquet to the patient, local callback.
*
* Arguments:
* 0: The patient <OBJECT>
* 1: Item used classname <STRING>
*
* Return Value:
2015-08-22 17:47:23 +00:00
* None
2015-02-21 20:26:39 +00:00
*
* Public: No
*/
#include "script_component.hpp"
2015-09-03 13:49:49 +00:00
private ["_tourniquets", "_part", "_applyingTo"];
params ["_target", "_tourniquetItem", "_selectionName"];
2015-02-21 20:26:39 +00:00
[_target] call FUNC(addToInjuredCollection);
_part = [_selectionName] call FUNC(selectionNameToNumber);
// Place a tourniquet on the bodypart
_tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
2015-02-21 20:26:39 +00:00
_applyingTo = (_tourniquets select _part) + 1 + round(random(100));
_tourniquets set[_part, _applyingTo];
_target setVariable [QGVAR(tourniquets), _tourniquets, true];
2015-02-21 20:26:39 +00:00
[{
2015-08-22 17:47:23 +00:00
params ["_args", "_idPFH"];
_args params ["_target", "_applyingTo", "_part", "_time"];
2015-11-30 16:14:05 +00:00
if (!alive _target) exitWith {
2015-08-22 17:47:23 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-02-21 20:26:39 +00:00
};
_tourniquets = _target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
2015-11-30 16:14:05 +00:00
if !((_tourniquets select _part) == _applyingTo) exitWith {
2015-02-21 20:26:39 +00:00
// Tourniquet has been removed
2015-08-22 17:47:23 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-02-21 20:26:39 +00:00
};
if (ACE_time - _time > 120) then {
_target setVariable [QGVAR(pain), (_target getVariable [QGVAR(pain), 0]) + 0.005];
2015-02-21 20:26:39 +00:00
};
}, 5, [_target, _applyingTo, _part, ACE_time] ] call CBA_fnc_addPerFrameHandler;
2015-02-21 20:26:39 +00:00
2015-08-22 17:47:23 +00:00
true