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

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Grim 2023-09-25 12:36:46 -04:00 committed by GitHub
parent 6029e75aea
commit ac29287542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 152 additions and 0 deletions

View File

@ -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;
};

View File

@ -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

View File

@ -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, ""]]];

View File

@ -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);

View File

@ -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";
};
};

View File

@ -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"

View File

@ -0,0 +1,3 @@
#define SUBCOMPONENT arsenal
#define SUBCOMPONENT_BEAUTIFIED Arsenal
#include "..\script_component.hpp"

View File

@ -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";
};
};

View File

@ -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"

View File

@ -0,0 +1,3 @@
#define SUBCOMPONENT arsenal
#define SUBCOMPONENT_BEAUTIFIED Arsenal
#include "..\script_component.hpp"

View File

@ -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