Advertisement
Guest User

BIS_fnc_EXP_camp_IFF

a guest
Jul 7th, 2016
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.96 KB | None | 0 0
  1. /*
  2.     Author: Thomas Ryan
  3.    
  4.     Description:
  5.     Simple handling of the Support Team's scripted IFF.
  6.     Must be executed locally.
  7.    
  8.     Notes:
  9.     - To always show the icon and name of a unit, use:  <unit> setVariable ["BIS_iconAlways", true]
  10.     - Otherwise, icons can be hidden with:              <unit> setVariable ["BIS_iconShow", false]
  11.     - And names can be hidden with:                     <unit> setVariable ["BIS_iconName", false]
  12.    
  13.     Parameters:
  14.         _this select 0: ARRAY - Array of Support Team units.
  15.         _this select 1: ARRAY - Array of RGB values used for the icon/text color.
  16.    
  17.     Returns:
  18.     True if successfully initialized, false if not.
  19. */
  20.  
  21. params [["_units", [], [[]]],["_iconColor",[0,125,255],[[]],3]];
  22.  
  23. if (isNil "BIS_iconUnits") then {
  24.     BIS_iconUnits = [];
  25. };
  26.  
  27. {
  28.     _x setVariable ["BIS_iconColor",_iconColor];
  29. }forEach _units;
  30.  
  31. BIS_iconUnits append _units;
  32.  
  33. // Display units
  34. {
  35.     private _unit = _x;
  36.     {if (isNil {_unit getVariable _x}) then {_unit setVariable [_x, true]}} forEach ["BIS_iconShow", "BIS_iconName"];
  37. } forEach BIS_iconUnits;
  38.  
  39. if (!(isNil "BIS_fakeTexture")) exitWith {
  40.     true
  41.     //Draw3D already exists, quitting.
  42. };
  43.  
  44. // Global icon variables
  45. BIS_fakeTexture = [1,1,1,0] call BIS_fnc_colorRGBAtoTexture;
  46. //BIS_iconColor = [0,125,255];
  47.  
  48. // Icon eventhandler
  49. addMissionEventHandler [
  50.     "Draw3D",
  51.     {
  52.         {
  53.             private _unit = _x;
  54.             private _showAlways = _unit getVariable ["BIS_iconAlways", false];
  55.             private _showIcon = _unit getVariable ["BIS_iconShow", false];
  56.             private _showName = _unit getVariable ["BIS_iconName", false];
  57.             private _iconColor = _unit getVariable ["BIS_iconColor",[0,125,255]];
  58.            
  59.             // Determine if icon should be shown
  60.             if (_showAlways || { _showIcon }) then {
  61.                 if (_showAlways || { vehicle player distance _unit < 300 }) then {
  62.                     // Calculate position
  63.                     private _pos = _unit selectionPosition "Spine3";
  64.                     _pos = _unit modelToWorldVisual _pos;
  65.                    
  66.                     // Draw hex icon
  67.                     drawIcon3D [
  68.                         "a3\ui_f\data\igui\cfg\cursors\select_ca.paa",
  69.                         _iconColor + [0.15],
  70.                         _pos,
  71.                         1,
  72.                         1,
  73.                         0
  74.                     ];
  75.                    
  76.                     if (_showAlways) then {
  77.                         // Draw arrow if icon goes out of the screen
  78.                         drawIcon3D [
  79.                             BIS_fakeTexture,
  80.                             _iconColor + [0.5],
  81.                             _pos,
  82.                             1,
  83.                             1,
  84.                             0,
  85.                             "",
  86.                             0,
  87.                             0.03, "PuristaLight", "center", // Redundant font params, required to make the arrow work
  88.                             true
  89.                         ];
  90.                     };
  91.                    
  92.                     if (
  93.                         // Icon is forced
  94.                         _showAlways
  95.                         ||
  96.                         {
  97.                             // Name is allowed
  98.                             _showName
  99.                             &&
  100.                             // Unit is highlighted
  101.                             { cursorTarget == vehicle _unit }
  102.                         }
  103.                     ) then {
  104.                         // Determine name
  105.                         private _name = name _unit;
  106.                        
  107.                         // Draw name
  108.                         drawIcon3D [
  109.                             BIS_fakeTexture,
  110.                             _iconColor + [0.5],
  111.                             _pos,
  112.                             1,
  113.                             -1.8,
  114.                             0,
  115.                             _name,
  116.                             0,
  117.                             0.025
  118.                         ];
  119.                     };
  120.                 };
  121.             };
  122.         } forEach BIS_iconUnits;
  123.     }
  124. ];
  125.  
  126. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement