Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.10 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.  
  10.     //fall back to loop
  11.     while {true} do {scopeName "fallback";breakout"fallback";};
  12.  
  13.     //count the number of people on
  14.     if (isMultiplayer) then {
  15.         _playerCount = count playableUnits;
  16.     } else {
  17.         _playerCount = count switchableUnits;
  18.     };
  19.    
  20.     //don't be cruel to those 2 peeps on the server!
  21.     if (_playerCount <= 3) then {sleep 30; breakTo "fallback";};
  22.    
  23.     //pick the lucky basterd that's getting shot
  24.     if (isMultiplayer) then {
  25.         _unit = playableUnits select (floor (random (count playableUnits)));
  26.     } else {
  27.         _unit = switchableUnits select (floor (random (count switchableUnits)));
  28.     };
  29.     //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
  30.     if ((isNull _unit) || !(side _unit == WEST) || !(vehicle _unit == _unit)) then {sleep 10; breakTo "fallback";};
  31.    
  32.     _targetPos = getPos _unit;
  33.     //Aren't you shooting too close to base?
  34.     _noshooting = ["respawn_west","FOB_Martian","FOB_Marathon","FOB_Guardian","Dirt_Track","Dirt_Last_Stand","USS_Freedom"];
  35.     {
  36.         _TargetNearBaseLoc = _targetPos distance(getMarkerPos _x);
  37.         if (_TargetNearBaseLoc < 1000) then {sleep 5; breakTo "fallback";};
  38.     } forEach _noshooting;
  39.    
  40.     //Look what you're shooting dammit!
  41.     _dir = [_flatPos, _targetPos] call BIS_fnc_dirTo;
  42.     { _x setDir _dir; } forEach [priorityObj1, priorityObj2];
  43.  
  44.     //let's fire this baby
  45.     {
  46.         if (alive _x) then {
  47.             [_x,_targetPos] call AW_fnc_artyStrike;
  48.         };
  49.     } forEach [priorityObj1,priorityObj2];
  50.    
  51.     //let's put it to sleep so people don't get spammed
  52.     while {_sleeptimer < PARAMS_ArtilleryTargetTickTimeMin} do {
  53.     _timeToSleep = (PARAMS_ArtilleryTargetTickTimeMin/(5 + random 5));
  54.     _sleeptimer = _sleeptimer + _timeToSleep;
  55.     if (_sleeptimer > PARAMS_ArtilleryTargetTickTimeMax) exitwith {};
  56.     if ( !(canFire priorityObj1) || !(canFire priorityObj2) ) exitwith {breakOut "TargetingLoop";};
  57.     sleep _timeToSleep;
  58.     }; 
  59. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement