Continuing with addAction quirks, the 8th element in addAction params array is the condition statement. It has to return true in order for your custom action to show in action list. By default it always returns true. This condition is also evaluated every frame but there are certain rules to when it should be evaluated. You have to be closer than 15m to the object you added action to and you have to look at the object. If these 2 rules are met the condition script will run every frame for as long as you continue to look at the object and be close enough.

If you add an action to the player (yourself) you are obviously close enough to yourself and apparently are looking at yourself too, so condition is evaluated every frame all the time. Bear this in mind when adding action to player to avoid unnecessary CPU load. So nothing is new here, why is this useful?

This is huge in terms of its potential. You can arrange player interactions with surrounding objects at a very little cost. By simply adding specially crafted action to an object allows to execute scripts just when you are close enough to interact with objects and not before. For example you can create a trigger and attach it to an object and make it watch player, which is pretty good solution but not as efficient as using addAction. Of course you can just run while true loop with sleep and run nearObjects command with certain radius as a horrible horrible solution.

Other great feature that accompany this method is: Only one condition will be executed at any time, e.g. if you have 2 units close enough and looking at both only 1 unit’s action condition will be evaluated. I have constructed 2 simple scripts, one for player name tag showing over heads and another for doing the same for occupied vehicles. Both solutions, although maybe not the best looking, are extremely efficient.

So how such action needs to be constructed? For starters you can just fill first 7 params of addAction array with something, values don’t matter because we will never show the action anyway. Then for the 8th param, the code must return false to make sure the action doesn’t show, so the last line should always be false. Also note that while you can add action to many objects, in Arma 3 you cannot for example add action to animals. This is in fact intended.

Proof of concept #1 (Add tags to units):

{ _x setVariable ["tag", _x addAction ["", "", "", 0, false, false, "", " if (!alive _target) exitWith { _target removeAction (_target getVariable 'tag'); }; _dist = (_this distance _target) / 15; _color = getArray (configFile/'CfgInGameUI'/'SideColors'/call { if (playerSide getFriend side _target < 0.5) then [ {'colorEnemy'}, {'colorFriendly'} ] }); _color set [3, 1 - _dist]; drawIcon3D [ '', _color, [ visiblePosition _target select 0, visiblePosition _target select 1, (visiblePosition _target select 2) + ((_target modelToWorld ( _target selectionPosition 'head' )) select 2) + 0.4 + _dist / 1.5 ], 0, 0, 0, name _target, 2, 0.03, 'PuristaMedium' ]; false "]]; } forEach (allUnits - [player]);

Proof of concept #2 (Add tags to vehicles):

{ _x setVariable ["tag", _x addAction ["", "", "", 0, false, false, "", " if (!alive _target) exitWith { _target removeAction (_target getVariable 'tag'); }; if ( cameraView != 'EXTERNAL' && {_target == vehicle _this} ) exitWith {}; _crew = {alive _x} count crew _target; if (_crew == 0) exitWith {}; _color = getArray (configFile/'CfgInGameUI'/'SideColors'/call { if (side _target getFriend playerSide < 0.5) then [ {'colorEnemy'}, {'colorFriendly'} ] }); _color set [3, 1 - (_this distance _target) / 15]; drawIcon3D [ '', _color, [ visiblePosition _target select 0, visiblePosition _target select 1, (visiblePosition _target select 2) + (boundingBox _target select 1 select 2) * 1.5 ], 0, 0, 0, name (crew _target select 0) + ( if (_crew > 1) then [ {format [' + %1', _crew - 1]}, {''} ] ), 2, 0.04, 'PuristaMedium' ]; false "]]; } forEach vehicles;