Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.46 KB | None | 0 0
  1. while { canFire priorityObj1 || canFire priorityObj2 } do {
  2.     scopeName "TargetingLoop";
  3.    
  4.     //reset some stuff
  5.     _sleeptimer = 0;
  6.     _unit = objNull;
  7.     _targetPos = [0,0,0];
  8.     _playerCount = 1;
  9.     _failsleep = 0;
  10.     //Quartermaster_4 sideChat "debug";
  11.    
  12.     //fall back to loop
  13.     while {true} do {scopeName "fallback"; Quartermaster_4 sideChat "starting to sleep"; sleep _failsleep; Quartermaster_4 sideChat "slept"; breakto"TargetingLoop";};
  14.     Quartermaster_4 sideChat "broken out of fallback";
  15.  
  16.     //count the number of people on
  17.     if (isMultiplayer) then {
  18.         _playerCount = count playableUnits;
  19.     } else {
  20.         _playerCount = count switchableUnits;
  21.     };
  22.    
  23.     //don't be cruel to those 2 peeps on the server!
  24.     if (_playerCount <= 0) then {_failsleep = 30; breakTo "fallback";};
  25.     Quartermaster_4 sideChat "enough players";
  26.    
  27.    
  28.     //pick the lucky basterd that's getting shot
  29.     if (isMultiplayer) then {
  30.         _unit = playableUnits select (floor (random (count playableUnits)));
  31.     } else {
  32.         _unit = switchableUnits select (floor (random (count switchableUnits)));
  33.     };
  34.     Quartermaster_4 sideChat "selected a random unit";
  35.  
  36.     //just checking if what we're shooting at is: blufor, not in a vehicle and not nothing.  If any of those is not true go back and try again
  37.     if ((isNull _unit) || !(side _unit == WEST) || !(vehicle _unit == _unit)) then {_failsleep = 10; breakTo "fallback";};
  38.  
  39.     _targetPos = getPos _unit;
  40.    
  41.     //Aren't you shooting too close to base?
  42.     _noshooting = ["respawn_west","FOB_neptune","USS_Freedom"];
  43.     {
  44.         _TargetNearBaseLoc = _targetPos distance(getMarkerPos _x);
  45.         if (_TargetNearBaseLoc < 1000) then {_failsleep = 5; Quartermaster_4 sideChat "too close to something"; breakTo "fallback";};
  46.     } forEach _noshooting;
  47.     Quartermaster_4 sideChat "start shooting at him";
  48.     //Look what you're shooting dammit!
  49.     _dir = [_flatPos, _targetPos] call BIS_fnc_dirTo;
  50.     { _x setDir _dir; } forEach [priorityObj1, priorityObj2];
  51.  
  52.     //let's fire this baby
  53.     {
  54.         if (alive _x) then {
  55.             [_x,_targetPos] call AW_fnc_artyStrike;
  56.         };
  57.     } forEach [priorityObj1,priorityObj2];
  58.    
  59.     //let's put it to sleep so people don't get spammed
  60.     while {_sleeptimer < PARAMS_ArtilleryTargetTickTimeMin} do {
  61.     _timeToSleep = (PARAMS_ArtilleryTargetTickTimeMin/(5 + random 5));
  62.     _sleeptimer = _sleeptimer + _timeToSleep;
  63.     if (_sleeptimer > PARAMS_ArtilleryTargetTickTimeMax) exitwith {};
  64.     if ( !(canFire priorityObj1) || !(canFire priorityObj2) ) exitwith {breakOut "TargetingLoop";};
  65.     sleep _timeToSleep;
  66.     }; 
  67. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement