From 26ece1af9380c8c36f1618cdcc6459b94b1d13ba Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 12 Mar 2015 00:59:04 +0100 Subject: [PATCH] ignore selectionless hitpoints, dependand hitpoints and glass when averaging the total damage after repairing a hitpoint --- .../repair/functions/fnc_setHitPointDamage.sqf | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/repair/functions/fnc_setHitPointDamage.sqf b/addons/repair/functions/fnc_setHitPointDamage.sqf index 8b6b4204e6..5d6020b7f1 100644 --- a/addons/repair/functions/fnc_setHitPointDamage.sqf +++ b/addons/repair/functions/fnc_setHitPointDamage.sqf @@ -23,8 +23,10 @@ _hitPointDamage = _this select 2; if !(local _vehicle) exitWith {}; // get all valid hitpoints -private "_hitPoints"; +private ["_hitPoints", "_hitPointsWithSelections"]; + _hitPoints = [_vehicle] call EFUNC(common,getHitpoints); +_hitPointsWithSelections = [_vehicle] call EFUNC(common,getHitpointsWithSelections) select 0; // exit if the hitpoint is not valid if !(_hitPoint in _hitPoints) exitWith {}; @@ -44,8 +46,10 @@ _damageOld = damage _vehicle; _hitPointDamageSumOld = 0; { - _hitPointDamageSumOld = _hitPointDamageSumOld + _x; -} forEach _hitPointDamages; + if (!(_x in IGNORED_HITPOINTS) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then { + _hitPointDamageSumOld = _hitPointDamageSumOld + (_hitPointDamages select (_hitPoints find _x)); + }; +} forEach _hitPointsWithSelections; // set new damage in array _hitPointDamages set [_hitPoints find _hitPoint, _hitPointDamage]; @@ -55,8 +59,10 @@ private "_hitPointDamageSumNew"; _hitPointDamageSumNew = 0; { - _hitPointDamageSumNew = _hitPointDamageSumNew + _x; -} forEach _hitPointDamages; + if (!(_x in IGNORED_HITPOINTS) && {!isText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "HitPoints" >> _x >> "depends")}) then { + _hitPointDamageSumNew = _hitPointDamageSumNew + (_hitPointDamages select (_hitPoints find _x)); + }; +} forEach _hitPointsWithSelections; // calculate new strctural damage private "_damageNew";