mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge new wounds into existing wounds whenever possible
* Todo: separate 'amountOf' into two variables (wound count and bandage percentage)
This commit is contained in:
parent
b81a5adcb9
commit
3b82510751
@ -21,9 +21,9 @@ _bodyPartDamage params ["_headDamage", "_bodyDamage", "_leftArmDamage", "_rightA
|
||||
|
||||
// Exclude non penetrating body damage
|
||||
{
|
||||
_x params ["", "", "_bodyPartN", "", "", "_damage"];
|
||||
_x params ["", "", "_bodyPartN", "_amountOf", "", "_damage"];
|
||||
if (_bodyPartN == 1 && {_damage < PENETRATION_THRESHOLD}) then {
|
||||
_bodyDamage = _bodyDamage - _damage;
|
||||
_bodyDamage = _bodyDamage - (_amountOf * _damage);
|
||||
};
|
||||
} forEach (_unit getVariable [QGVAR(openWounds), []]);
|
||||
|
||||
|
@ -75,7 +75,25 @@ private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,
|
||||
[_unit, true] call EFUNC(medical_engine,setLimping);
|
||||
};
|
||||
|
||||
_openWounds pushBack _x;
|
||||
// if possible merge into existing wounds
|
||||
private _createNewWound = true;
|
||||
{
|
||||
_x params ["", "_classID", "_bodyPartN", "_oldAmountOf", "_oldBleeding", "_oldDamage"];
|
||||
if (_woundClassIDToAdd == _classID && {_bodyPartNToAdd == _bodyPartN && {(round(_damage * 10) / 10) == (round(_oldDamage * 10) / 10)}}) then {
|
||||
private _oldCategory = (floor ((0 max _oldBleeding min 0.1) / 0.05));
|
||||
private _newCategory = (floor ((0 max _bleeding min 0.1) / 0.05));
|
||||
if (_oldCategory == _newCategory) exitWith {
|
||||
private _newBleeding = (_oldAmountOf * _oldBleeding + _bleeding);
|
||||
private _newAmountOf = _newBleeding / _oldBleeding;
|
||||
_x set [3, _newAmountOf];
|
||||
_createNewWound = false;
|
||||
};
|
||||
};
|
||||
} forEach _openWounds;
|
||||
|
||||
if (_createNewWound) then {
|
||||
_openWounds pushBack _x;
|
||||
};
|
||||
} forEach _woundsCreated;
|
||||
|
||||
_unit setVariable [QEGVAR(medical,openWounds), _openWounds, true];
|
||||
|
@ -125,8 +125,25 @@ private _woundsCreated = [];
|
||||
[_unit, true] call EFUNC(medical_engine,setLimping);
|
||||
};
|
||||
|
||||
// Since it is a new injury, we will have to add it to the open wounds array to store it
|
||||
_openWounds pushBack _injury;
|
||||
// if possible merge into existing wounds
|
||||
private _createNewWound = true;
|
||||
{
|
||||
_x params ["", "_classID", "_bodyPartN", "_oldAmountOf", "_oldBleeding", "_oldDamage"];
|
||||
if (_woundClassIDToAdd == _classID && {_bodyPartNToAdd == _bodyPartN && {(round(_damage * 10) / 10) == (round(_oldDamage * 10) / 10)}}) then {
|
||||
private _oldCategory = (floor ((0 max _oldBleeding min 0.1) / 0.05));
|
||||
private _newCategory = (floor ((0 max _bleeding min 0.1) / 0.05));
|
||||
if (_oldCategory == _newCategory) exitWith {
|
||||
private _newBleeding = (_oldAmountOf * _oldBleeding + _bleeding);
|
||||
private _newAmountOf = _newBleeding / _oldBleeding;
|
||||
_x set [3, _newAmountOf];
|
||||
_createNewWound = false;
|
||||
};
|
||||
};
|
||||
} forEach _openWounds;
|
||||
|
||||
if (_createNewWound) then {
|
||||
_openWounds pushBack _injury;
|
||||
};
|
||||
|
||||
// New injuries will also increase the wound ID
|
||||
_woundID = _woundID + 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user