A3-Conquest.Altis / init.sqf
init.sqf
Raw
#include "\a3\ui_f\hpp\defineresincldesign.inc"

// Database Settings
[] execVM "scripts\AEGIS\Database\initINIDBI2.sqf";

if (didJIP || hasInterface) then {
	// Executed when mission is started (before briefing screen)
	// AEGIS Briefing
	[] execVM "scripts\AEGIS\Credits.sqf";
	[] execVM "scripts\AEGIS\Briefing.sqf";

	// Earplugs Script
	if ((paramsArray select 37) == 1) then {
		addMissionEventHandler ["Loaded", {
			params ["_saveType"];
			
			If(_saveType isEqualto "continue") then{
				[] execVM "scripts\GF_Earplugs\GF_Earplugs.sqf";
			};
		}];

		[] execVM "scripts\GF_Earplugs\GF_Earplugs.sqf";
	};

	// Holster Script
	if ((paramsArray select 38) == 1) then {
		addMissionEventHandler ["Loaded", {
			params ["_saveType"];
			
			If(_saveType isEqualto "continue") then{
				[] execVM "GF_Holster\GF_Holster.sqf";
			};
		}];

		[] execVM "scripts\GF_Holster\GF_Holster.sqf";
	};

	// Sector Markers Handler
	addMissionEventHandler ["EachFrame", {
		if (not visibleMap) then {
			_nearbySectorMarkers = missionNamespace getVariable "RscMissionStatus_sectors3D";
			_display = uiNamespace getVariable "RscMissionStatus";

			{
				_slot = _display displayCtrl _x;
				_currentSectorMarkerTexture = (_nearbySectorMarkers select _forEachIndex) select 3;
				_slot ctrlSetText _currentSectorMarkerTexture;
			}forEach[
				IDC_RSCMISSIONSTATUS_SLOT1, 
				IDC_RSCMISSIONSTATUS_SLOT2, 
				IDC_RSCMISSIONSTATUS_SLOT3, 
				IDC_RSCMISSIONSTATUS_SLOT4, 
				IDC_RSCMISSIONSTATUS_SLOT5, 
				IDC_RSCMISSIONSTATUS_SLOT6, 
				IDC_RSCMISSIONSTATUS_SLOT7, 
				IDC_RSCMISSIONSTATUS_SLOT8, 
				IDC_RSCMISSIONSTATUS_SLOT9, 
				IDC_RSCMISSIONSTATUS_SLOT0
			];
		} else {
			uiNamespace setVariable ["_map",(findDisplay 12) displayCtrl 51];
			_markerInfo = ctrlMapMouseOver (uiNamespace getVariable '_map');
			if (((_markerInfo select 0) == 'marker') and (["BIS_fnc_moduleSector_area", (_markerInfo select 1)] call BIS_fnc_inString)) then {
				// Find Sector Icon Marker 
				_sectorAreaMarkerName = _markerInfo select 1;
				_sectorAreaMarkerSize = (getMarkerSize _sectorAreaMarkerName) select 0;
				_pos = getMarkerPos ((ctrlMapMouseOver (findDisplay 12 displayCtrl 51)) select 1);
				_mkrs = allMapMarkers apply {[str(_pos distance2D getMarkerPos _x < 1),_pos distance2D getMarkerPos _x,_x]};
				_mkrs sort true;
				_sectorMarker = { if ((_x select 0 == 'true') and (["BIS_fnc_moduleSector_iconBIS", (_x select 2)] call BIS_fnc_inString)) exitWith {_x} } forEach _mkrs;
				
				// Marker Information Variables
				_sectorMarkerName = _sectorMarker select 2;
				_sectorMarkerType = getMarkerType _sectorMarkerName;
				_sectorMarkerColor = getMarkerColor _sectorMarkerName;
				
				// Sector Hint Variables
				_sectorSide = "";
				_sectorType = "";
				_color = [0,0,0,1];
				
				// Calculate Position
				_sectorGrid = 'Grid: ' + (mapGridPosition _pos);

				// Due to DAC not generating waypoints in smaller sectors, set optimal minimum size
				if (_distance < 200) then {
					_distance = 200;
				};
				
				if (_sectorMarkerType == "o_installation") then {
					_sectorType = "Minor";
				};
				if (_sectorMarkerType == "u_installation") then {
					_sectorType = "Major";
				};
				if (_sectorMarkerType == "c_plane") then {
					_sectorType = "Airport";
				};
				if (_sectorMarkerType == "loc_Quay") then {
					_sectorType = "Pier";
				};
				
				if (_sectorMarkerColor == "ColorWEST") then {
					_color = '#004D99';
					_sectorSide = format ["<t align='right'><t color='%2'>%1</t></t>","BLUFOR",_color];
				};
				if (_sectorMarkerColor == "ColorEAST") then {
					_color = '#800000';
					_sectorSide = format ["<t align='right'><t color='%2'>%1</t></t>","OPFOR",_color];
				};
				if (_sectorMarkerColor == "ColorGUER") then {
					_color = '#008000';
					_sectorSide = format ["<t align='right'><t color='%2'>%1</t></t>","Independent",_color];
				};
				if (_sectorMarkerColor == "ColorCIV") then {
					_color = '#660080';
					_sectorSide = format ["<t align='right'><t color='%2'>%1</t></t>","Civilian",_color];
				};
				if (_sectorMarkerColor == "colorblack") then {
					_color = '#B39900';
					_sectorSide = format ["<t align='right'><t color='%2'>%1</t></t>","Contested",_color];
				};
				
				_sectorSize = 'Diameter: ' + str _sectorAreaMarkerSize + 'm';
				
				hintSilent parseText format [
					"<t align='left'><t size='2'>%1</t></t>%2<br/><br/><t align='left'>%3</t><t align='right'>%4</t><br/>",
					_sectorType,
					_sectorSide,
					_sectorSize,
					_sectorGrid
				];
			};
		};
	}];
	
	// Set Sector 3D HUD Icons
	addMissionEventHandler ["Draw3D", {
		_allSectorMarkers = allMapMarkers;
		_allHUDMarkers = (missionNamespace getVariable "RscMissionStatus_sectors3D");
		{
			_sector3DIcon = _x;
			_sector3DIconPos = _sector3DIcon select 1;
			_sectorMarkerType = { if ((["BIS_fnc_moduleSector_iconBIS", (_allSectorMarkers select _forEachIndex)] call BIS_fnc_inString) and ((getMarkerPos (_allSectorMarkers select _forEachIndex)) isEqualTo _sector3DIconPos)) exitWith {getMarkerType (_allSectorMarkers select _forEachIndex);}; } forEach _allSectorMarkers;
				
			if (_sectorMarkerType == "o_installation") then {
				_sector3DIcon set [3, "\A3\ui_f\data\map\markers\nato\o_installation.paa"];
			};
			if (_sectorMarkerType == "u_installation") then {
				_sector3DIcon set [3, "\A3\ui_f\data\map\markers\nato\u_installation.paa"];
			};
			if (_sectorMarkerType == "c_plane") then {
				_sector3DIcon set [3, "\A3\ui_f\data\map\markers\nato\c_plane.paa"];
			};
			if (_sectorMarkerType == "loc_Quay") then {
				_sector3DIcon set [3, "\A3\ui_f\data\map\mapcontrol\Quay_CA.paa"];
			};
			_allHUDMarkers set [_forEachIndex, _sector3DIcon];
			missionNamespace setVariable ["RscMissionStatus_sectors3D", _allHUDMarkers];
		} forEach _allHUDMarkers;
	}];
	
	// Clear Hints on Opening or Closing Map
	addMissionEventHandler ["Map", {
		params ["_isOpened","_isForced"];
		hintSilent ""; 
	}];
	
	// Unit Map Markers Script
	if ((paramsArray select 39) == 1) then {
		[] execVM "scripts\MapMarkers\QS_icons.sqf";
	};

	// AEGISUI Listener
	[player] spawn {

		disableSerialization;
		waitUntil {!(isNull (findDisplay 46))};
		_display = findDisplay 46;
		_display displayAddEventHandler["KeyDown", {
		params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];
		
		if(_key isEqualto 0x05) then {
			createDialog "AEGISUI";
		};
	  }];
	};
	systemchat " [ AEGIS ] Press '4' to use AEGIS UI";
};