Repair - Support all modded toolkits (#8595)

This commit is contained in:
Filip Maciejewski 2021-11-11 12:41:25 +01:00 committed by GitHub
parent f8e06b49a2
commit 604f169ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 54 additions and 29 deletions

View File

@ -106,7 +106,6 @@ class CfgVehicles {
class values {
class None { name = "None"; value = 0; default = 1;};
class ToolKit { name = "ToolKit"; value = 1; };
class gm_repairkit_01 { name = "GM Repair Kit"; value = 1; };
};
};
};

View File

@ -17,6 +17,7 @@ PREP(doReplaceWheel);
PREP(getClaimObjects);
PREP(getHitPointString);
PREP(getPostRepairDamage);
PREP(getRepairItems);
PREP(getWheelHitPointsWithSelections);
PREP(hasItems);
PREP(isEngineer);

View File

@ -8,6 +8,8 @@ PREP_RECOMPILE_END;
#include "initSettings.sqf"
GVAR(allToolKits) = call (uiNamespace getVariable QGVAR(allToolKits));
["ACE_RepairItem_Base", "killed", {
params ["_object"];

View File

@ -1,3 +1,8 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
uiNamespace setVariable [
QGVAR(allToolKits),
compileFinal str (QUOTE(getNumber (_x >> 'ItemInfo' >> 'type') == TYPE_TOOLKIT) configClasses (configFile >> "CfgWeapons") apply {configName _x})
];

View File

@ -37,12 +37,7 @@ 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 missionNamespace variable
private _items = if (isArray (_config >> "items")) then {
getArray (_config >> "items");
} else {
missionNamespace getVariable [getText (_config >> "items"), []]
};
private _items = _config call FUNC(getRepairItems);
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
private _return = true;

View File

@ -7,7 +7,7 @@
* 0: Unit that does the repairing <OBJECT>
*
* Return Value:
* 0: Rpair Damage Threshold <NUMBER>
* 0: Repair Damage Threshold <NUMBER>
*
* Example:
* [unit] call ace_repair_fnc_getPostRepairDamage

View File

@ -0,0 +1,37 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Returns the items required for repair.
*
* Arguments:
* 0: Repair config <CONFIG>
*
* Return Value:
* 0: Required items <ARRAY>
*
* Example:
* [_config] call ace_repair_fnc_getRepairItems
*
* Public: No
*/
params [["_config", configNull]];
// 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 {
missionNamespace getVariable [getText (_config >> "items"), []]
};
// handle "any toolkit" setting
if (_items isEqualTo [ANY_TOOLKIT_FAKECLASS]) then {
TRACE_1("any toolkit",_items);
// array element inside items array means "any of these items"
_items = [GVAR(allToolKits)];
};
TRACE_2("get repair items",_config,_items);
_items

View File

@ -29,4 +29,4 @@ private _return = true;
};
} forEach _items;
_return;
_return

View File

@ -43,12 +43,7 @@ if ((isEngineOn _target) && {!GVAR(autoShutOffEngineWhenStartingRepair)}) exitWi
false
};
// 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 {
missionNamespace getVariable [getText (_config >> "items"), []]
};
private _items = _config call FUNC(getRepairItems);
if (count _items > 0 && {!([_caller, _items] call FUNC(hasItems))}) exitWith {false};
private _return = true;

View File

@ -94,7 +94,7 @@
"LIST",
[LSTRING(WheelRepairRequiredItems_DisplayName), LSTRING(WheelRepairRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 0],
[[[], [ANY_TOOLKIT_FAKECLASS]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 0],
true
] call CBA_fnc_addSetting;
@ -103,7 +103,7 @@
"LIST",
[LSTRING(MiscRepairRequiredItems_DisplayName), LSTRING(MiscRepairRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
[[[], [ANY_TOOLKIT_FAKECLASS]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
true
] call CBA_fnc_addSetting;
@ -112,7 +112,7 @@
"LIST",
[LSTRING(FullRepairRequiredItems_DisplayName), LSTRING(FullRepairRequiredItems_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_repair"],
[[[], ["ToolKit"]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
[[[], [ANY_TOOLKIT_FAKECLASS]], ["STR_A3_None", "STR_A3_CfgWeapons_Toolkit0"], 1],
true
] call CBA_fnc_addSetting;

View File

@ -19,3 +19,5 @@
#define TRACK_HITPOINTS ["hitltrack", "hitrtrack"]
#define DAMAGE_COLOR_SCALE ["#FFFFFF", "#FFFF7E", "#FFEC4D", "#FFD52C", "#FCB121", "#FF9916", "#FF7D16", "#FF4400", "#FF0000"]
#define ANY_TOOLKIT_FAKECLASS QGVAR(anyToolKit)

View File

@ -97,17 +97,6 @@ class CfgVehicles {
EGVAR(dragging,dragDirection) = 0;
};
// TOOLKIT
class ACE_Module;
class ACE_moduleRepairSettings: ACE_Module {
class wheelRepairRequiredItems {
class values {
class gm_repairkit_01 { name = "RepairKit"; value = 1; };
};
};
};
// STATIC
class gm_ge_army_shelteraceII_repair_base;