zen-mod / ZEN

Zeus enhancement mod for Arma 3
https://zen-mod.github.io/ZEN
GNU General Public License v3.0
110 stars 49 forks source link

Feature Request: Selection of multiple sets of units/groups #503

Open freghar opened 3 years ago

freghar commented 3 years ago

Is your feature request related to a problem? When using Achilles, I had this custom module:


[
    "AI Behaviour",
    "[U] Reveal enemies",
    {
        private _revealed = [_this select 1];
        if (objNull in _revealed) then {
            _revealed = ["to-be-revealed units"] call Achilles_fnc_SelectUnits;
        };
        if (isNil "_revealed") exitWith {};
        private _informed_units = ["groups to be informed"] call Achilles_fnc_SelectUnits;
        if (isNil "_informed_units") exitWith {};
        private _informed = [];
        { _informed pushBackUnique group _x } forEach (_informed_units select { alive _x });
        [
            [_revealed, _informed],
            {
                params ["_revealed", "_informed"];
                {
                    private _toinform = _x;
                    {
                        _toinform reveal _x;
                    } forEach _revealed;
                } forEach _informed;
            }
        ] remoteExec ["call"];  /* reveal has local effect, see wiki */
    }
] call Ares_fnc_RegisterCustomModule;

The Achilles_fnc_SelectUnits worked by letting the user select units/groups, pressing Return to submit - this has been largely replaced by ZEN's CBA keybind that can bring up a context menu for multiple units/groups, but this lacks the ability to distinguish multiple sets of units/groups.

In my case, I need two selections - units/groups to be revealed and units/groups that the first set should be revealed to.

And I figured there are probably other use cases for these selections (ie. suppressive fire from multiple units onto multiple units) that it might be worth solving in ZEN directly, somehow.

Solution you'd like: The Achilles method is intuitive enough to use and fairly state-less, with Curator messages telling the user what the selections is for and audio feedback confirming the selection, it's fast to use in a chaotic situation.

If the Return keypress is an issue for blocking on the function call (due to KeyDown / KeyUp having different context), then an API similar to ZEN's fnc_selectPosition.sqf would be probably reasonable, even if that would break up the code a bit.

Alternatives you've considered: On the group level, since ZEN/curatorSelected preserves selection ordering, I could designate that the first selected group has special meaning or something like that, but that doesn't have much flexibility.

Kexanone commented 3 years ago

ZEN_editor_fnc_getSelection that will be introduced with #501 will be the replacement for Achilles_fnc_SelectUnits.

Edit: It returns the last selection before the module gets placed, so it can't be used for getting multiple selections.

freghar commented 3 years ago

In the end, I implemented this in my repo as https://github.com/freghar/arma-additions/commit/017a7af6fb9cdeacbc9f897ce2036714562204ff for both scheduled and unscheduled envs - not creating a PR here as it uses the Achilles way of selecting units (place module on ground, play some sound, select units, confirm via Return or cancel via Escape, play another sound depending on that) instead of what's proposed in #501, which seems like a different approach to this according to the video (an automatic way to apply the module function on multiple objects, individually).

Still leaving this open in case anybody wants to implement something similar in ZEN (perhaps using a different approach that is more ZEN-like).