GREUH_platoonoverlay.sqf 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. platoon_icon1 = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
  2. platoon_icon2 = "\A3\ui_f\data\igui\cfg\cursors\board_ca.paa";
  3. soldier_icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa";
  4. formation_leader_icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa";
  5. commander_icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\general_gs.paa";
  6. group_leader_icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
  7. wounded_icon = "\A3\ui_f\data\map\vehicleicons\pictureHeal_ca.paa";
  8. nametags_distance = 32.0;
  9. private [ "_groups", "_unitstocount", "_totalx", "_totaly", "_totalz", "_alpha", "_textalpha", "_size", "_screenpos", "_grouppos", "_distlabel", "_dist", "_nextunit", "_color", "_drawicon", "_displayname", "_iconpos" ];
  10. waitUntil { !isNil "GRLIB_overlay_groups" };
  11. waitUntil { !isNil "GRLIB_nametag_units" };
  12. ["platoon_overlay", "onEachFrame", {
  13. if ( show_platoon ) then {
  14. {
  15. if ( count units _x > 0 ) then {
  16. _totalx = 0;
  17. _totaly = 0;
  18. _totalz = 0;
  19. _grouppos = [];
  20. _unitstocount = [];
  21. {
  22. if ( _x distance (leader group _x) < 300) then {
  23. _unitstocount pushback _x;
  24. _totalx = _totalx + (getpos _x select 0);
  25. _totaly = _totaly + (getpos _x select 1);
  26. _totalz = _totalz + (getpos _x select 2);
  27. };
  28. } foreach units _x;
  29. if ( count _unitstocount > 0 ) then {
  30. _totalx = _totalx / (count _unitstocount);
  31. _totaly = _totaly / (count _unitstocount);
  32. _totalz = _totalz / (count _unitstocount);
  33. };
  34. if ( _totalz > 2.1 ) then {
  35. _grouppos = [_totalx, _totaly, _totalz + 10];
  36. } else {
  37. _grouppos = [_totalx, _totaly, 2.1];
  38. };
  39. _alpha = 0.5;
  40. _textalpha = 0;
  41. _size = 0.8;
  42. _screenpos = worldToScreen _grouppos;
  43. if (count _screenpos != 0) then {
  44. if ( (abs (((worldToScreen _grouppos) select 0) - 0.5) < 0.06) && (abs (((worldToScreen _grouppos) select 1) - 0.5) < 0.08)) then {
  45. _alpha = 1;
  46. _textalpha = 1;
  47. _size = 1;
  48. };
  49. };
  50. _dist = player distance _grouppos;
  51. _distlabel = "";
  52. if ( _dist > 200 ) then {
  53. if ( _dist >= 1000 ) then {
  54. _distlabel = format [" (%1km)", floor (_dist / 1000)];
  55. } else {
  56. _distlabel = format [" (%1m)", (floor (_dist / 100)) * 100];
  57. };
  58. };
  59. _color = [0.8,1,0.2,_alpha];
  60. if ( _x == group player) then { _color = [1,0.9,0.3,_alpha] };
  61. drawIcon3D [platoon_icon1, _color, _grouppos, _size / 2, _size / 2,0, format ["%1 - %2%3",groupID _x, name (leader _x),_distlabel], 2, 0.03 * _textalpha, "puristaMedium"];
  62. drawIcon3D [platoon_icon2, _color, _grouppos, _size, _size,0, "", 2, 0.04, "puristaMedium"];
  63. };
  64. } foreach GRLIB_overlay_groups;
  65. };
  66. if ( show_nametags ) then {
  67. {
  68. _nextunit = _x;
  69. private _local_nametags_distance = nametags_distance;
  70. if( _nextunit == leader group player ) then {
  71. _local_nametags_distance = nametags_distance * 3;
  72. };
  73. _alpha = 1;
  74. if ( _nextunit distance player > (_local_nametags_distance / 2) ) then {
  75. _alpha = 1 - ((((_nextunit distance player) - (_local_nametags_distance / 2)) * 2) / _local_nametags_distance);
  76. };
  77. _color = [];
  78. if ( _nextunit in (units group player)) then {
  79. switch ( _nextunit getVariable [ "GRLIB_squad_color", "MAIN" ] ) do {
  80. case "BLUE" : { _color = [0.15,0.35,1.0,_alpha] };
  81. case "RED" : { _color = [0.8,0,0,_alpha] };
  82. case "YELLOW" : { _color = [0.85,0.85,0,_alpha] };
  83. case "GREEN" : { _color = [0,0.75,0,_alpha] };
  84. default { _color = [0.9,0.9,0.9,_alpha] };
  85. };
  86. } else {
  87. _color = [0.92,0.7,0.25,_alpha];
  88. };
  89. _drawicon = soldier_icon;
  90. if ( _nextunit getVariable [ "FAR_isUnconscious", 0 ] == 1 ) then {
  91. _drawicon = wounded_icon;
  92. } else {
  93. if ( _nextunit == [] call F_getCommander ) then {
  94. _drawicon = commander_icon;
  95. } else {
  96. if ( _nextunit == (leader group _nextunit) && (count (units group _nextunit) > 1 ) ) then {
  97. _drawicon = group_leader_icon;
  98. } else {
  99. if ( ( isFormationLeader _nextunit ) && ( count formationMembers _nextunit > 1 ) ) then {
  100. _drawicon = formation_leader_icon;
  101. };
  102. };
  103. };
  104. };
  105. _displayname = "";
  106. if(count (squadParams _nextunit) != 0) then {
  107. _displayname = "[" + ((squadParams _nextunit select 0) select 0) + "] ";
  108. };
  109. _displayname = _displayname + ( name _nextunit );
  110. _height = 2 + ((player distance _nextunit) / (0.75 * _local_nametags_distance));
  111. _iconpos = [ getPosATL _nextunit select 0, getPosATL _nextunit select 1, (getPosATL _nextunit select 2) + _height ];
  112. drawIcon3D [ _drawicon, _color, _iconpos , 0.75, 0.75,0, format [ "%1", _displayname] , 2, 0.032, "puristaMedium"];
  113. } foreach GRLIB_nametag_units;
  114. };
  115. }] call BIS_fnc_addStackedEventHandler;