Jump to content

Random song selection when entering new area.


Xegethra

Recommended Posts

Just as the title says, how do you make it so one of a selection of music tracks will play when entering a new area?

I have a bunch of custom music files I would like to have play in an area, and after being able to make the song change into one of those, and back again upon entering and leaving the area...I was wondering is it possible to make it select a random track from the ones I want?

I'm making my maps in Doom in Hexen format. Thanks if anyone can help, I've tried a few combinations in the ACS script but to no success.

Share this post


Link to post

Hey, this structure works for me:

#include "zcommon.acs"

script 1 (void)

{
int x = random(1,5);
if(x == 1)
{
setmusic("d_shawn",0);
}
else if(x == 2)
{
setmusic("d_ampie",0);
}
else if(x == 3)
{
setmusic("d_romero",0);
}
else if(x == 4)
{
setmusic("d_doom",0);
}
else
{
setmusic("d_betwee",0);
}
}


The script runs with a repeatable walk-over linedef trigger. Changing the music back requires just one setmusic function, of course.

Share this post


Link to post

Even better:

#define NUMSONGS 5
str songs[NUMSONGS] = { "d_shawn", "d_ampie", "d_romero", "d_doom", "d_betwee" };

script 1 (void)
{
      LocalSetMusic(songs[random(0, NUMSONGS - 1)]);
}

Share this post


Link to post

Oh man, mine was a bit off then, I had this.

"Script 2 (VOID)
{
SetMusic("CLBDOOM1",0); SetMusic("CLBDOOM2",0); SetMusic("CLBDOOM3",0); SetMusic("CLBDOOM4",0); SetMusic("CLBDOOM5",0); SetMusic("CLBDOOM6",0);
}"

And any other variation I tried I got the same results, it looks like I kept telling it the same thing but just in a different way. It kept on playing the last song all of the while.

Thanks for the help!! Now my area can be a little more..I guess unexpected when entered.

Share this post


Link to post
Xegethra said:

Oh man, mine was a bit off then, I had this.

"Script 2 (VOID)
{
SetMusic("CLBDOOM1",0); SetMusic("CLBDOOM2",0); SetMusic("CLBDOOM3",0); SetMusic("CLBDOOM4",0); SetMusic("CLBDOOM5",0); SetMusic("CLBDOOM6",0);
}"

And any other variation I tried I got the same results, it looks like I kept telling it the same thing but just in a different way. It kept on playing the last song all of the while.

Yes, in the same way that if you press 1 2 3 4 5 6 7 in Doom, you'll switch your weapon to the BFG. The last order wins. All music changes were run, it's just that you didn't get to hear the first five because they had 0 tics to run and they were instantly replaced by the next order.

For area-based music changes I recommend LocalSetMusic because this way in multiplayer this will not affect other players who are not in the same area.

Share this post


Link to post

Ahh, I see. Knowing that then maybe at some point I could experiment with ordered music then.

But yeah, thanks for the help again. Even better if it can be done to affect only the players who ran over the trigger.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...