Skip to content

Instantly share code, notes, and snippets.

@X39
Created April 29, 2016 14:59
Show Gist options
  • Save X39/42eddab99c71a488a410edc76d851cfc to your computer and use it in GitHub Desktop.
Save X39/42eddab99c71a488a410edc76d851cfc to your computer and use it in GitHub Desktop.
ArmA3 Draw Player Markers on HUD
if (!isNil "EH") then
{
removeMissionEventHandler ["Draw3D", EH];
};
EH = addMissionEventHandler ["Draw3D", {
_prefix = "_USER_DEFINED";
_prefixCount = count _prefix;
_cfgMarkers = configFile >> "CfgMarkers";
_cfgMarkerColors = configFile >> "CfgMarkerColors";
_FadeDistanceMax = [2000, 3000];
_FadeDistanceMin = [25, 10];
_overallAlpha = 1;
{
if (_x select [0, _prefixCount] == _prefix) then
{
_texture = getText (_cfgMarkers >> (markerType _x) >> "icon");
_color = getArray (_cfgMarkerColors >> markerColor _x >> "color");
_pos = markerPos _x;
_dstAlphaValue = player distance _pos;
if (_dstAlphaValue > _FadeDistanceMax select 0) then
{
_dstAlphaValue = ((_FadeDistanceMax select 1) - _dstAlphaValue) / ((_FadeDistanceMax select 1) - (_FadeDistanceMax select 0));
}
else
{
if(_dstAlphaValue < _FadeDistanceMin select 0) then
{
_dstAlphaValue = (_dstAlphaValue - (_FadeDistanceMin select 1)) / ((_FadeDistanceMin select 0) - (_FadeDistanceMin select 1));
}
else
{
_dstAlphaValue = 1;
};
};
_dstAlphaValue = _overallAlpha - (1 - _dstAlphaValue);
_color set [3, markerAlpha _x * _dstAlphaValue];
_color = _color apply {
if (typeName _x == "STRING") then
{
0 call compile _x
}
else
{
_x
}
};
_scale = markerSize _x;
_rotation = markerDir _x;
_text = markerText _x;
drawIcon3D [_texture, _color, _pos, _scale select 0, _scale select 1, _rotation, _text, 3];
};
false
} count AllMapMarkers;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment