Advertisement
Guest User

tpw_soap.sqf working sound

a guest
Feb 11th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.52 KB | None | 0 0
  1. /*
  2. TPW SOAP - SOnic Ambience Project
  3. Author: tpw, autigergrad
  4. Date: 20180128
  5. Version: 1.25
  6. Requires: CBA A3, tpw_core.sqf, tpw_ambience.pbo, tpw_sounds.pbo
  7. Compatibility: SP, MP client
  8.  
  9. Disclaimer: Feel free to use and modify this code, on the proviso that you post back changes and improvements so that everyone can benefit from them, and acknowledge the original author (tpw) in any derivative works.
  10.  
  11. To use:
  12. 1 - Save this script into your mission directory as eg tpw_soap.sqf
  13. 2 - Call it with 0 = [1,1,1,1,1,0,0,0,12] execvm "tpw_soap.sqf";
  14.  
  15. 1 = ambient sounds volume (0-2)
  16. 1 = music volume (0-2)
  17. 1 = Azan volume (0-2)
  18. 1 = house FX volume (0-2)
  19. 1 = scream volume (0-2)
  20. 0 = number of user music files in @TPW_MODS\music (0-20)
  21. 0 = number of user sound files in @TPW_MODS\sounds (0-20)
  22. 0 = region (0 = autoselect Greek/Fijian sounds on Greek/Fijian maps (1 = force Greek, 2 = force Mid East, 3 = force Fijian, 4 = force French, 5= force Russian))
  23. 12 = traffic volume (0= no traffic, 20 = very loud)
  24. THIS SCRIPT WON'T RUN ON DEDICATED SERVERS.
  25. */
  26.  
  27. if (isDedicated) exitWith {};
  28. WaitUntil {!isNull FindDisplay 46};
  29. if (count _this < 9) exitwith {hint "TPW soap incorrect/no config, exiting."};
  30.  
  31. // READ IN CONFIGURATION VALUES
  32. tpw_soap_version = "1.25"; // Version string
  33. tpw_soap_ambientvolume = _this select 0; // Ambient sounds volume
  34. tpw_soap_musicvolume = _this select 1; // Music volume
  35. tpw_soap_azanvolume = _this select 2; // Azan volume
  36. tpw_soap_housefxvolume = _this select 3; // House fx volume
  37. tpw_soap_screamvolume = _this select 4; // Screams volume
  38.  
  39. tpw_soap_usermusic = _this select 5; // Number of user supplied songs
  40. tpw_soap_usersounds = _this select 6; // Number of user supplied sounds
  41. tpw_soap_region = _this select 7; // 0 = autodetect 1 = Greece, 2 = Mideast, 3 = Fiji, 4 = France, 5 = Russia, 6 = all
  42. tpw_soap_trafficmult = _this select 8; // 0 = no traffic, 20 = very loud
  43.  
  44. // OTHER VARS
  45. tpw_soap_active = true; // Global enable/disabled
  46. tpw_soap_radius = 50; // Distance around player to spawn ambience into houses
  47. tpw_soap_attenuation = 100; // Distance over which sound fades out
  48. tpw_soap_greeksoundlength = [60,48,87,73,61,88,87,65,72,56,72,49,69,64,85,62,76]; // Length (sec) of each ambience clip in the order of the config
  49. tpw_soap_greeksonglength = [69,187,165,149,153,181,240,194,175]; // Length (sec) of each song in the order of the config
  50. tpw_soap_mideastsoundlength = [52,64,23,32,28,40,81,9,15,81,64,63,59,97,101,90,66,21,52,30,30,140]; // Length (sec) of each ambience clip in the order of the config
  51. tpw_soap_mideastsonglength = [19,180,180,180,180,180,180,276,329,133,120]; // Length (sec) of each song in the order of the config
  52. tpw_soap_fijisoundlength = [60,70,50,50,20,30,25,20,15,25,15,10,35,45,45,55,30,45,50,45,60,35,25,20,25]; // Length (sec) of each ambience clip in the order of the config
  53. tpw_soap_francesoundlength = [61,62,63,64,65,66,67,68,69,60,61,62,63,64,65,66,67,68,69,60,61,62,63,64,65,66,67,68,69];// Length (sec) of each ambience clip in the order of the config
  54. tpw_soap_francesonglength = [180,180,180,180,180,180,180,180,180,180,180,180];// Length (sec) of each song in the order of the config
  55. tpw_soap_fijisonglength = [220,180,40,120,120,130,150,110,80,180,180]; // Length (sec) of each song in the order of the config
  56. tpw_soap_russiasoundlength = [61,62,63,64,65,66,67,68,69,60,61,62,63,64,65,66,67,68,69,60,61,62,63,64,65,66,67,68,69];// Length (sec) of each ambience clip in the order of the config
  57. tpw_soap_russiasonglength = [180,180,180,180,180,180,180,180];// Length (sec) of each song in the order of the config
  58. tpw_soap_azanlength = [223,149,128,184,173,159,120,133,120,112];// Length (sec) of each Azan in the config
  59. tpw_soap_constructionlength = [60,35,90,120,80,75,100,180,80,80,80,70,50]; // Length (sec) of each construction noise
  60. tpw_soap_songsplaying = 0; // How many songs
  61. tpw_soap_maxsongs = 4; // Maximum simultaneous songs allowed
  62. tpw_soap_soundsplaying = 0; // How many songs
  63. tpw_soap_maxsounds = 12; // Maximum simultaneous sounds allowed
  64. tpw_soap_dead = 0; // initial number of deaths
  65. tpw_soap_nearhouses = []; // initial number of nearby buildings
  66. tpw_soap_volume = 1; // Master volume
  67. tpw_soap_constructionplaying = 0; // construction noises
  68.  
  69.  
  70. // SUNRISE AND SUNSET
  71. _riseset = [] call BIS_fnc_sunriseSunsetTime;
  72. tpw_soap_sunrise = _riseset select 0;
  73. tpw_soap_sunset = _riseset select 1;
  74.  
  75. // AUTO DETECT REGION
  76. if (tpw_soap_region == 0) then
  77. {
  78. // Default to Polyglot
  79. tpw_soap_region = 6;
  80.  
  81. // Greece
  82. if (tolower worldname in ["altis","stratis","bozcaada"]) then
  83. {
  84. tpw_soap_region = 1;
  85. };
  86.  
  87. // Mideast
  88. if (tolower worldname in [
  89. "mcn_aliabad",
  90. "bmfayshkhabur",
  91. "clafghan",
  92. "fata",
  93. "hellskitchen",
  94. "hellskitchens",
  95. "mcn_hazarkot",
  96. "praa_av",
  97. "reshmaan",
  98. "shapur_baf",
  99. "takistan",
  100. "torabora",
  101. "tup_qom",
  102. "zargabad",
  103. "pja306",
  104. "tunba",
  105. "mountains_acr",
  106. "kunduz",
  107. "pja310",
  108. "pja308",
  109. "tropica",
  110. "pja307",
  111. "wgl_palms",
  112. "fallujah",
  113. "dya",
  114. "kidal",
  115. "pja319",
  116. "lythium",
  117. "huntersvalley"
  118. ]) then
  119. {
  120. tpw_soap_region = 2
  121. };
  122.  
  123. // Tropical / Pacific / African
  124. if (tolower worldname in
  125. ["tanoa",
  126. "mak_jungle",
  127. "pja305",
  128. "tigeria",
  129. "tigeria_se",
  130. "plr_mana",
  131. "sara",
  132. "saralite",
  133. "sara_dbe1",
  134. "porto",
  135. "intro",
  136. "pja312",
  137. "tanoa",
  138. "bsoc_brasil",
  139. "lingor3",
  140. "isladuala3",
  141. "dingor",
  142. "prei_khmaoch_luong",
  143. "us101_cao_bang",
  144. "dakrong",
  145. "uns_dong_ha",
  146. "rungsat",
  147. "csj_sea",
  148. "csj_lowlands",
  149. "phu_bai",
  150. "uns_ptv",
  151. "rockwall"
  152. ]) then
  153. {
  154. tpw_soap_region = 3;
  155. };
  156.  
  157. // France
  158. if (tolower worldname in ["malden","tembelan"]) then
  159. {
  160. tpw_soap_region = 4;
  161. };
  162.  
  163. // Eastern Europe
  164. if (tolower worldname in [
  165. "caribou",
  166. "namalsk",
  167. "bush_island_51",
  168. "chernarus",
  169. "chernarus_summer",
  170. "chernarusredux",
  171. "fdf_isle1_a",
  172. "mbg_celle2",
  173. "woodland_acr",
  174. "bootcamp_acr",
  175. "thirsk",
  176. "thirskw",
  177. "utes",
  178. "gsep_mosch",
  179. "gsep_zernovo",
  180. "anim_helvantis_v2",
  181. "colleville",
  182. "staszow",
  183. "baranow",
  184. "panovo",
  185. "ivachev",
  186. "xcam_taunus",
  187. "pja314",
  188. "beketov"
  189. ]) then
  190. {
  191. tpw_soap_region = 5;
  192. };
  193. };
  194.  
  195.  
  196. // ADJUST TRAFFIC NOISE MULTIPLIER PER MAP
  197. private _maps = ["altis","stratis","malden","lythium","tanoa","prei_khmaoch_luong","dya"];
  198. private _adj = [1,1.5,1.5,1.5,1.2,0.2,0.5];
  199. if (tolower worldname in _maps) then
  200. {
  201. tpw_soap_mapfactor = (_adj select (_maps find tolower worldname));
  202. }
  203. else
  204. {
  205. tpw_soap_mapfactor = 1;
  206. };
  207.  
  208. // IS PLAYER IN A HOUSE?
  209. tpw_soap_fnc_indoors =
  210. {
  211. private ["_pos","_highpos","_return"];
  212. _pos = eyepos player;
  213. _highpos = [_pos select 0,_pos select 1,(_pos select 2) + 10];
  214. if (lineintersects [_pos,_highpos]) then
  215. {
  216. _return = true;
  217. }
  218. else
  219. {
  220. _return = false;
  221. };
  222. _return
  223. };
  224.  
  225. // NEAREST BUILDING
  226. tpw_soap_fnc_nearestbuilding =
  227. {
  228. private ["_return"];
  229. _return = (nearestObject [player, "House"]) distance player; // will also return walls
  230. _return
  231. };
  232.  
  233. // MAIN LOOP
  234. tpw_soap_fnc_mainloop =
  235. {
  236.  
  237. while {true} do
  238. {
  239. // Scan houses only if fewer than maximum sounds are playing
  240. if ((tpw_soap_active) &&
  241. {tpw_soap_soundsplaying < tpw_soap_maxsounds} &&
  242. {player == vehicle player} &&
  243. {!([] call tpw_soap_fnc_indoors)}) then
  244. {
  245. tpw_soap_nearhouses = [];
  246. if ([] call tpw_soap_fnc_nearestbuilding < tpw_soap_radius) then
  247. {
  248. 0 = [] call tpw_soap_fnc_housescan;
  249. };
  250. };
  251. sleep 5.11;
  252. };
  253. };
  254.  
  255. // AZAN LOOP
  256. tpw_soap_fnc_azanloop =
  257. {
  258. tpw_soap_azanflag = 0;
  259. while {true} do
  260. {
  261. if ((tpw_soap_active) &&
  262. {tpw_soap_azanflag == 0} &&
  263. {(daytime > tpw_soap_sunrise - 1.25 && daytime < tpw_soap_sunrise - 1 ) ||
  264. (daytime > tpw_soap_sunrise && daytime < tpw_soap_sunrise + 0.25) ||
  265. (daytime > 11.75 && daytime < 12) ||
  266. (daytime > 14 && daytime < 14.25) ||
  267. (daytime > tpw_soap_sunset - 2 && daytime < tpw_soap_sunset - 1.75) ||
  268. (daytime > tpw_soap_sunset && daytime < tpw_soap_sunset + 0.25)}) then
  269. {
  270. 0 = [] call tpw_soap_fnc_mosquescan;
  271. };
  272. sleep 61.3;
  273. };
  274. };
  275.  
  276. // HOUSE SCANNING
  277. tpw_soap_fnc_housescan =
  278. {
  279. private ["_nearhouses","_house","_i"];
  280. // Region - can be changed on the fly
  281. if (tpw_soap_region == 1) then
  282. {
  283. tpw_soap_sounds = 17;
  284. tpw_soap_songs = 9;
  285. tpw_soap_path = "sounds\greek\";
  286. tpw_soap_soundlength = tpw_soap_greeksoundlength;
  287. tpw_soap_songlength = tpw_soap_greeksonglength;
  288. tpw_soap_musicfactor = 2.5; // Slightly louder Greek music
  289. };
  290.  
  291. if (tpw_soap_region == 2) then
  292. {
  293. tpw_soap_sounds = 22;
  294. tpw_soap_songs = 11;
  295. tpw_soap_path = "sounds\mideast\";
  296. tpw_soap_soundlength = tpw_soap_mideastsoundlength;
  297. tpw_soap_songlength = tpw_soap_mideastsonglength;
  298. tpw_soap_musicfactor = 2;
  299. };
  300.  
  301. if (tpw_soap_region == 3) then
  302. {
  303. tpw_soap_sounds = 25;
  304. tpw_soap_songs = 11;
  305. tpw_soap_path = "sounds\fiji\";
  306. tpw_soap_soundlength = tpw_soap_fijisoundlength;
  307. tpw_soap_songlength = tpw_soap_fijisonglength;
  308. tpw_soap_musicfactor = 2;
  309. };
  310.  
  311. if (tpw_soap_region == 4) then
  312. {
  313. tpw_soap_sounds = 29;
  314. tpw_soap_songs = 12;
  315. tpw_soap_path = "sounds\france\";
  316. tpw_soap_soundlength = tpw_soap_francesoundlength;
  317. tpw_soap_songlength = tpw_soap_francesonglength;
  318. tpw_soap_musicfactor = 1.5;
  319. };
  320.  
  321. if (tpw_soap_region == 5) then
  322. {
  323. tpw_soap_sounds = 29;
  324. tpw_soap_songs = 8;
  325. tpw_soap_path = "sounds\russia\";
  326. tpw_soap_soundlength = tpw_soap_russiasoundlength;
  327. tpw_soap_songlength = tpw_soap_russiasonglength;
  328. tpw_soap_musicfactor = 1.5;
  329. };
  330.  
  331. if (tpw_soap_region == 6) then
  332. {
  333. private _rnd = floor random 5;
  334. tpw_soap_sounds = [17,19,25,29,29] select _rnd;
  335. tpw_soap_songs = [9,11,11,12,8] select _rnd;
  336. tpw_soap_path = format ["%1%2\","\sounds\",["greece","mideast","fiji","france","russia"] select _rnd];
  337. tpw_soap_soundlength = [tpw_soap_greeksoundlength, tpw_soap_mideastsoundlength,tpw_soap_fijisoundlength,tpw_soap_francesoundlength,tpw_soap_russiasoundlength] select _rnd;
  338. tpw_soap_songlength = [tpw_soap_greeksonglength, tpw_soap_mideastsonglength,tpw_soap_fijisonglength,tpw_soap_francesonglength,tpw_soap_russiasonglength] select _rnd;
  339. tpw_soap_musicfactor = [2.5,2,2,1.5,1.5] select _rnd;
  340. };
  341.  
  342. // Adjust volume & chance of spawning based on time of day
  343. tpw_soap_soundvolmult = [0,0,0,0,0,0.2,0.4,0.6,0.8,1,1.0,1,1,1,1,1,1,1,0.9,0.8,0.6,0.3,0.2,0.1,0] select (round daytime);
  344. tpw_soap_musicvolmult = [0,0,0,0,0,0,0,0.5,0.6,0.7,0.8,0.9,1,1,1,1,1,1,1,1.2,1.1,0.8,0.4,0.2,0,0] select (round daytime);
  345.  
  346. // Scan for habitable houses
  347. _nearhouses = [tpw_soap_radius] call tpw_core_fnc_screenhouses;
  348. tpw_soap_nearhouses = _nearhouses select {damage _x == 0};
  349.  
  350. // Loop through nearest houses, find first available
  351. for "_i" from 0 to (count tpw_soap_nearhouses - 1) do
  352. {
  353. _house = tpw_soap_nearhouses select _i;
  354.  
  355. // Play environmental ambience if not already doing so
  356. if (
  357. (_house getvariable ["tpw_soap_ambienceflag",0] == 0) &&
  358. {_house distance player > 5} &&
  359. {random 1 < tpw_soap_soundvolmult} &&
  360. {tpw_soap_soundsplaying < tpw_soap_maxsounds}
  361. ) then
  362. {
  363. tpw_soap_soundsplaying = tpw_soap_soundsplaying + 1;
  364. _house setvariable ["tpw_soap_ambienceflag",1,true];
  365. [_house] call tpw_soap_fnc_ambientsounds;
  366. };
  367.  
  368. // Occasionally play music if not already doing so
  369. if (
  370. (_house getvariable ["tpw_soap_musicflag",0] == 0) &&
  371. {_house distance player > 5} &&
  372. {random 50 < (1 * tpw_soap_musicvolmult)} &&
  373. {tpw_soap_songsplaying < tpw_soap_maxsongs}
  374. ) then
  375. {
  376. tpw_soap_songsplaying = tpw_soap_songsplaying + 1;
  377. _house setvariable ["tpw_soap_musicflag",1,true];
  378. [_house] call tpw_soap_fnc_ambientmusic;
  379. };
  380.  
  381. // Occasional construction noises
  382. if (tpw_soap_constructionplaying < 3 && {daytime > tpw_soap_sunrise && daytime < tpw_soap_sunset} && {_house distance player > 5} ) then
  383. {
  384. _house setvariable ["tpw_soap_constructionflag",1,true];
  385. tpw_soap_constructionplaying = tpw_soap_constructionplaying + 1;
  386. [_house] call tpw_soap_fnc_constructionsounds;
  387. };
  388. };
  389. };
  390.  
  391. // MOSQUE SCANNING
  392. tpw_soap_fnc_mosquescan =
  393. {
  394. private ["_nearhouses","_nearmosques","_mosque","_i","_playflag"];
  395. // Scan for habitable houses - which can include mosques
  396.  
  397. _nearhouses = [250] call tpw_core_fnc_screenhouses;
  398. _nearmosques = [];
  399.  
  400. // Grab nearest mosques - but only want one playing at a given time
  401. _playflag = 0;
  402. for "_i" from 0 to (count _nearhouses - 1) do
  403. {
  404. _mosque = _nearhouses select _i;
  405. if (["osque",str typeof _mosque] call BIS_fnc_inString) then
  406. {
  407. _nearmosques set [count _nearmosques,_mosque];
  408. };
  409. };
  410. _nearmosques = [_nearmosques,[],{player distance _x},"ASCEND"] call BIS_fnc_sortBy;
  411.  
  412. if ((count _nearmosques > 0) && {_mosque getvariable ["tpw_soap_azanflag",0] == 0}) then
  413. {
  414. _mosque = _nearmosques select 0;
  415. [_mosque] call tpw_soap_fnc_azanplay;
  416. };
  417. };
  418.  
  419. // PLAY MUSIC FROM HOUSES
  420. tpw_soap_fnc_ambientmusic =
  421. {
  422. private ["_house","_sel","_len","_finish","_clip","_pos","_pitch","_atten"];
  423. _house = _this select 0;
  424. [_house] spawn
  425. {
  426. sleep random 3;
  427. _house = _this select 0;
  428. _pitch = 1;
  429. _pos = getposasl _house;
  430. _atten = tpw_soap_attenuation + random tpw_soap_attenuation;
  431.  
  432. // Music
  433. _sel = floor (random tpw_soap_songs);
  434. _clip = format ["%1s%2.ogg",tpw_soap_path,_sel + 1];
  435. _len = tpw_soap_songlength select _sel;
  436.  
  437. // Play user song from @TPW_MODS\music
  438. if ((tpw_soap_usermusic >0) && {random 10 < 5}) then
  439. {
  440. _clip = format ["@TPW_MODS\music\%1.ogg",floor (random tpw_soap_usermusic) + 1];
  441. _len = 180;
  442. };
  443. _finish = diag_ticktime + _len - 5;
  444. _house setvariable ["tpw_soap_musicflag",_finish,true];
  445. playsound3d [MISSION_ROOT + _clip,_house,false,_pos,(tpw_soap_musicvolume * tpw_soap_volume * tpw_soap_musicvolmult * tpw_soap_musicfactor),_pitch,_atten];
  446. waituntil
  447. {
  448. sleep 5;
  449. (diag_ticktime > _house getvariable "tpw_soap_musicflag");
  450. };
  451. _house setvariable ["tpw_soap_musicflag",0,true];
  452. tpw_soap_songsplaying = tpw_soap_songsplaying - 1;
  453. };
  454. };
  455.  
  456. // PLAY ENVIROMENTAL AMBIENCE IN HOUSES
  457. tpw_soap_fnc_ambientsounds =
  458. {
  459. private ["_house","_sel","_len","_finish","_clip","_pos","_pitch","_atten"];
  460. _house = _this select 0;
  461. [_house] spawn
  462. {
  463. sleep random 3;
  464. _house = _this select 0;
  465. _pitch = 0.9 + random 0.2;
  466. _pos = getposasl _house;
  467. _atten = tpw_soap_attenuation + random tpw_soap_attenuation;
  468.  
  469. // Inbuilt SFX
  470. _sel = floor (random tpw_soap_sounds);
  471. _clip = format ["%1%2.ogg",tpw_soap_path,_sel + 1];
  472. _len = tpw_soap_soundlength select _sel;
  473.  
  474. // User SFX
  475. if ((tpw_soap_usersounds > 0) && {random 10 < 5}) then
  476. {
  477. _clip = format ["@TPW_MODS\sounds\%1.ogg",floor (random tpw_soap_usersounds) + 1];
  478. _len = 30;
  479. };
  480. _finish = diag_ticktime + _len - 5;
  481. _house setvariable ["tpw_soap_ambienceflag",_finish,true];
  482. playsound3d [MISSION_ROOT + _clip,_house,false,_pos,(tpw_soap_ambientvolume * tpw_soap_volume * tpw_soap_soundvolmult),_pitch,_atten];
  483. waituntil
  484. {
  485. sleep 5;
  486. (diag_ticktime > _house getvariable "tpw_soap_ambienceflag");
  487. };
  488. _house setvariable ["tpw_soap_ambienceflag",0,true];
  489. tpw_soap_soundsplaying = tpw_soap_soundsplaying - 1;
  490. };
  491. };
  492.  
  493. // PLAY CONSTRUCTION NOISES IN HOUSES
  494. tpw_soap_fnc_constructionsounds =
  495. {
  496. private ["_house","_sel","_len","_finish","_clip","_pos","_pitch","_atten"];
  497. _house = _this select 0;
  498. [_house] spawn
  499. {
  500. sleep random 3;
  501. _house = _this select 0;
  502. _pitch = 0.8 + random 0.3;
  503. _pos = getposasl _house;
  504. _atten = tpw_soap_attenuation + random tpw_soap_attenuation;
  505. _atten = tpw_soap_attenuation + random tpw_soap_attenuation;
  506.  
  507. _sel = floor random 12;
  508. _clip = format ["%1%2.ogg",'sounds\construction\b',_sel + 1];
  509. _len = tpw_soap_constructionlength select _sel;
  510. _finish = diag_ticktime + _len - 5;
  511. _house setvariable ["tpw_soap_constructionflag",_finish,true];
  512. playsound3d [MISSION_ROOT + _clip,_house,false,_pos,(tpw_soap_ambientvolume * tpw_soap_volume * tpw_soap_soundvolmult * 0.5),_pitch,_atten];
  513. waituntil
  514. {
  515. sleep 5;
  516. (diag_ticktime > _house getvariable "tpw_soap_constructionflag");
  517. };
  518. _house setvariable ["tpw_soap_constructionflag",0,true];
  519. tpw_soap_constructionplaying = tpw_soap_constructionplaying - 1;
  520. };
  521. };
  522.  
  523. // PLAY TELEPHONE NOISES IN HOUSES
  524. tpw_soap_fnc_phone =
  525. {
  526. private ["_house","_sel","_finish","_clip","_pos","_pitch","_atten"];
  527. while {true} do
  528. {
  529. if (count tpw_soap_nearhouses > 4 && {daytime > 5 && daytime < 23}) then
  530. {
  531. _house = tpw_soap_nearhouses select (floor (random (count tpw_soap_nearhouses)));
  532. _pitch = 0.8 + random 0.3;
  533. _pos = getposasl _house;
  534. _atten = tpw_soap_attenuation + random tpw_soap_attenuation;
  535. _sel = floor random 13;
  536. _clip = format ["%1%2.ogg",'sounds\phone\ringtone',_sel + 1];
  537. _pause = 2 + random 1;
  538. _rings = 2 + random 6;
  539. for "_i" from 1 to _rings do
  540. {
  541. playsound3d [MISSION_ROOT + _clip,_house,false,_pos,(tpw_soap_ambientvolume * tpw_soap_volume * tpw_soap_soundvolmult * 0.1),_pitch,_atten];
  542. sleep _pause;
  543. };
  544. };
  545. sleep random 90;
  546.  
  547. };
  548. };
  549.  
  550. // CREAKING NOISES IN HOUSES
  551. tpw_soap_fnc_housenoise =
  552. {
  553. private ["_sound","_pitch","_vol"];
  554. while {true} do
  555. {
  556. if (tpw_soap_active && {[] call tpw_soap_fnc_indoors} && {[] call tpw_soap_fnc_nearestbuilding < 10}) then
  557. {
  558. _pitch = 0.8 + random 0.4;
  559. _vol = (tpw_soap_housefxvolume * windstr * 0.25); // louder creaking in the wind
  560. _sound = format ["sounds\house\c%1.ogg",(ceil random 7)];
  561. playsound3d [MISSION_ROOT + _sound,player,false,getposasl player,_vol,_pitch,50];
  562. };
  563. sleep random 30;
  564. };
  565. };
  566.  
  567. // TRAFFIC
  568. tpw_soap_fnc_traffic =
  569. {
  570. private ["_roads","_vol","_sound","_building","_buildings"];
  571. while {true} do
  572. {
  573. if (tpw_soap_active) then
  574. {
  575. //_building = nearestbuilding player;
  576. _buildings = nearestTerrainObjects [position player, ["house","building"], 50, true];
  577. if (count _buildings > 1) then
  578. {
  579. _building = _buildings select 1;
  580. _roads = count ((player nearroads 400) select {isonroad _x}) / 400;
  581. _vol = tpw_soap_mapfactor * tpw_soap_trafficmult * _roads * _roads * tpw_soap_soundvolmult;
  582. if (_vol > tpw_soap_trafficmult) then {_vol = tpw_soap_trafficmult};
  583. _sound = format [MISSION_ROOT + "sounds\traffic\%1.ogg",(ceil random 3)];
  584. //hint format ["Roads:%1, Vol:%2, Dist: %3 Sound:%4", _roads,_vol,_building distance player,_sound];
  585. playsound3d [_sound, _building,false,getposasl _building vectoradd [0,0,20],_vol,1,200];
  586. };
  587. };
  588. sleep random 45;
  589. };
  590. };
  591.  
  592.  
  593. // WIND NOISE IN HOUSES
  594. tpw_soap_fnc_windnoise =
  595. {
  596. private ["_sound","_pitch","_vol"];
  597. while {true} do
  598. {
  599. if (tpw_soap_active &&{[] call tpw_soap_fnc_indoors} && {[] call tpw_soap_fnc_nearestbuilding < 10} && {windstr > 0.2}) then
  600. {
  601. _pitch = 0.8 + random 0.4;
  602. _vol = (tpw_soap_housefxvolume * windstr * 0.5);
  603. _sound = format ["sounds\house\w%1.ogg",(ceil random 9)];
  604. playsound3d [MISSION_ROOT + _sound,player,false,getposasl player,_vol,_pitch,50]; // wind
  605. sleep random 10;
  606. _sound = format ["sounds\house\r%1.ogg",(ceil random 6)]; // rattle
  607. playsound3d [MISSION_ROOT + _sound,player,false,getposasl player,_vol * 2,_pitch,50];
  608. };
  609. sleep 30 + random 10;
  610. };
  611. };
  612.  
  613. // MONITOR DEATHS, LOWER MASTER VOLUME FOR A FEW MINUTES AFTER EACH NEW DEATH
  614. tpw_soap_fnc_battle =
  615. {
  616. private ["_battletime","_orig_vol"];
  617. _battletime = 0;
  618. _orig_vol = tpw_soap_volume;
  619. while {true} do
  620. {
  621. if (count alldeadmen > tpw_soap_dead) then
  622. {
  623. tpw_soap_dead = count alldead;
  624. _battletime = diag_ticktime + (random 120);
  625. tpw_soap_volume = _orig_vol * 0.5;
  626. };
  627. if (diag_ticktime > _battletime) then
  628. {
  629. tpw_soap_volume = _orig_vol;
  630. };
  631. sleep 11.53;
  632. };
  633. };
  634.  
  635. // PLAY AZAN IN NEARBY MOSQUE
  636. tpw_soap_fnc_azanplay =
  637. {
  638. private ["_mosque","_sel","_len","_finish","_song","_vol","_pos"];
  639. _mosque = _this select 0;
  640. if (player distance _mosque > 250) exitwith {};
  641. [_mosque] spawn
  642. {
  643. _mosque = _this select 0;
  644. _sel = floor random 10;
  645. _len = tpw_soap_azanlength select _sel;
  646. _song = format ["sounds\TPW_AZAN\sounds\%1.ogg",(_sel + 1)];
  647. _finish = diag_ticktime + _len;
  648. _mosque setvariable ["tpw_soap_azanflag",_finish,true];
  649. _vol = tpw_soap_azanvolume * 0.5 + random 0.5;
  650. _pos = getposasl _mosque;
  651. _pos = [_pos select 0, _pos select 1, (_pos select 2) + 50];
  652. playsound3d [MISSION_ROOT + _song,_mosque,false,_pos,_vol,1,0];
  653. tpw_soap_azanflag = 1;
  654. sleep 10;
  655. // Play prayer in nearest house
  656. playsound3d [MISSION_ROOT + "sounds\mideast\18.ogg",nearestbuilding player];
  657. waituntil
  658. {
  659. sleep 10;
  660. (diag_ticktime > _mosque getvariable "tpw_soap_azanflag");
  661. };
  662. _mosque setvariable ["tpw_soap_azanflag",0,true];
  663. tpw_soap_azanflag = 0;
  664. };
  665. };
  666.  
  667. // SCREAMS / BARKS / SIRENS IF NEARBY GUNFIRE
  668. player addeventhandler ["firednear",{0 = [player] spawn tpw_soap_fnc_scream}];
  669. tpw_soap_bulletcount = 0;
  670. tpw_soap_nextcry = 0;
  671. tpw_soap_fnc_scream =
  672. {
  673. private ["_sound","_pitch","_vol","_house","_nearhouses"];
  674. if ((tpw_soap_active) && {diag_ticktime > tpw_soap_nextcry} && {random 10 < 3}) then
  675. {
  676. tpw_soap_nextcry = diag_ticktime + random 15;
  677. sleep 1 + random 5;
  678. _nearhouses = [tpw_soap_radius * 0.75] call tpw_core_fnc_screenhouses;
  679. if ((_nearhouses select 0 distance player < tpw_soap_radius) && {!([] call tpw_soap_fnc_indoors)}) then
  680. {
  681. _house = _nearhouses select floor (random (count _nearhouses));
  682. _vol = tpw_soap_housefxvolume * 2;
  683. _pitch = 0.9 + random 0.2;
  684. if (random 10 < 5) then
  685. {
  686. _sound = format ["sounds\fear\%1.ogg",(ceil random 12)]; // screams, babies
  687. } else
  688. {
  689. _sound = format ["sounds\tpw_sounds\sounds\dog%1.ogg",ceil (random 20)]; // barks
  690. };
  691. playsound3d [MISSION_ROOT + _sound,_house,false,getposasl _house,_vol,_pitch,100];
  692.  
  693. if (count ([100] call tpw_core_fnc_screenhouses) > 20) then
  694. {
  695. sleep random 10;
  696. _sound = format ["sounds\tpw_sounds\sounds\siren%1.ogg",ceil (random 4)]; // sirens
  697. playsound3d [MISSION_ROOT + _sound,_house,false,getposasl _house,1.5,_pitch,250];
  698. };
  699. };
  700. };
  701. };
  702.  
  703. // RUN IT
  704. [] spawn tpw_soap_fnc_battle;
  705. [] spawn tpw_soap_fnc_mainloop;
  706. [] spawn tpw_soap_fnc_housenoise;
  707. [] spawn tpw_soap_fnc_windnoise;
  708. [] spawn tpw_soap_fnc_phone;
  709. [] spawn tpw_soap_fnc_azanloop;
  710. tpw_soap_soundvolmult = 0;
  711. [] spawn tpw_soap_fnc_traffic;
  712.  
  713. while {true} do
  714. {
  715. // dummy loop so script doesn't terminate
  716. sleep 10;
  717. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement