Random song of choosing on load?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Armaetus
Posts: 1256
Joined: Fri Mar 13, 2009 3:55 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10 Home
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: New York State
Contact:

Random song of choosing on load?

Post by Armaetus »

Say I want to make a music WAD with multiple renditions of the same song (IE D_RUNNIN, D_RUNNI2, D_RUNNI3, D_RUNNI4, etc) but want the game to randomly choose one of those and loop it for the duration of the level and repeat the same with the next track (D_STALKS, STLKS2-4, etc)

Is this possible?
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Random song of choosing on load?

Post by wildweasel »

Probably with an ACS ENTER script of some type that checks the current map number and chooses from an array of song lump titles.
User avatar
Xeotroid
Posts: 448
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Re: Random song of choosing on load?

Post by Xeotroid »

I didn't test this script, but you could try if it works. This picks from 3 random music tracks for each of 4 maps. I don't know how to get around the switch/case block because afaik, ACS can't mix two different strings together.
Spoiler:
Aliotroph?
Posts: 35
Joined: Wed May 07, 2008 2:54 am

Re: Random song of choosing on load?

Post by Aliotroph? »

Xeotroid wrote:I don't know how to get around the switch/case block because afaik, ACS can't mix two different strings together.
You don't need to concatenate strings. I tested this version.
Spoiler:
User avatar
edward850
Posts: 5889
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Random song of choosing on load?

Post by edward850 »

Why is this an enter script for a global, non-player, action? This is what open scripts are for.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: Random song of choosing on load?

Post by Arctangent »

To be fair, it could also be fixed with LocalSetMusic instead of SetMusic, too. That'd mean each player gets to roll for which music file is used, instead of all of them using the same one.
Aliotroph?
Posts: 35
Joined: Wed May 07, 2008 2:54 am

Re: Random song of choosing on load?

Post by Aliotroph? »

edward850 wrote:Why is this an enter script for a global, non-player, action? This is what open scripts are for.
I tried that. It didn't change the music.

I didn't think of LocalSetMusic().
User avatar
edward850
Posts: 5889
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Random song of choosing on load?

Post by edward850 »

Really? Because it works perfectly fine. Why would it not work?
Aliotroph?
Posts: 35
Joined: Wed May 07, 2008 2:54 am

Re: Random song of choosing on load?

Post by Aliotroph? »

Turns out using "open" works with SetMusic(), but not LocalSetMusic(). That was my mistake when I changed two things at the same time and didn't pay enough attention.
Last edited by Aliotroph? on Mon Jun 01, 2015 4:37 am, edited 1 time in total.
User avatar
edward850
Posts: 5889
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Random song of choosing on load?

Post by edward850 »

Aliotroph?
Posts: 35
Joined: Wed May 07, 2008 2:54 am

Re: Random song of choosing on load?

Post by Aliotroph? »

Yeah, I forgot I changed that one. I then stared at the two otherwise superficially different versions of the script for a while and didn't see my mistake. Dumb.
Locked

Return to “Editing (Archive)”