Advertisement
bejiitas_wrath

AI Garrison function.

Aug 16th, 2018
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. BIS_CP_enemyGrp_rifleSquad = configFile >> "CfgGroups" >> "East" >> "LOP_AM_OPF" >> "Infantry" >> "LOP_AM_OPF_Rifle_squad";
  2.  
  3. BIS_CP_enemyTroops = [];
  4. {
  5.     BIS_CP_enemyTroops pushBack getText (_x >> "vehicle");
  6. } forEach ("TRUE" configClasses BIS_CP_enemyGrp_rifleSquad);
  7.  
  8. sleep 2;
  9.  
  10. BIS_CP_targetLocationPos = _this select 0;
  11. BIS_CP_radius_insertion = _this select 1;
  12.  
  13. _allBuildings = BIS_CP_targetLocationPos nearObjects ["House", BIS_CP_radius_insertion];
  14. _allUsableBuildings = _allBuildings select {count (_x buildingPos -1) > 5};
  15. _allUsableBuildings_cnt = count _allUsableBuildings;
  16. _unusedBuildings = +_allUsableBuildings;
  17.  
  18. for [{_i = 1}, {_i <= ceil (_allUsableBuildings_cnt / 2) && _i <= (190 * 300)}, {_i = _i + 1}] do {
  19.     _building = selectRandom _unusedBuildings;
  20.     _unusedBuildings = _unusedBuildings - [_building];
  21.     if (_building distance BIS_CP_targetLocationPos > 2) then {
  22.         _building setVariable ["BIS_occupied", TRUE];
  23.         _buldingPosArr = _building buildingPos -1;
  24.         _newGrp = createGroup EAST;
  25.         _unitsCnt = ceil random 23;
  26.         _emptyBuildingPosArr = [];
  27.         {_emptyBuildingPosArr pushBack _forEachIndex} forEach _buldingPosArr;
  28.         for [{_j = 1}, {_j <= _unitsCnt}, {_j = _j + 1}] do {
  29.             _buildingPosID = selectRandom _emptyBuildingPosArr;
  30.             //_emptyBuildingPosArr = _emptyBuildingPosArr - [_buildingPosID];
  31.             _buildingPos = _buldingPosArr select _buildingPosID;
  32.             _newUnit = _newGrp createUnit [selectRandom BIS_CP_enemyTroops, _buildingPos, [], 0, "NONE"];
  33.             _newUnit setPosATL _buildingPos;
  34.             _newUnit setUnitPos "AUTO";
  35.             _newUnit disableai "PATH";
  36.         };
  37.     //hint format ["%1 occupied by %2", getText (configFile >> "CfgVehicles" >> typeOf _building >> "displayName"), groupId _newGrp];
  38.     };
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement