diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 8285a15519..6fdf99113c 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -11,6 +11,7 @@ PREP(addCanInteractWithCondition); PREP(addLineToDebugDraw); PREP(addSetting); PREP(addToInventory); +PREP(assignObjectsInList); PREP(ambientBrightness); PREP(applyForceWalkStatus); PREP(ASLToPosition); diff --git a/addons/common/functions/fnc_assignObjectsInList.sqf b/addons/common/functions/fnc_assignObjectsInList.sqf new file mode 100644 index 0000000000..0d10066d01 --- /dev/null +++ b/addons/common/functions/fnc_assignObjectsInList.sqf @@ -0,0 +1,50 @@ +/* + * Author: Glowbal + * Loops through a string and filters out object names/variables to assign a value for given variable. + * Used by moduleAssign* within various parts of the ACE3 project. + * + * Arguments: + * 0: list + * 1: variableName + * 2: value + * 3: Global + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_splittedList", "_nilCheckPassedList"]; +params ["_list", "_variable", "_setting", "_global"]; + +if (typeName _list == "STRING") then { + _splittedList = [_list, ","] call BIS_fnc_splitString; + _nilCheckPassedList = ""; + { + _x = [_x] call FUNC(stringRemoveWhiteSpace); + if !(isnil _x) then { + if (_nilCheckPassedList == "") then { + _nilCheckPassedList = _x; + } else { + _nilCheckPassedList = _nilCheckPassedList + ","+ _x; + }; + }; + }foreach _splittedList; + + _list = [] call compile format["[%1]",_nilCheckPassedList]; +}; + +{ + if (!isnil "_x") then { + if (typeName _x == typeName objNull) then { + if (local _x) then { + _x setvariable [_variable, _setting, _global]; + }; + }; + }; +}foreach _list; + +true diff --git a/addons/repair/CfgVehicles.hpp b/addons/repair/CfgVehicles.hpp index 54c30bddeb..b70e415b53 100644 --- a/addons/repair/CfgVehicles.hpp +++ b/addons/repair/CfgVehicles.hpp @@ -144,6 +144,78 @@ class CfgVehicles { sync[] = {}; }; }; + class ACE_moduleAssignRepairVehicle: Module_F { + scope = 2; + displayName = CSTRING(AssignRepairVehicle_Module_DisplayName); + icon = QUOTE(PATHTOF(ui\Icon_Module_Repair_ca.paa)); + category = "ACE"; + function = QUOTE(DFUNC(moduleAssignRepairVehicle)); + functionPriority = 10; + isGlobal = 2; + isTriggerActivated = 0; + isDisposable = 0; + author = ECSTRING(common,ACETeam); + class Arguments { + class EnableList { + displayName = CSTRING(AssignRepairVehicle_EnableList_DisplayName); + description = CSTRING(AssignRepairVehicle_EnableList_Description); + defaultValue = ""; + typeName = "STRING"; + }; + class role { + displayName = CSTRING(AssignRepairVehicle_role_DisplayName); + description = CSTRING(AssignRepairVehicle_role_Description); + typeName = "NUMBER"; + class values { + class none { + name = ECSTRING(common,No); + value = 0; + }; + class isVehicle { + name = ECSTRING(common,Yes); + value = 1; + default = 1; + }; + }; + }; + }; + class ModuleDescription { + description = CSTRING(AssignRepairVehicle_Module_Description); + sync[] = {}; + }; + }; + class ACE_moduleAssignRepairFacility: ACE_moduleAssignRepairVehicle { + displayName = CSTRING(AssignRepairFacility_Module_DisplayName); + function = QUOTE(DFUNC(moduleAssignRepairFacility)); + class Arguments { + class EnableList { + displayName = CSTRING(AssignRepairFacility_EnableList_DisplayName); + description = CSTRING(AssignRepairFacility_EnableList_Description); + defaultValue = ""; + typeName = "STRING"; + }; + class role { + displayName = CSTRING(AssignRepairFacility_role_DisplayName); + description = CSTRING(AssignRepairFacility_role_Description); + typeName = "NUMBER"; + class values { + class none { + name = ECSTRING(common,No); + value = 0; + }; + class isFacility { + name = ECSTRING(common,Yes); + value = 1; + default = 1; + }; + }; + }; + }; + class ModuleDescription { + description = CSTRING(AssignRepairFacility_Module_Description); + sync[] = {}; + }; + }; class LandVehicle; diff --git a/addons/repair/XEH_preInit.sqf b/addons/repair/XEH_preInit.sqf index 51819caae3..38de84a452 100644 --- a/addons/repair/XEH_preInit.sqf +++ b/addons/repair/XEH_preInit.sqf @@ -25,6 +25,8 @@ PREP(isNearRepairVehicle); PREP(isRepairVehicle); PREP(moduleRepairSettings); PREP(moduleAssignEngineer); +PREP(moduleAssignRepairVehicle); +PREP(moduleAssignRepairFacility); PREP(normalizeHitPoints); PREP(repair); PREP(repair_failure); diff --git a/addons/repair/functions/fnc_isInRepairFacility.sqf b/addons/repair/functions/fnc_isInRepairFacility.sqf index 47ecbabf3a..725cddd4c2 100644 --- a/addons/repair/functions/fnc_isInRepairFacility.sqf +++ b/addons/repair/functions/fnc_isInRepairFacility.sqf @@ -1,12 +1,12 @@ /* * Author: Glowbal - * Checks if a unit is in a designated engineeral facility + * Checks if a unit is in a repair facility * * Arguments: * 0: The Unit * * ReturnValue: - * Is in engineeral facility + * Is inside a repair facility * * Public: Yes */ @@ -24,7 +24,7 @@ _repairFacility = []; _objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position select 2)], _object modelToWorldVisual [0, 0, (_position select 2) +10], _object]); { - if (((typeOf _x) in _repairFacility) || (_x getVariable [QGVAR(isRepairFacility),false])) exitwith { + if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitwith { _isInBuilding = true; }; } forEach _objects; @@ -32,7 +32,7 @@ _objects = (lineIntersectsWith [_object modelToWorldVisual [0, 0, (_position sel if (!_isInBuilding) then { _objects = position _object nearObjects 7.5; { - if (((typeOf _x) in _repairFacility) || (_x getVariable [QGVAR(isRepairFacility),false])) exitwith { + if (((typeOf _x) in _repairFacility) || (_x getVariable ["ACE_isRepairFacility",0]) > 0) exitwith { _isInBuilding = true; }; } forEach _objects; diff --git a/addons/repair/functions/fnc_isRepairVehicle.sqf b/addons/repair/functions/fnc_isRepairVehicle.sqf index 6013b9a870..72da9783d1 100644 --- a/addons/repair/functions/fnc_isRepairVehicle.sqf +++ b/addons/repair/functions/fnc_isRepairVehicle.sqf @@ -17,4 +17,4 @@ TRACE_1("params",_vehicle); if (_vehicle isKindOf "CAManBase") exitwith {false}; -((_vehicle getVariable [QGVAR(engineerClass), getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair))]) > 0); +((_vehicle getVariable ["ACE_isRepairVehicle", getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(canRepair))]) > 0); diff --git a/addons/repair/functions/fnc_moduleAssignEngineer.sqf b/addons/repair/functions/fnc_moduleAssignEngineer.sqf index 195bc8d80d..e5310bfa5a 100644 --- a/addons/repair/functions/fnc_moduleAssignEngineer.sqf +++ b/addons/repair/functions/fnc_moduleAssignEngineer.sqf @@ -15,49 +15,15 @@ #include "script_component.hpp" -private ["_logic","_setting","_objects", "_list", "_splittedList", "_nilCheckPassedList", "_parsedList"]; -_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param; +params ["_logic"]; if (!isNull _logic) then { + private ["_list", "_setting"]; _list = _logic getvariable ["EnableList",""]; - - _splittedList = [_list, ","] call BIS_fnc_splitString; - _nilCheckPassedList = ""; - { - _x = [_x] call EFUNC(common,stringRemoveWhiteSpace); - if !(isnil _x) then { - if (_nilCheckPassedList == "") then { - _nilCheckPassedList = _x; - } else { - _nilCheckPassedList = _nilCheckPassedList + ","+ _x; - }; - }; - }foreach _splittedList; - - _list = "[" + _nilCheckPassedList + "]"; - _parsedList = [] call compile _list; _setting = _logic getvariable ["role",0]; - _objects = synchronizedObjects _logic; - if (!(_objects isEqualTo []) && _parsedList isEqualTo []) then { - { - if (!isnil "_x") then { - if (typeName _x == typeName objNull) then { - if (local _x) then { - _x setvariable ["ACE_IsEngineer", _setting, true]; - }; - }; - }; - }foreach _objects; - }; - { - if (!isnil "_x") then { - if (typeName _x == typeName objNull) then { - if (local _x) then { - _x setvariable ["ACE_IsEngineer", _setting, true]; - }; - }; - }; - }foreach _parsedList; + + [_list, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList); + [synchronizedObjects _logic, "ACE_IsEngineer", _setting, true] call EFUNC(common,assignObjectsInList); }; -true \ No newline at end of file +true diff --git a/addons/repair/functions/fnc_moduleAssignRepairFacility.sqf b/addons/repair/functions/fnc_moduleAssignRepairFacility.sqf new file mode 100644 index 0000000000..e9e60f4190 --- /dev/null +++ b/addons/repair/functions/fnc_moduleAssignRepairFacility.sqf @@ -0,0 +1,29 @@ +/* + * Author: Glowbal + * Assign an repair facility + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_logic"]; + +if (!isNull _logic) then { + private ["_list", "_setting"]; + _list = _logic getvariable ["EnableList",""]; + _setting = _logic getvariable ["role",0]; + + [_list, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList); + [synchronizedObjects _logic, "ACE_isRepairFacility", _setting, true] call EFUNC(common,assignObjectsInList); + }; + +true diff --git a/addons/repair/functions/fnc_moduleAssignRepairVehicle.sqf b/addons/repair/functions/fnc_moduleAssignRepairVehicle.sqf new file mode 100644 index 0000000000..991de2d8d6 --- /dev/null +++ b/addons/repair/functions/fnc_moduleAssignRepairVehicle.sqf @@ -0,0 +1,29 @@ +/* + * Author: Glowbal + * Assign an repair vehicle + * + * Arguments: + * 0: The module logic + * 1: units + * 2: activated + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_logic"]; + +if (!isNull _logic) then { + private ["_list", "_setting"]; + _list = _logic getvariable ["EnableList",""]; + _setting = _logic getvariable ["role",0]; + + [_list, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList); + [synchronizedObjects _logic, "ACE_isRepairVehicle", _setting, true] call EFUNC(common,assignObjectsInList); + }; + +true diff --git a/addons/repair/stringtable.xml b/addons/repair/stringtable.xml index db4556ac9e..6f341f6484 100644 --- a/addons/repair/stringtable.xml +++ b/addons/repair/stringtable.xml @@ -1,4 +1,4 @@ - + @@ -598,5 +598,42 @@ Assign one or multiple units as an engineer + + Assign Repair Vehicle + + + List + + + List of vehicles that will be classified as repair vehicle, separated by commas. + + + Is Repair Vehicle + + + Is the vehicle classified as a repair vehicle? + + + Assign one or multiple vehicles as a repair vehicle + + + + Assign Repair Facility + + + List + + + List of objects that will be classified as repair Facility, separated by commas. + + + Is Repair Facility + + + Is the object classified as a repair Facility? + + + Assign one or multiple objects as a repair Facility + - \ No newline at end of file +