Advertisement
Daniel1357911

ARMA 3 Illuminating Flares Script

Jan 25th, 2020 (edited)
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 5.27 KB | None | 0 0
  1. /*
  2.  
  3. illuminatingFlares.sqf
  4. startFlares = 1; null = [<max distance>, <base delay>, <max added delay>, <base height>, <random added or subtracted height>, <color>, <speed (must be negative)>, <flareIntensity>, <flareRange>, <timeout>, <object pos>] execVM "illuminatingFlares.sqf";
  5.  
  6. A is the maximum distance each flare can spawn from the given position. The distance ranges from 0 meters to the number you supply.
  7.  
  8. B is the base number of seconds before a new flare can be spawned.
  9.  
  10. C is the maximum amount of more seconds randomly added to this delay.
  11.  
  12. D is the base height of each flare.
  13.  
  14. E is a maximum amount of meters that can be randomly added to or subtracted from the base height.
  15.  
  16. F is the color of the flare. Available colors are "WHITE", "RED", "GREEN", "YELLOW", or "IR". If you make this "RANDOM" each flare will be a random color.
  17.  
  18. G is the speed of the flare. Must be negative or flares will tend to freeze in the air.
  19.  
  20. H is the flare light intensity (If you set it too high, you will burn your eyes)
  21.  
  22. I will change the illuminated area. (Dont set it too high because it will cause problems)
  23.  
  24. J Time in seconds after which the flares disappears. Value 0 for never ending flares.
  25.  
  26. K is the object the flares will be centered around. The player for example.
  27.  
  28. null = [A, B, C, D, E, F, G, H, I, J, K] execVM "illuminatingFlares.sqf"
  29. Standard example: startFlares = 1; null = [150, 10, 5, 250, 10, "WHITE", -10, 50, 300, 0, player] execVM "illuminatingFlares.sqf";
  30. To stop the flares, replace 1 in startFlares = 1 with a different number. Example: startFlares = 0;
  31.  
  32. */
  33.  
  34. // declare a few variables we need and make _sign randomly negative
  35. _sign = 1;
  36. _random = false;
  37. if (floor random 10 > 4) then { _sign = -1 };
  38. _flareArray = ["WHITE", "RED", "GREEN", "YELLOW", "IR"];
  39.  
  40. // organize our arguments
  41. _flareDist = _this select 0;
  42. _delay = _this select 1;
  43. _delayRandom = _this select 2;
  44. _flareHeight = _this select 3;
  45. _flareHeightRandom = _this select 4;
  46. _flareType = _this select 5;
  47. _flareSpeed = _this select 6;
  48. _flareIntensity = _this select 7;
  49. _flareRange = _this select 8;
  50. _timeout = _this select 9;
  51. _flarePos = _this select 10;
  52.  
  53. // timeout
  54. if (_timeout != 0) then {
  55.     [_timeout] spawn {
  56.         scriptName "fn_moduleEffectsSmoke_timeoutLoop";
  57.         _timeout = _this select 0;
  58.  
  59.         sleep _timeout;
  60.         startFlares = 0;
  61.     };
  62. };
  63.  
  64. // create loop for spawning flares
  65. while { startFlares == 1 } do
  66. {
  67.         // check if random
  68.         if (_flareType == "RANDOM") then { _flareType = _flareArray call BIS_fnc_selectRandom; _random = true };
  69.         // assign flares
  70.         switch (_flareType) do
  71.         {
  72.                 case "WHITE":   { _flareType = "F_40mm_White" };
  73.                 case "RED":     { _flareType = "F_40mm_Red" };
  74.                 case "GREEN":   { _flareType = "F_40mm_Green" };
  75.                 case "YELLOW":  { _flareType = "F_40mm_Yellow" };
  76.                 //case "IR":      { _flareType = "F_40mm_CIR" };
  77.         };
  78.  
  79.         // get a random spot around the target
  80.         _pos = [_flarePos, random _flareDist, random 360] call BIS_fnc_relPos;
  81.         _pos = [_pos select 0, _pos select 1, _flareHeight + (random _flareHeightRandom * _sign)];
  82.         // make the flare at that spot
  83.         _flare = _flareType createVehicle _pos;
  84.         // set its speed
  85.         _flare setVelocity [0, 0, _flareSpeed];
  86.    
  87.     sleep 3;
  88.     _light = "#lightpoint" createVehicleLocal getPosVisual _flare;
  89.  
  90.     // Flare sounds
  91.     _flare spawn {
  92.        
  93.         //The sound of the flare starting to burn
  94.         playSound3D ["a3\missions_f_beta\data\sounds\Showcase_Night\flaregun_4.wss", _this, false, getPosVisual _this, 1, 1, 0];
  95.    
  96.         sleep 1;
  97.    
  98.         //The flare burning loop sound
  99.         while { !isNull _this } do {
  100.             _this say3D "SN_Flare_Loop";
  101.             sleep 4;
  102.         };
  103.    
  104.     };
  105.    
  106.     // light colors and ambient light colors for flares
  107.     if(_flaretype == "F_40mm_White") then { _light setLightAmbient [0.7,0.7,0.8] };
  108.     if(_flaretype == "F_40mm_Red") then { _light setLightAmbient [0.7,0.15,0.1] };
  109.     if(_flaretype == "F_40mm_Green") then { _light setLightAmbient [0.2,0.7,0.2] };
  110.     if(_flaretype == "F_40mm_Yellow") then { _light setLightAmbient [0.7,0.7,0] };
  111.  
  112.     if(_flaretype == "F_40mm_White") then { _light setLightColor [0.7,0.7,0.8] };
  113.     if(_flaretype == "F_40mm_Red") then { _light setLightColor [0.7,0.15,0.1] };
  114.     if(_flaretype == "F_40mm_Green") then { _light setLightColor [0.2,0.7,0.2] };
  115.     if(_flaretype == "F_40mm_Yellow") then { _light setLightColor [0.7,0.7,0] };
  116.  
  117.     _light setLightUseFlare true;
  118.     _light setLightFlareSize 10;
  119.     _light setLightFlareMaxDistance 2000;
  120.  
  121.     flare_range = _flareRange;
  122.     _light setLightAttenuation [/*start*/ flare_range, /*constant*/1, /*linear*/ 100, /*quadratic*/ 0, /*hardlimitstart*/50,/* hardlimitend*/span class="re5"> flare_range-10];
  123.     _light setLightDayLight true;
  124.  
  125.     flare_brightness = _flareIntensity;
  126.     _inter_flare = 0;
  127.  
  128.     while {!isNull _flare /*_inter_flare<21*/} do {
  129.         _int_mic = 0.05 + random 0.01;
  130.         sleep _int_mic;
  131.         _flare_brig = flare_brightness+random 10;
  132.         _light setLightIntensity _flare_brig;
  133.         _inter_flare = _inter_flare + _int_mic;
  134.         _light setpos (getPosVisual _flare);
  135.     };
  136.  
  137.         // delay plus random delay
  138.         sleep (_delay + random _delayRandom);
  139.         // reset random if it was there before
  140.         if (_random) then { _flareType = "RANDOM" };
  141.  
  142. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement