Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arsenal/Compat RHS - Improve support for RHS attachments #9386

Merged
merged 12 commits into from
Sep 25, 2023
22 changes: 22 additions & 0 deletions addons/arsenal/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
8 changes: 8 additions & 0 deletions addons/arsenal/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions addons/arsenal/functions/fnc_onSelChangedRight.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""]]];
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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, ""]]];
Expand Down Expand Up @@ -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, ""]]];
Expand Down
10 changes: 10 additions & 0 deletions addons/arsenal/functions/fnc_scanConfig.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
@@ -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";
};
};
18 changes: 18 additions & 0 deletions addons/compat_rhs_afrf3/compat_rhs_afrf3_arsenal/config.cpp
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define SUBCOMPONENT arsenal
#define SUBCOMPONENT_BEAUTIFIED Arsenal
#include "..\script_component.hpp"
50 changes: 50 additions & 0 deletions addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -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";
};
};
18 changes: 18 additions & 0 deletions addons/compat_rhs_usf3/compat_rhs_usf3_arsenal/config.cpp
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define SUBCOMPONENT arsenal
#define SUBCOMPONENT_BEAUTIFIED Arsenal
#include "..\script_component.hpp"
1 change: 1 addition & 0 deletions docs/wiki/framework/arsenal-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down