From 1bc1865313d2f54872123840c752e67f725f2605 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 10 Dec 2016 15:39:03 +0100 Subject: [PATCH] Minor cleanup: 'treatmentBandageLocal' --- .../functions/fnc_treatmentBandageLocal.sqf | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf index 9cb80c0c49..a91d3ff829 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf @@ -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];