From a304e95e3869d725dfe2920c89f866fd604adf3e Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:37:50 -0300 Subject: [PATCH] Medical API - Add getter for IVs (#10553) --- addons/medical/XEH_PREP.hpp | 1 + addons/medical/functions/fnc_getIVs.sqf | 43 +++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 addons/medical/functions/fnc_getIVs.sqf diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 82fc144bf2f..63d22caefe1 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -4,6 +4,7 @@ PREP(deserializeState); PREP(fullHeal); PREP(getBandagedWounds); PREP(getBloodLoss); +PREP(getIVs); PREP(getOpenWounds); PREP(getStitchedWounds); PREP(isInjured); diff --git a/addons/medical/functions/fnc_getIVs.sqf b/addons/medical/functions/fnc_getIVs.sqf new file mode 100644 index 00000000000..e9352090b0d --- /dev/null +++ b/addons/medical/functions/fnc_getIVs.sqf @@ -0,0 +1,43 @@ +#include "..\script_component.hpp" +/* + * Author: LinkIsGrim + * Returns a copy of unit's IVs. + * + * Arguments: + * 0: Unit + * + * Return Value: + * IVs : + * 0: IV volume remaining, in liters + * 1: IV type (blood, saline, plasma, etc) + * 2: Body part IV is attached to + * 3: IV classname + * 4: IV flow rate coef + * + * Example: + * player call ace_medical_fnc_getIVs + * + * Public: Yes + */ + +params [["_unit", objNull, [objNull]]]; + +if (!alive _unit) exitWith { + ERROR_1("getIVs - null or dead unit %1",_unit); + + [] +}; + +if !(_unit isKindOf "CAManBase") exitWith { + ERROR_2("getIVs - unit %1 is not child of CAManBase - type %2",_unit,typeOf _unit); + + [] +}; + +private _ivBags = []; + +{ + _ivBags pushBack +_x; // manual deep copy so modification doesn't affect unit state +} forEach (_unit getVariable [QGVAR(ivBags), []]); + +_ivBags