EL_LEJI 13 Posted November 12, 2013 (edited) I found this script in the campaign work fine :p demo example: http://www58.zippyshare.com/v/7302191/file.html waitUntil {!isNull player};_unit = _this select 0; private ["_explosions"]; _explosions = [ "BattlefieldExplosions1_3D", "BattlefieldExplosions2_3D", "BattlefieldExplosions5_3D" ]; private ["_fireFights"]; _fireFights = [ "BattlefieldFirefight1_3D", "BattlefieldFirefight2_3D" ]; { [_forEachIndex, _explosions, _fireFights] spawn { private ["_index","_explosions", "_fireFights"]; _index = _this select 0; scriptName format ["initAmbientSounds.sqf: random sound playing - [%1]", _index]; _explosions = _this select 1; _fireFights = _this select 2; while {true} do { sleep (1 + random 59); private ["_sound"]; _sound = if (random 1 < 0.5) then { _explosions call BIS_fnc_selectRandom } else { _fireFights call BIS_fnc_selectRandom }; playSound _sound; }; }; } forEach [0,1,2]; Edited November 12, 2013 by Thor632 demo example Share this post Link to post Share on other sites
barbolani 198 Posted November 12, 2013 Thanks a lot! In the old times this was in efectos option of triggers, but I could'nt be able to find it now. Share this post Link to post Share on other sites
EL_LEJI 13 Posted November 12, 2013 Thanks barbolani. Edit first post with a demo example Share this post Link to post Share on other sites
pipyn1970 19 Posted November 13, 2013 Thanks for this mate. I cant download the example till next wk but i was wandering if i could ask a couple of questions please just to get my ideas flowing. Does this script give us the fire fights in the back ground like in the survive campagn? Where do i put the code? Im my mission we start off from a ship, so is it possible to have the sounds on a trigger? Many thanks for taking the time to answer this mate Share this post Link to post Share on other sites
EL_LEJI 13 Posted November 13, 2013 (edited) -Yes this script is the same in the survive campaign -Create a SQF file in your folder mission an rename initAmbientSounds copy and paste the script in the SQF -In a trigger Activation: if you want to use OPFOR or BLUFOR etc AL ACT: initAmbientSounds = [] execVM "initAmbientSounds.sqf"; And this is all, good luck! and thanks Sorry my English is not good :p Edited November 13, 2013 by Thor632 Share this post Link to post Share on other sites
pipyn1970 19 Posted November 15, 2013 Thank very much for this mate Share this post Link to post Share on other sites
lightspeed_aust 681 Posted November 2, 2014 Anyone know if this is still the way to get distant combat sounds? Share this post Link to post Share on other sites
redarmy 422 Posted November 3, 2014 How does this differ from the trigger effects module? Share this post Link to post Share on other sites
lightspeed_aust 681 Posted November 3, 2014 It's in a module!?!?! I'll check tonight! Share this post Link to post Share on other sites
Jigsor 176 Posted November 4, 2014 (edited) I checked this script out, but I didn't like the fact that the sounds are not positional (3d). In fact they are mono. Below uses all A3 sounds beginning with battlefield_explosions* and battlefield_firefight* and plays them in 3d. It requires an object/logic as the positional source. This example uses invisible object "Land_ClutterCutter_small_F" I named objective_pos_logic. It works out well if object is placed/moved to the center of AO, objective or where ever you want the sound to come from. Note: in line the with playsound3d command, the last 3 numbers "5,1,600" represent volume,pitch,distance that sound is audible. // A3 Ambient Combat Sound in 3D if (!isdedicated && hasInterface) then { [] spawn { waitUntil {!isNull player}; waitUntil {player == player}; private ["_allsounds","_source"]; _allsounds = []; _source = objective_pos_logic;// object/logic while {true} do { private ["_sound","_sound1","_sound2","_maxtype"]; _allsounds = _allsounds - _allsounds; _sound1 = format ["A3\Sounds_F\ambient\battlefield\battlefield_explosions%1.wss",ceil (random 5)]; _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",ceil (random 4)]; _allsounds pushBack _sound1; _allsounds pushBack _sound2; _maxtype = (count _allsounds); _sound = _allsounds select (floor random _maxtype); playsound3d [_sound,_source,false,getPosasl _source,5,1,600]; sleep (1 + random 29); }; }; }; Edited January 12, 2015 by Jigsor edited to work with last game patch 1 Share this post Link to post Share on other sites
lightspeed_aust 681 Posted November 5, 2014 thanx for the input lads - i am actually using both scripts in the mission so they are nicely mixed up - work beautifully! Share this post Link to post Share on other sites
Gattobuono 10 Posted November 21, 2014 I checked this script out, but I didn't like the fact that the sounds are not positional (3d). In fact they are mono. Below uses all A3 sounds beginning with battlefield_explosions* and battlefield_firefight* and plays them in 3d. It requires an object/logic as the positional source. This example uses invisible object "Land_ClutterCutter_small_F" I named objective_pos_logic. It works out well if object is placed/moved to the center of AO, objective or where ever you want the sound to come from.Note: in line the with playsound3d command, the last 3 numbers "5,1,600" represent volume,pitch,distance that sound is audible. // A3 Ambient Combat Sound in 3D if (!isdedicated && hasInterface) then { [] spawn { waitUntil {!isNull player}; waitUntil {player == player}; private ["_allsounds","_source"]; _allsounds = []; _source = objective_pos_logic;// object/logic while {true} do { private ["_sound","_sound1","_sound2","_maxtype"]; _allsounds = _allsounds - _allsounds; _sound1 = format ["A3\Sounds_F\ambient\battlefield\battlefield_explosions%1.wss",ceil (random 5)]; _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",floor (random 4)]; _allsounds pushBack _sound1; _allsounds pushBack _sound2; _maxtype = (count _allsounds)-1; _sound = _allsounds select (floor random _maxtype); playsound3d [_sound,_source,false,getPosasl _source,5,1,600]; sleep (1 + random 29); }; }; }; Could you please give me a clear step by step walkthrough of how to do this. Thanks Share this post Link to post Share on other sites
2nd ranger 282 Posted November 21, 2014 A small error in that script: _maxtype = (count _allsounds)-1; _sound = _allsounds select (floor random _maxtype); Since there's only ever going to be two sounds in the array at any one time, _maxtype is always going to be 1, which means floor random _maxtype is always going to return 0, so it will always play an explosion sound, never a firefight variant. It should just be _maxtype = (count _allsounds) Share this post Link to post Share on other sites
Jigsor 176 Posted November 21, 2014 Yep, good catch. Change was made to original post. Thank you 2nd Ranger. ---------- Post added at 06:55 AM ---------- Previous post was at 06:51 AM ---------- @Gattobuono, step 1. copy code to init.sqf step 2. place an object you want the sound to come from in the editor and name it objective_pos_logic. step 3. save and preview. Share this post Link to post Share on other sites
Gattobuono 10 Posted November 21, 2014 Thanks, I'll give that a try with the updated script :-) Share this post Link to post Share on other sites
mikey74 169 Posted January 11, 2015 (edited) hey guys I love it.... edited it. try this. use a game logic or two or more. lol put this in each game logic's init o = This execVM "Amb_battle.sqf"; Then make a sqf call it Amb_battle.sqf and put this in it: if (!isdedicated && hasInterface) then { waitUntil {!isNull player}; waitUntil {player == player}; _source = _this;//objective_pos_logic;// object/logic _center = createCenter sideLogic; _group = createGroup _center; _logic = _group createUnit ["LOGIC",(getPos _source) , [], 0, ""]; _plays = true; while {_plays} do { [_logic,_source] spawn { private ["_logic","_source","_allsounds"]; _logic = _this select 0; _source = _this select 1; _allsounds = []; _posS = (getPos _source); _logic setPos [(_posS select 0)+ random 305 - Random 305,(_posS select 1)+ random 305 - Random 305,1]; private ["_sound","_sound1","_sound2","_maxtype"]; _sound1 = format ["A3\Sounds_F\ambient\battlefield\battlefield_explosions%1.wss",ceil (random 5)]; _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",floor (random 4)]; _allsounds pushBack _sound1; _allsounds pushBack _sound2; _maxtype = (count _allsounds); _sound = _allsounds select (floor random _maxtype); playsound3d [_sound,_logic,false,getPosasl _logic,5,1,0]; }; sleep (random 1 + random 7); }; }; Edited January 12, 2015 by Mikey74 Share this post Link to post Share on other sites
Jigsor 176 Posted January 12, 2015 Cool, As on last game patch BIS removed one of the dummy sounds ending with 0 so it gives errors now if you try to play it. Changing this line _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",floor (random 4)]; to this fixes it. _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",ceil (random 4)]; My original post now reflects the change. Share this post Link to post Share on other sites
mikey74 169 Posted January 19, 2015 if (!isdedicated && hasInterface) then { waitUntil {!isNull player}; waitUntil {player == player}; //hint format ["%1",count _this]; _source = _this select 0;//objective_pos_logic;// object/logic _plays = true; AmB_nosound = false; _battle_radius = if (count _this >=1) then {(_this select 1)} else {350}; hint format ["Battle radius %1",_battle_radius]; while {_plays} do { _center = createCenter sideLogic; _group = createGroup _center; _logic = _group createUnit ["LOGIC",(getPos _source) , [], 0, ""]; sleep (1 + random 7); for "_s" from 1 to (1 + Ceil (random 2)) do { [_logic,_source,_battle_radius] spawn { for "_s" from 1 to (random 7 + random 56) do { private ["_logic","_source","_radius","_allsounds"]; _logic = _this select 0; _source = _this select 1; _radius = if ((_this select 2) > 100) then {(_this select 2)/25} else {(_this select 2)}; _allsounds = []; _logic setPos (_logic modelToWorld [random _radius - Random _radius,random _radius - Random _radius,random 1 - Random 2]); private ["_sound","_sound1","_sound2","_maxtype"]; _sound1 = format ["A3\Sounds_F\ambient\battlefield\battlefield_explosions%1.wss",floor (random 4)+1]; _sound2 = format ["A3\Sounds_F\ambient\battlefield\battlefield_firefight%1.wss",floor (random 2)+2]; if (!(surfaceIsWater getPos _logic)) then {_allsounds pushBack _sound2;} else {AmB_nosound = true}; if (random 1 > .5 or (surfaceIsWater getPos _logic) or AmB_nosound) then {_allsounds pushBack _sound1;}; _vol = switch (true) do { case (_logic distance player <= 250) : {.1}; case (_logic distance player > 250 and _logic distance player <= 500) : {.5}; case (_logic distance player > 500 and _logic distance player <= 800) : {1}; case (_logic distance player > 800 and _logic distance player <= 1000) : {1.5}; case (_logic distance player > 1000) : {2}; }; _maxtype = (count _allsounds); _sound = _allsounds select (floor random _maxtype); _pitch = if (_sound == _sound1) then {random .5 + .5} else {random .6 + .8}; _volumn = if (_sound == _sound1) then {_vol + 1 + random 3} else {_vol + .1 + random 2}; playsound3d [_sound,_logic,false,getPosasl _logic,_volumn,_pitch,0]; sleep (random 1 + random 14); }; };//spawn sleep (random 21 + random 21); }; deleteVehicle _logic; }; }; called by logic, trigger or init.sqf o=[this,1000] execVM "Amb_battle.sqf"; If you guys are ok with it or want it I can make a module for this. let me know Share this post Link to post Share on other sites