Hello, dear community.
I want to ask a question about music and Zscript.
Somewhere in depths of ZDoom forum found "Music Changer" (from YouTube link), which has two music - one that replaces theme of level, another - if you attract the attention of monsters (battle music).
In parameters, you can set how many monsters (5-10, it doesn't matter) will change music.
I tried did it like in Doom 2016 - when music changes to combat, so that there are several tracks and each time one of available files ones is selected.
I couldn't do this with S_ChangeMusic function - the music is constantly being loop and game starts hard lag every second.
But I got point where level was assigned to its source track (S_ChangeMusic"*").
Can I ask knowledgeable persons to help me understand this question, how starting from the 44th line in the ZSCRIPT file to gramatically make a random selection of music without lags? To change - and nicely play. And at next battle - another one.
On the 7 line I declaring list of tracks.
File is located here.
Thanks for your attention.
Music Randomizer (4.6.0; ZScript; S_ChangeMusic)
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- Player701
-
- Posts: 1710
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Music Randomizer (4.6.0; ZScript; S_ChangeMusic)
This doesn't have to do anything with random selection, the actual problem here is that you change the music every time the battle condition is triggered. You need to do it only once instead, for that you already have the variable play_music_until_array_of_actor_have_at_least_one_entry in your script. Here is the correct code for that (replace the if statement on line 45):
Code: Select all
if ((monsters_which_have_player_as_target.size() >= cvar.findcvar('amount_of_monsters_in_chase').getint() || (is_boss_joined_to_party && cvar.findcvar('take_in_account_boss_flag').getint() == 0)) && !play_music_until_array_of_actor_have_at_least_one_entry)
-
- Posts: 36
- Joined: Tue Aug 02, 2016 12:41 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
- Location: UAC
Re: Music Randomizer (4.6.0; ZScript; S_ChangeMusic)
It really works the way I expected it to. I don't understand why I was struggling for a long time with a problem whose solution was right under nose.
Thank you so much!
Thank you so much!