diff --git a/addons/arsenal/XEH_postInit.sqf b/addons/arsenal/XEH_postInit.sqf index 1aaa0203b1..ee03bff9a9 100644 --- a/addons/arsenal/XEH_postInit.sqf +++ b/addons/arsenal/XEH_postInit.sqf @@ -149,3 +149,25 @@ GVAR(lastSortDirectionRight) = DESCENDING; }; }; }] call CBA_fnc_addEventHandler; + +// Compatibility for RHS attachment system. Also used by NIArms. +// Will only work for ACE_player, different arsenal centers will be ignored. RHS limitation. +if (!isNil "rhs_fnc_accGripod") then { + [QEGVAR(arsenal,weaponItemChanged), { + params ["_weapon", "_item", "_itemIndex"]; + if (EGVAR(arsenal,center) != ACE_player) exitWith {}; + + switch (_itemIndex) do { + case ITEM_INDEX_SIDE: { + call rhs_fnc_anpeq15_rail; + }; + case ITEM_INDEX_BIPOD: { + // Need this call to make sure RHS's functions are set + call rhs_fnc_accGripod; + if (getText (configFile >> "CfgWeapons" >> _item >> "rhs_grip_type") == "") then { + call rhs_grip_deinitialize; + }; + }; + }; + }] call CBA_fnc_addEventHandler; +}; diff --git a/addons/arsenal/defines.hpp b/addons/arsenal/defines.hpp index cfc12df3d3..73116dde76 100644 --- a/addons/arsenal/defines.hpp +++ b/addons/arsenal/defines.hpp @@ -22,6 +22,14 @@ // Favorites #define FAVORITES_COLOR (GVAR(favoritesColor) + [1]) +// Attachments +#define ITEM_INDEX_MUZZLE 0 +#define ITEM_INDEX_SIDE 1 +#define ITEM_INDEX_OPTIC 2 +#define ITEM_INDEX_BIPOD 3 +#define ITEM_INDEX_MAGAZINE 4 +#define ITEM_INDEX_MAGAZINE_SECONDARY 5 + // IDCs #define IDD_ace_arsenal 1127001 #define IDC_mouseArea 0 diff --git a/addons/arsenal/functions/fnc_onSelChangedRight.sqf b/addons/arsenal/functions/fnc_onSelChangedRight.sqf index ba4a9fe353..ccb2988765 100644 --- a/addons/arsenal/functions/fnc_onSelChangedRight.sqf +++ b/addons/arsenal/functions/fnc_onSelChangedRight.sqf @@ -57,6 +57,9 @@ switch (_currentItemsIndex) do { }; }; + // Call event for compatibility + [QGVAR(weaponItemChanged), [primaryWeapon GVAR(center), _item, _itemIndex]] call CBA_fnc_localEvent; + // Update currentItems (getUnitLoadout GVAR(center) select IDX_LOADOUT_PRIMARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"]; GVAR(currentItems) set [IDX_CURR_PRIMARY_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine param [0, ""], _secondaryMagazine param [0, ""]]]; @@ -102,6 +105,9 @@ switch (_currentItemsIndex) do { }; }; + // Call event for compatibility + [QGVAR(weaponItemChanged), [secondaryWeapon GVAR(center), _item, _itemIndex]] call CBA_fnc_localEvent; + // Update currentItems if !(_isDisposable && {_itemIndex >= 4}) then { (getUnitLoadout GVAR(center) select IDX_LOADOUT_SECONDARY_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"]; @@ -141,6 +147,9 @@ switch (_currentItemsIndex) do { }; }; + // Call event for compatibility + [QGVAR(weaponItemChanged), [handgunWeapon GVAR(center), _item, _itemIndex]] call CBA_fnc_localEvent; + // Update currentItems (getUnitLoadout GVAR(center) select IDX_LOADOUT_HANDGUN_WEAPON) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"]; GVAR(currentItems) set [IDX_CURR_HANDGUN_WEAPON_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine param [0, ""], _secondaryMagazine param [0, ""]]]; @@ -178,6 +187,9 @@ switch (_currentItemsIndex) do { }; }; + // Call event for compatibility + [QGVAR(weaponItemChanged), [binocular GVAR(center), _item, _itemIndex]] call CBA_fnc_localEvent; + // Update currentItems (getUnitLoadout GVAR(center) select IDX_LOADOUT_BINO) params ["", "_muzzle", "_flashlight", "_optics", "_primaryMagazine", "_secondaryMagazine", "_bipod"]; GVAR(currentItems) set [IDX_CURR_BINO_ITEMS, [_muzzle, _flashlight, _optics, _bipod, _primaryMagazine param [0, ""], _secondaryMagazine param [0, ""]]]; diff --git a/addons/arsenal/functions/fnc_scanConfig.sqf b/addons/arsenal/functions/fnc_scanConfig.sqf index 484e1bbbca..8110f33b5f 100644 --- a/addons/arsenal/functions/fnc_scanConfig.sqf +++ b/addons/arsenal/functions/fnc_scanConfig.sqf @@ -280,3 +280,13 @@ uiNamespace setVariable [QGVAR(putCache), _putList]; uiNamespace setVariable [QGVAR(magazineMiscItems), _magazineMiscItems]; uiNamespace setVariable [QGVAR(CBAdisposableLaunchers), _launchers]; uiNamespace setVariable [QGVAR(configItemsTools), _toolList]; + +// Compatibility: Override baseWeapon for RHS optics +// No good way to do this via script for other attachments, needs manual compat +private _baseWeaponCache = uiNamespace getVariable QGVAR(baseWeaponNameCache); +{ + private _baseAttachment = configName (_cfgWeapons >> getText (_x >> "rhs_optic_base")); + if (_baseAttachment != "") then { + _baseWeaponCache set [toLower configName _x, _baseAttachment]; + }; +} forEach ("getText (_x >> 'rhs_optic_base') != ''" configClasses _cfgWeapons); diff --git a/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/CfgWeapons.hpp b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/CfgWeapons.hpp new file mode 100644 index 0000000000..994af4f667 --- /dev/null +++ b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/CfgWeapons.hpp @@ -0,0 +1,7 @@ +class CfgWeapons { + // Last update: RHSAFRF 0.5.6 + class rhs_acc_perst3; + class rhs_acc_perst3_2dp: rhs_acc_perst3 { + baseWeapon = "rhs_acc_perst3_2dp"; + }; +}; diff --git a/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/config.cpp b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/config.cpp new file mode 100644 index 0000000000..bb2e1bf3a2 --- /dev/null +++ b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class SUBADDON { + addonRootClass = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "rhs_main_loadorder", + "ace_arsenal" + }; + skipWhenMissingDependencies = 1; + VERSION_CONFIG; + }; +}; + +//#include "CfgWeapons.hpp" diff --git a/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/script_component.hpp b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/script_component.hpp new file mode 100644 index 0000000000..9de14c499c --- /dev/null +++ b/addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/script_component.hpp @@ -0,0 +1,3 @@ +#define SUBCOMPONENT arsenal +#define SUBCOMPONENT_BEAUTIFIED Arsenal +#include "..\script_component.hpp" diff --git a/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/CfgWeapons.hpp b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/CfgWeapons.hpp new file mode 100644 index 0000000000..7888e52393 --- /dev/null +++ b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/CfgWeapons.hpp @@ -0,0 +1,50 @@ +class CfgWeapons { + // Last update: RHSUSAF 0.5.6 + class acc_pointer_IR; + class rhsusf_acc_anpeq15: acc_pointer_IR { + baseWeapon = "rhsusf_acc_anpeq15"; + }; + class rhsusf_acc_anpeq15_bk: rhsusf_acc_anpeq15 { + baseWeapon = "rhsusf_acc_anpeq15_bk"; + }; + class rhsusf_acc_anpeq15_light; + class rhsusf_acc_anpeq15_bk_light: rhsusf_acc_anpeq15_light { + baseWeapon = "rhsusf_acc_anpeq15_bk"; + }; + class rhsusf_acc_anpeq15_wmx: rhsusf_acc_anpeq15 { + baseWeapon = "rhsusf_acc_anpeq15_wmx"; + }; + class rhsusf_acc_anpeq15_wmx_light: rhsusf_acc_anpeq15_light { + baseWeapon = "rhsusf_acc_anpeq15_wmx"; + }; + class rhsusf_acc_M952V: rhsusf_acc_anpeq15_light { + baseWeapon = "rhsusf_acc_M952V"; + }; + class rhsusf_acc_wmx: rhsusf_acc_M952V { + baseWeapon = "rhsusf_acc_wmx"; + }; + class rhsusf_acc_wmx_bk: rhsusf_acc_M952V { + baseWeapon = "rhsusf_acc_wmx_bk"; + }; + class rhsusf_acc_anpeq15A: acc_pointer_IR { + baseWeapon = "rhsusf_acc_anpeq15A"; + }; + class rhsusf_acc_anpeq15side: acc_pointer_IR { + baseWeapon = "rhsusf_acc_anpeq15side"; + }; + class rhsusf_acc_anpeq15side_bk: rhsusf_acc_anpeq15side { + baseWeapon = "rhsusf_acc_anpeq15side_bk"; + }; + class rhsusf_acc_anpeq16a: rhsusf_acc_anpeq15 { + baseWeapon = "rhsusf_acc_anpeq16a"; + }; + class rhsusf_acc_anpeq16a_light: rhsusf_acc_anpeq15_light { + baseWeapon = "rhsusf_acc_anpeq16a"; + }; + class rhsusf_acc_anpeq16a_top: rhsusf_acc_anpeq16a { + baseWeapon = "rhsusf_acc_anpeq16a_top"; + }; + class rhsusf_acc_anpeq16a_light_top: rhsusf_acc_anpeq16a_light { + baseWeapon = "rhsusf_acc_anpeq16a_top"; + }; +}; diff --git a/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/config.cpp b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/config.cpp new file mode 100644 index 0000000000..93e0f33289 --- /dev/null +++ b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class SUBADDON { + addonRootClass = QUOTE(COMPONENT); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = { + "rhsusf_main_loadorder", + "ace_arsenal" + }; + skipWhenMissingDependencies = 1; + VERSION_CONFIG; + }; +}; + +#include "CfgWeapons.hpp" diff --git a/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/script_component.hpp b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/script_component.hpp new file mode 100644 index 0000000000..9de14c499c --- /dev/null +++ b/addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/script_component.hpp @@ -0,0 +1,3 @@ +#define SUBCOMPONENT arsenal +#define SUBCOMPONENT_BEAUTIFIED Arsenal +#include "..\script_component.hpp" diff --git a/docs/wiki/framework/arsenal-framework.md b/docs/wiki/framework/arsenal-framework.md index 75a59bc9b8..329b445d2e 100644 --- a/docs/wiki/framework/arsenal-framework.md +++ b/docs/wiki/framework/arsenal-framework.md @@ -501,6 +501,7 @@ All are local. | ace_arsenal_loadoutsDisplayClosed | None | 3.12.3 | | ace_arsenal_loadoutsTabChanged | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 | | ace_arsenal_loadoutsListFilled | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 | +| ace_arsenal_weaponItemChanged | weapon classname (STRING), item classname (STRING), item index (NUMBER, 0-5: muzzle, side, optic, bipod, magazine, underbarrel) | 3.16.0 | ## 9. Custom sub item categories