Guest User

Untitled

a guest
May 7th, 2021
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.31 KB | None | 0 0
  1.  
  2. private _markerNames = ["Objective1", "Objective2"]; // change these to your marker names
  3. private _hasSpawned = [];
  4. { _hasSpawned pushBack false; } forEach _markerNames;
  5.  
  6. private _allEnemiesSpawned = false;
  7. while { not _allEnemiesSpawned } do {
  8.     _allEnemiesSpawned = true;
  9.  
  10.     {
  11.         if (not (_hasSpawned select _forEachIndex)) then {
  12.             // this marker has not yet spawned enemies, check if any players are inside marker
  13.             _allEnemiesSpawned = false;
  14.             private _markerName = _x;
  15.             private _index = _forEachIndex;
  16.             {
  17.                 if (_x inArea _markerName) exitWith {
  18.                     // a player is inside the marker
  19.                     // spawn the enemies on the other side of the marker from the player and move them to the marker center
  20.                     _hasSpawned set [_index, true];
  21.                     private _markerPos = markerPos _markerName;
  22.                     private _playerPos = getPos _x;
  23.                     private _playerDistance = _playerPos distance _markerPos;
  24.                     private _enemySpawnLocation = (_playerPos vectorFromTo _markerPos) vectorMultiply (_playerDistance * 2);
  25.                     _enemySpawnLocation set [2, 0];
  26.                     private _newGroup = [_enemySpawnLocation, east, 5] call BIS_fnc_spawnGroup;
  27.                     _newGroup move _markerPos;
  28.                 };
  29.             } forEach allPlayers;
  30.         };
  31.  
  32.         // wait 1 second between checking markers to reduce performance impact
  33.         sleep 1;
  34.     } forEach _markerNames;
  35. };
  36.  
Advertisement
Add Comment
Please, Sign In to add comment