Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repair - Add settings to control item requirements for different actions #7243

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addons/repair/ACE_Repair.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {};
};
Expand Down Expand Up @@ -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);
};
};
Expand Down
2 changes: 0 additions & 2 deletions addons/repair/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -29,7 +28,6 @@ class ACE_Settings {
};
class GVAR(wheelRepairRequiredItems) {
movedToSQF = 1;
_values[] = {{}, {"ToolKit"}};
};
class GVAR(autoShutOffEngineWhenStartingRepair) {
movedToSQF = 1;
Expand Down
9 changes: 2 additions & 7 deletions addons/repair/functions/fnc_canRepair.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
9 changes: 2 additions & 7 deletions addons/repair/functions/fnc_repair.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
32 changes: 24 additions & 8 deletions addons/repair/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// CBA Settings [ADDON: ace_repair]:

[
QGVAR(displayTextOnRepair), "CHECKBOX",
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],
Expand All @@ -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
Expand Down Expand Up @@ -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;

[
Expand Down
20 changes: 16 additions & 4 deletions addons/repair/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1783,8 +1783,8 @@
<Chinesesimp>选择的备件数量</Chinesesimp>
<Chinese>選擇的備件數量</Chinese>
</Key>
<Key ID="STR_ACE_Repair_wheelRepairRequiredItems_name">
<English>Wheel repair requirements</English>
<Key ID="STR_ACE_Repair_WheelRepairRequiredItems_DisplayName">
<English>Wheel Repair Requirements</English>
<German>Erfordernisse zur Reifenreperatur</German>
<Polish>Wym. naprawy kół</Polish>
<Spanish>Requisitos de reparación de ruedas</Spanish>
Expand All @@ -1798,8 +1798,8 @@
<Chinesesimp>维修轮胎限制</Chinesesimp>
<Chinese>維修輪胎限制</Chinese>
</Key>
<Key ID="STR_ACE_Repair_wheelRepairRequiredItems_description">
<English>Items required to remove/replace wheels</English>
<Key ID="STR_ACE_Repair_WheelRepairRequiredItems_Description">
<English>Items required to remove/replace wheels.</English>
<German>Gegenstänge, die zum Entfernen/Austauschen eines Reifens benötigt werden</German>
<Polish>Przedmioty potrzebne do wymiany kół</Polish>
<Spanish>Elementos necesarios para quitar/cambiar ruedas</Spanish>
Expand All @@ -1813,6 +1813,18 @@
<Chinesesimp>需要特定物品来移除/更换车轮</Chinesesimp>
<Chinese>需要特定物品來移除/更換車輪</Chinese>
</Key>
<Key ID="STR_ACE_Repair_MiscRepairRequiredItems_DisplayName">
<English>Misc Repair Requirements</English>
</Key>
<Key ID="STR_ACE_Repair_MiscRepairRequiredItems_Description">
<English>Items required to repair a specific vehicle component or remove/replace tracks.</English>
</Key>
<Key ID="STR_ACE_Repair_FullRepairRequiredItems_DisplayName">
<English>Full Repair Requirements</English>
</Key>
<Key ID="STR_ACE_Repair_FullRepairRequiredItems_Description">
<English>Items required to perform a full vehicle repair.</English>
</Key>
<Key ID="STR_ACE_Repair_shutOffEngineWarning">
<English>Engine must be off to repair</English>
<German>Motor muss ausgeschaltet zu reparieren sein</German>
Expand Down