mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Arsenal - Fix FUNC(removeVirtualItems)
for JIP players (#9650)
* Fix removeItems for JIP * Different approach * Update fnc_addVirtualItems.sqf * Refresh arsenal globally
This commit is contained in:
parent
65c16b6a0a
commit
8f3129a02e
@ -18,6 +18,15 @@ GVAR(lastSortDirectionRight) = DESCENDING;
|
||||
[QGVAR(removeDefaultLoadout), LINKFUNC(removeDefaultLoadout)] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(renameDefaultLoadout), LINKFUNC(renameDefaultLoadout)] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(refresh), {
|
||||
params ["_object"];
|
||||
|
||||
// If the arsenal is already open, refresh arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[true, true] call FUNC(refresh);
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(broadcastFace), {
|
||||
params ["_unit", "_face"];
|
||||
_unit setFace _face;
|
||||
|
@ -125,6 +125,8 @@ if (_items isEqualType true) then {
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
|
||||
// If the arsenal is already open, refresh arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[true, true] call FUNC(refresh);
|
||||
if (_global) then {
|
||||
[QGVAR(refresh), _object] call CBA_fnc_globalEvent;
|
||||
} else {
|
||||
[QGVAR(refresh), _object] call CBA_fnc_localEvent;
|
||||
};
|
||||
|
@ -24,14 +24,12 @@ if (_mode > 0) then {
|
||||
// Blacklist: add full arsenal and take items away
|
||||
[_object, true, true] call FUNC(initBox);
|
||||
|
||||
// Need to delay removal by 2 frames
|
||||
// Wait until all items have been added, so that the blacklisted items can be removed
|
||||
[{
|
||||
[{
|
||||
params ["_object", "_items"];
|
||||
|
||||
[_object, _items, true] call FUNC(removeVirtualItems);
|
||||
}, _this] call CBA_fnc_execNextFrame;
|
||||
}, [_object, _items]] call CBA_fnc_execNextFrame;
|
||||
!isNil {(_this select 0) getVariable QGVAR(virtualItems)}
|
||||
}, {
|
||||
[_this select 0, _this select 1, true] call FUNC(removeVirtualItems);
|
||||
}, [_object, _items], 20] call CBA_fnc_waitUntilAndExecute; // 20s timeout in case of failure
|
||||
} else {
|
||||
// Exit on whitelist mode with no items
|
||||
if (_items isEqualTo []) exitWith {};
|
||||
|
@ -51,7 +51,10 @@ if (_global && {isMultiplayer} && {isNil {_object getVariable QGVAR(initBoxJIP)}
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
[_object, 0, ["ACE_MainActions"], _action] call EFUNC(interact_menu,addActionToObject);
|
||||
|
||||
[_object, _items, false] call FUNC(addVirtualItems);
|
||||
// If items were set globally, do not add items locally
|
||||
if (isNil {_object getVariable QGVAR(virtualItems)}) then {
|
||||
[_object, _items, false] call FUNC(addVirtualItems);
|
||||
};
|
||||
|
||||
[QGVAR(boxInitialized), [_object, _items]] call CBA_fnc_localEvent;
|
||||
};
|
||||
|
@ -28,13 +28,15 @@ if (
|
||||
) exitWith {};
|
||||
|
||||
// If object has no arsenal and chosen option is to not ignore virtual items of object, exit
|
||||
if (isNil {_object getVariable QGVAR(virtualItems)} && {!_mode}) exitWith {
|
||||
private _virtualItems = _object getVariable QGVAR(virtualItems);
|
||||
|
||||
if (isNil "_virtualItems" && {!_mode}) exitWith {
|
||||
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
|
||||
};
|
||||
|
||||
// Don't execute in scheduled environment
|
||||
if (canSuspend) exitWith {
|
||||
[{_this call FUNC(openBox)}, _this] call CBA_fnc_directCall;
|
||||
[FUNC(openBox), _this] call CBA_fnc_directCall;
|
||||
};
|
||||
|
||||
private _displayToUse = findDisplay IDD_RSCDISPLAYCURATOR;
|
||||
@ -46,6 +48,7 @@ if (isNull _displayToUse || {!isNil QGVAR(camera)}) exitWith {
|
||||
[LLSTRING(CantOpenDisplay), false, 5, 1] call EFUNC(common,displayText);
|
||||
};
|
||||
|
||||
GVAR(center) = _center;
|
||||
GVAR(currentBox) = _object;
|
||||
|
||||
if (_mode) then {
|
||||
@ -56,29 +59,12 @@ if (_mode) then {
|
||||
GVAR(ignoredVirtualItems) = true;
|
||||
} else {
|
||||
// Add only specified items to the arsenal
|
||||
private _virtualItems = _object getVariable QGVAR(virtualItems);
|
||||
|
||||
GVAR(virtualItems) = if (isNil "_virtualItems") then {
|
||||
_virtualItems = [
|
||||
[IDX_VIRT_WEAPONS, createHashMapFromArray [[IDX_VIRT_PRIMARY_WEAPONS, createHashMap], [IDX_VIRT_SECONDARY_WEAPONS, createHashMap], [IDX_VIRT_HANDGUN_WEAPONS, createHashMap]]],
|
||||
[IDX_VIRT_ATTACHMENTS, createHashMapFromArray [[IDX_VIRT_OPTICS_ATTACHMENTS, createHashMap], [IDX_VIRT_FLASHLIGHT_ATTACHMENTS, createHashMap], [IDX_VIRT_MUZZLE_ATTACHMENTS, createHashMap], [IDX_VIRT_BIPOD_ATTACHMENTS, createHashMap]]]
|
||||
];
|
||||
|
||||
_virtualItems = createHashMapFromArray _virtualItems;
|
||||
|
||||
for "_index" from IDX_VIRT_ITEMS_ALL to IDX_VIRT_MISC_ITEMS do {
|
||||
_virtualItems set [_index, createHashMap];
|
||||
};
|
||||
} else {
|
||||
+_virtualItems
|
||||
};
|
||||
GVAR(virtualItems) = +_virtualItems;
|
||||
|
||||
// Flatten out hashmaps for easy checking later
|
||||
call FUNC(updateVirtualItemsFlat);
|
||||
};
|
||||
|
||||
GVAR(center) = _center;
|
||||
|
||||
if (is3DEN) then {
|
||||
_displayToUse createDisplay QGVAR(display);
|
||||
} else {
|
||||
|
@ -25,7 +25,7 @@ private _id = _object getVariable QGVAR(initBoxJIP);
|
||||
|
||||
if (_global && {isMultiplayer} && {!isNil "_id"}) then {
|
||||
// Remove event from JIP queue
|
||||
[_id] call CBA_fnc_removeGlobalEventJIP;
|
||||
_id call CBA_fnc_removeGlobalEventJIP;
|
||||
|
||||
// Reset JIP ID
|
||||
_object setVariable [QGVAR(initBoxJIP), nil, true];
|
||||
|
@ -100,9 +100,12 @@ if (_items isEqualType true) then {
|
||||
[_object, _global] call FUNC(removeBox);
|
||||
} else {
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
|
||||
// If the arsenal is already open, refresh arsenal display
|
||||
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
|
||||
[true, true] call FUNC(refresh);
|
||||
if (_global) then {
|
||||
[QGVAR(refresh), _object] call CBA_fnc_globalEvent;
|
||||
} else {
|
||||
[QGVAR(refresh), _object] call CBA_fnc_localEvent;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user