Posted on October 19, 2017 at 05:01 (GMT +00:00) by
Colin
Another Arma post, this time I'm posting my team tag SQF script. This script allows players to see friendlies up to max distance specified by definition. They are visible using the rank icon of the friendly, the colour is green down to red depending on health of the friendly.
The distance also affects the size of the icon based on max distance:
The code uses a function from my PX library which I have added it to the final source for easy implementation.
PX_fnc_LerpRGBA = {
params ["_from", "_to", "_t"];
_r = (_from select 0) + ((_to select 0) - (_from select 0)) * _t;
_g = (_from select 1) + ((_to select 1) - (_from select 1)) * _t;
_b = (_from select 2) + ((_to select 2) - (_from select 2)) * _t;
_a = (_from select 3) + ((_to select 3) - (_from select 3)) * _t;
[_r,_g,_b,_a];
};
if (hasInterface) then {
addMissionEventHandler ["EachFrame", {
{
private ["_offset", "_xdist", "_iconSize", "_colour", "_rankIcon", "_rankTitle", "_name"];
if (side _x == side player) then {
if (_x == vehicle _x) then {
_offset = ((_x modelToWorld (_x selectionPosition 'head')) select 2) + 0.4;
} else {
_offset = 1;
};
_dist = _x distance player;
_xdist = _dist / PX_TAGS_VIEW_DIST;
_colour = getArray (configFile/'CfgInGameUI'/'SideColors'/'colorFriendly');
_colour = [_colour, [255,0,0,1], damage _x] call PX_fnc_LerpRGBA;
_rankIcon = [_x, "texture"] call BIS_fnc_rankParams;
_iconSize = 1.0 - _xdist;
if ((cursorTarget == _x) && ([objNull, "VIEW", objNull] checkVisibility [eyePos player, eyePos _x] > 0)) then {
_rankTitle = [_x, "displayNameShort"] call BIS_fnc_rankParams;
_name = format["%1. %2", _rankTitle, name _x];
drawIcon3D [_rankIcon, _colour, [visiblePosition _x select 0, visiblePosition _x select 1, (visiblePosition _x select 2) + _offset], _iconSize, _iconSize, 45, _name, 2, 0.03, 'PuristaMedium'];
} else {
if (_dist < PX_TAGS_VIEW_DIST) then {
_colour set [3, 1.0 - _xdist];
drawIcon3D [_rankIcon, _colour, [visiblePosition _x select 0, visiblePosition _x select 1, (visiblePosition _x select 2) + _offset], _iconSize, _iconSize, 45, "", 2];
};
};
};
} count allUnits - [player];
}];
};
place the above code into a file "px_teamtags.sqf" and place it into a folder "PX/" inside your mission folder. Now open your init.sqf file and add the following:
Change the variable to the desired tag view distance and you're ready to load up the mission and enjoy. If you find this useful, please leave me a comment below, name of the mission you are using it and if you like drop a link to your server (if you have one).