ACE3/addons/medical/functions/fnc_treatmentTourniquetLocal.sqf

53 lines
1.6 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:
* nil
*
* Public: No
*/
#include "script_component.hpp"
2015-04-15 22:17:17 +00:00
private ["_target", "_tourniquetItem", "_part", "_tourniquets", "_applyingTo", "_selectionName"];
2015-02-21 20:26:39 +00:00
_target = _this select 0;
_tourniquetItem = _this select 1;
2015-04-15 22:14:05 +00:00
_selectionName = _this select 2;
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]];
_applyingTo = (_tourniquets select _part) + 1 + round(random(100));
_tourniquets set[_part, _applyingTo];
_target setvariable [QGVAR(tourniquets), _tourniquets, true];
[{
private ["_args","_target","_applyingTo","_part", "_tourniquets"];
_args = _this select 0;
_target = _args select 0;
_applyingTo = _args select 1;
_part = _args select 2;
_time = _args select 3;
if (!alive _target) exitwith {
[(_this select 1)] 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
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if (time - _time > 120) then {
_target setvariable [QGVAR(pain), (_target getvariable [QGVAR(pain), 0]) + 0.005];
};
}, 5, [_target, _applyingTo, _part, time] ] call CBA_fnc_addPerFrameHandler;
true;