JackFighter

S.O.G. PF Dynamic Ambient Script

Jul 12th, 2021 (edited)
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.94 KB | None | 0 0
  1. // S.O.G. Prairie Fire Dynamic Ambient Music script by JackFighter
  2. // Definition of tracks
  3. dayActionAmbient = [
  4.     "vn_contact",
  5.     "vn_time_to_leave",
  6.     "vn_imminent_attack",
  7.     "vn_hell_on_earth",
  8.     "vn_trippin",
  9.     "vn_drafted",
  10.     "vn_route9",
  11.     "vn_voodoo_girl",
  12.     "vn_tequila_highway",
  13.     "vn_there_it_is",
  14.     "vn_fire_in_the_sky"
  15. ];
  16.  
  17. dayCalmAmbient = [
  18.     "vn_prairie_fire",
  19.     "vn_calm_before_the_storm",
  20.     "vn_behind_enemy_lines",
  21.     "vn_prayer_for_the_fallen",
  22.     "vn_the_village",
  23.     "vn_deadly_jungle",
  24.     "vn_enemy_territory",
  25.     "vn_stealth_mode",
  26.     "vn_shadows_of_the_forest",
  27.     "vn_im_home",
  28.     "vn_another_life",
  29.     "vn_unsung_heroes",
  30.     "vn_blues_for_suzy",
  31.     "vn_kitty_bar_blues",
  32.     "vn_freedom_bird",
  33.     "vn_up_here_looking_down",
  34.     "vn_jungle_boots"
  35. ];
  36.  
  37. nightActionAmbient = [
  38.     "vn_contact",
  39.     "vn_time_to_leave",
  40.     "vn_imminent_attack",
  41.     "vn_hell_on_earth"
  42. ];
  43.  
  44. nightCalmAmbient = [
  45.     "vn_prairie_fire",
  46.     "vn_calm_before_the_storm",
  47.     "vn_behind_enemy_lines",
  48.     "vn_prayer_for_the_fallen",
  49.     "vn_the_village",
  50.     "vn_deadly_jungle",
  51.     "vn_enemy_territory",
  52.     "vn_stealth_mode",
  53.     "vn_shadows_of_the_forest",
  54.     "vn_im_home",
  55.     "vn_another_life"
  56. ];
  57.  
  58. //Script itself
  59. detectionBoolean = false;
  60. musicBooleanStop = false;
  61. addMusicEventHandler ["MusicStop", {musicBooleanStop = true}];
  62.  
  63. [] spawn {
  64. scopeName "checkingLoop";
  65. while {true} do
  66.     {
  67.         detectionBoolean = true;
  68.         _closestEnemy = player findNearestEnemy player;
  69.         _distanceToClosestEnemy = player distance2D _closestEnemy;
  70.         _enemyAwareness = opfor knowsAbout player; // <-------------------------------------------could be blufor, opfor or independent
  71.         if (_enemyAwareness > 3.95 and _distanceToClosestEnemy < 650) then {detectionBoolean = true;} else {detectionBoolean = false;};
  72.         sleep 0.5;
  73.     };
  74. };
  75.  
  76. [] spawn {
  77. scopeName "ambientLoop";
  78.     while {true} do {
  79.         _randomCalmDay = selectRandom dayCalmAmbient;
  80.         _randomCalmNight = selectRandom nightCalmAmbient;
  81.         _randomActionDay = selectRandom dayActionAmbient;
  82.         _randomActionNight = selectRandom nightActionAmbient;
  83.             3 fadeMusic 1;
  84.         if (dayTime < 19) then {playMusic _randomCalmDay;} else {playMusic _randomCalmNight;};
  85.         waitUntil {detectionBoolean isEqualTo true or musicBooleanStop isEqualTo true};
  86.         if (musicBooleanStop isEqualTo true) then {musicBooleanStop = false};
  87.         if (detectionBoolean isEqualTo true) then {
  88.             scopeName "actionLoop";
  89.             while {true} do {
  90.                 3 fadeMusic 1;
  91.                 if (dayTime < 19) then {playMusic _randomActionDay;} else {playMusic _randomActionNight;};
  92.                 sleep 4;
  93.                 waitUntil {detectionBoolean isEqualTo false or musicBooleanStop isEqualTo true};
  94.                 if (musicBooleanStop isEqualTo true) then {musicBooleanStop = false};              
  95.                 sleep 0.5;
  96.                     3 fadeMusic 0;
  97.                     sleep 3;
  98.                 _randomActionDay = selectRandom dayActionAmbient;
  99.                 _randomActionNight = selectRandom nightActionAmbient;
  100.                 if (detectionBoolean isEqualTo false) then {breakOut "ActionLoop";};
  101.             };
  102.             sleep 0.5;
  103.         };
  104.         sleep 0.5;
  105.     };
  106. };
Add Comment
Please, Sign In to add comment