Advertisement
Thatguy5532

Untitled

May 23rd, 2023
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.84 KB | None | 0 0
  1. span class="re5"> params ["_trigger", "_marker"];
  2. private ["_aiLimit", "_garrisonLimit", "_vehLimit", "_houses", "_unitArr", "_vehArr", "_unitObjs"];
  3.  
  4. diag_log format["[TRA] Activating Military Zone: %1", markerText _marker];
  5.  
  6. /* Total ai should be distributed equally among max amount of zones active */
  7. _aiLimit = round(TRA_maxAiActive / TRA_maxZonesActive);
  8. _garrisonLimit = round(TRA_percentGarrisoned * _aiLimit);
  9. _vehLimit = round(TRA_percentVehicle * _aiLimit);
  10.  
  11. /* Remove the ai that will become vehicles or be garrisoning from infantry limit */
  12. _aiLimit = _aiLimit - _garrisonLimit;
  13. _aiLimit = _aiLimit - _vehLimit;
  14.  
  15. _unitObjs = [];
  16.  
  17.  
  18. // Get units to spawn according to awareness
  19. if (TRA_enemyAwareness <= 100) then {
  20.     _unitArr = TRA_sectorDefendersInf get "high";
  21.     _vehArr = TRA_sectorDefendersVeh get "high";
  22. };
  23.  
  24. if (TRA_enemyAwareness <= 60) then {
  25.     _unitArr = TRA_sectorDefendersInf get "medium";
  26.     _vehArr = TRA_sectorDefendersVeh get "medium";
  27. };
  28.  
  29. if (TRA_enemyAwareness <= 30) then {
  30.     _unitArr = TRA_sectorDefendersInf get "low";
  31.     _vehArr = TRA_sectorDefendersVeh get "low";
  32. };
  33.  
  34. diag_log format["[TRA] Infantry Limit: %1", _aiLimit];
  35.  
  36. for "_i" from 1 to round(_aiLimit / 5) do {
  37.     _group = createGroup TRA_enemySide;
  38.     _squadPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  39.  
  40.     [_unitObjs, _group, _unitArr, _squadPos] spawn {
  41.         params ["_unitObjs", "_group", "_unitArr", "_squadPos"];
  42.         for "_j" from 1 to 5 do {
  43.             _unitObjs pushback (_group createUnit [selectRandom _unitArr, _squadPos, [], 0, "FORM"]);
  44.             sleep (((abs(50 - diag_fps) / (50 - 20))^2) * 2);
  45.         };
  46.         [_group, _squadPos, TRA_milCaptureRadius / 2] call lambs_wp_fnc_taskPatrol;
  47.     };
  48. };
  49.  
  50. for "_i" from 1 to round(_garrisonLimit / 3) do {
  51.     _group = createGroup TRA_enemySide;
  52.     _squadPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  53.  
  54.     [_unitObjs, _group, _unitArr, _squadPos] spawn {
  55.         params ["_unitObjs", "_group", "_unitArr", "_squadPos"];
  56.         for "_j" from 1 to 3 do {
  57.             _unitObjs pushback (_group createUnit [selectRandom _unitArr, _squadPos, [], 0, "FORM"]);
  58.             sleep (((abs(50 - diag_fps) / (50 - 20))^2) * 2);
  59.         };
  60.         [_group, _squadPos, TRA_milCaptureRadius / 2] call lambs_wp_fnc_taskGarrison;
  61.     };
  62. };
  63.  
  64. for "_i" from 1 to _vehLimit do {
  65.     _spawnPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  66.     _spawnPos = _spawnPos findEmptyPosition [10, 100];
  67.     [_spawnPos, _vehArr, _unitObjs] spawn {
  68.         params ["_spawnPos", "_vehArr", "_unitObjs"];
  69.         _veh = ([_spawnPos, random 360, selectRandom _vehArr, TRA_enemySide] call BIS_fnc_spawnVehicle);
  70.         _unitObjs append (crew (_veh select 0));
  71.         _unitObjs pushback (_veh select 0);
  72.  
  73.         [_veh select 0, _spawnPos, TRA_milCaptureRadius / 2] call lambs_wp_fnc_taskPatrol;
  74.     };
  75. };
  76.  
  77. _trigger setVariable [format["%1%2", _marker, "_units"], _unitObjs, true];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement