Advertisement
Guest User

I&A airbaseDefense

a guest
Jun 26th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.17 KB | None | 0 0
  1. /*
  2. @filename: airbaseDefense.sqf
  3. Author:
  4.  
  5.     Quiksilver
  6.  
  7. Last modified:
  8.  
  9.     26/06/2017 by McKillen
  10.  
  11. Description:
  12.  
  13.     Spawns a friendly AA vehicle to protect the airbase from OPFOR air assets, for a short time.
  14.     Activated via a laptop addAction.
  15.    
  16.     Benefits of doing it this way = dont need an AI vehicle sitting there at all times eating server resources,
  17.     and hands over interactive control to players from server.
  18.  
  19. __________________________________________________________________________*/
  20.  
  21. private ["_loopTimeout","_activeTimer","_inactiveTimer","_airdefenseGroup","_defensePos"];
  22.  
  23. _loopTimeout = 10 + (random 10);
  24.  
  25. AIRBASEDEFENSE_SWITCH = false; publicVariable "AIRBASEDEFENSE_SWITCH";
  26.  
  27. while { true } do {
  28.  
  29.     if (AIRBASEDEFENSE_SWITCH) then {
  30.    
  31.         hqSideChat = "Air-defense activated."; publicVariable "hqSideChat"; [WEST,"HQ"] sideChat hqSideChat;
  32.  
  33.         //---------- Useful stuff
  34.  
  35.         _activeTimer = 300;                                     // How long will it remain active for, in seconds. 300 = 5 minutes
  36.         _inactiveTimer = 600;                                   // Shortest time between activations, in seconds. 900 = 15 minutes
  37.         _defensePos = getMarkerPos "airbaseDefense";
  38.         _airdefenseGroup = createGroup west;
  39.        
  40.         //---------- Spawn vehicles and attach them, adds crew and locks it so UAV op cannot control
  41.        
  42.     _truck = createVehicle ["B_Truck_01_mover_F", _defensePos, [],0,"NONE"];
  43.     _truck allowDamage false;
  44.     _truck setDir 0;
  45.     _AA = createVehicle ["B_AAA_System_01_F", _defensePos, [],0,"NONE"];
  46.     _AA allowDamage false;
  47.     _AA attachTo [_truck,[0,-2.9,1.5]];
  48.     _AA setDir 180;
  49.     createVehicleCrew _AA;
  50.     _truck setDir 135;
  51.     _truck lock 3;
  52.     _AA lock 3;
  53.    
  54.         //---------- Configure
  55.  
  56.         _airdefenseGroup setBehaviour "COMBAT";
  57.         _airdefenseGroup setCombatMode "RED";
  58.         sleep 0.1;
  59.  
  60.         //---------- Active time
  61.  
  62.         sleep _activeTimer;
  63.  
  64.         //---------- Delete after use
  65.  
  66.         { deleteVehicle _x } forEach [_AA,_truck];
  67.  
  68.         //---------- Cool-off period before next use
  69.  
  70.         sleep _inactiveTimer;
  71.         AIRBASEDEFENSE_SWITCH = false; publicVariable "AIRBASEDEFENSE_SWITCH";
  72.         hqSideChat = "Air-defense available."; publicVariable "hqSideChat"; [WEST,"HQ"] sideChat hqSideChat;
  73.        
  74.     };
  75.    
  76.     sleep _loopTimeout;
  77.    
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement