Guest User

Team Map Intel (Group Only)

a guest
Apr 3rd, 2024
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.20 KB | None | 0 0
  1. SLT_fnc_RE_Server = {
  2. params["_arguments","_code"];
  3. _varName = ("SLT"+str (round random 10000));
  4.  
  5. TempCode = compile ("if(!isServer) exitWith{};_this call "+str _code+"; "+(_varName+" = nil;"));
  6. TempArgs = _arguments;
  7.  
  8. call compile (_varName +" = [TempArgs,TempCode];
  9. publicVariable '"+_varName+"';
  10.  
  11. [[], {
  12. ("+_varName+" select 0) spawn ("+_varName+" select 1);
  13. }] remoteExec ['spawn',2];");
  14. };
  15.  
  16. with uiNamespace do {SLTScriptDisplayName = "Team Map Icons";};
  17.  
  18. SLT_fnc_enableScript = {
  19. {
  20. [] spawn
  21. {
  22. if(!hasInterface) exitWith {};
  23. if (!isNil "TeamMapEvent") exitWith {};
  24. if(isMultiplayer) then {waitUntil{getClientState isEqualTo "BRIEFING READ"};};
  25. sleep 1;
  26. waitUntil {sleep 0.1; !((findDisplay 12 displayCtrl 51) isEqualTo controlNull)};
  27. disableMapIndicators [true,false,false,false];
  28.  
  29. with uiNamespace do
  30. {
  31. TMIMaxCursorRangeUnitMarker = 0.02;
  32. TMIMinMapZoomUnitMarker = 0.0010;
  33.  
  34. comment "[location,direction,isOnFoot,lifetime]";
  35. TMIAllMapTrails = [];
  36. TMITrailLifetime = 30;
  37. TMITrailDistance = 10;
  38. TMIMaxAlpha = 0.5;
  39. TMITrailSize = 1;
  40.  
  41. TMI_fnc_mapTrailTick = {
  42.  
  43. comment "Add new trails";
  44. private _unit = player;
  45.  
  46. private _lastTrailLocation = _unit getVariable "TMILastTrailLocation";
  47.  
  48. if (isNil "_lastTrailLocation") then
  49. {
  50. _unit setVariable ["TMILastTrailLocation",(_unit modelToWorldVisual [0,0,0])];
  51. _lastTrailLocation = (_unit modelToWorldVisual [0,0,0]);
  52. };
  53.  
  54. private _currentLocation = (_unit modelToWorldVisual [0,0,0]);
  55. private _dist = _lastTrailLocation distance2D _currentLocation;
  56.  
  57. if (_dist >= TMITrailDistance) then
  58. {
  59. TMIAllMapTrails pushBack [_lastTrailLocation,getdir _unit,vehicle _unit isEqualTo _unit,TMITrailLifetime];
  60. _unit setVariable ["TMILastTrailLocation",_currentLocation];
  61. };
  62.  
  63. private _updatedTrails = TMIAllMapTrails;
  64. {
  65. private _location = _x select 0;
  66. private _direction = _x select 1;
  67. private _isOnFoot = _x select 2;
  68. private _timeLeft = _x select 3;
  69.  
  70. comment "Update trails data";
  71. _updatedTrails set [_forEachIndex,[_location,_direction,_isOnFoot,_timeleft-diag_deltaTime]];
  72. if (_timeLeft <= 0) then {_updatedTrails deleteAt _forEachIndex;};
  73. } foreach TMIAllMapTrails;
  74.  
  75. TMIAllMapTrails = _updatedTrails;
  76. };
  77.  
  78. TMI_fnc_mapTrailDraw = {
  79. {
  80. private _location = _x select 0;
  81. private _direction = _x select 1;
  82. private _isOnFoot = _x select 2;
  83. private _timeLeft = _x select 3;
  84. private _alpha = linearConversion [0, 1, (_timeLeft/TMITrailLifetime), 0, TMIMaxAlpha, true];
  85. private _color = [1,1,1,_alpha];
  86. private _scale = 6.4 * worldSize / 8192 * ctrlMapScale (findDisplay 12 displayCtrl 51);
  87. private _size = (TMITrailSize) / _scale;
  88. private _iconFile = if (_isOnFoot)
  89. then {"\a3\ui_f\data\igui\cfg\simpletasks\types\walk_ca.paa"}
  90. else {"\a3\ui_f_curator\data\cfgcurator\entity_selected_ca.paa"};
  91.  
  92. (findDisplay 12 displayCtrl 51) drawIcon
  93. [
  94. _iconFile,
  95. _color,
  96. _location,
  97. _size,
  98. _size,
  99. _direction-10,
  100. "",
  101. 0
  102. ];
  103. } foreach TMIAllMapTrails;
  104. };
  105. };
  106.  
  107. TeamMapMissionEvent = addMissionEventHandler ["EachFrame",{
  108. with uiNamespace do {call TMI_fnc_mapTrailTick;};
  109. }];
  110.  
  111. TeamMapEvent = (findDisplay 12 displayCtrl 51) ctrlAddEventHandler ["Draw",
  112. {
  113. _vehicleList = [];
  114. {
  115. if((side group _x) isEqualTo (side group player) && (group _x isEqualTo group player)) then
  116. {
  117. _pos = _x modelToWorldVisual [0,0,0];
  118. _driver = if (driver vehicle _x isEqualTo objNull) then {effectiveCommander vehicle _x} else {driver vehicle _x};
  119. _dir = getDir _x;
  120. _text = (name _x);
  121. _textSize = 0.05;
  122. _font = "RobotoCondensedBold";
  123. _distance = player distance _x;
  124. _iconFile = "\A3\ui_f\data\Map\VehicleIcons\iconManVirtual_ca.paa";
  125. _iconSize = 21;
  126. _vehicleIconSize = 21;
  127.  
  128. comment "Dead";
  129. _deadIcon = "\A3\ui_f\data\igui\cfg\revive\overlayicons\d100_ca.paa";
  130. _deadColor = [0.25,0.25,0.25,0.75];
  131.  
  132. comment "Incap";
  133. _incapIcon = "\A3\ui_f\data\igui\cfg\revive\overlayicons\u100_ca.paa";
  134. _incapColor = [0.75,0.15,0.15,1];
  135.  
  136. comment "Mic";
  137. _micIcon = "\a3\ui_f\data\IGUI\RscIngameUI\RscDisplayVoiceChat\microphone_ca.paa";
  138.  
  139. _alpha = 1;
  140. _color = switch (side group _x) do
  141. {
  142. case west: {[0,0.3,0.6,_alpha]};
  143. case east: {[0.5,0,0,_alpha]};
  144. case independent: {[0,0.5,0,_alpha]};
  145. case civilian: {[0.4,0,0.5,_alpha]};
  146. default {[1,1,1,_alpha]};
  147. };
  148.  
  149. if((group player) isEqualTo (group _driver)) then
  150. {
  151. _color = switch (side group _x) do
  152. {
  153. case west: {[0,0.45,1,_alpha]};
  154. case east: {[0.8,0.35,0,_alpha]};
  155. case independent: {[0.34,0.75,0,_alpha]};
  156. case civilian: {[0.7,0,0.75,_alpha]};
  157. default {[1,1,1,_alpha]};
  158. };
  159. };
  160.  
  161. if (lifeState _driver isEqualTo "INCAPACITATED" && damage _driver > 0.4) then
  162. {
  163. _color = _incapColor;
  164. _iconFile = _incapIcon;
  165. _dir = 0;
  166. _iconSize = 25;
  167. };
  168.  
  169. if (!alive _driver) then
  170. {
  171. _color = _deadColor;
  172. _iconFile = _deadIcon;
  173. _dir = 0;
  174. _iconSize = 25;
  175. };
  176.  
  177. if !(getPlayerChannel _driver isEqualTo -1) then
  178. {
  179. _iconFile = _micIcon;
  180. _dir = 0;
  181. };
  182.  
  183. _pos2D = (_this select 0) ctrlMapWorldToScreen _pos;
  184. _posCursor2D = getMousePosition;
  185. _dist = _pos2D distance2D _posCursor2D;
  186. _scale = ctrlMapScale (_this select 0);
  187.  
  188. if (vehicle _x == _x) then
  189. {
  190. if((_scale > (uiNamespace getVariable "TMIMinMapZoomUnitMarker")) && (_dist > (uiNamespace getVariable "TMIMaxCursorRangeUnitMarker"))) then {_text = "";};
  191.  
  192. _this select 0 drawIcon
  193. [
  194. _iconFile,
  195. _color,
  196. _pos,
  197. _iconSize,
  198. _iconSize,
  199. _dir,
  200. _text,
  201. 2,
  202. _textSize,
  203. _font,
  204. "left"
  205. ];
  206.  
  207. _this select 0 drawIcon
  208. [
  209. _iconFile,
  210. _color,
  211. _pos,
  212. _iconSize,
  213. _iconSize,
  214. _dir,
  215. _text,
  216. 1,
  217. _textSize,
  218. _font,
  219. "left"
  220. ];
  221. }
  222. else
  223. {
  224. if !((vehicle _x) in _vehicleList) then
  225. {
  226. _vehicleList pushback vehicle _x;
  227.  
  228. _dir = getDir vehicle _x;
  229.  
  230. _className = (typeOf vehicle _x);
  231. _iconFile = getText (configfile >> "CfgVehicles" >> _className >> "icon");
  232.  
  233. _vehName = getText (configfile >> "CfgVehicles" >> _className >> "displayName");
  234. _text = _vehName;
  235.  
  236. _text2 = "";
  237. _count = count crew vehicle _x;
  238. if(_count > 1) then
  239. {
  240. _text2 = ((name _driver) + " + " + (str (_count-1)) + " more");
  241. }
  242. else
  243. {
  244. _text2 = (name _driver);
  245. };
  246.  
  247. if((_scale > (uiNamespace getVariable "TMIMinMapZoomUnitMarker")) && (_dist > (uiNamespace getVariable "TMIMaxCursorRangeUnitMarker"))) then {_text = ""; _text2 = "";};
  248.  
  249. _this select 0 drawIcon
  250. [
  251. _iconFile,
  252. _color,
  253. _pos,
  254. _vehicleIconSize,
  255. _vehicleIconSize,
  256. _dir,
  257. _text,
  258. 2,
  259. _textSize,
  260. _font,
  261. "left"
  262. ];
  263.  
  264. _this select 0 drawIcon
  265. [
  266. _iconFile,
  267. _color,
  268. _pos,
  269. _vehicleIconSize,
  270. _vehicleIconSize,
  271. _dir,
  272. _text,
  273. 1,
  274. _textSize,
  275. _font,
  276. "left"
  277. ];
  278.  
  279. _this select 0 drawIcon
  280. [
  281. _iconFile,
  282. _color,
  283. _pos,
  284. _vehicleIconSize,
  285. _vehicleIconSize,
  286. _dir,
  287. _text2,
  288. 1,
  289. _textSize,
  290. _font,
  291. "right"
  292. ];
  293.  
  294. _this select 0 drawIcon
  295. [
  296. _iconFile,
  297. _color,
  298. _pos,
  299. _vehicleIconSize,
  300. _vehicleIconSize,
  301. _dir,
  302. _text2,
  303. 2,
  304. _textSize,
  305. _font,
  306. "right"
  307. ];
  308. };
  309. };
  310.  
  311. if(_x == player) then
  312. {
  313. _color set[3,0.5];
  314. _draw = {
  315. _this select 0 drawIcon
  316. [
  317. "\a3\ui_f\data\Map\groupIcons\selector_selected_ca.paa",
  318. _color,
  319. _pos,
  320. 32,
  321. 32,
  322. _dir,
  323. "",
  324. 0,
  325. 0.05,
  326. _font,
  327. "left"
  328. ];
  329. };
  330. [_this select 0] call _draw;
  331. [_this select 0] call _draw;
  332. };
  333. };
  334. } foreach (if (count allPlayers isEqualTo 1) then {allUnits+allDeadMen} else {allPlayers});
  335.  
  336. with uiNamespace do {call TMI_fnc_mapTrailDraw;};
  337. }];
  338. };
  339. } remoteExec ["BIS_fnc_call",0,"TeamMapIcons"];
  340. };
  341.  
  342. SLT_fnc_disableScript = {
  343. {} remoteExec ['BIS_fnc_call',0,'TeamMapIcons'];
  344. {
  345. (findDisplay 12 displayCtrl 51) ctrlRemoveEventHandler ['Draw',TeamMapEvent];
  346. removeMissionEventHandler ['EachFrame',TeamMapMissionEvent];
  347. TeamMapEvent = nil;
  348. TeamMapMissionEvent = nil;
  349. } remoteExec ['BIS_fnc_call',0];
  350. };
  351.  
  352. SLT_fnc_init = {
  353. params[["_useToggleOptions",true]];
  354.  
  355. with uiNamespace do {
  356.  
  357. createDialog "RscDisplayEmpty";
  358. private _display = findDisplay -1;
  359. {_x ctrlShow false;} foreach allControls _display;
  360.  
  361. private _ctrlHeader = _display ctrlCreate ["RscStructuredText",-1];
  362. _ctrlHeader ctrlSetPosition [0.396875 * safezoneW + safezoneX,0.445 * safezoneH + safezoneY,0.20625 * safezoneW,0.022 * safezoneH];
  363. _ctrlHeader ctrlSetBackgroundColor [1,0.7,0,0.66];
  364. _ctrlHeader ctrlSetStructuredText parseText ("<t size='0.85' font='PuristaMedium'>"+toUpper SLTScriptDisplayName+"</t>");
  365. _ctrlHeader ctrlCommit 0;
  366.  
  367. private _ctrlBorder = _display ctrlCreate ["RscPicture",-1];
  368. _ctrlBorder ctrlSetPosition [0.396875 * safezoneW + safezoneX,0.467 * safezoneH + safezoneY,0.20625 * safezoneW,0.077 * safezoneH];
  369. _ctrlBorder ctrlSetText "#(rgb,1,1,1)color(1,1,1,1)";
  370. _ctrlBorder ctrlSetTextColor [0,0,0,0.5];
  371. _ctrlBorder ctrlCommit 0;
  372.  
  373. private _ctrlBackground = _display ctrlCreate ["RscPicture",-1];
  374. _ctrlBackground ctrlSetPosition [0.402031 * safezoneW + safezoneX,0.478 * safezoneH + safezoneY,0.195937 * safezoneW,0.055 * safezoneH];
  375. _ctrlBackground ctrlSetText "#(rgb,1,1,1)color(1,1,1,1)";
  376. _ctrlBackground ctrlSetTextColor [0.1,0.1,0.1,0.75];
  377. _ctrlBackground ctrlCommit 0;
  378.  
  379. SLTEnableButton = _display ctrlCreate ["RscButtonMenu",-1];
  380. SLTEnableButton ctrlSetPosition [0.407187 * safezoneW + safezoneX,0.489 * safezoneH + safezoneY,0.0928125 * safezoneW,0.033 * safezoneH];
  381. SLTEnableButton ctrlSetText "ENABLE";
  382. SLTEnableButton ctrlCommit 0;
  383. SLTEnableButton ctrlAddEventHandler ["ButtonClick",{
  384. [[],missionNamespace getVariable "SLT_fnc_enableScript"] call (missionNamespace getVariable "SLT_fnc_RE_Server");
  385. closeDialog 0;
  386. }];
  387.  
  388. SLTDisableButton = _display ctrlCreate ["RscButtonMenu",-1];
  389. SLTDisableButton ctrlSetPosition [0.5 * safezoneW + safezoneX,0.489 * safezoneH + safezoneY,0.0928125 * safezoneW,0.033 * safezoneH];
  390. SLTDisableButton ctrlSetText "DISABLE";
  391. SLTDisableButton ctrlCommit 0;
  392. SLTDisableButton ctrlAddEventHandler ["ButtonClick",{
  393. [[],missionNamespace getVariable "SLT_fnc_disableScript"] call (missionNamespace getVariable "SLT_fnc_RE_Server");
  394. closeDialog 0;
  395. }];
  396.  
  397. if (!_useToggleOptions) then
  398. {
  399. SLTEnableButton ctrlSetText "ARE YOU SURE?";
  400. SLTEnableButton ctrlSetTooltip "This script cannot be disabled!";
  401. SLTEnableButton ctrlCommit 0;
  402.  
  403. SLTDisableButton ctrlSetText "CANCEL";
  404. SLTDisableButton ctrlCommit 0;
  405. };
  406. };
  407. deleteVehicle this;
  408. };
  409.  
  410. if (time < 1) then
  411. {
  412. [] spawn SLT_fnc_enableScript;
  413. }
  414. else
  415. {
  416. [true] call SLT_fnc_init;
  417. };
Advertisement
Add Comment
Please, Sign In to add comment