Jump to content
Billy EatWorld

Any way to add actions to the Commanding Menus?

Recommended Posts

11 minutes ago, gc8 said:

I'm not sure... 

I saw that and found BIS_fnc_addCommMenuItem could be used to add actions to the "supports" menu.

What I'm really after though is a method to add actions to the default menu that pops up when a unit is selected. Looking to delete selected AI units and possibly more things as well.

Just wondering if these menus can be customised at all. Is BIS_fnc_addCommMenuItem  what I'm after?

This is the one I'm talking about - https://imgur.com/CI3acoR

 

Share this post


Link to post
Share on other sites

@Billy EatWorld https://community.bistudio.com/wiki/addAction

few more examples with different parameters..

 this AddAction ["<t color=""#4DB0E2"">" +"hello", "script.sqf"]   - color plus scipt

 this addAction [("<t color=""#51A55B"">" + ("hello") + "</t>"),"script.sqf",[],1,false,true,"","_this distance someobject < 5"]   - script plus distance of something named someobject

 

Share this post


Link to post
Share on other sites

addAction is not compatible with menus once units are selected.

You can try something like:
 

player addAction ["test", {
  params ["_tgt","_caller","_id"];
  MGI_tooLate = diag_tickTime;
  waitUntil {groupSelectedUnits _caller isNotEqualTo [] or diag_tickTime > MGI_tooLate +3};
  if (diag_tickTime > MGI_tooLate +3) exitWith {false};
  sleep 3;
  {_x setDammage 1} forEach groupSelectedUnits _caller;
}, [], 6, false, true, "", ""];

 

Probably not the best code but should work as far as you need to apply something on selected units with addAction, wherever the units are.

Share this post


Link to post
Share on other sites

@Billy EatWorld , The image you show (the RscGroupRootMenu) is not listed in the Description.ext , so you couldn't add anything to it from there.  Whether it could be patched by creating an addon, someone else would have to say.

 

But the "Supports" menu is customizable by using BIS_fnc_addCommMenuItem and BIS_fnc_removeCommMenuItem , and that can be used to add the sort of custom team management function you seek; maybe consider it as a "Team Communications" type of support and assign it the radio or instructor icons.

 

I looked into A2 Warfare to see how it provided the menus for a leader to "dismiss" selected units (actually kills them off though), or "send" selected units off to another team (reassigns their group).  In A3, one can build similar custom menus for that, and access it in the comms menu (under "Supports").

 

Below is an example, for a team-switch scenario.  Note: I found that the hardest thing about doing a Communication Menu is figuring out the use of the simple expressions, so that a particular menu item will appear or disappear, or is active or inactive, when you properly want it to do so, without relying on BIS_fnc_addCommMenuItem and BIS_fnc_removeCommMenuItem.  I'm not going to go into how simple expressions work, I'm just going to use the "IsLeader" expression to ensure that the group leader can see and use the menus, but a switchable subordinate (not the leader) can only see the menus, not use them.

 

Example:

Quote

- In Editor, place a group of four or more units.  Name the leader ASL, and name one of the subordinate units A1.
- Set A1 as the player unit, then set ASL as a playable unit.
- Place a single unit somewhere nearby.  Reassigned units will join on this unit (join his group).
- Name the single unit BSL, set it as playable

- Save the mission.

 

Find the mission folder, create a description.ext file inside it, and add this:
description.ext

Spoiler

class CfgCommunicationMenu
{
	class Menu_TeamComms
	{
		text = "Team Communications";
		submenu = "#USER:Menu_TeamComms";
		expression = "";
		icon = "\a3\Ui_f\data\GUI\Cfg\CommunicationMenu\call_ca.paa";
		cursor = "";
		enable = "1";
		removeAfterExpressionCall = 0;
	};
};

 

 

Then create an initPlayerLocal.sqf in the mission folder, and add this:
initPlayerLocal.sqf

Spoiler

// Define the "Team Communications" menu.  It will appear whenever Team Communications is selected in "Supports".
Menu_TeamComms = 
[
	["Team Communications",false],
	["Dismiss Selected (%SELECTED_UNIT_ID)",[2],"",-5,[["expression","_selectedUnits = GroupSelectedUnits player; ShowCommandingMenu ''; {[_x,1] remoteExec ['setDamage',2];} forEach _selectedUnits;"]],"1","IsLeader",-1],
	["Reassign Selected (%SELECTED_UNIT_ID)",[3],"",-5,[["expression","_selectedUnits = GroupSelectedUnits player; ShowCommandingMenu ''; {[[_x],(Group BSL)] remoteExec ['join',2];} forEach _selectedUnits;"]],"1","IsLeader",-1]
];

// Add the team communications menu to the "Supports" menu of each team switchable unit.
TeamCommsMenuID_ASL = [ASL,"Menu_TeamComms",nil,nil,""] call BIS_fnc_addCommMenuItem;
TeamCommsMenuID_BSL = [BSL,"Menu_TeamComms",nil,nil,""] call BIS_fnc_addCommMenuItem;
TeamCommsMenuID_A1 = [A1,"Menu_TeamComms",nil,nil,""] call BIS_fnc_addCommMenuItem;

 

 

Save the mission.  Launch, and play around with the support menu and the teamswitch function, to see how the menus respond between being leader and non-leader.

 

And if not satisfied with the "dismiss" and "reassign" action results, change the remoteExecs to something you'd prefer, maybe run a function instead.  Just remember that the code lies within an "expression" string, where you have to use semi-quotes ( ' ' ) instead of actual quotes ( " " ).

 

Hope this helps.

 

Edited by opusfmspol
- added links for simple expressions
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×