// Resource_Spawn.sqf: Used to randomally generate Airport, and Pier Sectors // Define Globals detailsPiers = []; detailsAirports = []; // Geo Center of Map _coordsMapCenter = [worldSize / 2, worldsize / 2, 0]; _searchRadius = (worldSize / 2); // Generate Airfield Sectors // Define arrays, populate with coords _airfieldsPrimary = []; _airfieldsSecondary = []; if (count allAirports > 0) then { private _first = getArray (configfile >> "CfgWorlds" >> worldname >> "ilsPosition"); _airfieldsPrimary pushbackunique _first; _sec = (configfile >> "CfgWorlds" >> worldname >> "SecondaryAirports"); for "_i" from 0 to (count _sec - 1) do { _airfieldsSecondary pushbackunique getarray ((_sec select _i) >> "ilsPosition"); }; }; _coordsAirports = _airfieldsPrimary + _airfieldsSecondary; _coordsAirportsSafe = []; // Proceed with generating Airport sectors IF there are actually Airports on the map if (count _coordsAirports > 0) then { // Loop through all Airport coords and assign a new coord X meters away at a safe pos { private _posAirportSafe = [_x, 75, 75, 0, 0, 1, 0] call BIS_fnc_findSafePos; _posAirportSafe = [(_posAirportSafe select 0), (_posAirportSafe select 1), 0]; _coordsAirportsSafe = _coordsAirportsSafe + [_posAirportSafe]; } forEach _coordsAirports; }; // Generate Pier Sectors // Define arrays, populate with coords _coordsPiers = []; { _coordsPiers append [[(position _x select 0),(position _x select 1),0]] } forEach nearestLocations [_coordsMapCenter, ["NameMarine"], _searchRadius]; _coordsRemainingPiers = _coordsPiers; _coordsPiersSectors = []; _coordsPiersSafe = []; // Transfer chosen coords to be used, into _coordsPiersSectors _amountAllowedPierSectors = [6,12] call BIS_fnc_randomInt; if !((count _coordsRemainingPiers) == 1) then { for [{ _i = 0 }, { _i < _amountAllowedPierSectors }, { _i = _i + 1 }] do { _tempCoord = _coordsRemainingPiers call BIS_fnc_selectRandom; if ((count _coordsRemainingPiers) > 1) then { _coordsRemainingPiers = _coordsRemainingPiers - [_tempCoord]; }; _coordsPiersSectors = _coordsPiersSectors + [_tempCoord]; }; }; // Proceed with generating Pier sectors IF there are actually NameMarines on the map if (count _coordsPiersSectors > 0) then { // Loop through all Pier coords and assign a new coord X meters away at a safe pos { private _posPierSafeBeach = [_x, 0, 1500, 0, 0, 1, 1] call BIS_fnc_findSafePos; private _posPierSafe = [_posPierSafeBeach, 0, 75, 0, 0, 1, 0] call BIS_fnc_findSafePos; _posPierSafe = [(_posPierSafe select 0), (_posPierSafe select 1), 0]; _coordsPiersSafe = _coordsPiersSafe + [_posPierSafe]; } forEach _coordsPiersSectors; } else { for [{ _i = 0 }, { _i < _amountAllowedPierSectors }, { _i = _i + 1 }] do { private _posPierSafeBeach = [[_searchRadius, _searchRadius, 0], 0, _searchRadius, 0, 0, 1, 1] call BIS_fnc_findSafePos; private _posPierSafe = [_posPierSafeBeach, 0, 25, 0, 0, 1, 0] call BIS_fnc_findSafePos; _posPierSafe = [(_posPierSafe select 0), (_posPierSafe select 1), 0]; _coordsPiersSafe = _coordsPiersSafe + [_posPierSafe]; }; }; // Set Default Sector Owner private _defaultOwner = 2; // Spawn Civilians //waituntil{DAC_NewZone == 0}; //[ _coordsMapCenter ,_searchRadius,_searchRadius,0,0, ["triggerDAC_Sector_CIVILIANS_WORLD",[10,0,0],[75,1,75,10],[50,1,50,10],[],[15,1,5],[3,3,3,0,0]] ] call DAC_fNewZone; //waituntil{DAC_NewZone == 0}; // Generate all Airport Sectors private _sectorAirportCounter = 1; { // Define radius of sector _distance = 200; // Generate sector owner active DAC Zone, generate inactive for all other sides _sectorCoords = [(_x select 0), (_x select 1), 0]; // Create Sector & Set Variables _sector = (createGroup sideLogic) createUnit ["ModuleSector_F",_sectorCoords,[],0,"NONE"]; _areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_sectorCoords,[],0,"NONE"]; _sector synchronizeObjectsAdd [_areaLogic]; //Sector settings _sector setVariable ["CostAir","1"]; _sector setVariable ["CostInfantry","1"]; _sector setVariable ["CostPlayers","1"]; _sector setVariable ["CostTracked","1"]; _sector setVariable ["CostWater","1"]; _sector setVariable ["CostWheeled","1"]; _sector setVariable ["DefaultOwner",_defaultOwner]; _sector setVariable ["Designation"," "]; _sector setvariable ["OnOwnerChange","[_this select 0, _this select 1, _this select 2, 2] execVM 'scripts\AEGIS\Random\Sector_Icons.sqf'"]; _sector setVariable ["Name"," "]; _sector setVariable ["OwnerLimit","1"]; _sector setVariable ["ScoreReward","0"]; _sector setVariable ["sides",[east,west,resistance]]; // Initialize Sector [_sector] call BIS_fnc_moduleSector; waitUntil { !isNil { _sector getVariable ["finalized",nil] } && { !( _sector getVariable ["finalized",true] ) } }; _sectorAirportCounter = _sectorAirportCounter + 1; // Append generated markers, coords, and areas _sectorTrigger = (_sector getVariable "areas") select 0; detailsAirports append [[(_sectorTrigger getVariable "markers") select 1, _sectorCoords, _distance]]; } forEach _coordsAirportsSafe; // Generate all Pier Sectors { // Define radius of sector _distance = 200; // Generate sector owner active DAC Zone, generate inactive for all other sides _sectorCoords = [(_x select 0), (_x select 1), 0]; // Create Sector & Set Variables _sector = (createGroup sideLogic) createUnit ["ModuleSector_F",_sectorCoords,[],0,"NONE"]; _areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_sectorCoords,[],0,"NONE"]; _sector synchronizeObjectsAdd [_areaLogic]; //Sector settings _sector setVariable ["CostAir","1"]; _sector setVariable ["CostInfantry","1"]; _sector setVariable ["CostPlayers","1"]; _sector setVariable ["CostTracked","1"]; _sector setVariable ["CostWater","1"]; _sector setVariable ["CostWheeled","1"]; _sector setVariable ["DefaultOwner",_defaultOwner]; _sector setVariable ["Designation"," "]; _sector setvariable ["OnOwnerChange","[_this select 0, _this select 1, _this select 2, 3] execVM 'scripts\AEGIS\Random\Sector_Icons.sqf'"]; _sector setVariable ["Name"," "]; _sector setVariable ["OwnerLimit","1"]; _sector setVariable ["ScoreReward","0"]; _sector setVariable ["sides",[east,west,resistance]]; // Initialize Sector [_sector] call BIS_fnc_moduleSector; waitUntil { !isNil { _sector getVariable ["finalized",nil] } && { !( _sector getVariable ["finalized",true] ) } }; // Append generated markers, coords, and areas _sectorTrigger = (_sector getVariable "areas") select 0; detailsPiers append [[(_sectorTrigger getVariable "markers") select 1, _sectorCoords, _distance]]; } forEach _coordsPiersSafe;