From 450aeacf48d6b3379d9e9fbd19aeef7a2f89b46f Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 00:29:11 -0400 Subject: [PATCH 01/74] Add Unpack Static Weapon module --- addons/modules/CfgVehicles.hpp | 6 + addons/modules/XEH_PREP.hpp | 2 + addons/modules/config.cpp | 1 + .../functions/fnc_moduleFireLauncher.sqf | 6514 +++++++++++++++++ .../fnc_moduleUnpackStaticWeapon.sqf | 71 + .../functions/fnc_unpackStaticWeapon.sqf | 50 + addons/modules/stringtable.xml | 3 + 7 files changed, 6647 insertions(+) create mode 100644 addons/modules/functions/fnc_moduleFireLauncher.sqf create mode 100644 addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf create mode 100644 addons/modules/functions/fnc_unpackStaticWeapon.sqf diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index 7247d45cc..d1a650798 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -434,6 +434,12 @@ class CfgVehicles { displayName = CSTRING(ModuleUnGarrison); function = QFUNC(moduleUnGarrison); }; + class GVAR(moduleUnpackStaticWeapon): GVAR(moduleBase) { + curatorCanAttach = 1; + category = QGVAR(AI); + displayName = CSTRING(moduleUnpackStaticWeapon); + function = QFUNC(moduleUnpackStaticWeapon); + }; class GVAR(moduleVisibility): GVAR(moduleBase) { curatorCanAttach = 1; category = QGVAR(Objects); diff --git a/addons/modules/XEH_PREP.hpp b/addons/modules/XEH_PREP.hpp index 6306638ed..4c3be2b20 100644 --- a/addons/modules/XEH_PREP.hpp +++ b/addons/modules/XEH_PREP.hpp @@ -82,5 +82,7 @@ PREP(moduleToggleIRLasers); PREP(moduleToggleLamps); PREP(moduleTurretOptics); PREP(moduleUnGarrison); +PREP(moduleUnpackStaticWeapon); PREP(moduleVisibility); PREP(moduleWeather); +PREP(unpackStaticWeapon); diff --git a/addons/modules/config.cpp b/addons/modules/config.cpp index 7fb016182..6a23f03f6 100644 --- a/addons/modules/config.cpp +++ b/addons/modules/config.cpp @@ -67,6 +67,7 @@ class CfgPatches { QGVAR(moduleToggleLamps), QGVAR(moduleTurretOptics), QGVAR(moduleUnGarrison), + QGVAR(moduleUnpackStaticWeapon), QGVAR(moduleVisibility), QGVAR(moduleWeather) }; diff --git a/addons/modules/functions/fnc_moduleFireLauncher.sqf b/addons/modules/functions/fnc_moduleFireLauncher.sqf new file mode 100644 index 000000000..33d398b2d --- /dev/null +++ b/addons/modules/functions/fnc_moduleFireLauncher.sqf @@ -0,0 +1,6514 @@ +{#line 1 "x\zen\addons\modules\functions\fnc_moduleUnpackStaticWeapon.sqf" +#line 1 "x\zen\addons\modules\functions\script_component.hpp" +#line 1 "x\zen\addons\modules\script_component.hpp" + + +#line 1 "x\zen\addons\main\script_mod.hpp" + + + + + +#line 1 "x\zen\addons\main\script_version.hpp" + + + + +#line 6 "x\zen\addons\main\script_mod.hpp" + + + + + + + + + + + + + +#line 3 "x\zen\addons\modules\script_component.hpp" + + + + + + + + + + +#line 1 "x\zen\addons\main\script_macros.hpp" + +#line 1 "x\cba\addons\main\script_macros_common.hpp" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 2 "x\zen\addons\main\script_macros.hpp" + +#line 1 "x\cba\addons\xeh\script_xeh.hpp" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 3 "x\zen\addons\main\script_macros.hpp" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 1 "x\zen\addons\main\script_debug.hpp" + + + + + + + + + + + + + + + + + + + + + + + + + +#line 106 "x\zen\addons\main\script_macros.hpp" + +#line 17 "x\zen\addons\modules\script_component.hpp" + + +#line 1 "a3\ui_f\hpp\defineDIKCodes.inc" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 19 "x\zen\addons\modules\script_component.hpp" + +#line 1 "a3\ui_f\hpp\defineCommonGrids.inc" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 20 "x\zen\addons\modules\script_component.hpp" + +#line 1 "x\zen\addons\common\defineResinclDesign.inc" +#line 1 "a3\ui_f\hpp\defineResincl.inc" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 1 "x\zen\addons\common\defineResinclDesign.inc" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 21 "x\zen\addons\modules\script_component.hpp" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#line 1 "x\zen\addons\modules\functions\script_component.hpp" + +#line 1 "x\zen\addons\modules\functions\fnc_moduleUnpackStaticWeapon.sqf" + + + + + + + + + + + + + + + +zen_modules_fnc_moduleUnpackStaticWeapon = { + +params ["_logic"]; + +private _gunner = attachedTo _logic; +deleteVehicle _logic; + +if (isNull _gunner) exitWith { +["STR_zen_modules_NoUnitSelected"] call zen_common_fnc_showMessage; +}; + +if !(_gunner isKindOf "CAManBase") exitWith { +["STR_zen_modules_OnlyInfantry"] call zen_common_fnc_showMessage; +}; + +if !(alive _gunner) exitWith { +["STR_zen_modules_OnlyAlive"] call zen_common_fnc_showMessage; +}; + +if (isPlayer _gunner) exitWith { +["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call zen_common_fnc_showMessage; +}; + +getCompatibleBases = { +params ["_backpack"]; +private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; +private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; +_compatibleBases +}; + +private _backpack = backpack _gunner; +systemChat _backpack; +if (_backpack isEqualTo "") exitWith { + ["Unit must carry a weapon bag"] call zen_common_fnc_showMessage; +}; + +private _compatibleBases = [_backpack] call getCompatibleBases; +if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];}; + +private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; +private _assistant = { +if (backpack _x in _compatibleBases) exitWith {_x}; +if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; + +objNull +} forEach _backpackers; + +if (_assistant isEqualTo objNull) exitWith { +["Unit group must contain two compatible weapon bags"] call zen_common_fnc_showMessage; +}; + + +[_gunner, { +params ["_successful", "_gunner", "_mousePosASL", "_assistant"],; +[_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; +}, _assistant, "Static Weapon Facing"] call zen_common_fnc_selectPosition; +} diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf new file mode 100644 index 000000000..6dbbae4a3 --- /dev/null +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -0,0 +1,71 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Zeus module function to use backpacks to assemble a static weapon + * + * Arguments: + * 0: Logic + * + * Return Value: + * None + * + * Example: + * [LOGIC] call zen_modules_fnc_moduleUnpackStaticWeapon + * + * Public: No + */ + +params ["_logic"]; + +private _gunner = attachedTo _logic; +deleteVehicle _logic; + +if (isNull _gunner) exitWith { + [LSTRING(NoUnitSelected)] call EFUNC(common,showMessage); +}; + +if !(_gunner isKindOf "CAManBase") exitWith { + [LSTRING(OnlyInfantry)] call EFUNC(common,showMessage); +}; + +if !(alive _gunner) exitWith { + [LSTRING(OnlyAlive)] call EFUNC(common,showMessage); +}; + +if (isPlayer _gunner) exitWith { + ["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage); +}; + +getCompatibleBases = { + params ["_backpack"]; + private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; + private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; + _compatibleBases +}; + +private _backpack = backpack _gunner; + +if (_backpack isEqualTo "") exitWith { + ["Unit must carry a weapon bag"] call EFUNC(common,showMessage); +}; + +private _compatibleBases = [_backpack] call getCompatibleBases; +if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];}; + +private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; +private _assistant = { + if (backpack _x in _compatibleBases) exitWith {_x}; + if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; + + objNull +} forEach _backpackers; + +if (_assistant isEqualTo objNull) exitWith { + ["Unit group must contain two compatible weapon bags"] call EFUNC(common,showMessage); +}; + +// Get target position +[_gunner, { + params ["_successful", "_gunner", "_mousePosASL", "_assistant"],; + [_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; +}, _assistant, "Static Weapon Facing"] call EFUNC(common,selectPosition); diff --git a/addons/modules/functions/fnc_unpackStaticWeapon.sqf b/addons/modules/functions/fnc_unpackStaticWeapon.sqf new file mode 100644 index 000000000..a2106d91f --- /dev/null +++ b/addons/modules/functions/fnc_unpackStaticWeapon.sqf @@ -0,0 +1,50 @@ +//#include "script_component.hpp" +/* + * Author: Ampersand + * Unpacks static weapon from units' backpacks. + * + * Arguments: + * 0: Gunner + * 1: Assistant + * + * Return Value: + * None + * + * Example: + * [gunner, assistant] call zen_modules_fnc_unpackStaticWeapon + * + * Public: No + */ + +params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; +if !(local _gunner) exitWith {_this remoteExecCall ["zen_ai_fnc_unpackStaticWeapon", _gunner]}; + +_gunner setVariable ["zen_ai_fnc_unpackStaticWeaponTargetPos", _targetPos]; + +_gunner addEventHandler ["WeaponAssembled", { + params ["_gunner", "_weapon"]; + + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; + + _weapon setVectorUp surfaceNormal position _weapon; + + _gunner assignAsGunner _weapon; + _gunner moveInGunner _weapon; + + private _targetPos = _gunner getVariable ["zen_ai_fnc_unpackStaticWeaponTargetPos", []]; + if !(_targetPos isEqualTo []) then { + _weapon setDir (_weapon getDir _targetPos); + _gunner doWatch _targetPos; + }; + + _group = group _gunner; + _group addVehicle _weapon; +}]; + +_weaponBase = unitBackpack _assistant; +_gunner action ["PutBag", _assistant]; +_gunner action ["Assemble", _weaponBase]; + +if !(_targetPos isEqualTo []) then { + _assistant doWatch _targetPos; +}; diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index a18621302..74279db30 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -2326,6 +2326,9 @@ LZ에 배치 Postaw LZ + + Unpack Static Weapon + Unable to find suitable position to teleport vehicle to. Kein valide Position zum Teleporieren des Fahrzeugs gefunden. From e5c9938858a47b3fc4453af8c71467b1edafc198 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 11:25:31 -0400 Subject: [PATCH 02/74] Extraneous file deleted --- .../functions/fnc_moduleFireLauncher.sqf | 6514 ----------------- 1 file changed, 6514 deletions(-) delete mode 100644 addons/modules/functions/fnc_moduleFireLauncher.sqf diff --git a/addons/modules/functions/fnc_moduleFireLauncher.sqf b/addons/modules/functions/fnc_moduleFireLauncher.sqf deleted file mode 100644 index 33d398b2d..000000000 --- a/addons/modules/functions/fnc_moduleFireLauncher.sqf +++ /dev/null @@ -1,6514 +0,0 @@ -{#line 1 "x\zen\addons\modules\functions\fnc_moduleUnpackStaticWeapon.sqf" -#line 1 "x\zen\addons\modules\functions\script_component.hpp" -#line 1 "x\zen\addons\modules\script_component.hpp" - - -#line 1 "x\zen\addons\main\script_mod.hpp" - - - - - -#line 1 "x\zen\addons\main\script_version.hpp" - - - - -#line 6 "x\zen\addons\main\script_mod.hpp" - - - - - - - - - - - - - -#line 3 "x\zen\addons\modules\script_component.hpp" - - - - - - - - - - -#line 1 "x\zen\addons\main\script_macros.hpp" - -#line 1 "x\cba\addons\main\script_macros_common.hpp" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 2 "x\zen\addons\main\script_macros.hpp" - -#line 1 "x\cba\addons\xeh\script_xeh.hpp" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 3 "x\zen\addons\main\script_macros.hpp" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 1 "x\zen\addons\main\script_debug.hpp" - - - - - - - - - - - - - - - - - - - - - - - - - -#line 106 "x\zen\addons\main\script_macros.hpp" - -#line 17 "x\zen\addons\modules\script_component.hpp" - - -#line 1 "a3\ui_f\hpp\defineDIKCodes.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 19 "x\zen\addons\modules\script_component.hpp" - -#line 1 "a3\ui_f\hpp\defineCommonGrids.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 20 "x\zen\addons\modules\script_component.hpp" - -#line 1 "x\zen\addons\common\defineResinclDesign.inc" -#line 1 "a3\ui_f\hpp\defineResincl.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 1 "x\zen\addons\common\defineResinclDesign.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 21 "x\zen\addons\modules\script_component.hpp" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#line 1 "x\zen\addons\modules\functions\script_component.hpp" - -#line 1 "x\zen\addons\modules\functions\fnc_moduleUnpackStaticWeapon.sqf" - - - - - - - - - - - - - - - -zen_modules_fnc_moduleUnpackStaticWeapon = { - -params ["_logic"]; - -private _gunner = attachedTo _logic; -deleteVehicle _logic; - -if (isNull _gunner) exitWith { -["STR_zen_modules_NoUnitSelected"] call zen_common_fnc_showMessage; -}; - -if !(_gunner isKindOf "CAManBase") exitWith { -["STR_zen_modules_OnlyInfantry"] call zen_common_fnc_showMessage; -}; - -if !(alive _gunner) exitWith { -["STR_zen_modules_OnlyAlive"] call zen_common_fnc_showMessage; -}; - -if (isPlayer _gunner) exitWith { -["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call zen_common_fnc_showMessage; -}; - -getCompatibleBases = { -params ["_backpack"]; -private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; -private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; -_compatibleBases -}; - -private _backpack = backpack _gunner; -systemChat _backpack; -if (_backpack isEqualTo "") exitWith { - ["Unit must carry a weapon bag"] call zen_common_fnc_showMessage; -}; - -private _compatibleBases = [_backpack] call getCompatibleBases; -if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];}; - -private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; -private _assistant = { -if (backpack _x in _compatibleBases) exitWith {_x}; -if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; - -objNull -} forEach _backpackers; - -if (_assistant isEqualTo objNull) exitWith { -["Unit group must contain two compatible weapon bags"] call zen_common_fnc_showMessage; -}; - - -[_gunner, { -params ["_successful", "_gunner", "_mousePosASL", "_assistant"],; -[_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; -}, _assistant, "Static Weapon Facing"] call zen_common_fnc_selectPosition; -} From 70caa97a54155d2a51c73bd350ec55ac8c4f0308 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 11:48:45 -0400 Subject: [PATCH 03/74] Tabs to spaces --- .../fnc_moduleUnpackStaticWeapon.sqf | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 6dbbae4a3..b873c2680 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -37,10 +37,10 @@ if (isPlayer _gunner) exitWith { }; getCompatibleBases = { - params ["_backpack"]; - private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; - _compatibleBases + params ["_backpack"]; + private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; + private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; + _compatibleBases }; private _backpack = backpack _gunner; @@ -54,10 +54,10 @@ if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases] private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = { - if (backpack _x in _compatibleBases) exitWith {_x}; - if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; - - objNull + if (backpack _x in _compatibleBases) exitWith {_x}; + if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; + + objNull } forEach _backpackers; if (_assistant isEqualTo objNull) exitWith { @@ -66,6 +66,6 @@ if (_assistant isEqualTo objNull) exitWith { // Get target position [_gunner, { - params ["_successful", "_gunner", "_mousePosASL", "_assistant"],; - [_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; + params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; + [_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; }, _assistant, "Static Weapon Facing"] call EFUNC(common,selectPosition); From 569249cac0bdbe4cefa0fa6a4a1e24a70f064863 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 11:49:18 -0400 Subject: [PATCH 04/74] Update fnc_unpackStaticWeapon.sqf --- addons/modules/functions/fnc_unpackStaticWeapon.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/modules/functions/fnc_unpackStaticWeapon.sqf b/addons/modules/functions/fnc_unpackStaticWeapon.sqf index a2106d91f..0ab7c7f47 100644 --- a/addons/modules/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_unpackStaticWeapon.sqf @@ -23,11 +23,11 @@ _gunner setVariable ["zen_ai_fnc_unpackStaticWeaponTargetPos", _targetPos]; _gunner addEventHandler ["WeaponAssembled", { params ["_gunner", "_weapon"]; - + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; - + _weapon setVectorUp surfaceNormal position _weapon; - + _gunner assignAsGunner _weapon; _gunner moveInGunner _weapon; @@ -39,7 +39,7 @@ _gunner addEventHandler ["WeaponAssembled", { _group = group _gunner; _group addVehicle _weapon; -}]; +}]; _weaponBase = unitBackpack _assistant; _gunner action ["PutBag", _assistant]; From 22936d8b626b2c2b268683d17d0e122eb1efd447 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 11:52:16 -0400 Subject: [PATCH 05/74] Add icon --- addons/modules/CfgVehicles.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index d1a650798..bab8b0909 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -439,6 +439,7 @@ class CfgVehicles { category = QGVAR(AI); displayName = CSTRING(moduleUnpackStaticWeapon); function = QFUNC(moduleUnpackStaticWeapon); + icon = "\a3\static_f_gamma\data\ui\gear_staticturret_mg_high_ca.paa"; }; class GVAR(moduleVisibility): GVAR(moduleBase) { curatorCanAttach = 1; From 92b8a15e757515ce9351b3e494cca76e6e4bdf78 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 14 May 2020 12:10:12 -0400 Subject: [PATCH 06/74] Square icon --- addons/modules/CfgVehicles.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index bab8b0909..bfc0724e7 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -439,7 +439,7 @@ class CfgVehicles { category = QGVAR(AI); displayName = CSTRING(moduleUnpackStaticWeapon); function = QFUNC(moduleUnpackStaticWeapon); - icon = "\a3\static_f_gamma\data\ui\gear_staticturret_mg_high_ca.paa"; + icon = "\a3\ui_f\data\map\vehicleicons\iconstaticmg_ca.paa"; }; class GVAR(moduleVisibility): GVAR(moduleBase) { curatorCanAttach = 1; From 922e4b546f3940c1193e68ee8ab26b0fb59d7741 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Sat, 16 May 2020 09:18:48 -0400 Subject: [PATCH 07/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index b873c2680..e44dfa7d6 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Ampersand - * Zeus module function to use backpacks to assemble a static weapon + * Zeus module function to unpack and assemble a static weapon from supported backpacks. * * Arguments: * 0: Logic From ca86fe43b6d5f1e55cc0037170ba8645a2987389 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Sat, 16 May 2020 09:19:33 -0400 Subject: [PATCH 08/74] Update addons/modules/functions/fnc_unpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_unpackStaticWeapon.sqf b/addons/modules/functions/fnc_unpackStaticWeapon.sqf index 0ab7c7f47..96f151ec0 100644 --- a/addons/modules/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_unpackStaticWeapon.sqf @@ -1,7 +1,7 @@ //#include "script_component.hpp" /* * Author: Ampersand - * Unpacks static weapon from units' backpacks. + * Unpacks a static weapon from units' backpacks. * * Arguments: * 0: Gunner From f845df7493955a5169fd1b53ecd781064b454b2c Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Sat, 16 May 2020 23:25:50 -0400 Subject: [PATCH 09/74] Update addons/modules/functions/fnc_unpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_unpackStaticWeapon.sqf b/addons/modules/functions/fnc_unpackStaticWeapon.sqf index 96f151ec0..68e91facb 100644 --- a/addons/modules/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_unpackStaticWeapon.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [gunner, assistant] call zen_modules_fnc_unpackStaticWeapon + * [_gunner, _assistant] call zen_modules_fnc_unpackStaticWeapon * * Public: No */ From 60631fce149bf9a1c1616dd81c3f381b5fbe5528 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sun, 17 May 2020 00:16:07 -0400 Subject: [PATCH 10/74] unpackStaticWeapon function moved to ai component --- addons/ai/XEH_PREP.hpp | 1 + .../functions/fnc_unpackStaticWeapon.sqf | 10 +++++----- addons/modules/XEH_PREP.hpp | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) rename addons/{modules => ai}/functions/fnc_unpackStaticWeapon.sqf (72%) diff --git a/addons/ai/XEH_PREP.hpp b/addons/ai/XEH_PREP.hpp index 5fa7eef30..deeceba0d 100644 --- a/addons/ai/XEH_PREP.hpp +++ b/addons/ai/XEH_PREP.hpp @@ -5,3 +5,4 @@ PREP(handleSkillsChange); PREP(initMan); PREP(searchBuilding); PREP(unGarrison); +PREP(unpackStaticWeapon); diff --git a/addons/modules/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf similarity index 72% rename from addons/modules/functions/fnc_unpackStaticWeapon.sqf rename to addons/ai/functions/fnc_unpackStaticWeapon.sqf index 68e91facb..5414bf7c8 100644 --- a/addons/modules/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -1,4 +1,4 @@ -//#include "script_component.hpp" +#include "script_component.hpp" /* * Author: Ampersand * Unpacks a static weapon from units' backpacks. @@ -11,15 +11,15 @@ * None * * Example: - * [_gunner, _assistant] call zen_modules_fnc_unpackStaticWeapon + * [_gunner, _assistant] call zen_ai_fnc_unpackStaticWeapon * * Public: No */ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if !(local _gunner) exitWith {_this remoteExecCall ["zen_ai_fnc_unpackStaticWeapon", _gunner]}; +if !(local _gunner) exitWith {_this remoteExecCall [FUNC(unpackStaticWeapon), _gunner]}; -_gunner setVariable ["zen_ai_fnc_unpackStaticWeaponTargetPos", _targetPos]; +_gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; _gunner addEventHandler ["WeaponAssembled", { params ["_gunner", "_weapon"]; @@ -31,7 +31,7 @@ _gunner addEventHandler ["WeaponAssembled", { _gunner assignAsGunner _weapon; _gunner moveInGunner _weapon; - private _targetPos = _gunner getVariable ["zen_ai_fnc_unpackStaticWeaponTargetPos", []]; + private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; if !(_targetPos isEqualTo []) then { _weapon setDir (_weapon getDir _targetPos); _gunner doWatch _targetPos; diff --git a/addons/modules/XEH_PREP.hpp b/addons/modules/XEH_PREP.hpp index 4c3be2b20..f4bf41138 100644 --- a/addons/modules/XEH_PREP.hpp +++ b/addons/modules/XEH_PREP.hpp @@ -85,4 +85,3 @@ PREP(moduleUnGarrison); PREP(moduleUnpackStaticWeapon); PREP(moduleVisibility); PREP(moduleWeather); -PREP(unpackStaticWeapon); From 8a4194a89fd71786cba500330bc5d14d465fc1af Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sun, 17 May 2020 00:16:35 -0400 Subject: [PATCH 11/74] Text elements added to stringtable --- addons/modules/stringtable.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 74279db30..c7ace19d0 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -1294,6 +1294,15 @@ Odgarnizonuj grupę 非歩哨グループ + + Unpack Static Weapon + + + Unit must carry a weapon bag + + + Unit group must contain two compatible weapon bags + Group Side Сторона группы @@ -2326,9 +2335,6 @@ LZ에 배치 Postaw LZ - - Unpack Static Weapon - Unable to find suitable position to teleport vehicle to. Kein valide Position zum Teleporieren des Fahrzeugs gefunden. From 028ac3ad5e2a3a0e3e8e48015a92fefa89085ec7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sun, 17 May 2020 00:21:38 -0400 Subject: [PATCH 12/74] Update fnc_moduleUnpackStaticWeapon.sqf Changed `remoteExec` to `CBA_fnc_targetEvent`. Added text elements to stringtable. Converted to script macros. Changed `getCompatibleBases` to private and simplified. --- .../functions/fnc_moduleUnpackStaticWeapon.sqf | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index e44dfa7d6..4721e7c5c 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -36,36 +36,35 @@ if (isPlayer _gunner) exitWith { ["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage); }; -getCompatibleBases = { +private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - private _compatibleBases = if (isText _cfgBase) then {[getText _cfgBase]} else {getArray _cfgBase}; - _compatibleBases + [getArray _cfgBase, [getText _cfgBase]] select (isText _cfgBase) }; private _backpack = backpack _gunner; if (_backpack isEqualTo "") exitWith { - ["Unit must carry a weapon bag"] call EFUNC(common,showMessage); + [LSTRING(ModuleUnpackStaticWeapon_Unit)] call EFUNC(common,showMessage); }; -private _compatibleBases = [_backpack] call getCompatibleBases; +private _compatibleBases = [_backpack] call _fnc_getCompatibleBases; if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];}; private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = { if (backpack _x in _compatibleBases) exitWith {_x}; - if (_backpack in ([backpack _x] call getCompatibleBases)) exitWith {_x}; - + if (_backpack in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; + objNull } forEach _backpackers; if (_assistant isEqualTo objNull) exitWith { - ["Unit group must contain two compatible weapon bags"] call EFUNC(common,showMessage); + [LSTRING(ModuleUnpackStaticWeapon_Group)] call EFUNC(common,showMessage); }; // Get target position [_gunner, { params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; - [_gunner, _assistant, ASLToAGL _mousePosASL] remoteExecCall ["zen_modules_fnc_unpackStaticWeapon", _gunner]; + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; }, _assistant, "Static Weapon Facing"] call EFUNC(common,selectPosition); From cc5dcc79db7a6636620888a629a316c5445cfe84 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sun, 17 May 2020 00:21:44 -0400 Subject: [PATCH 13/74] Changed `remoteExec` to `CBA_fnc_targetEvent`. --- addons/ai/XEH_postInit.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/ai/XEH_postInit.sqf b/addons/ai/XEH_postInit.sqf index 3db3b8514..848fcee35 100644 --- a/addons/ai/XEH_postInit.sqf +++ b/addons/ai/XEH_postInit.sqf @@ -5,3 +5,5 @@ QGVAR(skills) addPublicVariableEventHandler LINKFUNC(handleSkillsChange); ["CAManBase", "InitPost", LINKFUNC(initMan), true, [], false] call CBA_fnc_addClassEventHandler; [QGVAR(unGarrison), LINKFUNC(unGarrison)] call CBA_fnc_addEventHandler; + +[QGVAR(unpackStaticWeapon), LINKFUNC(unpackStaticWeapon)] call CBA_fnc_addEventHandler; From 4809634fdeb2ddae1dba1e5c54b473934358d74e Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 21 May 2020 11:21:29 -0400 Subject: [PATCH 14/74] Localize --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- addons/modules/stringtable.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 4721e7c5c..5cd8a2e49 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -67,4 +67,4 @@ if (_assistant isEqualTo objNull) exitWith { [_gunner, { params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; -}, _assistant, "Static Weapon Facing"] call EFUNC(common,selectPosition); +}, _assistant, LSTRING(ModuleUnpackStaticWeapon_Facing)] call EFUNC(common,selectPosition); diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index c7ace19d0..83b27a96f 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -1303,6 +1303,9 @@ Unit group must contain two compatible weapon bags + + Static Weapon Facing + Group Side Сторона группы From 5a71f89c611a057c480d09393bb165c3296a4b65 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 16 Jun 2020 20:39:27 -0400 Subject: [PATCH 15/74] Missing `private` --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 5414bf7c8..cf8c826eb 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -41,7 +41,7 @@ _gunner addEventHandler ["WeaponAssembled", { _group addVehicle _weapon; }]; -_weaponBase = unitBackpack _assistant; +private _weaponBase = unitBackpack _assistant; _gunner action ["PutBag", _assistant]; _gunner action ["Assemble", _weaponBase]; From b2274af4875d38f0d2bdabf5ddad39958fc1fc76 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 16 Jun 2020 20:41:49 -0400 Subject: [PATCH 16/74] isNull --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 5cd8a2e49..776f29092 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -59,7 +59,7 @@ private _assistant = { objNull } forEach _backpackers; -if (_assistant isEqualTo objNull) exitWith { +if (isNull _assistant) exitWith { [LSTRING(ModuleUnpackStaticWeapon_Group)] call EFUNC(common,showMessage); }; From 026669a0fdae5d82945e186c2b904057d13cc1ce Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 16 Jun 2020 20:44:04 -0400 Subject: [PATCH 17/74] replace select with if --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 776f29092..fa1b65c59 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,7 +39,8 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - [getArray _cfgBase, [getText _cfgBase]] select (isText _cfgBase) + if (isText _cfgBase) exitWith { getText _cfgBase }; + getArray _cfgBase }; private _backpack = backpack _gunner; From 16d46e9b3f1093cb371dbd9fa10bdfb877bdf0d7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 16 Jun 2020 20:46:24 -0400 Subject: [PATCH 18/74] Don't run if position selection cancelled --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index fa1b65c59..533147446 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -67,5 +67,7 @@ if (isNull _assistant) exitWith { // Get target position [_gunner, { params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + if _successful then { + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + }; }, _assistant, LSTRING(ModuleUnpackStaticWeapon_Facing)] call EFUNC(common,selectPosition); From 9a7569df6301d9fb7afb29b6eebca50d9d9a52af Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 16 Jun 2020 20:51:59 -0400 Subject: [PATCH 19/74] Replace remoteExec with CBA_fnc_targetEvent --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index cf8c826eb..f977a3a72 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -17,7 +17,10 @@ */ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if !(local _gunner) exitWith {_this remoteExecCall [FUNC(unpackStaticWeapon), _gunner]}; +//if !(local _gunner) exitWith {_this remoteExecCall [FUNC(unpackStaticWeapon), _gunner]}; +if !(local _gunner) exitWith { + [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; +}; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; From 777038174f6c187719c78d62273b8cb705085a95 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 23 Jun 2020 14:18:39 -0400 Subject: [PATCH 20/74] orderGetIn instead of moveInGunner --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index f977a3a72..bb029858c 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -32,7 +32,8 @@ _gunner addEventHandler ["WeaponAssembled", { _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; - _gunner moveInGunner _weapon; + //_gunner moveInGunner _weapon; + [_gunner] orderGetIn true; private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; if !(_targetPos isEqualTo []) then { From 9c15718e5acccb50a3f2fad94cb4fd1eef4c08d2 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 23 Jun 2020 14:18:56 -0400 Subject: [PATCH 21/74] Check gunner/assistant distance, pfh --- .../fnc_moduleUnpackStaticWeapon.sqf | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 533147446..c19b8e60c 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -68,6 +68,38 @@ if (isNull _assistant) exitWith { [_gunner, { params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; if _successful then { - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + if (_gunner distance _assistant < 3) then { + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + } else { + private _startTime = CBA_MissionTime; + _assistant disableAI "FSM"; + _gunner disableAI "PATH"; + (group _assistant) enableAttack false; + _assistant doMove getPos _gunner; + [{ + params ["_args", "_pfID"]; + _args params ["_gunner", "_assistant", "_mousePosASL", "_startTime"]; + + if (CBA_MissionTime > (_startTime + 60) || {!alive _gunner || {!alive _assistant}}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _assistant enableAI "FSM"; + _gunner enableAI "PATH"; + (group _assistant) enableAttack true; + }; + + if (_gunner distance _assistant < 3) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _assistant enableAI "FSM"; + _gunner enableAI "PATH"; + (group _assistant) enableAttack true; + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + }; + + if (unitReady _assistant) then { + _assistant doMove getPos _gunner; + }; + + }, 0.1, [_gunner, _assistant, _mousePosASL, _startTime]] call CBA_fnc_addPerFrameHandler; + }; }; }, _assistant, LSTRING(ModuleUnpackStaticWeapon_Facing)] call EFUNC(common,selectPosition); From 53be889766bc23925550c922ee25a1435d19c69f Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Mon, 29 Jun 2020 10:14:30 -0400 Subject: [PATCH 22/74] Add toLower in backpack check --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index c19b8e60c..e5a0f8d22 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,8 +39,8 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith { getText _cfgBase }; - getArray _cfgBase + if (isText _cfgBase) exitWith { toLower (getText _cfgBase) }; + (getArray _cfgBase) apply {toLower _x} }; private _backpack = backpack _gunner; @@ -54,8 +54,8 @@ if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases] private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = { - if (backpack _x in _compatibleBases) exitWith {_x}; - if (_backpack in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; + if ((toLower backpack _x) in _compatibleBases) exitWith {_x}; + if ((toLower _backpack) in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; objNull } forEach _backpackers; From cac53b128e3c67d00fa183e61a1f3f3c87e4776d Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Mon, 29 Jun 2020 10:59:56 -0400 Subject: [PATCH 23/74] if condition, moved pfh to ai fnc --- .../ai/functions/fnc_unpackStaticWeapon.sqf | 82 ++++++++++++++----- .../fnc_moduleUnpackStaticWeapon.sqf | 36 +------- 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index bb029858c..8080b77ce 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -23,32 +23,72 @@ if !(local _gunner) exitWith { }; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; +private _startTime = CBA_MissionTime; +_gunner disableAI "PATH"; +[_assistant] joinSilent grpNull; +private _g = (group _assistant); +_g setBehaviourStrong "CARELESS"; +_g deleteGroupWhenEmpty true; +_g enableAttack false; +_assistant doMove getPos _gunner; +_assistant disableAI "FSM"; +[{ + params ["_args", "_pfID"]; + _args params ["_gunner", "_assistant", "_mousePosASL", "_startTime"]; -_gunner addEventHandler ["WeaponAssembled", { - params ["_gunner", "_weapon"]; + if (CBA_MissionTime > (_startTime + 60) || {!alive _gunner || {!alive _assistant}}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _gunner enableAI "PATH"; + private _g = group _gunner; + [_assistant] joinSilent _g; + _g setBehaviour (behaviour _gunner); + _assistant enableAI "FSM"; + //(group _assistant) enableAttack true; + }; - _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; + if (_gunner distance _assistant < 3) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _gunner enableAI "PATH"; + private _g = group _gunner; + [_assistant] joinSilent _g; + _g setBehaviour (behaviour _gunner); // + _assistant enableAI "FSM"; + //(group _assistant) enableAttack true; + _canUnpack = true; + //[QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; - _weapon setVectorUp surfaceNormal position _weapon; + _gunner addEventHandler ["WeaponAssembled", { + params ["_gunner", "_weapon"]; - _gunner assignAsGunner _weapon; - //_gunner moveInGunner _weapon; - [_gunner] orderGetIn true; + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; - private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; - if !(_targetPos isEqualTo []) then { - _weapon setDir (_weapon getDir _targetPos); - _gunner doWatch _targetPos; - }; + private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; + if !(_targetPos isEqualTo []) then { + _weapon setDir (_weapon getDir _targetPos); + _gunner doWatch _targetPos; + }; - _group = group _gunner; - _group addVehicle _weapon; -}]; + _weapon setVectorUp surfaceNormal position _weapon; -private _weaponBase = unitBackpack _assistant; -_gunner action ["PutBag", _assistant]; -_gunner action ["Assemble", _weaponBase]; + _gunner assignAsGunner _weapon; + //_gunner moveInGunner _weapon; + [_gunner] orderGetIn true; -if !(_targetPos isEqualTo []) then { - _assistant doWatch _targetPos; -}; + _group = group _gunner; + _group addVehicle _weapon; + }]; + + private _weaponBase = unitBackpack _assistant; + _gunner action ["PutBag", _assistant]; + _gunner action ["Assemble", _weaponBase]; + + if !(_targetPos isEqualTo []) then { + _assistant doWatch _targetPos; + }; + }; + + if (unitReady _assistant) then { + _assistant doMove getPos _gunner; + }; + +}, 0.1, [_gunner, _assistant, _mousePosASL, _startTime]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index e5a0f8d22..bff1c9482 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -67,39 +67,7 @@ if (isNull _assistant) exitWith { // Get target position [_gunner, { params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; - if _successful then { - if (_gunner distance _assistant < 3) then { - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; - } else { - private _startTime = CBA_MissionTime; - _assistant disableAI "FSM"; - _gunner disableAI "PATH"; - (group _assistant) enableAttack false; - _assistant doMove getPos _gunner; - [{ - params ["_args", "_pfID"]; - _args params ["_gunner", "_assistant", "_mousePosASL", "_startTime"]; - - if (CBA_MissionTime > (_startTime + 60) || {!alive _gunner || {!alive _assistant}}) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _assistant enableAI "FSM"; - _gunner enableAI "PATH"; - (group _assistant) enableAttack true; - }; - - if (_gunner distance _assistant < 3) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _assistant enableAI "FSM"; - _gunner enableAI "PATH"; - (group _assistant) enableAttack true; - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; - }; - - if (unitReady _assistant) then { - _assistant doMove getPos _gunner; - }; - - }, 0.1, [_gunner, _assistant, _mousePosASL, _startTime]] call CBA_fnc_addPerFrameHandler; - }; + if (_successful) then { + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; }; }, _assistant, LSTRING(ModuleUnpackStaticWeapon_Facing)] call EFUNC(common,selectPosition); From 9f5f3464cb3d8a137be013da554f6c4cedf6cf39 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Mon, 29 Jun 2020 11:43:42 -0400 Subject: [PATCH 24/74] Add back pfh skip --- .../ai/functions/fnc_unpackStaticWeapon.sqf | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 8080b77ce..2bbaf76b0 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -23,6 +23,46 @@ if !(local _gunner) exitWith { }; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; + +if (_gunner distance _assistant < 3) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _gunner enableAI "PATH"; + private _g = group _gunner; + [_assistant] joinSilent _g; + _g setBehaviour (behaviour _gunner); // + _assistant enableAI "FSM"; + //(group _assistant) enableAttack true; + _canUnpack = true; + //[QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + + _gunner addEventHandler ["WeaponAssembled", { + params ["_gunner", "_weapon"]; + + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; + + private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; + if !(_targetPos isEqualTo []) then { + _weapon setDir (_weapon getDir _targetPos); + _gunner doWatch _targetPos; + }; + + _weapon setVectorUp surfaceNormal position _weapon; + + _gunner assignAsGunner _weapon; + //_gunner moveInGunner _weapon; + [_gunner] orderGetIn true; + + _group = group _gunner; + _group addVehicle _weapon; + }]; + + private _weaponBase = unitBackpack _assistant; + _gunner action ["PutBag", _assistant]; + _gunner action ["Assemble", _weaponBase]; + + _assistant doWatch _targetPos; +}; + private _startTime = CBA_MissionTime; _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; @@ -82,12 +122,10 @@ _assistant disableAI "FSM"; _gunner action ["PutBag", _assistant]; _gunner action ["Assemble", _weaponBase]; - if !(_targetPos isEqualTo []) then { - _assistant doWatch _targetPos; - }; + _assistant doWatch _targetPos; }; - if (unitReady _assistant) then { + if (unitReady _assistant || {CBA_MissionTime > (_startTime + 5)}) then { _assistant doMove getPos _gunner; }; From 222c09d2f8b0ebd6438c7b8d59293fc645145bdf Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 7 Jul 2020 01:55:48 -0400 Subject: [PATCH 25/74] Update addons/ai/functions/fnc_unpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 2bbaf76b0..ee13bc58d 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -91,7 +91,7 @@ _assistant disableAI "FSM"; _gunner enableAI "PATH"; private _g = group _gunner; [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); // + _g setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; //(group _assistant) enableAttack true; _canUnpack = true; From dd7d74c5399661706df1e86aa0cc887f6445ae3a Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 7 Jul 2020 11:57:52 -0400 Subject: [PATCH 26/74] Removed unused code --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index ee13bc58d..e6e0cc4c7 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -17,23 +17,22 @@ */ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -//if !(local _gunner) exitWith {_this remoteExecCall [FUNC(unpackStaticWeapon), _gunner]}; + if !(local _gunner) exitWith { [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; }; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; +// close enough, set up weapon if (_gunner distance _assistant < 3) exitWith { [_pfID] call CBA_fnc_removePerFrameHandler; _gunner enableAI "PATH"; private _g = group _gunner; [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); // + _g setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; - //(group _assistant) enableAttack true; _canUnpack = true; - //[QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; _gunner addEventHandler ["WeaponAssembled", { params ["_gunner", "_weapon"]; @@ -49,7 +48,6 @@ if (_gunner distance _assistant < 3) exitWith { _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; - //_gunner moveInGunner _weapon; [_gunner] orderGetIn true; _group = group _gunner; @@ -63,6 +61,7 @@ if (_gunner distance _assistant < 3) exitWith { _assistant doWatch _targetPos; }; +// too far, order assistant to move to gunner and start pfh private _startTime = CBA_MissionTime; _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; @@ -83,7 +82,6 @@ _assistant disableAI "FSM"; [_assistant] joinSilent _g; _g setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; - //(group _assistant) enableAttack true; }; if (_gunner distance _assistant < 3) exitWith { @@ -93,9 +91,7 @@ _assistant disableAI "FSM"; [_assistant] joinSilent _g; _g setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; - //(group _assistant) enableAttack true; _canUnpack = true; - //[QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; _gunner addEventHandler ["WeaponAssembled", { params ["_gunner", "_weapon"]; @@ -111,7 +107,6 @@ _assistant disableAI "FSM"; _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; - //_gunner moveInGunner _weapon; [_gunner] orderGetIn true; _group = group _gunner; From 3938ea9e2f538329b01a3445237ead828af4642d Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 7 Jul 2020 12:53:21 -0400 Subject: [PATCH 27/74] Separated PFH from actual unpack to reduce repeated code --- addons/ai/XEH_PREP.hpp | 1 + addons/ai/XEH_postInit.sqf | 2 +- .../ai/functions/fnc_unpackStaticWeapon.sqf | 120 ++++-------------- .../functions/fnc_unpackStaticWeaponPFH.sqf | 67 ++++++++++ 4 files changed, 91 insertions(+), 99 deletions(-) create mode 100644 addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf diff --git a/addons/ai/XEH_PREP.hpp b/addons/ai/XEH_PREP.hpp index deeceba0d..484f2b82e 100644 --- a/addons/ai/XEH_PREP.hpp +++ b/addons/ai/XEH_PREP.hpp @@ -6,3 +6,4 @@ PREP(initMan); PREP(searchBuilding); PREP(unGarrison); PREP(unpackStaticWeapon); +PREP(unpackStaticWeaponPFH); diff --git a/addons/ai/XEH_postInit.sqf b/addons/ai/XEH_postInit.sqf index 848fcee35..260e6f65b 100644 --- a/addons/ai/XEH_postInit.sqf +++ b/addons/ai/XEH_postInit.sqf @@ -6,4 +6,4 @@ QGVAR(skills) addPublicVariableEventHandler LINKFUNC(handleSkillsChange); [QGVAR(unGarrison), LINKFUNC(unGarrison)] call CBA_fnc_addEventHandler; -[QGVAR(unpackStaticWeapon), LINKFUNC(unpackStaticWeapon)] call CBA_fnc_addEventHandler; +[QGVAR(unpackStaticWeapon), LINKFUNC(unpackStaticWeaponPFH)] call CBA_fnc_addEventHandler; diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index e6e0cc4c7..f2288e28f 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -6,11 +6,13 @@ * Arguments: * 0: Gunner * 1: Assistant + * 2: Target Position * * Return Value: * None * * Example: + * [_gunner, _assistant, _targetPos] call zen_ai_fnc_unpackStaticWeapon * [_gunner, _assistant] call zen_ai_fnc_unpackStaticWeapon * * Public: No @@ -18,110 +20,32 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if !(local _gunner) exitWith { - [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; -}; - -_gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; - -// close enough, set up weapon -if (_gunner distance _assistant < 3) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _gunner enableAI "PATH"; - private _g = group _gunner; - [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); - _assistant enableAI "FSM"; - _canUnpack = true; - - _gunner addEventHandler ["WeaponAssembled", { - params ["_gunner", "_weapon"]; - - _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; - - private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; - if !(_targetPos isEqualTo []) then { - _weapon setDir (_weapon getDir _targetPos); - _gunner doWatch _targetPos; - }; - - _weapon setVectorUp surfaceNormal position _weapon; - - _gunner assignAsGunner _weapon; - [_gunner] orderGetIn true; - - _group = group _gunner; - _group addVehicle _weapon; - }]; - - private _weaponBase = unitBackpack _assistant; - _gunner action ["PutBag", _assistant]; - _gunner action ["Assemble", _weaponBase]; - +if !(_targetPos isEqualTo []) then { _assistant doWatch _targetPos; + _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; }; -// too far, order assistant to move to gunner and start pfh -private _startTime = CBA_MissionTime; -_gunner disableAI "PATH"; -[_assistant] joinSilent grpNull; -private _g = (group _assistant); -_g setBehaviourStrong "CARELESS"; -_g deleteGroupWhenEmpty true; -_g enableAttack false; -_assistant doMove getPos _gunner; -_assistant disableAI "FSM"; -[{ - params ["_args", "_pfID"]; - _args params ["_gunner", "_assistant", "_mousePosASL", "_startTime"]; +_gunner addEventHandler ["WeaponAssembled", { + params ["_gunner", "_weapon"]; - if (CBA_MissionTime > (_startTime + 60) || {!alive _gunner || {!alive _assistant}}) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _gunner enableAI "PATH"; - private _g = group _gunner; - [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); - _assistant enableAI "FSM"; - }; - - if (_gunner distance _assistant < 3) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; - _gunner enableAI "PATH"; - private _g = group _gunner; - [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); - _assistant enableAI "FSM"; - _canUnpack = true; - - _gunner addEventHandler ["WeaponAssembled", { - params ["_gunner", "_weapon"]; - - _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; - - private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; - if !(_targetPos isEqualTo []) then { - _weapon setDir (_weapon getDir _targetPos); - _gunner doWatch _targetPos; - }; + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; - _weapon setVectorUp surfaceNormal position _weapon; - - _gunner assignAsGunner _weapon; - [_gunner] orderGetIn true; + private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; + if !(_targetPos isEqualTo []) then { + _weapon setDir (_weapon getDir _targetPos); + _gunner doWatch _targetPos; + }; - _group = group _gunner; - _group addVehicle _weapon; - }]; + // added due to occassional tripod leg clipping through ground + _weapon setPos (position _weapon vectorAdd [0,0,0.05]); + _weapon setVectorUp surfaceNormal position _weapon; - private _weaponBase = unitBackpack _assistant; - _gunner action ["PutBag", _assistant]; - _gunner action ["Assemble", _weaponBase]; + _gunner assignAsGunner _weapon; + [_gunner] orderGetIn true; - _assistant doWatch _targetPos; - }; - - if (unitReady _assistant || {CBA_MissionTime > (_startTime + 5)}) then { - _assistant doMove getPos _gunner; - }; + _group = group _gunner; + _group addVehicle _weapon; +}]; -}, 0.1, [_gunner, _assistant, _mousePosASL, _startTime]] call CBA_fnc_addPerFrameHandler; +_gunner action ["PutBag", _assistant]; +_gunner action ["Assemble", unitBackpack _assistant]; diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf new file mode 100644 index 000000000..0016ae08f --- /dev/null +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -0,0 +1,67 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Move units together if needed and unpacks a static weapon from units' backpacks. + * + * Arguments: + * 0: Gunner + * 1: Assistant + * 2: Target Position + * + * Return Value: + * None + * + * Example: + * [_gunner, _assistant] call zen_ai_fnc_unpackStaticWeaponPFH + * + * Public: No + */ + +params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; + +if !(local _gunner) exitWith { + [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; +}; + +_gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; + +// close enough, set up weapon +if (_gunner distance _assistant < 3) exitWith { + [_gunner, _assistant] call FUNC(unpackStaticWeapon); +}; + +// too far, order assistant to move to gunner and start pfh +_gunner disableAI "PATH"; +[_assistant] joinSilent grpNull; +private _g = (group _assistant); +_g setBehaviourStrong "CARELESS"; +_g deleteGroupWhenEmpty true; +_g enableAttack false; +_assistant doMove getPos _gunner; +_assistant disableAI "FSM"; + +[{ + params ["_args", "_pfID"]; + _args params ["_gunner", "_assistant", "_startTime"]; + + private _closeEnough = _gunner distance _assistant < 3; + private _elapsedtime = CBA_MissionTime - _startTime; + + if (_closeEnough || {_elapsedtime > 60 || {!alive _gunner || {!alive _assistant}}}) exitWith { + [_pfID] call CBA_fnc_removePerFrameHandler; + _gunner enableAI "PATH"; + private _g = group _gunner; + [_assistant] joinSilent _g; + _g setBehaviour (behaviour _gunner); // reset assistant behaviour + _assistant enableAI "FSM"; + + if (_closeEnough) then { + [_gunner, _assistant] call FUNC(unpackStaticWeapon); + }; + }; + + if (unitReady _assistant || {_elapsedtime % 5 < 0.1}) then { + _assistant doMove getPos _gunner; + }; + +}, 0.1, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From c9935b981203fe9e0b06b92a363d59ae12e58e5e Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 23 Jul 2020 16:25:46 -0400 Subject: [PATCH 28/74] Update addons/ai/functions/fnc_unpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index f2288e28f..918a24388 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -36,7 +36,7 @@ _gunner addEventHandler ["WeaponAssembled", { _gunner doWatch _targetPos; }; - // added due to occassional tripod leg clipping through ground + // Added due to occassional tripod leg clipping through ground _weapon setPos (position _weapon vectorAdd [0,0,0.05]); _weapon setVectorUp surfaceNormal position _weapon; From 5c7112828ea0e4ab2977904fcc64b55053334b27 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 23 Jul 2020 16:25:58 -0400 Subject: [PATCH 29/74] Update addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 0016ae08f..ca3b8930e 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -25,7 +25,7 @@ if !(local _gunner) exitWith { _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; -// close enough, set up weapon +// Close enough, set up weapon if (_gunner distance _assistant < 3) exitWith { [_gunner, _assistant] call FUNC(unpackStaticWeapon); }; From cbc3e5feadaed6c705c4ce393f1ea69a24b366d7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Thu, 23 Jul 2020 16:27:59 -0400 Subject: [PATCH 30/74] Comment case --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index ca3b8930e..c29a5a5ac 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -30,7 +30,7 @@ if (_gunner distance _assistant < 3) exitWith { [_gunner, _assistant] call FUNC(unpackStaticWeapon); }; -// too far, order assistant to move to gunner and start pfh +// Too far, order assistant to move to gunner and start pfh _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; private _g = (group _assistant); @@ -50,9 +50,10 @@ _assistant disableAI "FSM"; if (_closeEnough || {_elapsedtime > 60 || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfID] call CBA_fnc_removePerFrameHandler; _gunner enableAI "PATH"; + // Reset assistant behaviour private _g = group _gunner; [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); // reset assistant behaviour + _g setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; if (_closeEnough) then { From 1b02ccf319c71eda5b13ef328e9769ba1d1e17f6 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 28 Jul 2020 19:16:41 -0400 Subject: [PATCH 31/74] "Static Weapon Facing" to "Weapon Direction" --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- addons/modules/stringtable.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index bff1c9482..7b2f2eb7e 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -70,4 +70,4 @@ if (isNull _assistant) exitWith { if (_successful) then { [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; }; -}, _assistant, LSTRING(ModuleUnpackStaticWeapon_Facing)] call EFUNC(common,selectPosition); +}, _assistant, LSTRING(ModuleUnpackStaticWeapon_Direction)] call EFUNC(common,selectPosition); diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 83b27a96f..58f516b33 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -1303,8 +1303,8 @@ Unit group must contain two compatible weapon bags - - Static Weapon Facing + + Weapon Direction Group Side From a6835aa26f648e932d7699c559d710277942f2ed Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 28 Jul 2020 19:19:03 -0400 Subject: [PATCH 32/74] Suggested changes Use the full word _group as the variable name. Also, no parentheses around unary commands. Use _pfhID. getPosATL for doMove _nextMove for CBA_missionTime comparison --- .../ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- .../functions/fnc_unpackStaticWeaponPFH.sqf | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 918a24388..3b4af3c31 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -41,7 +41,7 @@ _gunner addEventHandler ["WeaponAssembled", { _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; - [_gunner] orderGetIn true; + _gunner moveInGunner _weapon; _group = group _gunner; _group addVehicle _weapon; diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index c29a5a5ac..9bf26323f 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -33,27 +33,27 @@ if (_gunner distance _assistant < 3) exitWith { // Too far, order assistant to move to gunner and start pfh _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; -private _g = (group _assistant); +private _g = group _assistant; _g setBehaviourStrong "CARELESS"; _g deleteGroupWhenEmpty true; _g enableAttack false; -_assistant doMove getPos _gunner; +_assistant doMove getPosATL _gunner; _assistant disableAI "FSM"; +_assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; [{ - params ["_args", "_pfID"]; + params ["_args", "_pfhID"]; _args params ["_gunner", "_assistant", "_startTime"]; private _closeEnough = _gunner distance _assistant < 3; - private _elapsedtime = CBA_MissionTime - _startTime; - if (_closeEnough || {_elapsedtime > 60 || {!alive _gunner || {!alive _assistant}}}) exitWith { - [_pfID] call CBA_fnc_removePerFrameHandler; + if (_closeEnough || {CBA_MissionTime - _startTime > 60 || {!alive _gunner || {!alive _assistant}}}) exitWith { + [_pfhID] call CBA_fnc_removePerFrameHandler; _gunner enableAI "PATH"; // Reset assistant behaviour - private _g = group _gunner; - [_assistant] joinSilent _g; - _g setBehaviour (behaviour _gunner); + private _group = group _gunner; + [_assistant] joinSilent _group; + _group setBehaviour (behaviour _gunner); _assistant enableAI "FSM"; if (_closeEnough) then { @@ -61,8 +61,10 @@ _assistant disableAI "FSM"; }; }; - if (unitReady _assistant || {_elapsedtime % 5 < 0.1}) then { - _assistant doMove getPos _gunner; + private _nextMoveTime = _assistant getVariable [QGVAR(nextMoveTime), CBA_MissionTime]; + if (unitReady _assistant || {CBA_MissionTime > _nextMoveTime}) then { + _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; + _assistant doMove getPosATL _gunner; }; }, 0.1, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From b94d4a7d91096e8b5638e15c0124455ddf2bfacb Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:26:00 -0400 Subject: [PATCH 33/74] Only one example. --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 3b4af3c31..20dd8ef93 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -12,7 +12,6 @@ * None * * Example: - * [_gunner, _assistant, _targetPos] call zen_ai_fnc_unpackStaticWeapon * [_gunner, _assistant] call zen_ai_fnc_unpackStaticWeapon * * Public: No From 0ede92118ba04f8e0f9d4e345ac62d6dd562a122 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:26:53 -0400 Subject: [PATCH 34/74] Use full word for variable name: _group. --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 9bf26323f..b439113ea 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -33,10 +33,10 @@ if (_gunner distance _assistant < 3) exitWith { // Too far, order assistant to move to gunner and start pfh _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; -private _g = group _assistant; -_g setBehaviourStrong "CARELESS"; -_g deleteGroupWhenEmpty true; -_g enableAttack false; +private _group = group _assistant; +_group setBehaviourStrong "CARELESS"; +_group deleteGroupWhenEmpty true; +_group enableAttack false; _assistant doMove getPosATL _gunner; _assistant disableAI "FSM"; _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; From f6840c4c6b1dd3929b98db8f8d699d7eda20d7fc Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:35:09 -0400 Subject: [PATCH 35/74] Positions to work off ASL --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 20dd8ef93..463159057 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -36,7 +36,7 @@ _gunner addEventHandler ["WeaponAssembled", { }; // Added due to occassional tripod leg clipping through ground - _weapon setPos (position _weapon vectorAdd [0,0,0.05]); + _weapon setPosASL (getPosASL _weapon vectorAdd [0,0,0.05]); _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index b439113ea..218241056 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -64,7 +64,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; private _nextMoveTime = _assistant getVariable [QGVAR(nextMoveTime), CBA_MissionTime]; if (unitReady _assistant || {CBA_MissionTime > _nextMoveTime}) then { _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; - _assistant doMove getPosATL _gunner; + _assistant doMove ASLtoAGL getPosASL _gunner; }; }, 0.1, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From 664684333e5bcc63f0f79bb3e2da2af3f02b4130 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:35:21 -0400 Subject: [PATCH 36/74] Remove magic numbers --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 218241056..c2382265d 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -1,4 +1,7 @@ #include "script_component.hpp" +#define DISTANCE_CLOSE 3 +#define MOVE_DELAY 0.1 +#define MOVE_TIMEOUT 60 /* * Author: Ampersand * Move units together if needed and unpacks a static weapon from units' backpacks. @@ -45,9 +48,9 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; params ["_args", "_pfhID"]; _args params ["_gunner", "_assistant", "_startTime"]; - private _closeEnough = _gunner distance _assistant < 3; + private _closeEnough = _gunner distance _assistant < DISTANCE_CLOSE; - if (_closeEnough || {CBA_MissionTime - _startTime > 60 || {!alive _gunner || {!alive _assistant}}}) exitWith { + if (_closeEnough || {CBA_MissionTime - _startTime > MOVE_TIMEOUT || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; _gunner enableAI "PATH"; // Reset assistant behaviour @@ -67,4 +70,4 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant doMove ASLtoAGL getPosASL _gunner; }; -}, 0.1, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; +}, MOVE_DELAY, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From a00352d6f7b7cf64d697e004ffe0303618538263 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:37:49 -0400 Subject: [PATCH 37/74] move ! into paren --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 463159057..2fd360162 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -30,7 +30,7 @@ _gunner addEventHandler ["WeaponAssembled", { _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; - if !(_targetPos isEqualTo []) then { + if (!_targetPos isEqualTo []) then { _weapon setDir (_weapon getDir _targetPos); _gunner doWatch _targetPos; }; From 3d3eafb7421a4b14361a4847ebf990cc4e10b67e Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:38:05 -0400 Subject: [PATCH 38/74] remove paren around unary --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 7b2f2eb7e..f5e7279cf 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,7 +39,7 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith { toLower (getText _cfgBase) }; + if (isText _cfgBase) exitWith { toLower getText _cfgBase }; (getArray _cfgBase) apply {toLower _x} }; From e2265cddb3fcd09ece5d30c6162e386ebf2d7f59 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:38:26 -0400 Subject: [PATCH 39/74] remove spaces around braces --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index f5e7279cf..d7217e2dd 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,7 +39,7 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith { toLower getText _cfgBase }; + if (isText _cfgBase) exitWith {toLower getText _cfgBase}; (getArray _cfgBase) apply {toLower _x} }; From dcaa2d9528f27a7ff8ef31fa676198732d2b49f0 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:40:02 -0400 Subject: [PATCH 40/74] move config type check into _fnc_getCompatibleBases --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index d7217e2dd..30049c981 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,7 +39,7 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith {toLower getText _cfgBase}; + if (isText _cfgBase) exitWith {[toLower getText _cfgBase]}; (getArray _cfgBase) apply {toLower _x} }; @@ -50,7 +50,6 @@ if (_backpack isEqualTo "") exitWith { }; private _compatibleBases = [_backpack] call _fnc_getCompatibleBases; -if (_compatibleBases isEqualType "") then {_compatibleBases = [_compatibleBases];}; private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = { From 365244bd9ce063c093f0466c31cfabb026d8921c Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:40:59 -0400 Subject: [PATCH 41/74] _mousePosASL to _position --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 30049c981..e21d6f864 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -65,8 +65,8 @@ if (isNull _assistant) exitWith { // Get target position [_gunner, { - params ["_successful", "_gunner", "_mousePosASL", "_assistant"]; + params ["_successful", "_gunner", "_position", "_assistant"]; if (_successful) then { - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _mousePosASL], _gunner] call CBA_fnc_targetEvent; + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _position], _gunner] call CBA_fnc_targetEvent; }; }, _assistant, LSTRING(ModuleUnpackStaticWeapon_Direction)] call EFUNC(common,selectPosition); From b0db71f9374c5d82b52329f41e7b0af6dabb9527 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:44:19 -0400 Subject: [PATCH 42/74] _endTime for cleaner comparison --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index c2382265d..6d09e5f97 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -49,8 +49,9 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _args params ["_gunner", "_assistant", "_startTime"]; private _closeEnough = _gunner distance _assistant < DISTANCE_CLOSE; + private _endTime = _startTime + MOVE_TIMEOUT; - if (_closeEnough || {CBA_MissionTime - _startTime > MOVE_TIMEOUT || {!alive _gunner || {!alive _assistant}}}) exitWith { + if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; _gunner enableAI "PATH"; // Reset assistant behaviour From 64516066becf975c8ba962e6444237b01d7226f8 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:44:37 -0400 Subject: [PATCH 43/74] Move the ! into the parentheses. --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 6d09e5f97..6a3b40035 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -22,7 +22,7 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if !(local _gunner) exitWith { +if (!local _gunner) exitWith { [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; }; From 142a0b5ffedd2c9f077284643999ea273b7c8569 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:45:01 -0400 Subject: [PATCH 44/74] Spaces after commas in arrays. --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 2fd360162..8651c42d4 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -36,7 +36,7 @@ _gunner addEventHandler ["WeaponAssembled", { }; // Added due to occassional tripod leg clipping through ground - _weapon setPosASL (getPosASL _weapon vectorAdd [0,0,0.05]); + _weapon setPosASL (getPosASL _weapon vectorAdd [0, 0, 0.05]); _weapon setVectorUp surfaceNormal position _weapon; _gunner assignAsGunner _weapon; From 6718095a6abc1eb6c34208ca801d56a387b14a5f Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:46:29 -0400 Subject: [PATCH 45/74] no need to declare _group --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 8651c42d4..d2039838f 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -42,8 +42,7 @@ _gunner addEventHandler ["WeaponAssembled", { _gunner assignAsGunner _weapon; _gunner moveInGunner _weapon; - _group = group _gunner; - _group addVehicle _weapon; + group _gunner addVehicle _weapon; }]; _gunner action ["PutBag", _assistant]; From ca6ebc2b7d1c168ccb8a43f6b5b01ee987e607b9 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:47:05 -0400 Subject: [PATCH 46/74] removed blank line --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 6a3b40035..9b6818a58 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -70,5 +70,4 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant doMove ASLtoAGL getPosASL _gunner; }; - }, MOVE_DELAY, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From 196e1440cd7e90f7d2b60fb0e449676c7132e3ef Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 10:47:30 -0400 Subject: [PATCH 47/74] > to >= --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 9b6818a58..671c46ca8 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -66,7 +66,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; }; private _nextMoveTime = _assistant getVariable [QGVAR(nextMoveTime), CBA_MissionTime]; - if (unitReady _assistant || {CBA_MissionTime > _nextMoveTime}) then { + if (unitReady _assistant || {CBA_MissionTime >= _nextMoveTime}) then { _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant doMove ASLtoAGL getPosASL _gunner; }; From 474f4ec2d33dc7a960ae291499e5f8cff0d45a31 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:03:30 -0400 Subject: [PATCH 48/74] fix Move the ! into the parentheses. --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index d2039838f..050a1c132 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -19,7 +19,7 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if !(_targetPos isEqualTo []) then { +if (!(_targetPos isEqualTo [])) then { _assistant doWatch _targetPos; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; }; @@ -30,7 +30,7 @@ _gunner addEventHandler ["WeaponAssembled", { _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; - if (!_targetPos isEqualTo []) then { + if (!(_targetPos isEqualTo [])) then { _weapon setDir (_weapon getDir _targetPos); _gunner doWatch _targetPos; }; From 7204ff0dccbd44787395a1096649c82c88c41ec7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:03:44 -0400 Subject: [PATCH 49/74] Change lower case to config case --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index e21d6f864..4487816b2 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,8 +39,8 @@ if (isPlayer _gunner) exitWith { private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith {[toLower getText _cfgBase]}; - (getArray _cfgBase) apply {toLower _x} + if (isText _cfgBase) exitWith {[getText _cfgBase]}; + (getArray _cfgBase) //apply {toLower _x} }; private _backpack = backpack _gunner; @@ -53,8 +53,8 @@ private _compatibleBases = [_backpack] call _fnc_getCompatibleBases; private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = { - if ((toLower backpack _x) in _compatibleBases) exitWith {_x}; - if ((toLower _backpack) in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; + if ((backpack _x) in _compatibleBases) exitWith {_x}; + if ((_backpack) in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; objNull } forEach _backpackers; From 2d2465f44faa45c081bbfeafd04729c0ebde69be Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:19:54 -0400 Subject: [PATCH 50/74] run unpackStaticWeapon first, then pfh if needed --- addons/ai/XEH_postInit.sqf | 2 +- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 10 ++++++++++ .../ai/functions/fnc_unpackStaticWeaponPFH.sqf | 17 +++-------------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/addons/ai/XEH_postInit.sqf b/addons/ai/XEH_postInit.sqf index 260e6f65b..848fcee35 100644 --- a/addons/ai/XEH_postInit.sqf +++ b/addons/ai/XEH_postInit.sqf @@ -6,4 +6,4 @@ QGVAR(skills) addPublicVariableEventHandler LINKFUNC(handleSkillsChange); [QGVAR(unGarrison), LINKFUNC(unGarrison)] call CBA_fnc_addEventHandler; -[QGVAR(unpackStaticWeapon), LINKFUNC(unpackStaticWeaponPFH)] call CBA_fnc_addEventHandler; +[QGVAR(unpackStaticWeapon), LINKFUNC(unpackStaticWeapon)] call CBA_fnc_addEventHandler; diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 050a1c132..39d9e194f 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -1,4 +1,5 @@ #include "script_component.hpp" +#define DISTANCE_CLOSE 3 /* * Author: Ampersand * Unpacks a static weapon from units' backpacks. @@ -19,6 +20,15 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; +if (!local _gunner) exitWith { + [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; +}; + +// too far, run PFH +if (_gunner distance _assistant > DISTANCE_CLOSE) exitWith { + [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeaponPFH); +}; + if (!(_targetPos isEqualTo [])) then { _assistant doWatch _targetPos; _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 671c46ca8..8fa7cbd75 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -22,17 +22,6 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -if (!local _gunner) exitWith { - [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; -}; - -_gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _targetPos]; - -// Close enough, set up weapon -if (_gunner distance _assistant < 3) exitWith { - [_gunner, _assistant] call FUNC(unpackStaticWeapon); -}; - // Too far, order assistant to move to gunner and start pfh _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; @@ -46,7 +35,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; [{ params ["_args", "_pfhID"]; - _args params ["_gunner", "_assistant", "_startTime"]; + _args params ["_gunner", "_assistant", "_targetPos", "_startTime"]; private _closeEnough = _gunner distance _assistant < DISTANCE_CLOSE; private _endTime = _startTime + MOVE_TIMEOUT; @@ -61,7 +50,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant enableAI "FSM"; if (_closeEnough) then { - [_gunner, _assistant] call FUNC(unpackStaticWeapon); + [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeapon); }; }; @@ -70,4 +59,4 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant doMove ASLtoAGL getPosASL _gunner; }; -}, MOVE_DELAY, [_gunner, _assistant, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; +}, MOVE_DELAY, [_gunner, _assistant, _targetPos, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; From f8dc7913f7c577b619f1c49eaa051fe7e55459e4 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:26:30 -0400 Subject: [PATCH 51/74] distance check to <= 3 --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 8fa7cbd75..7a8cc9d3f 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -37,7 +37,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; params ["_args", "_pfhID"]; _args params ["_gunner", "_assistant", "_targetPos", "_startTime"]; - private _closeEnough = _gunner distance _assistant < DISTANCE_CLOSE; + private _closeEnough = _gunner distance _assistant <= DISTANCE_CLOSE; private _endTime = _startTime + MOVE_TIMEOUT; if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith { From 283d60d6efe254078cf1eaa2f7d81726e2575b45 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:37:42 -0400 Subject: [PATCH 52/74] Comment case --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 39d9e194f..079dfec73 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -24,7 +24,7 @@ if (!local _gunner) exitWith { [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; }; -// too far, run PFH +// Too far, run PFH if (_gunner distance _assistant > DISTANCE_CLOSE) exitWith { [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeaponPFH); }; From d98c457f14de47dc4102c42b190dbfdc9c8ea1bd Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:37:54 -0400 Subject: [PATCH 53/74] Should not restore FSM if it was already disabled. Use checkAIFeature --- .../ai/functions/fnc_unpackStaticWeaponPFH.sqf | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 7a8cc9d3f..b356d42de 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -22,7 +22,8 @@ params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; -// Too far, order assistant to move to gunner and start pfh +// Order assistant to move to gunner and start pfh +_gunner setVariable [QGVAR(statePATH), _gunner checkAIFeature "PATH"]; _gunner disableAI "PATH"; [_assistant] joinSilent grpNull; private _group = group _assistant; @@ -30,6 +31,7 @@ _group setBehaviourStrong "CARELESS"; _group deleteGroupWhenEmpty true; _group enableAttack false; _assistant doMove getPosATL _gunner; +_assistant setVariable [QGVAR(stateFSM), _assistant checkAIFeature "FSM"]; _assistant disableAI "FSM"; _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; @@ -42,13 +44,21 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; - _gunner enableAI "PATH"; + // Gunner AI PATH + if (_gunner getVariable [QGVAR(statePATH), true]) then { + _gunner setVariable [QGVAR(statePATH), nil]; + _gunner enableAI "PATH"; + }; // Reset assistant behaviour private _group = group _gunner; [_assistant] joinSilent _group; _group setBehaviour (behaviour _gunner); - _assistant enableAI "FSM"; - + // Assistant AI FSM + if (_assistant getVariable [QGVAR(stateFSM), true]) then { + _assistant setVariable [QGVAR(stateFSM), nil]; + _assistant enableAI "FSM"; + }; + // CLose enough, unpack if (_closeEnough) then { [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeapon); }; From 4fc2b7a769e62c2f3d44c1586660943bab4b2c1e Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 11:55:28 -0400 Subject: [PATCH 54/74] gunner watch targetPos while assistant runs up --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 079dfec73..fbccdcb45 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -24,6 +24,10 @@ if (!local _gunner) exitWith { [QGVAR(unpackStaticWeapon), _this, _gunner] call CBA_fnc_targetEvent; }; +if (!(_targetPos isEqualTo [])) then { + _gunner doWatch _targetPos; +}; + // Too far, run PFH if (_gunner distance _assistant > DISTANCE_CLOSE) exitWith { [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeaponPFH); From 3dd73670c79d4368b295e89cc288a8da14c73202 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 12:03:05 -0400 Subject: [PATCH 55/74] Add weapon to curator --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index fbccdcb45..283512db9 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -42,6 +42,7 @@ _gunner addEventHandler ["WeaponAssembled", { params ["_gunner", "_weapon"]; _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; + [QEGVAR(common,addObjects), [[_weapon]]] call CBA_fnc_serverEvent; private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; if (!(_targetPos isEqualTo [])) then { From 5c72ec3a014f78499ae768450feb1bbaa30f04bb Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 12:12:24 -0400 Subject: [PATCH 56/74] No parentheses around unary commands. --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index b356d42de..fa3fafb78 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -52,7 +52,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; // Reset assistant behaviour private _group = group _gunner; [_assistant] joinSilent _group; - _group setBehaviour (behaviour _gunner); + _group setBehaviour behaviour _gunner; // Assistant AI FSM if (_assistant getVariable [QGVAR(stateFSM), true]) then { _assistant setVariable [QGVAR(stateFSM), nil]; From 39ef2e8c844a07ea4b8b43940df1126d4cd1b112 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 5 Aug 2020 12:26:36 -0400 Subject: [PATCH 57/74] store nextMoveTime in PFH args --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index fa3fafb78..402c76db3 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" #define DISTANCE_CLOSE 3 -#define MOVE_DELAY 0.1 +#define MOVE_DELAY 5 #define MOVE_TIMEOUT 60 /* * Author: Ampersand @@ -37,10 +37,9 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; [{ params ["_args", "_pfhID"]; - _args params ["_gunner", "_assistant", "_targetPos", "_startTime"]; + _args params ["_gunner", "_assistant", "_targetPos", "_nextMoveTime", "_endTime"]; private _closeEnough = _gunner distance _assistant <= DISTANCE_CLOSE; - private _endTime = _startTime + MOVE_TIMEOUT; if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; @@ -64,9 +63,8 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; }; }; - private _nextMoveTime = _assistant getVariable [QGVAR(nextMoveTime), CBA_MissionTime]; if (unitReady _assistant || {CBA_MissionTime >= _nextMoveTime}) then { - _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant doMove ASLtoAGL getPosASL _gunner; + _args set [3, CBA_missionTime + MOVE_DELAY]; }; -}, MOVE_DELAY, [_gunner, _assistant, _targetPos, CBA_MissionTime]] call CBA_fnc_addPerFrameHandler; +}, 0.1, [_gunner, _assistant, _targetPos, CBA_MissionTime + MOVE_DELAY, CBA_missionTime + MOVE_TIMEOUT]] call CBA_fnc_addPerFrameHandler; From dfe1f179326535c6630e6ee80c5817fe38f1a7f7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 11 Aug 2020 12:33:58 -0400 Subject: [PATCH 58/74] Modules List documentation --- docs/user_guide/modules_list.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/user_guide/modules_list.md b/docs/user_guide/modules_list.md index 7933b1c16..15fd2c876 100644 --- a/docs/user_guide/modules_list.md +++ b/docs/user_guide/modules_list.md @@ -271,6 +271,10 @@ Toggles the visibility of the attached object. Un-garrisons units from the attached group. +## Unpack Static Weapon + +Orders AI with weapons bags to set up the static weapon facing the target position. + ## Update Editable Objects Adds or removes editable objects of the selected types from the local or all curators. From 10ce85684088c7ef6d07066c60d1a2f88dcb7e3c Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Fri, 21 Aug 2020 22:33:01 -0400 Subject: [PATCH 59/74] Move defines below docs --- addons/ai/functions/fnc_unpackStaticWeapon.sqf | 3 ++- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeapon.sqf b/addons/ai/functions/fnc_unpackStaticWeapon.sqf index 283512db9..1e81c75d2 100644 --- a/addons/ai/functions/fnc_unpackStaticWeapon.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeapon.sqf @@ -1,5 +1,4 @@ #include "script_component.hpp" -#define DISTANCE_CLOSE 3 /* * Author: Ampersand * Unpacks a static weapon from units' backpacks. @@ -18,6 +17,8 @@ * Public: No */ +#define DISTANCE_CLOSE 3 + params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; if (!local _gunner) exitWith { diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 402c76db3..600aed6ca 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -1,7 +1,4 @@ #include "script_component.hpp" -#define DISTANCE_CLOSE 3 -#define MOVE_DELAY 5 -#define MOVE_TIMEOUT 60 /* * Author: Ampersand * Move units together if needed and unpacks a static weapon from units' backpacks. @@ -20,6 +17,10 @@ * Public: No */ +#define DISTANCE_CLOSE 3 +#define MOVE_DELAY 5 +#define MOVE_TIMEOUT 60 + params ["_gunner", "_assistant", ["_targetPos", [], [[]], 3]]; // Order assistant to move to gunner and start pfh From 2f167e9220a6bf06badcdd37995c8a34b4cba065 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Fri, 21 Aug 2020 22:33:38 -0400 Subject: [PATCH 60/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 4487816b2..82376e66f 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -40,7 +40,7 @@ private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; if (isText _cfgBase) exitWith {[getText _cfgBase]}; - (getArray _cfgBase) //apply {toLower _x} + getArray _cfgBase }; private _backpack = backpack _gunner; From 2cfb05c2e078f31fa11ac48371da2ec5848e956c Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Fri, 21 Aug 2020 22:34:35 -0400 Subject: [PATCH 61/74] new line before return value --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 82376e66f..12dab8f10 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -40,6 +40,7 @@ private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; if (isText _cfgBase) exitWith {[getText _cfgBase]}; + getArray _cfgBase }; From 0db8c1ed0e323b8262dd4d1d058a1b80545e462f Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Fri, 18 Dec 2020 17:42:27 -0500 Subject: [PATCH 62/74] New Icon --- addons/modules/CfgVehicles.hpp | 2 +- addons/modules/ui/unpack_static_ca.paa | Bin 0 -> 5625 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 addons/modules/ui/unpack_static_ca.paa diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index bfc0724e7..c33931058 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -439,7 +439,7 @@ class CfgVehicles { category = QGVAR(AI); displayName = CSTRING(moduleUnpackStaticWeapon); function = QFUNC(moduleUnpackStaticWeapon); - icon = "\a3\ui_f\data\map\vehicleicons\iconstaticmg_ca.paa"; + icon = QPATHTOF(ui\unpack_static_ca.paa); }; class GVAR(moduleVisibility): GVAR(moduleBase) { curatorCanAttach = 1; diff --git a/addons/modules/ui/unpack_static_ca.paa b/addons/modules/ui/unpack_static_ca.paa new file mode 100644 index 0000000000000000000000000000000000000000..c9ac1224258ed1ab52d15fa0151861fd62b7cb6a GIT binary patch literal 5625 zcmeI0dr(wW7{Cwfvb@<1*Ju?IgygM~vW@R$nikg)QA#vl0gFh&ic+I#I^ZL)e6UEG z7Q{F?p`#|6-FzmXLufFfHWNq+BnqYm%0tkV(>Ztf&R*8>g;4#`nO(TQJ&*5kzWbf; zUP~Mj68z4aArZl1giu36!w{Zl1cy?_q)`qDo}{L1LB5pVR;$BQ}@nmFqITui#+c+Qk6}&zoD`4NfoUVM`ZMP5G~Euzc&15Yd?fxAk_9tG_q2_ z!;qi8mV^xS+g_TbRSEhPx7x>FPmLP@{c|3Wt25H;z{nuqdiNZqPJNI{pG{fV^k)tgZ}dO^*CY@3 zu>HYEqbK(>^QY5MAN$_4*W7;JUCL--ybyD{=<_J6X#QdPny>di8$AH=^P>KkLgTYt zKL*yD7*1~9ZPDz0my94R$Opcuga!FTRzf&0I~3-RQqz8idBCGXDR0~b?6IBj%ULIZ zt;f**>_Xt@wP)HLPUoeJWcr3zaM_;7#8a!fa>SiSxmGZK)H>}Q?4f1rMI6yLV~xol zE;lRhW1ZFm^!2Zf$|1?j5m>={Qp)np4sx=bOcwnF{rDJCg(H0}ub2x~LV*avi?rRu7GjSG-Uw%z_#%zJm4jG*mn6`5a4m=a-nP%iEI&_c;BwgCMfqCsKUL;>CxY)P? zViK%}ZfUFoiBZ5__f~f_&d?43c4ZetLz>^s7#r&)b#U(ZGPm(X70dP{H|t#5V$4?K^XLWWLa z`ObRc0S95dM14XVj5pG=v)}I4cq?TB+fR`qFjlz!J@l%6y5?(BKB*&;5*#;zybA{W z0JlrCfJ-_m8p$;~56)HF^0^B7w>HzODmk!}Y;N8AZ?OIBcOiL6VV)_!NYRA{t`mlE>Vl zqx_vlM~=A3=_a(B9&6pIxDz%whxN<<@z3OV<`16_2y0BojQ2rKhhju3&|g}{In2_1zYo~`HWz?O z2W|!?uO%E3aE=$S3rBKtj_WfYd*=4M%O7h|ez4xF)#^28KQZmc6;!w_OAy9=%KWl& z`^U2|KaMo7j}u*GWk|qOV&4EaK88{X+%a} z1zMnmm#G=^nc3b=+>XHtdnU%`Zc6s_qUf){Y;iH?P_bj>C16D;DYdv0>@<*nL)J?P zR6@V3Ss7D_ejN;KosmhN{#@DmZv1JeWAc|Gn~b2vg)EHSe$>Wl1#YlPUXxuc@nCNC z$yX*07o1ko=0mQw3!?jgJcnbPWlQp4HvXf_s{(|#xizw;uSM4*o0o2DlD>dxb_ZQI u6iG_X0z2m^WAZ0Q?E$u4;TNTib75`}lZ;CIIaB7`f9R1p^)Sr1$$tZ^zFx%u literal 0 HcmV?d00001 From a7a58226e2640acd9a741fca8940d8ae44803d95 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Fri, 18 Dec 2020 17:45:20 -0500 Subject: [PATCH 63/74] Players, Distance, Single-bag - Dropping module on unit in the same group as a player will only show a message - Single-bag weapons such as UAVs and Remote Designators are now supported - Check all compatible assistants and choose the closest one - Error msg if closest assistant is over 100m away since it would probably take too long --- .../fnc_moduleUnpackStaticWeapon.sqf | 89 +++++++++++++++---- addons/modules/stringtable.xml | 6 ++ 2 files changed, 78 insertions(+), 17 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 12dab8f10..53d78df0a 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -36,6 +36,10 @@ if (isPlayer _gunner) exitWith { ["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage); }; +if ({isPlayer _x} count units _gunner > 0) exitWith { + [LSTRING(ModuleUnpackStaticWeapon_Player)] call EFUNC(common,showMessage); +}; +/* private _fnc_getCompatibleBases = { params ["_backpack"]; private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; @@ -43,31 +47,82 @@ private _fnc_getCompatibleBases = { getArray _cfgBase }; - +*/ private _backpack = backpack _gunner; - if (_backpack isEqualTo "") exitWith { [LSTRING(ModuleUnpackStaticWeapon_Unit)] call EFUNC(common,showMessage); }; -private _compatibleBases = [_backpack] call _fnc_getCompatibleBases; +private _assembleInfo = ["assembleTo", "base", "displayName", "dissasembleTo", "primary"] apply {(configOf backpackContainer _gunner >> "assembleInfo" >> _x) call BIS_fnc_getCfgData}; +_assembleInfo params ["_assembleTo", "_compatibleBases", "_displayName", "_dissasembleTo", "_primary"]; +if (_compatibleBases isEqualType "") then {_compatibleBases = [];}; -private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; -private _assistant = { - if ((backpack _x) in _compatibleBases) exitWith {_x}; - if ((_backpack) in ([backpack _x] call _fnc_getCompatibleBases)) exitWith {_x}; +if (_primary == 1 && {_compatibleBases isEqualTo [] || {_compatibleBases isEqualTo "" || {_compatibleBases isEqualTo [""]}}}) then { + // single-backpack weapon + [_gunner, { + params ["_successful", "_gunner", "_position"]; + if (_successful) then { + _gunner setVariable [QGVAR(unpackStaticWeaponTargetPos), _position]; - objNull -} forEach _backpackers; + _gunner addEventHandler ["WeaponAssembled", { + params ["_gunner", "_weapon"]; -if (isNull _assistant) exitWith { - [LSTRING(ModuleUnpackStaticWeapon_Group)] call EFUNC(common,showMessage); -}; + _gunner removeEventHandler ["WeaponAssembled", _thisEventHandler]; + [QEGVAR(common,addObjects), [[_weapon]]] call CBA_fnc_serverEvent; + + private _targetPos = _gunner getVariable [QGVAR(unpackStaticWeaponTargetPos), []]; + if (!(_targetPos isEqualTo [])) then { + _weapon setDir (_weapon getDir _targetPos); + _gunner doWatch _targetPos; + }; + + // Added due to occassional tripod leg clipping through ground + _weapon setPosASL (getPosASL _weapon vectorAdd [0, 0, 0.05]); + _weapon setVectorUp surfaceNormal position _weapon; + + if (unitIsUAV _weapon) exitWith { + _gunner connectTerminalToUAV _weapon; + }; -// Get target position -[_gunner, { - params ["_successful", "_gunner", "_position", "_assistant"]; - if (_successful) then { - [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _position], _gunner] call CBA_fnc_targetEvent; + if (isNull gunner _weapon) exitWith { + _gunner assignAsGunner _weapon; + _gunner moveInGunner _weapon; + + group _gunner addVehicle _weapon; + }; + }]; + + _gunner action ["Assemble"]; + }; + }, [], LSTRING(ModuleUnpackStaticWeapon_Direction)] call EFUNC(common,selectPosition); +} else { + // two-backpack weapon + private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; + private _assistant = objNull; + { + if ( + // has matching backpack + (backpack _x in _compatibleBases || {_backpack in ((configOf backpackContainer _x >> "assembleInfo" >> "base") call BIS_fnc_getCfgData)}) + // closer than current + && {_assistant == objNull || {(_gunner distance _x) < (_gunner distance _assistant)}} + ) then { + _assistant = _x; + }; + } forEach _backpackers; + + if (isNull _assistant) exitWith { + [LSTRING(ModuleUnpackStaticWeapon_Group)] call EFUNC(common,showMessage); }; + + if (_assistant distance _gunner > 100) exitWith { + [LSTRING(ModuleUnpackStaticWeapon_Distance)] call EFUNC(common,showMessage); + }; + + // Get target position + [_gunner, { + params ["_successful", "_gunner", "_position", "_assistant"]; + if (_successful) then { + [QEGVAR(ai,unpackStaticWeapon), [_gunner, _assistant, ASLToAGL _position], _gunner] call CBA_fnc_targetEvent; + }; }, _assistant, LSTRING(ModuleUnpackStaticWeapon_Direction)] call EFUNC(common,selectPosition); +}; diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 58f516b33..960f81831 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -1303,6 +1303,12 @@ Unit group must contain two compatible weapon bags + + Assistant must be closer to gunner (<100m) + + + Unit must not be in a player's group + Weapon Direction From aea37ab0e77104d78e76a82e75d2dd9e92f8f25a Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 19 Dec 2020 13:49:57 -0500 Subject: [PATCH 64/74] Removed < in text --- addons/modules/stringtable.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 960f81831..29c726673 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -1304,7 +1304,7 @@ Unit group must contain two compatible weapon bags - Assistant must be closer to gunner (<100m) + Assistant must be within 100 m of gunner Unit must not be in a player's group From 1bd1ba006f183369f11277f98e9b29a01b128b23 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Tue, 12 Jan 2021 23:19:57 -0500 Subject: [PATCH 65/74] findIf instead of count Co-authored-by: NeilZar --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 53d78df0a..523002b53 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -36,7 +36,7 @@ if (isPlayer _gunner) exitWith { ["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call EFUNC(common,showMessage); }; -if ({isPlayer _x} count units _gunner > 0) exitWith { +if (units _gunner findIf {isPlayer _x} != -1) exitWith { [LSTRING(ModuleUnpackStaticWeapon_Player)] call EFUNC(common,showMessage); }; /* From 6a4192201e43c7cccfa62668ad9df071b776f810 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:05:17 -0500 Subject: [PATCH 66/74] Update addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 600aed6ca..512348318 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -58,7 +58,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _assistant setVariable [QGVAR(stateFSM), nil]; _assistant enableAI "FSM"; }; - // CLose enough, unpack + // Close enough, unpack if (_closeEnough) then { [_gunner, _assistant, _targetPos] call FUNC(unpackStaticWeapon); }; From a4df41cfa0a6789f5924c60eda0b379f6d8836c8 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:05:32 -0500 Subject: [PATCH 67/74] Update addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 512348318..563f403e3 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -53,6 +53,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; private _group = group _gunner; [_assistant] joinSilent _group; _group setBehaviour behaviour _gunner; + // Assistant AI FSM if (_assistant getVariable [QGVAR(stateFSM), true]) then { _assistant setVariable [QGVAR(stateFSM), nil]; From 96e8a82ce4168d34b5d025615f3e0535863cc1ff Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:05:41 -0500 Subject: [PATCH 68/74] Update addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 563f403e3..87f9eefe7 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -49,6 +49,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; _gunner setVariable [QGVAR(statePATH), nil]; _gunner enableAI "PATH"; }; + // Reset assistant behaviour private _group = group _gunner; [_assistant] joinSilent _group; From 69b1da8653fde773dc05e46120acafe3b2dcfd9d Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:05:47 -0500 Subject: [PATCH 69/74] Update addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf Co-authored-by: Ralfs Garkaklis --- addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf index 87f9eefe7..90378d75b 100644 --- a/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf +++ b/addons/ai/functions/fnc_unpackStaticWeaponPFH.sqf @@ -44,6 +44,7 @@ _assistant setVariable [QGVAR(nextMoveTime), CBA_MissionTime + 5]; if (_closeEnough || {CBA_MissionTime > _endTime || {!alive _gunner || {!alive _assistant}}}) exitWith { [_pfhID] call CBA_fnc_removePerFrameHandler; + // Gunner AI PATH if (_gunner getVariable [QGVAR(statePATH), true]) then { _gunner setVariable [QGVAR(statePATH), nil]; From e1e006d5a16b280afeb15e71feeb0642287d8fca Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:06:03 -0500 Subject: [PATCH 70/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 523002b53..22410a889 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -58,7 +58,7 @@ _assembleInfo params ["_assembleTo", "_compatibleBases", "_displayName", "_dissa if (_compatibleBases isEqualType "") then {_compatibleBases = [];}; if (_primary == 1 && {_compatibleBases isEqualTo [] || {_compatibleBases isEqualTo "" || {_compatibleBases isEqualTo [""]}}}) then { - // single-backpack weapon + // Single-backpack weapon [_gunner, { params ["_successful", "_gunner", "_position"]; if (_successful) then { From 73aa57c92b7269d70008683519052fb0f72e4bb2 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:06:09 -0500 Subject: [PATCH 71/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 22410a889..79277bce4 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -103,7 +103,7 @@ if (_primary == 1 && {_compatibleBases isEqualTo [] || {_compatibleBases isEqual if ( // has matching backpack (backpack _x in _compatibleBases || {_backpack in ((configOf backpackContainer _x >> "assembleInfo" >> "base") call BIS_fnc_getCfgData)}) - // closer than current + // Closer than current && {_assistant == objNull || {(_gunner distance _x) < (_gunner distance _assistant)}} ) then { _assistant = _x; From 398c5d233120f8cc545f12ec5bb312da29f9f652 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:06:18 -0500 Subject: [PATCH 72/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 79277bce4..271269396 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -96,7 +96,7 @@ if (_primary == 1 && {_compatibleBases isEqualTo [] || {_compatibleBases isEqual }; }, [], LSTRING(ModuleUnpackStaticWeapon_Direction)] call EFUNC(common,selectPosition); } else { - // two-backpack weapon + // Two-backpack weapon private _backpackers = units _gunner select {!(backpack _x isEqualTo "")}; private _assistant = objNull; { From dd7872042ddca29020e0a4b80f5469e46c9341b0 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:06:23 -0500 Subject: [PATCH 73/74] Update addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 271269396..732d35117 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -101,7 +101,7 @@ if (_primary == 1 && {_compatibleBases isEqualTo [] || {_compatibleBases isEqual private _assistant = objNull; { if ( - // has matching backpack + // Has matching backpack (backpack _x in _compatibleBases || {_backpack in ((configOf backpackContainer _x >> "assembleInfo" >> "base") call BIS_fnc_getCfgData)}) // Closer than current && {_assistant == objNull || {(_gunner distance _x) < (_gunner distance _assistant)}} From bc929a21a94939374c4f07c9872abd0609a4ebe7 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 09:07:51 -0500 Subject: [PATCH 74/74] remove commented code --- addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf index 732d35117..8d32af238 100644 --- a/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf +++ b/addons/modules/functions/fnc_moduleUnpackStaticWeapon.sqf @@ -39,15 +39,7 @@ if (isPlayer _gunner) exitWith { if (units _gunner findIf {isPlayer _x} != -1) exitWith { [LSTRING(ModuleUnpackStaticWeapon_Player)] call EFUNC(common,showMessage); }; -/* -private _fnc_getCompatibleBases = { - params ["_backpack"]; - private _cfgBase = configFile >> "CfgVehicles" >> _backpack >> "assembleInfo" >> "base"; - if (isText _cfgBase) exitWith {[getText _cfgBase]}; - getArray _cfgBase -}; -*/ private _backpack = backpack _gunner; if (_backpack isEqualTo "") exitWith { [LSTRING(ModuleUnpackStaticWeapon_Unit)] call EFUNC(common,showMessage);