Minor cleanup: 'treatmentBandageLocal'

This commit is contained in:
ulteq 2016-12-10 15:39:03 +01:00
parent 852f78b801
commit 1bc1865313

View File

@ -16,13 +16,11 @@
params ["_target", "_bandage", "_bodyPart", ["_specificClass", -1]];
// Ensure it is a valid bodypart
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
if (_partIndex < 0) exitWith {false};
if (_partIndex < 0) exitWith { false };
// Get the open wounds for this unit
private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
if (count _openWounds == 0) exitWith {false}; // nothing to do here!
if (_openWounds isEqualTo []) exitWith { false };
// Get the default effectiveness for the used bandage
private _config = configFile >> QUOTE(ADDON) >> "Bandaging";
@ -44,7 +42,7 @@ private _mostEffectiveInjury = _openWounds select 0;
private _exit = false;
{
_x params ["", "_classID", "_partIndexN"];
_x params ["", "_classID", "_partIndexN", "_amountOf", "_bleeding"];
TRACE_2("OPENWOUND: ", _target, _x);
// Only parse injuries that are for the selected bodypart.
@ -78,7 +76,7 @@ private _exit = false;
};
// Check if this is the currently most effective found.
if (_woundEffectiveness * ((_x select 4) * (_x select 3)) > _effectivenessFound * ((_mostEffectiveInjury select 4) * (_mostEffectiveInjury select 3))) then {
if (_woundEffectiveness * _amountOf * _bleeding > _effectivenessFound * (_mostEffectiveInjury select 3) * (_mostEffectiveInjury select 4)) then {
_effectivenessFound = _woundEffectiveness;
_mostEffectiveSpot = _forEachIndex;
_mostEffectiveInjury = _x;
@ -90,11 +88,10 @@ private _exit = false;
if (_effectivenessFound == -1) exitWith {}; // Seems everything is patched up on this body part already..
// TODO refactor this part
// Find the impact this bandage has and reduce the amount this injury is present
private _impact = if (_mostEffectiveInjury select 3 >= _effectivenessFound) then {_effectivenessFound} else { _mostEffectiveInjury select 3 };
_mostEffectiveInjury set [3, ((_mostEffectiveInjury select 3) - _impact) max 0];
private _amountOf = _mostEffectiveInjury select 3;
private _impact = _effectivenessFound min _amountOf;
_mostEffectiveInjury set [3, _amountOf - _impact];
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
_target setVariable [QEGVAR(medical,openWounds), _openWounds, true];