From e78016d7f7e193691f92bac10c3e437d64a4bfd0 Mon Sep 17 00:00:00 2001
From: mharis001 <34453221+mharis001@users.noreply.github.com>
Date: Thu, 24 Oct 2019 22:52:04 -0400
Subject: [PATCH] Repair - Add settings to control item requirements for
different actions (#7243)
---
addons/repair/ACE_Repair.hpp | 3 ++-
addons/repair/ACE_Settings.hpp | 2 --
addons/repair/functions/fnc_canRepair.sqf | 9 ++-----
addons/repair/functions/fnc_repair.sqf | 9 ++-----
addons/repair/initSettings.sqf | 32 +++++++++++++++++------
addons/repair/stringtable.xml | 20 +++++++++++---
6 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/addons/repair/ACE_Repair.hpp b/addons/repair/ACE_Repair.hpp
index ec0624e2dc..97710940e7 100644
--- a/addons/repair/ACE_Repair.hpp
+++ b/addons/repair/ACE_Repair.hpp
@@ -37,7 +37,7 @@ class ACE_Repair {
requiredEngineer = QGVAR(engineerSetting_Repair);
repairingTime = 15;
callbackSuccess = QUOTE(call FUNC(doRepair));
- items[] = {"ToolKit"};
+ items = QGVAR(miscRepairRequiredItems);
itemConsumed = QGVAR(consumeItem_ToolKit);
claimObjects[] = {};
};
@@ -74,6 +74,7 @@ class ACE_Repair {
repairingTime = 30;
condition = "-1 != ((getAllHitPointsDamage _target param [2,[]]) findIf {_x > 0})";
callbackSuccess = QUOTE(call FUNC(doFullRepair));
+ items = QGVAR(fullRepairRequiredItems);
itemConsumed = QGVAR(consumeItem_ToolKit);
};
};
diff --git a/addons/repair/ACE_Settings.hpp b/addons/repair/ACE_Settings.hpp
index 82217bc5ad..45e8b15aa9 100644
--- a/addons/repair/ACE_Settings.hpp
+++ b/addons/repair/ACE_Settings.hpp
@@ -1,4 +1,3 @@
-// Warning: do not remove without handling wheelRepairRequiredItems's _values config on line 32 [used in repair/canRepair]
class ACE_Settings {
class GVAR(displayTextOnRepair) {
movedToSQF = 1;
@@ -29,7 +28,6 @@ class ACE_Settings {
};
class GVAR(wheelRepairRequiredItems) {
movedToSQF = 1;
- _values[] = {{}, {"ToolKit"}};
};
class GVAR(autoShutOffEngineWhenStartingRepair) {
movedToSQF = 1;
diff --git a/addons/repair/functions/fnc_canRepair.sqf b/addons/repair/functions/fnc_canRepair.sqf
index 93d5eef7a0..8172e1d188 100644
--- a/addons/repair/functions/fnc_canRepair.sqf
+++ b/addons/repair/functions/fnc_canRepair.sqf
@@ -37,16 +37,11 @@ private _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
};
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false};
-//Items can be an array of required items or a string to a ACE_Setting array
+// Items can be an array of required items or a string to a missionNamespace variable
private _items = if (isArray (_config >> "items")) then {
getArray (_config >> "items");
} else {
- private _settingName = getText (_config >> "items");
- private _settingItemsArray = getArray (configFile >> "ACE_Settings" >> _settingName >> "_values");
- if ((isNil _settingName) || {(missionNamespace getVariable _settingName) >= (count _settingItemsArray)}) exitWith {
- ERROR("bad setting"); ["BAD"]
- };
- _settingItemsArray select (missionNamespace getVariable _settingName);
+ missionNamespace getVariable [getText (_config >> "items"), []]
};
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
diff --git a/addons/repair/functions/fnc_repair.sqf b/addons/repair/functions/fnc_repair.sqf
index 9edd36bc83..10aea66823 100644
--- a/addons/repair/functions/fnc_repair.sqf
+++ b/addons/repair/functions/fnc_repair.sqf
@@ -43,16 +43,11 @@ if ((isEngineOn _target) && {!GVAR(autoShutOffEngineWhenStartingRepair)}) exitWi
false
};
-//Items can be an array of required items or a string to a ACE_Setting array
+// Items can be an array of required items or a string to a missionNamespace variable
private _items = if (isArray (_config >> "items")) then {
getArray (_config >> "items");
} else {
- private _settingName = getText (_config >> "items");
- private _settingItemsArray = getArray (configFile >> "ACE_Settings" >> _settingName >> "_values");
- if ((isNil _settingName) || {(missionNamespace getVariable _settingName) >= (count _settingItemsArray)}) exitWith {
- ERROR("bad setting"); ["BAD"]
- };
- _settingItemsArray select (missionNamespace getVariable _settingName);
+ missionNamespace getVariable [getText (_config >> "items"), []]
};
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
diff --git a/addons/repair/initSettings.sqf b/addons/repair/initSettings.sqf
index e226085a29..38e9e19e97 100644
--- a/addons/repair/initSettings.sqf
+++ b/addons/repair/initSettings.sqf
@@ -1,5 +1,3 @@
-// CBA Settings [ADDON: ace_repair]:
-
[
QGVAR(displayTextOnRepair), "CHECKBOX",
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],
@@ -11,7 +9,7 @@
[
QGVAR(engineerSetting_repair), "LIST",
- [LSTRING(engineerSetting_Repair_name), LSTRING(engineerSetting_Repair_description)],
+ [LSTRING(engineerSetting_Repair_name), LSTRING(engineerSetting_Repair_description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[0,1,2],[LSTRING(engineerSetting_anyone), LSTRING(engineerSetting_EngineerOnly), LSTRING(engineerSetting_AdvancedOnly)],1], // [values, titles, defaultIndex]
true, // isGlobal
@@ -83,12 +81,30 @@
] call CBA_settings_fnc_init;
[
- QGVAR(wheelRepairRequiredItems), "LIST",
- [LSTRING(wheelRepairRequiredItems_name), LSTRING(wheelRepairRequiredItems_description)],
+ QGVAR(wheelRepairRequiredItems),
+ "LIST",
+ [LSTRING(WheelRepairRequiredItems_DisplayName), LSTRING(WheelRepairRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
- [[0,1],["None", "ToolKit"],0], // [values, titles, defaultIndex]
- true, // isGlobal
- {[QGVAR(wheelRepairRequiredItems), _this] call EFUNC(common,cbaSettings_settingChanged)}
+ [[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 0],
+ true
+] call CBA_settings_fnc_init;
+
+[
+ QGVAR(miscRepairRequiredItems),
+ "LIST",
+ [LSTRING(MiscRepairRequiredItems_DisplayName), LSTRING(MiscRepairRequiredItems_Description)],
+ [localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
+ [[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
+ true
+] call CBA_settings_fnc_init;
+
+[
+ QGVAR(fullRepairRequiredItems),
+ "LIST",
+ [LSTRING(FullRepairRequiredItems_DisplayName), LSTRING(FullRepairRequiredItems_Description)],
+ [localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
+ [[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
+ true
] call CBA_settings_fnc_init;
[
diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml
index 4dd42d4880..63da4f50e0 100644
--- a/addons/repair/stringtable.xml
+++ b/addons/repair/stringtable.xml
@@ -1783,8 +1783,8 @@
选择的备件数量
選擇的備件數量
-
- Wheel repair requirements
+
+ Wheel Repair Requirements
Erfordernisse zur Reifenreperatur
Wym. naprawy kół
Requisitos de reparación de ruedas
@@ -1798,8 +1798,8 @@
维修轮胎限制
維修輪胎限制
-
- Items required to remove/replace wheels
+
+ Items required to remove/replace wheels.
Gegenstänge, die zum Entfernen/Austauschen eines Reifens benötigt werden
Przedmioty potrzebne do wymiany kół
Elementos necesarios para quitar/cambiar ruedas
@@ -1813,6 +1813,18 @@
需要特定物品来移除/更换车轮
需要特定物品來移除/更換車輪
+
+ Misc Repair Requirements
+
+
+ Items required to repair a specific vehicle component or remove/replace tracks.
+
+
+ Full Repair Requirements
+
+
+ Items required to perform a full vehicle repair.
+
Engine must be off to repair
Motor muss ausgeschaltet zu reparieren sein