ACE3/addons/medical_treatment/functions/fnc_tourniquetRemove.sqf
johnb432 cd678c5b90
Medical AI - Add tourniquet support (#10158)
Add tourniquet support for Medical AI
2024-08-05 02:39:01 -07:00

74 lines
2.5 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Glowbal, mharis001
* Removes the tourniquet from the patient on the given body part.
* Note: Patient may not be local
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
* 2: Body Part <STRING>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject, "LeftLeg"] call ace_medical_treatment_fnc_tourniquetRemove
*
* Public: No
*/
params ["_medic", "_patient", "_bodyPart"];
TRACE_3("tourniquetRemove",_medic,_patient,_bodyPart);
// Remove tourniquet from body part, exit if no tourniquet applied
private _partIndex = ALL_BODY_PARTS find tolowerANSI _bodyPart;
private _tourniquets = GET_TOURNIQUETS(_patient);
if (_tourniquets select _partIndex == 0) exitWith {
if (_medic == ACE_player) then {
[LSTRING(noTourniquetOnBodyPart), 1.5] call EFUNC(common,displayTextStructured);
};
};
_tourniquets set [_partIndex, 0];
_patient setVariable [VAR_TOURNIQUET, _tourniquets, true];
[_patient] call EFUNC(medical_status,updateWoundBloodLoss);
private _nearPlayers = (_patient nearEntities ["CAManBase", 6]) select {_x call EFUNC(common,isPlayer)};
TRACE_1("clearConditionCaches: tourniquetRemove",_nearPlayers);
[QEGVAR(interact_menu,clearConditionCaches), [], _nearPlayers] call CBA_fnc_targetEvent;
// Add tourniquet item to medic or patient
if (_medic call EFUNC(common,isPlayer)) then {
private _receiver = [_patient, _medic, _medic] select GVAR(allowSharedEquipment);
[_receiver, "ACE_tourniquet"] call EFUNC(common,addToInventory);
} else {
// If the medic is AI, only return tourniquet if enabled
if (missionNamespace getVariable [QEGVAR(medical_ai,requireItems), 0] > 0) then {
[_medic, "ACE_tourniquet"] call EFUNC(common,addToInventory);
};
};
// Handle occluded medications that were blocked due to tourniquet
private _occludedMedications = _patient getVariable [QEGVAR(medical,occludedMedications), []];
private _arrayModified = false;
{
_x params ["_bodyPartN", "_medication"];
if (_partIndex == _bodyPartN) then {
TRACE_1("delayed medication call after tourniquet removeal",_x);
[QGVAR(medicationLocal), [_patient, _bodyPart, _medication], _patient] call CBA_fnc_targetEvent;
_occludedMedications set [_forEachIndex, []];
_arrayModified = true;
};
} forEach _occludedMedications;
if (_arrayModified) then {
_occludedMedications = _occludedMedications - [[]];
_patient setVariable [QEGVAR(medical,occludedMedications), _occludedMedications, true];
};