mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improved efficiency of wound counting.
Using a switch/case conditional since it offers early termination if a matching condition is found before all conditions are checked. It also unnecessary to use a conditional to confirm whether a limb is wounded or not. Number of Wounds multiplied by Blood loss will return zero for a fully bandaged body part, not incrementing the wound counter; or it will return some other number which will increment the wound counter.
This commit is contained in:
parent
f69f4066e9
commit
0a788a282e
@ -114,34 +114,40 @@ if (GVAR(healHitPointAfterAdvBandage)) then {
|
|||||||
{
|
{
|
||||||
_x params ["", "", "_bodyPart", "_numOpenWounds", "_bloodLoss"];
|
_x params ["", "", "_bodyPart", "_numOpenWounds", "_bloodLoss"];
|
||||||
|
|
||||||
|
// Use switch/case for early termination if wounded limb is found before all six are checked.
|
||||||
|
// Multiplying wounds by blood loss will either increment the wound count by
|
||||||
|
// some number (only care if greater than zero) or it will return zero indicating
|
||||||
|
// the body part is still undamaged.
|
||||||
|
switch (_bodyPart) do {
|
||||||
// Head
|
// Head
|
||||||
if (_bodyPart == 0 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 0: {
|
||||||
_headWounds = _headWounds + 1;
|
_headWounds = _headWounds + (_numOpenWounds * _bloodLoss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Body
|
// Body
|
||||||
if (_bodyPart == 1 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 1: {
|
||||||
_bodyWounds = _bodyWounds + 1;
|
_bodyWounds = _bodyWounds + (_numOpenWounds * _bloodLoss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Left Arm
|
// Left Arm
|
||||||
if (_bodyPart == 2 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 2: {
|
||||||
_armWounds = _armWounds + 1;
|
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Right Arm
|
// Right Arm
|
||||||
if (_bodyPart == 3 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 3: {
|
||||||
_armWounds = _armWounds + 1;
|
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Left Leg
|
// Left Leg
|
||||||
if (_bodyPart == 4 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 4: {
|
||||||
_legsWounds = _legsWounds + 1;
|
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Right Leg
|
// Right Leg
|
||||||
if (_bodyPart == 5 && {(_numOpenWounds * _bloodLoss) > 0}) then {
|
case 5: {
|
||||||
_legsWounds = _legsWounds + 1;
|
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} forEach _currentWounds;
|
} forEach _currentWounds;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user