Jump to content
Starker

Music Trigger During A Lull In Combat

Recommended Posts

Is it possible to trigger music to play after a certain amount of time has passed without any combat? Would it be possible to make the music stop as soon as combat begins again? I have never heard of something like this being done, but I think it would significantly contribute to the atmosphere of my missions. It would reduce the bored of long walks and build tension. I also think that music during combat is distracting. Any feedback would be very appreciated.

Share this post


Link to post
Share on other sites

I do something similar for my own stuff. Try using an eventhandler to determine if there's been gunfire near the player,.

musictime = diag_ticktime;
musicflag = 0;
player addeventhandler ["firednear",{musictime = diag_ticktime + 30}]
_main_music_loop = 
    {
    while {true} do
        {
        if (diag_ticktime > musictime && musicflag = 0) then
            {
            playmusic "BackgroundTrack01_F";
			musicflag = 1;
            } else
            {
            playmusic "";
			musicflag = 0;
            };
        sleep 10;
        };
    };
0 = [] spawn _main_music_loop;

This will make sure that no music will play during close combat and for up to 30 seconds after.

 

EDIT: you can use music eventhandlers to assess when music is actually playing, instead of the musicflag. 

https://community.bistudio.com/wiki/addMusicEventHandler

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, tpw said:

I do something similar for my own stuff. Try using an eventhandler to determine if there's been gunfire near the player,.


musictime = diag_ticktime;
musicflag = 0;
player addeventhandler ["firednear",{musictime = diag_ticktime + 30}]
_main_music_loop = 
    {
    while {true} do
        {
        if (diag_ticktime > musictime && musicflag = 0) then
            {
            playmusic "BackgroundTrack01_F";
			musicflag = 1;
            } else
            {
            playmusic "";
			musicflag = 0;
            };
        sleep 10;
        };
    };
0 = [] spawn _main_music_loop;

This will make sure that no music will play during close combat and for up to 30 seconds after.

 

EDIT: you can use music eventhandlers to assess when music is actually playing, instead of the musicflag. 

https://community.bistudio.com/wiki/addMusicEventHandler

 

Thankyou!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×