diff --git a/addons/repair/CfgVehicleClasses.hpp b/addons/repair/CfgVehicleClasses.hpp index 1a5cafac0e..0cd2e70942 100644 --- a/addons/repair/CfgVehicleClasses.hpp +++ b/addons/repair/CfgVehicleClasses.hpp @@ -1,6 +1,6 @@ class CfgVehicleClasses { class GVAR(items) { - displayName = "ACE REPAIR ITEMS"; + displayName = "ACE"; }; }; diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index a1adee763a..d84d293a67 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -4,7 +4,7 @@ class ACE_MainActions { \ class GVAR(Repair) { \ displayName = "$STR_ACE_Repair_Repair"; \ - condition = ""; \ + condition = QUOTE([ARR_2(_this select 0, GVAR(engineerSetting_Repair))] call DFUNC(isEngineer)); \ statement = "'show a hint with the hitpart damage'"; \ runOnHover = 1; \ showDisabled = 0; \ diff --git a/addons/repair/XEH_preInit.sqf b/addons/repair/XEH_preInit.sqf index 87cc3dc749..4fe44aa9fe 100644 --- a/addons/repair/XEH_preInit.sqf +++ b/addons/repair/XEH_preInit.sqf @@ -9,7 +9,9 @@ PREP(canReplaceWheel); PREP(doRemoveWheel); PREP(doRepair); PREP(doReplaceWheel); +PREP(getPostRepairDamage); PREP(getWheelHitPointsWithSelections); +PREP(isEngineer); PREP(moduleRepairSettings); PREP(normalizeHitPoints); PREP(removeWheel); diff --git a/addons/repair/functions/fnc_canRepair.sqf b/addons/repair/functions/fnc_canRepair.sqf index 565b739983..ea0dd79b73 100644 --- a/addons/repair/functions/fnc_canRepair.sqf +++ b/addons/repair/functions/fnc_canRepair.sqf @@ -21,4 +21,6 @@ _hitPoint = _this select 2; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; -alive _target && {_target getHitPointDamage _hitPoint > 0} +if !([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {false}; + +alive _target && {_target getHitPointDamage _hitPoint > ([_unit] call FUNC(getPostRepairDamage))} diff --git a/addons/repair/functions/fnc_canReplaceWheel.sqf b/addons/repair/functions/fnc_canReplaceWheel.sqf index 41c147388c..26038fc78d 100644 --- a/addons/repair/functions/fnc_canReplaceWheel.sqf +++ b/addons/repair/functions/fnc_canReplaceWheel.sqf @@ -21,6 +21,8 @@ _hitPoint = _this select 2; if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false}; +if !([_unit, GVAR(engineerSetting_Wheel)] call FUNC(isEngineer)) exitWith {false}; + // check for a near wheel private "_wheel"; _wheel = objNull; diff --git a/addons/repair/functions/fnc_doRemoveWheel.sqf b/addons/repair/functions/fnc_doRemoveWheel.sqf index 16b31012f4..101ecc82d3 100644 --- a/addons/repair/functions/fnc_doRemoveWheel.sqf +++ b/addons/repair/functions/fnc_doRemoveWheel.sqf @@ -31,7 +31,7 @@ if (_hitPointDamage >= 1) exitWith {}; // spawn wheel private "_wheel"; _wheel = ["ACE_Wheel", getPosASL _unit] call FUNC(spawnObject); -_wheel setdamage _damage; +_wheel setdamage _hitPointDamage; // raise event to set the new hitpoint damage ["setWheelHitPointDamage", _vehicle, [_vehicle, _hitPoint, 1]] call EFUNC(common,targetEvent); diff --git a/addons/repair/functions/fnc_doRepair.sqf b/addons/repair/functions/fnc_doRepair.sqf index 3a35eae261..e75dc024fd 100644 --- a/addons/repair/functions/fnc_doRepair.sqf +++ b/addons/repair/functions/fnc_doRepair.sqf @@ -11,10 +11,11 @@ */ #include "script_component.hpp" -private ["_vehicle", "_hitPoint", "_elapsedTime", "_totalTime"]; +private ["_unit", "_vehicle", "_hitPoint", "_elapsedTime", "_totalTime"]; -_vehicle = _this select 0 select 0; -_hitPoint = _this select 0 select 1; +_unit = _this select 0 select 0; +_vehicle = _this select 0 select 1; +_hitPoint = _this select 0 select 2; _elapsedTime = _this select 1; _totalTime = _this select 2; @@ -27,7 +28,7 @@ _hitPointDamage = _vehicle getHitPointDamage _hitPoint; _hitPointDamage = _hitPointDamage - _hitPointDamage * (_elapsedTime / _totalTime); // don't use negative values for damage -_hitPointDamage = _hitPointDamage max 0; +_hitPointDamage = _hitPointDamage max ([_unit] call FUNC(getPostRepairDamage)); // raise event to set the new hitpoint damage ["setVehicleHitPointDamage", _vehicle, [_vehicle, _hitPoint, _hitPointDamage]] call EFUNC(common,targetEvent); diff --git a/addons/repair/functions/fnc_getPostRepairDamage.sqf b/addons/repair/functions/fnc_getPostRepairDamage.sqf new file mode 100644 index 0000000000..43ba23c26f --- /dev/null +++ b/addons/repair/functions/fnc_getPostRepairDamage.sqf @@ -0,0 +1,11 @@ +// by comm2 +#include "script_component.hpp" + +private "_unit"; + +_unit = _this select 0; + +if ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold_Engineer)}; +if ([_unit, GVAR(engineerSetting_Repair)] call FUNC(isEngineer)) exitWith {GVAR(repairDamageThreshold)}; + +1 diff --git a/addons/repair/functions/fnc_isEngineer.sqf b/addons/repair/functions/fnc_isEngineer.sqf new file mode 100644 index 0000000000..f8bbe18b88 --- /dev/null +++ b/addons/repair/functions/fnc_isEngineer.sqf @@ -0,0 +1,25 @@ +/* + * Author: Glowbal, KoffeinFlummi, commy2 + * Check if a unit is any engineer class + * + * Arguments: + * 0: The Unit + * 1: Class + * + * ReturnValue: + * Is in of medic class + * + * Public: Yes + */ +#include "script_component.hpp" + +private ["_unit", "_engineerN", "_class"]; + +_unit = _this select 0; +_engineerN = if (count _this > 1) then {_this select 1} else {1}; + +_class = _unit getVariable [QGVAR(engineerClass), + getNumber (configFile >> "CfgVehicles" >> typeOf _unit >> "engineer") +]; + +_class >= _engineerN min GVAR(engineerSetting_Repair) diff --git a/addons/repair/functions/fnc_repairVehicle.sqf b/addons/repair/functions/fnc_repairVehicle.sqf index f59799b6c6..c253e7f36e 100644 --- a/addons/repair/functions/fnc_repairVehicle.sqf +++ b/addons/repair/functions/fnc_repairVehicle.sqf @@ -27,7 +27,7 @@ private ["_damage", "_time"]; _damage = _vehicle getHitPointDamage _hitPoint; -_time = 5 + 10 * _damage; +_time = (5 + 10 * _damage) * ([1.5, 1] select ([_unit, GVAR(engineerSetting_Repair) + 1] call FUNC(isEngineer))); // get string of the hitpoint private "_text"; @@ -40,7 +40,7 @@ if (isLocalized _text) then { }; // open the loading bar -[_time, [_vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {true}, []] call EFUNC(common,progressBar); +[_time, [_unit, _vehicle, _hitPoint], {_this call DFUNC(doRepair)}, {_this call DFUNC(doRepair)}, _text, {true}, []] call EFUNC(common,progressBar); // do animation [_unit] call EFUNC(common,goKneeling);