Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical - Add API for getting unit wounds #10544

Merged
merged 5 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading