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

This commit is contained in:
mharis001 2019-10-24 22:52:04 -04:00 committed by GitHub
parent f9d181c72e
commit e78016d7f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 29 deletions

View File

@ -37,7 +37,7 @@ class ACE_Repair {
requiredEngineer = QGVAR(engineerSetting_Repair); requiredEngineer = QGVAR(engineerSetting_Repair);
repairingTime = 15; repairingTime = 15;
callbackSuccess = QUOTE(call FUNC(doRepair)); callbackSuccess = QUOTE(call FUNC(doRepair));
items[] = {"ToolKit"}; items = QGVAR(miscRepairRequiredItems);
itemConsumed = QGVAR(consumeItem_ToolKit); itemConsumed = QGVAR(consumeItem_ToolKit);
claimObjects[] = {}; claimObjects[] = {};
}; };
@ -74,6 +74,7 @@ class ACE_Repair {
repairingTime = 30; repairingTime = 30;
condition = "-1 != ((getAllHitPointsDamage _target param [2,[]]) findIf {_x > 0})"; condition = "-1 != ((getAllHitPointsDamage _target param [2,[]]) findIf {_x > 0})";
callbackSuccess = QUOTE(call FUNC(doFullRepair)); callbackSuccess = QUOTE(call FUNC(doFullRepair));
items = QGVAR(fullRepairRequiredItems);
itemConsumed = QGVAR(consumeItem_ToolKit); itemConsumed = QGVAR(consumeItem_ToolKit);
}; };
}; };

View File

@ -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 ACE_Settings {
class GVAR(displayTextOnRepair) { class GVAR(displayTextOnRepair) {
movedToSQF = 1; movedToSQF = 1;
@ -29,7 +28,6 @@ class ACE_Settings {
}; };
class GVAR(wheelRepairRequiredItems) { class GVAR(wheelRepairRequiredItems) {
movedToSQF = 1; movedToSQF = 1;
_values[] = {{}, {"ToolKit"}};
}; };
class GVAR(autoShutOffEngineWhenStartingRepair) { class GVAR(autoShutOffEngineWhenStartingRepair) {
movedToSQF = 1; movedToSQF = 1;

View File

@ -37,16 +37,11 @@ private _engineerRequired = if (isNumber (_config >> "requiredEngineer")) then {
}; };
if !([_caller, _engineerRequired] call FUNC(isEngineer)) exitWith {false}; 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 { private _items = if (isArray (_config >> "items")) then {
getArray (_config >> "items"); getArray (_config >> "items");
} else { } else {
private _settingName = getText (_config >> "items"); missionNamespace getVariable [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);
}; };
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false}; if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};

View File

@ -43,16 +43,11 @@ if ((isEngineOn _target) && {!GVAR(autoShutOffEngineWhenStartingRepair)}) exitWi
false 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 { private _items = if (isArray (_config >> "items")) then {
getArray (_config >> "items"); getArray (_config >> "items");
} else { } else {
private _settingName = getText (_config >> "items"); missionNamespace getVariable [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);
}; };
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false}; if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};

View File

@ -1,5 +1,3 @@
// CBA Settings [ADDON: ace_repair]:
[ [
QGVAR(displayTextOnRepair), "CHECKBOX", QGVAR(displayTextOnRepair), "CHECKBOX",
[LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)], [LSTRING(SettingDisplayTextName), LSTRING(SettingDisplayTextDesc)],
@ -83,12 +81,30 @@
] call CBA_settings_fnc_init; ] call CBA_settings_fnc_init;
[ [
QGVAR(wheelRepairRequiredItems), "LIST", QGVAR(wheelRepairRequiredItems),
[LSTRING(wheelRepairRequiredItems_name), LSTRING(wheelRepairRequiredItems_description)], "LIST",
[LSTRING(WheelRepairRequiredItems_DisplayName), LSTRING(WheelRepairRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"], [localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[0,1],["None", "ToolKit"],0], // [values, titles, defaultIndex] [[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 0],
true, // isGlobal true
{[QGVAR(wheelRepairRequiredItems), _this] call EFUNC(common,cbaSettings_settingChanged)} ] 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; ] call CBA_settings_fnc_init;
[ [

View File

@ -1783,8 +1783,8 @@
<Chinesesimp>选择的备件数量</Chinesesimp> <Chinesesimp>选择的备件数量</Chinesesimp>
<Chinese>選擇的備件數量</Chinese> <Chinese>選擇的備件數量</Chinese>
</Key> </Key>
<Key ID="STR_ACE_Repair_wheelRepairRequiredItems_name"> <Key ID="STR_ACE_Repair_WheelRepairRequiredItems_DisplayName">
<English>Wheel repair requirements</English> <English>Wheel Repair Requirements</English>
<German>Erfordernisse zur Reifenreperatur</German> <German>Erfordernisse zur Reifenreperatur</German>
<Polish>Wym. naprawy kół</Polish> <Polish>Wym. naprawy kół</Polish>
<Spanish>Requisitos de reparación de ruedas</Spanish> <Spanish>Requisitos de reparación de ruedas</Spanish>
@ -1798,8 +1798,8 @@
<Chinesesimp>维修轮胎限制</Chinesesimp> <Chinesesimp>维修轮胎限制</Chinesesimp>
<Chinese>維修輪胎限制</Chinese> <Chinese>維修輪胎限制</Chinese>
</Key> </Key>
<Key ID="STR_ACE_Repair_wheelRepairRequiredItems_description"> <Key ID="STR_ACE_Repair_WheelRepairRequiredItems_Description">
<English>Items required to remove/replace wheels</English> <English>Items required to remove/replace wheels.</English>
<German>Gegenstänge, die zum Entfernen/Austauschen eines Reifens benötigt werden</German> <German>Gegenstänge, die zum Entfernen/Austauschen eines Reifens benötigt werden</German>
<Polish>Przedmioty potrzebne do wymiany kół</Polish> <Polish>Przedmioty potrzebne do wymiany kół</Polish>
<Spanish>Elementos necesarios para quitar/cambiar ruedas</Spanish> <Spanish>Elementos necesarios para quitar/cambiar ruedas</Spanish>
@ -1813,6 +1813,18 @@
<Chinesesimp>需要特定物品来移除/更换车轮</Chinesesimp> <Chinesesimp>需要特定物品来移除/更换车轮</Chinesesimp>
<Chinese>需要特定物品來移除/更換車輪</Chinese> <Chinese>需要特定物品來移除/更換車輪</Chinese>
</Key> </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"> <Key ID="STR_ACE_Repair_shutOffEngineWarning">
<English>Engine must be off to repair</English> <English>Engine must be off to repair</English>
<German>Motor muss ausgeschaltet zu reparieren sein</German> <German>Motor muss ausgeschaltet zu reparieren sein</German>