A3-Conquest.Altis / scripts / AEGIS / Random / Sector_Icons.sqf
Sector_Icons.sqf
Raw
// Sector Icons.sqf: Used to chnage sector Icons upon owner change
// Inital Definitions
private _sector = _this select 0;
private _moduleOwnerSide = _this select 1;
private _modulePriorOwnerSide = _this select 2;
private _sectorType = _this select 3;

private _sectorTypeName = "Null";
private _markerSectorIconType = "Null";

if (_sectorType == 0) then {
	_sectorTypeName = "Minor";
	_markerSectorIconType = "o_installation"; // Minor Sector
};
if (_sectorType == 1) then {
	_sectorTypeName = "Major";
	_markerSectorIconType = "u_installation"; // Major Sector
};
if (_sectorType == 2) then {
	_sectorTypeName = "Airport";
	_markerSectorIconType = "c_plane"; // Airport Sector
};
if (_sectorType == 3) then {
	_sectorTypeName = "Pier";
	_markerSectorIconType = "loc_Quay"; // Pier Sector
};

private _distance = 200;
private _sectorPos = getPos _sector;

if ((_sectorType == 0) || (_sectorType == 1)) then {
	// Generate height & width for sector area
	private _coordX = _sectorPos;
	private _coordY = _sectorPos;

	// Fetch X Max
	while {(_coordX inArea nearestLocation [_coordX, ""]) == true} do { 
		_coordX = [(_coordX select 0) + 1, _coordX select 1, _coordX select 2]; 
		_coordX inArea nearestLocation [_coordX, ""]; 
	};
	 
	// Fetch Y Max
	while {(_coordY inArea nearestLocation [_coordY, ""]) == true} do { 
		_coordY = [_coordY select 0, (_coordY select 1) + 1, _coordY select 2]; 
		_coordY inArea nearestLocation [_coordY, ""]; 
	};

	// Calcuate 2D Squared Distance between orig coords and max X/Y
	_distance = _sectorPos distance2D [((_coordX select 0) - 1), ((_coordY select 1) - 1), 0];
	_distance = round _distance;

	// Due to DAC not generating waypoints in smaller sectors, set optimal minimum size
	if (_distance < 200) then {
		_distance = 200;
	};
};

// Set Sector Maker
 
	// Define Sector Size
	_sector setVariable ["size", _distance];
	[_sector, [], true, "area"] call BIS_fnc_moduleSector;

		// Define Marker Settings
		_sectorTrigger = (_sector getVariable "areas") select 0;
		_markerSectorArea = (_sectorTrigger getVariable "markers") select 0;
		_markerSectorArea setMarkerShape "ELLIPSE";
		_markerSectorArea setMarkerSize [_distance,_distance];
		_markerSectorArea setMarkerBrush "SolidBorder";
		_markerSectorArea setMarkerAlpha 0.5;
		
		_markerSectorIcon = (_sectorTrigger getVariable "markers") select 1;
		_markerSectorIcon setMarkerType _markerSectorIconType;
		if (_sectorType == 0) then {
			_markerSectorIcon setMarkerSize [0.75,0.75];
		};
		if (_sectorType == 1) then {
			_markerSectorIcon setMarkerSize [1,1];
		};
		if (_sectorType == 2) then {
			_markerSectorIcon setMarkerSize [0.65,0.65];
		};
		if (_sectorType == 3) then {
			_markerSectorIcon setMarkerSize [0.6,0.6];
		};

// Spawn DAC New Owner Units
if (Init_Finished == true) then {
	_scriptDACSpawns = [_sectorType, _distance, _markerSectorIcon, _sectorPos, _moduleOwnerSide, _modulePriorOwnerSide] execVM 'scripts\AEGIS\Random\Spawn_DAC.sqf';
	waitUntil { scriptDone _scriptDACSpawns };
};