Advertisement
Thatguy5532

Untitled

May 25th, 2023
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.98 KB | None | 0 0
  1. span class="re5"> params ["_trigger", "_marker"];
  2. private ["_aiLimit", "_garrisonLimit", "_vehLimit", "_houses", "_unitArr", "_vehArr", "_unitObjs", "_infSquadSize", "_garSquadSize"];
  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. _infSquadSize = 5;
  17. _garSquadSize = 3;
  18.  
  19. // Get units to spawn according to awareness
  20. if (TRA_enemyAwareness <= 100) then {
  21.     _unitArr = TRA_sectorDefendersInf get "high";
  22.     _vehArr = TRA_sectorDefendersVeh get "high";
  23. };
  24.  
  25. if (TRA_enemyAwareness <= 60) then {
  26.     _unitArr = TRA_sectorDefendersInf get "medium";
  27.     _vehArr = TRA_sectorDefendersVeh get "medium";
  28. };
  29.  
  30. if (TRA_enemyAwareness <= 30) then {
  31.     _unitArr = TRA_sectorDefendersInf get "low";
  32.     _vehArr = TRA_sectorDefendersVeh get "low";
  33. };
  34.  
  35. diag_log format["[TRA] Infantry Limit: %1", _aiLimit];
  36.  
  37. for "_i" from 1 to round(_aiLimit / _infSquadSize) do {
  38.     _group = createGroup TRA_enemySide;
  39.     _squadPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  40.  
  41.     [_unitObjs, _group, _unitArr, _squadPos] spawn {
  42.         params ["_unitObjs", "_group", "_unitArr", "_squadPos"];
  43.         for "_j" from 1 to 5 do {
  44.             _unitObjs pushback (_group createUnit [selectRandom _unitArr, _squadPos, [], 0, "FORM"]);
  45.             sleep (((abs(50 - diag_fps) / (50 - 20))^2) * 2);
  46.         };
  47.         [_group, _squadPos, TRA_milCaptureRadius / 2] call lambs_wp_fnc_taskPatrol;
  48.     };
  49. };
  50.  
  51. for "_i" from 1 to round(_garrisonLimit / _garSquadSize) do {
  52.     _group = createGroup TRA_enemySide;
  53.     _squadPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  54.  
  55.     [_unitObjs, _group, _unitArr, _squadPos] spawn {
  56.         params ["_unitObjs", "_group", "_unitArr", "_squadPos"];
  57.         for "_j" from 1 to 3 do {
  58.             _unitObjs pushback (_group createUnit [selectRandom _unitArr, _squadPos, [], 0, "FORM"]);
  59.             sleep (((abs(50 - diag_fps) / (50 - 20))^2) * 2);
  60.         };
  61.         [_group, _squadPos, TRA_milCaptureRadius / 2] call lambs_wp_fnc_taskGarrison;
  62.     };
  63. };
  64.  
  65. for "_i" from 1 to _vehLimit do {
  66.     _spawnPos = (getMarkerPos _marker) getPos [random TRA_milCaptureRadius, random 360];
  67.     _spawnPos = _spawnPos findEmptyPosition [10, 100];
  68.     [_spawnPos, _vehArr, _unitObjs] spawn {
  69.         params ["_spawnPos", "_vehArr", "_unitObjs"];
  70.         _veh = ([_spawnPos, random 360, selectRandom _vehArr, TRA_enemySide] call BIS_fnc_spawnVehicle);
  71.         _unitObjs append (crew (_veh select 0));
  72.         _unitObjs pushback (_veh select 0);
  73.  
  74.         [_veh select 0, _spawnPos, TRA_milCaptureRadius] call lambs_wp_fnc_taskPatrol;
  75.     };
  76.     sleep (((abs(50 - diag_fps) / (50 - 20))^2) * 2);
  77. };
  78.  
  79. _trigger setVariable [format["%1%2", _marker, "_units"], _unitObjs, true];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement