ACE3/addons/switchunits/functions/fnc_markAiOnMap.sqf
2015-01-12 21:14:27 -08:00

67 lines
1.7 KiB
Plaintext

/*
Name: AGM_SwitchUnits_fnc_markAiOnMap
Author(s):
bux578
Description:
Creates markers for AI units for given sides
Marks players in a different color
Parameters:
0: OBJECT - side
Returns:
VOID
*/
#include "script_component.hpp"
private ["_sidesToShow"];
_sidesToShow = _this select 0;
_sidesToShow spawn {
private ["_sides", "_allMarkerNames"];
_sides = _this;
_allMarkerNames = [];
while { true } do {
sleep 1.5;
// delete markers
{
deleteMarkerLocal _x;
} forEach _allMarkerNames;
// create markers
{
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
private ["_markerName", "_marker", "_markerColor"];
//_markerName = format ["%1", [_x] call EFUNC(common,getName)];
_markerName = str _x;
_marker = createMarkerLocal [_markerName, position _x];
_markerName setMarkerTypeLocal "mil_triangle";
_markerName setMarkerShapeLocal "ICON";
_markerName setMarkerSizeLocal [0.5,0.7];
_markerName setMarkerDirLocal getDir _x;
// commy's one liner magic
_markerColor = format ["Color%1", side group _x];
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
_markerName setMarkerColorLocal "ColorOrange";
_markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName),""]);
} else {
_markerName setMarkerColorLocal _markerColor;
_markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName"));
};
_allMarkerNames pushBack _markerName;
};
} forEach allUnits;
};
};