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

Filtered Loadouts #1270

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addons/common/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class CfgFunctions {
PATHTO_FNC(addBinocularMagazine);
PATHTO_FNC(removeBinocularMagazine);
PATHTO_FNC(randomizeFacewear);
PATHTO_FNC(filterLoadout);
PATHTO_FNC(addLoadoutFilter);
};

class Cargo {
Expand Down
1 change: 1 addition & 0 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GVAR(featureCamerasNames) = [
call COMPILE_FILE(init_gauss);
call COMPILE_FILE(init_perFrameHandler);
call COMPILE_FILE(init_delayLess);
call COMPILE_FILE(init_filteredLoadout);

// Due to activateAddons being overwritten by eachother (only the last executed command will be active), we apply this bandaid
GVAR(addons) = call (uiNamespace getVariable [QGVAR(addons), {[]}]);
Expand Down
32 changes: 32 additions & 0 deletions addons/common/fnc_addLoadoutFilter.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_addLoadoutFilter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add blank lines between different header sections.

Description:
Add a filter for CBA_fnc_getUnitLoadout.
Parameters:
_function - The function you wish to execute. <CODE>
Passed Arguments:
_this <ARRAY>
0: _loadout - A getUnitLoadout array
Returns:
Nothing.
Examples:
Remove the radio from loadouts
(begin example)
[{
params ["_loadout"];
if ((_loadout select 9) select 2 == "ItemRadio") then {
(_loadout select 9) set [2, ""];
};
_loadout
}] call CBA_fnc_addLoadoutFilter;
(end)
Author:
SynixeBrett
---------------------------------------------------------------------------- */

params [["_function", {}, [{}]]];

if (_function isEqualTo {}) exitWith {-1};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove -1 and add nil at the end of file since header says function returns nothing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could return false, and true if it worked.


GVAR(loadoutFilters) pushBack [_function];
25 changes: 25 additions & 0 deletions addons/common/fnc_filterLoadout.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_filterLoadout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add blank lines between different header sections.

Description:
Used to filter a getUnitLoadout array.
Parameters:
_loadout - getUnitLoadout array <ARRAY>
Example:
(begin example)
_loadout = [getUnitLoadout player] call CBA_fnc_filterLoadout;
(end)
Returns:
filtered getUnitLoadout array <ARRAY>
Author:
SynixeBrett
---------------------------------------------------------------------------- */
SCRIPT(filterLoadout);

params [["_loadout", [], [[]]]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should handle receiving the different inputs (OBJECT, STRING, CONFIG) for the getUnitLoadout command as well as a normal loadout array.


{
_loadout = [_loadout] call _x;
} forEach GVAR(loadoutFilters);

_loadout
3 changes: 3 additions & 0 deletions addons/common/init_filteredLoadout.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

GVAR(loadoutFilters) = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this directly in XEH_preInit.sqf; one line does not need a separate file.