Merge pull request #2646 from DerekSauer/FixArmaInjury

Fix healHitPointAfterAdvBandage - Issue #2498.
This commit is contained in:
Glowbal 2015-10-04 09:28:47 +02:00
commit e36df978ec

View File

@ -94,12 +94,79 @@ if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then {
[_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
};
// If all wounds have been bandaged, we will reset all damage to 0, so the unit is not showing any blood on the model anymore.
if (GVAR(healHitPointAfterAdvBandage) && {{(_x select 2) == _part && {((_x select 4) * (_x select 3)) > 0}}count _openWounds == 0}) then {
_hitSelections = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"];
_hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
_point = _hitPoints select (_hitSelections find _selectionName);
_target setHitPointDamage [_point, 0];
// If all wounds to a body part have been bandaged, reset damage to that body part to zero
// so that the body part functions normally and blood is removed from the uniform.
// Arma combines left and right arms into a single body part (HitHands), same with left and right legs (HitLegs).
// Arms are actually hands.
if (GVAR(healHitPointAfterAdvBandage)) then {
private["_currentWounds", "_headWounds", "_bodyWounds", "_legsWounds", "_armWounds"];
// Get the list of the wounds the target is currently suffering from.
_currentWounds = _target getVariable [QGVAR(openWounds), []];
// Tally of unbandaged wounds to each body part.
_headWounds = 0;
_bodyWounds = 0;
_legsWounds = 0;
_armWounds = 0;
// Loop through all current wounds and add up the number of unbandaged wounds on each body part.
{
_x params ["", "", "_bodyPart", "_numOpenWounds", "_bloodLoss"];
// Use switch/case for early termination if wounded limb is found before all six are checked.
// 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.
switch (_bodyPart) do {
// Head
case 0: {
_headWounds = _headWounds + (_numOpenWounds * _bloodLoss);
};
// Body
case 1: {
_bodyWounds = _bodyWounds + (_numOpenWounds * _bloodLoss);
};
// Left Arm
case 2: {
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
};
// Right Arm
case 3: {
_armWounds = _armWounds + (_numOpenWounds * _bloodLoss);
};
// Left Leg
case 4: {
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
};
// Right Leg
case 5: {
_legsWounds = _legsWounds + (_numOpenWounds * _bloodLoss);
};
};
} forEach _currentWounds;
// Any body part that has no wounds is healed to full health
if (_headWounds == 0) then {
_target setHitPointDamage ["hitHead", 0.0];
};
if (_bodyWounds == 0) then {
_target setHitPointDamage ["hitBody", 0.0];
};
if (_armWounds == 0) then {
_target setHitPointDamage ["hitHands", 0.0];
};
if (_legsWounds == 0) then {
_target setHitPointDamage ["hitLegs", 0.0];
};
};
true;