Skip to content

Commit

Permalink
Medical - Add API for getting unit wounds (#10544)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkIsGrim authored Dec 15, 2024
1 parent fd28405 commit 6ddd020
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/medical/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ PREP(addDamageToUnit);
PREP(adjustPainLevel);
PREP(deserializeState);
PREP(fullHeal);
PREP(getBandagedWounds);
PREP(getOpenWounds);
PREP(getStitchedWounds);
PREP(serializeState);
PREP(setUnconscious);
51 changes: 51 additions & 0 deletions addons/medical/functions/fnc_getBandagedWounds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "..\script_component.hpp"
/*
* Author: LinkIsGrim
* Returns a copy of unit's bandaged wounds on a body part.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Body Part <STRING>
*
* Return Value:
* Wounds <ARRAY of ARRAY>:
* 0: Wound Class ID <NUMBER>
* 1: Wound Bandaged Amount <NUMBER>
* 2: Wound Bleeding Coef <NUMBER>
* 3: Wound Damage <NUMBER>
*
* Example:
* [player, "head"] call ace_medical_fnc_getBandagedWounds
*
* Public: Yes
*/

params [["_unit", objNull, [objNull]], ["_bodyPart", "", [""]]];

if (isNull _unit) exitWith {
ERROR("getBandagedWounds - null unit");

[]
};

if !(_unit isKindOf "CAManBase") exitWith {
ERROR_2("getBandagedWounds - unit %1 is not child of CAManBase - type %2",_unit,typeOf _unit);

[]
};

_bodyPart = toLowerANSI _bodyPart;

if !(_bodyPart in ALL_BODY_PARTS) exitWith {
ERROR_2("getBandagedWounds - invalid body part %1, expected one of %2",_bodyPart,ALL_BODY_PARTS);

[]
};

private _bandagedWounds = [];

{
_bandagedWounds pushBack +_x; // manual deep copy so modification doesn't affect unit state
} forEach (GET_OPEN_WOUNDS(_patient) getOrDefault [_bodyPart, []]);

_bandagedWounds
54 changes: 54 additions & 0 deletions addons/medical/functions/fnc_getOpenWounds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "..\script_component.hpp"
/*
* Author: LinkIsGrim
* Returns a copy of unit's open wounds on a body part.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Body Part <STRING>
*
* Return Value:
* Wounds <ARRAY of ARRAY>:
* 0: Wound Class ID <NUMBER>
* 1: Wound Open Amount <NUMBER>
* 2: Wound Bleeding Coef <NUMBER>
* 3: Wound Damage <NUMBER>
*
* Example:
* [player, "head"] call ace_medical_fnc_getOpenWounds
*
* Public: Yes
*/

params [["_unit", objNull, [objNull]], ["_bodyPart", "", [""]]];

if (isNull _unit) exitWith {
ERROR("getOpenWounds - null unit");

[]
};

if !(_unit isKindOf "CAManBase") exitWith {
ERROR_2("getOpenWounds - unit %1 is not child of CAManBase - type %2",_unit,typeOf _unit);

[]
};

_bodyPart = toLowerANSI _bodyPart;

if !(_bodyPart in ALL_BODY_PARTS) exitWith {
ERROR_2("getOpenWounds - invalid body part %1, expected one of %2",_bodyPart,ALL_BODY_PARTS);

[]
};

private _openWounds = [];

{
_x params ["", "_xAmount"];
if (_xAmount > 0) then { // bandaged wounds are open wounds with count 0, skip those
_openWounds pushBack +_x; // manual deep copy so modification doesn't affect unit state
};
} forEach (GET_OPEN_WOUNDS(_patient) getOrDefault [toLowerANSI _bodyPart, []]);

_openWounds
51 changes: 51 additions & 0 deletions addons/medical/functions/fnc_getStitchedWounds.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "..\script_component.hpp"
/*
* Author: LinkIsGrim
* Returns a copy of unit's stitched wounds on a body part.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Body Part <STRING>
*
* Return Value:
* Wounds <ARRAY of ARRAY>:
* 0: Wound Class ID <NUMBER>
* 1: Wound Stitched Amount <NUMBER>
* 2: Wound Bleeding Coef <NUMBER>
* 3: Wound Damage <NUMBER>
*
* Example:
* [player, "head"] call ace_medical_fnc_getStitchedWounds
*
* Public: Yes
*/

params [["_unit", objNull, [objNull]], ["_bodyPart", "", [""]]];

if (isNull _unit) exitWith {
ERROR("getStitchedWounds - null unit");

[]
};

if !(_unit isKindOf "CAManBase") exitWith {
ERROR_2("getStitchedWounds - unit %1 is not child of CAManBase - type %2",_unit,typeOf _unit);

[]
};

_bodyPart = toLowerANSI _bodyPart;

if !(_bodyPart in ALL_BODY_PARTS) exitWith {
ERROR_2("getStitchedWounds - invalid body part %1, expected one of %2",_bodyPart,ALL_BODY_PARTS);

[]
};

private _stitchedWounds = [];

{
_stitchedWounds pushBack +_x; // manual deep copy so modification doesn't affect unit state
} forEach (GET_STITCHED_WOUNDS(_patient) getOrDefault [toLowerANSI _bodyPart, []]);

_stitchedWounds

0 comments on commit 6ddd020

Please sign in to comment.