From df710235d5a5ccac62c1ad3caa486b6c1b4603a9 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sun, 22 Feb 2015 19:50:14 +0100 Subject: [PATCH] Added useItems Fixed header on hasItems --- addons/medical/XEH_preInit.sqf | 1 + addons/medical/functions/fnc_hasItems.sqf | 5 ++-- addons/medical/functions/fnc_useItems.sqf | 35 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 addons/medical/functions/fnc_useItems.sqf diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 58d9232250..07daf04b5e 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -44,6 +44,7 @@ PREP(onTreatmentCompleted); PREP(onMedicationUsed); PREP(reactionToDamage); PREP(useItem); +PREP(useItems); PREP(hasItem); PREP(hasItems); PREP(hasMedicalEnabled); diff --git a/addons/medical/functions/fnc_hasItems.sqf b/addons/medical/functions/fnc_hasItems.sqf index 3676649651..4bae508ecf 100644 --- a/addons/medical/functions/fnc_hasItems.sqf +++ b/addons/medical/functions/fnc_hasItems.sqf @@ -5,17 +5,16 @@ * Arguments: * 0: Medic * 1: Patient - * 2: Item + * 2: Items > * * ReturnValue: - * + * Has the items * * Public: Yes */ #include "script_component.hpp" - private ["_medic", "_patient", "_items", "_return"]; _medic = _this select 0; _patient = _this select 1; diff --git a/addons/medical/functions/fnc_useItems.sqf b/addons/medical/functions/fnc_useItems.sqf new file mode 100644 index 0000000000..adb4bcea1d --- /dev/null +++ b/addons/medical/functions/fnc_useItems.sqf @@ -0,0 +1,35 @@ +/* + * Author: Glowbal + * Use Equipment items if any is available. Priority: 1) Medic, 2) Patient. If in vehicle: 3) Crew + * + * Arguments: + * 0: Medic + * 1: Patient + * 2: Items > + * + * ReturnValue: + * + * + * Public: Yes + */ + +#include "script_component.hpp" + +private ["_medic", "_patient", "_items"]; +_medic = _this select 0; +_patient = _this select 1; +_items = _this select 2; + +{ + // handle a one of type use item + if (typeName _x == "ARRAY") then { + { + if ([_medic, _patient, _x] call FUNC(useItem)) exitwith {}; + }foreach _x; + }; + + // handle required item + if (typeName _x == "STRING") then { + [_medic, _patient, _x] call FUNC(useItem); + }; +}foreach _items;