mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
02365609b5
* Refactor medical to use hashmaps for wound storage - We most frequently want to access wounds by body part, so this makes that a constant time lookup. - The body part index is no longer stored in every wound since it's inherent in the wound storage. - Using body part names as the keys of the hashmap to improve code clarity (no more magic numbers). closes #6468 * Add deserilization migration from old wound arrays Will migrate from old form array wound storage to the new hashmap strucutre during deserlization. This is relevant for communities piping medical state out to a database or similar between sessions. * fix issue with suture stitching * change version number in comment --------- Co-authored-by: Salluci <salluci.lovi@gmail.com>
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: kymckay
|
|
* Returns a hashmap of the stitchable wounds that the given unit has on each body part.
|
|
* A stitchable wound is a bandaged wound on a body part that does not have any bleeding wounds.
|
|
*
|
|
* Arguments:
|
|
* 0: Unit <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Stitchable Wounds <HASHMAP>
|
|
*
|
|
* Example:
|
|
* [player] call ace_medical_treatment_fnc_getStitchableWounds
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_unit"];
|
|
|
|
// First determine which body parts have a bleeding wound
|
|
private _bleedingBodyParts = createHashMap;
|
|
{
|
|
private _isBleeding = _y findIf {
|
|
_x params ["", "_amountOf", "_bleedingRate"];
|
|
_amountOf > 0 && {_bleedingRate > 0}
|
|
} != -1;
|
|
|
|
if (_isBleeding) then {
|
|
_bleedingBodyParts set [_x, true];
|
|
};
|
|
} forEach GET_OPEN_WOUNDS(_unit);
|
|
|
|
// Any bandaged wound on a body part not bleeding is stitchable
|
|
private _stitchableWounds = createHashMap;
|
|
{
|
|
if (!(_x in _bleedingBodyParts) && {_y isNotEqualTo []}) then {
|
|
_stitchableWounds set [_x, _y];
|
|
};
|
|
} forEach GET_BANDAGED_WOUNDS(_unit);
|
|
|
|
_stitchableWounds
|