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

Filtered Loadouts #1270

wants to merge 3 commits into from

Conversation

BrettMayson
Copy link
Contributor

When merged this pull request will:

private _loadout = [player] call CBA_fnc_getUnitLoadout; // Loadout with ItemRadio

private _handle = [{ 
    params ["_loadout", "_handle"]; 
    if ((_loadout select 9) select 2 == "ItemRadio") then { 
        (_loadout select 9) set [2, ""]; 
    }; 
    _loadout
}] call CBA_fnc_addLoadoutFilter;

_loadout = [_loadout] call CBA_fnc_filterLoadout; // Previous loadout with ItemRadio removed
_loadout = [player] call CBA_fnc_getUnitLoadout; // Loadout without ItemRadio

[_handle] call CBA_fnc_removeLoadoutFilter;

_loadout = [player] call CBA_fnc_getUnitLoadout; // Loadout with ItemRadio

@commy2
Copy link
Contributor

commy2 commented Dec 31, 2019

Explain the purpose of this in CBA in 500 words or less.

@BrettMayson
Copy link
Contributor Author

BrettMayson commented Jan 3, 2020

Filtered Loadouts: A Case For

Loadouts are an integral aspect of the Arma 3 gameplay, an aspect that players of any game mode are familiar. getUnitLoadout is a command many are familiar with due to its importance in persistent missions, loadout management, dynamic role selection, and overall utility. The inclusion in CBA would remedy the downfalls of current solutions and benefit the entire community. This implementation would be a small change for a lot of lasting good.

Persistent Missions

There are several communities and game modes that take advantage of persistence spanning multiple sessions. These missions rely on utilities like getUnitLoadout to get the information they need. Unfortunately, programmers can not prepare for every case, we are human. These persistent missions do not always have the proper protections and systems in place to properly handle ID'd items such as those found in the popular TFAR and ACRE modifications. This can pose a threat to stability when duplicate instances of items can be present in a single session. This threat to stability can be easily neutralized by the implementation of loadout filtering at save and load.

Loadout Management

Various popular modifications have implemented various forms of loadout management. Take ACE 3's ACE Arsenal, even such a well developed and managed community project suffers from the inability to properly handle ID'd items. Loadouts are saved, loaded, and exported with ID'd items causing potential instability and unexpected behavior. Filtered loadouts specified by mod makers could assure that these issues are avoided both during saving and loading, instantly resolving any previous issues as poisoned loadouts are repaired during load.

Dynamic Role Selection

Game modes that implement dynamic role selection may rely on user-generated or config loadouts. These loadouts can change over time introducing potential mission breaking changes. Imagine a mission based on inserting, retrieving an item, and extracting back to the start. This could be a potential issue as future loadouts or config changes by additional modifications could result in missions ending instantly if players receive a loadout containing the item they are intended to retrieve. While this scenario is less likely that the two previously discussed, it is still an element that will be improved by the addition of filtered loadouts.

Conclusion

Filtered loadouts may not be as sexy as weapon optics or face wear randomization in the eyes of everyone, but they provide another tool in the toolbox that creators can use to increase dependability, durability, persistence, permanence, perseverance, stableness, cohesion, constancy, stability, and functionality. The simplicity of implementation for creators compared to current solutions being created will allow these benefits to be realized with ease.

Arma has a rich community of creators, builders, and dreamers. Adding this utility to the already vast abilities of CBA would unlock more possibilities than this amazing project already has. It would be impossible to cover the potential of this amazing community in such a brief analysis.

Historically CBA has stood for stability, functionality, and user experience. Filtered loadouts stand for the same three principals. CBA should stand with filtered loadouts.

@mharis001
Copy link
Contributor

mharis001 commented Jan 3, 2020

This will definitely be a useful addition, however, I think this can be simplified to just two functions:

CBA_fnc_addLoadoutFilter

  • Adds a new loadout filter, simply just adds the given code to an array.
  • I don't think removal is needed or ever makes sense, but this could adopt the CBA_fnc_addClassEventHandler approach for that.

CBA_fnc_filterLoadout

  • Filters the given loadout by applying all loadout filters to it.
  • CBA_fnc_getUnitLoadout will not be needed because this function should handle receiving the different inputs for the getUnitLoadout command as well as a normal loadout array - OBJECT (unit), STRING (CfgVehicles class name), and CONFIG (loadout config).

@commy2
Copy link
Contributor

commy2 commented Jan 3, 2020

Totally agree with what mharis001 wrote.

Removal makes no sense (here and I argue in general). If you need to disable it on the fly, turn it off by condition in the filter script.

CBA_fnc_getUnitLoadout currently is just input validation for CBA_fnc_filterLoadout. CBA_fnc_filterLoadout should do its own validation (if even necessary for this!), get is not needed.

2 functions are enough.


Filtered loadouts may not be as sexy as weapon optics or face wear randomization in the eyes of everyone

lol nice dig

@jonpas
Copy link
Member

jonpas commented Jan 3, 2020

Let's just appreciate his post is exactly 500 words long. :D

@commy2
Copy link
Contributor

commy2 commented Jan 3, 2020

505 according to MS Word.

@jonpas
Copy link
Member

jonpas commented Jan 3, 2020

Don't count the title.

@dedmen
Copy link
Contributor

dedmen commented Jan 3, 2020

So in TFAR I iterate all BI Arsenal loadouts after you close arsenal, and remove the ID from TFAR radios,
Would this be essentially the same then? Would tihs automatically integrate with Arsenal or would I still need to do that myself?
I assume ACE Arsenal and BI Arsenal would need to implement this system into their loadout save/load code?
We know BI Arsenal will never do that, so who does that?
Or will TFAR/ACRE keep their loadout handlers the same but instead of patching directly, just invoke the CBA stuff?
Such that we end up with a dozen mods all doing that and calling the loadout filtering a dozen times?

@BrettMayson
Copy link
Contributor Author

I guess that could be added to CBA as part of this PR? Then that functionality would be part of every mod that would use this. That would potentially cause an issue though as mod defined filters should be used, but not mission defined filters

Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

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

What @mharis001 wrote.

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

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

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


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.

---------------------------------------------------------------------------- */
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.

@BrettMayson
Copy link
Contributor Author

Close in favour of #1503

@BrettMayson BrettMayson closed this Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filtered getUnitLoadout
5 participants