Advertisement
Guest User

Enhanced flares v2 with flare rockets

a guest
Oct 23rd, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.02 KB | None | 0 0
  1.  
  2.  
  3. flareHoverHeight = 3;
  4.  
  5. createRocketFlare = {
  6.     sleep 0.65;
  7.     [_this, 0, 0] spawn createRocketFlareSub;
  8.     sleep 0.8;
  9.     [_this, 90, 10] spawn createRocketFlareSub;
  10.     [_this, -90, 10] spawn createRocketFlareSub;
  11.     [_this, 0, 0] spawn createRocketFlareSub;
  12.     sleep 0.8;
  13.     [_this, 90, 15] spawn createRocketFlareSub;
  14.     [_this, -90, 15] spawn createRocketFlareSub;
  15.     [_this, 0, 0] spawn createRocketFlareSub;
  16.     sleep 0.8;
  17.     [_this, 90, 20] spawn createRocketFlareSub;
  18.     [_this, -90, 20] spawn createRocketFlareSub;
  19.     [_this, 0, 0] spawn createRocketFlareSub;
  20.     sleep 0.8;
  21.     [_this, 90, 20] spawn createRocketFlareSub;
  22.     [_this, -90, 20] spawn createRocketFlareSub;
  23.     [_this, 0, 0] spawn createRocketFlareSub;
  24.     sleep 0.8;
  25.     [_this, 90, 20] spawn createRocketFlareSub;
  26.     [_this, -90, 20] spawn createRocketFlareSub;
  27.     [_this, 0, 0] spawn createRocketFlareSub;
  28.     sleep 0.8;
  29.     [_this, 90, 20] spawn createRocketFlareSub;
  30.     [_this, -90, 20] spawn createRocketFlareSub;
  31.     [_this, 0, 0] spawn createRocketFlareSub;
  32. }
  33.  
  34.  
  35. createRocketFlareSub = {
  36.     _rocket = _this select 0;
  37.     _dirMod = _this select 1;
  38.     _speed = _this select 2;
  39.                 if(_speed == 0) then {
  40.                     _speed = 0.001;
  41.                 };
  42.                 _pos = position _rocket;
  43.                 _rDir = vectorDir _rocket;
  44.                 _rUp = vectorUp _rocket;
  45.                 _stone1="F_40mm_White" createVehicleLocal(_pos);  
  46.                 _stone1 setVectorDirAndUp [_rDir, _rUp];
  47.                 _vel = (velocity _rocket) vectorMultiply 0.5;
  48.                 _dir = direction _rocket + _dirMod;
  49.                 _stone1 setVelocity [
  50.                     (sin _dir * _speed),
  51.                     (cos _dir * _speed),
  52.                     (_vel select 2) + 30
  53.                 ];
  54.                 sleep 10;
  55.                 _stone2="F_40mm_White" createVehicleLocal(_pos);  
  56.                 _stone2 setVectorDirAndUp [_rDir, _rUp];
  57.                 _stone2 setVelocity [
  58.                     (sin _dir * _speed),
  59.                     (cos _dir * _speed),
  60.                     (_vel select 2) + 30
  61.                 ];
  62.                 sleep 5;
  63.                
  64.                 deleteVehicle _stone1;
  65.  
  66. };
  67.  
  68. flarePossible = ["F_40mm_Red", "F_40mm_White", "F_40mm_Green", "F_40mm_Yellow", "R_PG32V_F", "R_TBG32V_F"];
  69.  
  70.  
  71. flareClusterFunction = {
  72.     [_this, [-20, 0, 0]] spawn flareClusterSubFunction;
  73.     [_this, [20, 0, 0]] spawn flareClusterSubFunction;
  74.     [_this, [0, 20, 0]] spawn flareClusterSubFunction;
  75.     [_this, [0, -20, 0]] spawn flareClusterSubFunction;
  76. };
  77.  
  78. flareClusterSubFunction = {
  79.     _flare = _this select 0;
  80.     _light = (typeOf _flare) createVehicle (position _flare vectorAdd (_this select 1));
  81.     _light setVelocity (velocity _flare);
  82.     _light setVectorDirAndUp [vectorDir _flare, vectorUp _flare];
  83.    
  84.     sleep 3;
  85.     _light remoteExec ["flareHoverFunction", 0];
  86. };
  87.  
  88. flareHoverFunction = {
  89.     _start = time;
  90.     if(((getPosATL _this) select 2) < flareHoverHeight) then {
  91.         _this setPosATL ( getPosATL _this vectorAdd [0,0, flareHoverHeight]);
  92.         _this enableSimulation false;
  93.         sleep 22;
  94.         deleteVehicle _this;
  95.     }else {
  96.         waitUntil {((getPosATL _this) select 2) < flareHoverHeight};
  97.         _delay = 25 - (time - _start);
  98.         _this enableSimulation false;
  99.         sleep _delay;
  100.         deleteVehicle _this;
  101.     }
  102.    
  103. };
  104.  
  105.  
  106. flareFunction = {
  107.                 if(typeOf _this == "R_PG32V_F" || typeOf _this == "R_TBG32V_F") then {
  108.                     _this call createRocketFlare;
  109.                 }else {
  110.                     sleep 0.2;
  111.                     _this spawn flareClusterFunction;
  112.                     sleep 3;
  113.                     _this remoteExec ["flareHoverFunction", 0];
  114.                 };
  115.                
  116. };
  117.  
  118. {
  119.  _x addEventHandler ["Fired", {
  120.     if((typeOf (_this select 6)) in flarePossible) then {
  121.             (_this select 6) spawn flareFunction;
  122.     }
  123.    
  124. }];
  125.  
  126. } forEach allUnits;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement