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>
47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Glowbal
|
|
* Update total wound bleeding based on open wounds and tourniquets
|
|
* Wound bleeding = percentage of cardiac output lost
|
|
*
|
|
* Arguments:
|
|
* 0: The Unit <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* Nothing
|
|
*
|
|
* Example:
|
|
* [player] call ace_medical_status_fnc_updateWoundBloodLoss
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_unit"];
|
|
|
|
private _tourniquets = GET_TOURNIQUETS(_unit);
|
|
private _bodyPartBleeding = [0,0,0,0,0,0];
|
|
{
|
|
private _partIndex = ALL_BODY_PARTS find _x;
|
|
if (_tourniquets select _partIndex == 0) then {
|
|
{
|
|
_x params ["", "_amountOf", "_bleeeding"];
|
|
_bodyPartBleeding set [_partIndex, (_bodyPartBleeding select _partIndex) + (_amountOf * _bleeeding)];
|
|
} forEach _y;
|
|
};
|
|
} forEach GET_OPEN_WOUNDS(_unit);
|
|
|
|
if (_bodyPartBleeding isEqualTo [0,0,0,0,0,0]) then {
|
|
TRACE_1("updateWoundBloodLoss-none",_unit);
|
|
_unit setVariable [VAR_WOUND_BLEEDING, 0, true];
|
|
} else {
|
|
_bodyPartBleeding params ["_headBleeding", "_bodyBleeding", "_leftArmBleeding", "_rightArmBleeding", "_leftLegBleeding", "_rightLegBleeding"];
|
|
private _bodyBleedingRate = ((_headBleeding min 0.9) + (_bodyBleeding min 1.0)) min 1.0;
|
|
private _limbBleedingRate = ((_leftArmBleeding min 0.3) + (_rightArmBleeding min 0.3) + (_leftLegBleeding min 0.5) + (_rightLegBleeding min 0.5)) min 1.0;
|
|
|
|
// limb bleeding is scaled down based on the amount of body bleeding
|
|
_limbBleedingRate = _limbBleedingRate * (1 - _bodyBleedingRate);
|
|
|
|
TRACE_3("updateWoundBloodLoss-bleeding",_unit,_bodyBleedingRate,_limbBleedingRate);
|
|
_unit setVariable [VAR_WOUND_BLEEDING, _bodyBleedingRate + _limbBleedingRate, true];
|
|
};
|