legacyclonk / LegacyClonk

The LegacyClonk engine and the c4group command line tool.
https://clonkspot.org/lc-en
Other
81 stars 18 forks source link

C4Script: Extend Music() with additional parameters #51

Open Somebodyisnobody opened 3 years ago

Somebodyisnobody commented 3 years ago

Many scenarios use Sound() instead of Music() as Sound() is more practical in usability:

With Music() you have following problems:

This results in some scenarios which uses Sound() instead of Music(). Example Templepushing: After switching from ingame-lobby into the actual game, the section is being chosen dynamically. Depending on the section and game mode one of a few tracks (with about 15 sec length) is played and always repeated. Using Sound() will not cause the normal clonk music from Music.c4g stop playing. Music is being played with Sound() as it needs to be regulated and normalized in the game. This is done via iVolume. Overmore Sound() is used because Music() generates log entries when looping. Looping would also be possbile via SetPlaylist(track) but this wouldn't support suppress the log and the volume can't be adjusted per track. Instead of using engine built-in features (e.g. F3) a parallel existing sound menu is programmed itself. The settings are saved in the player file.

Suggestion: Extend the function Music() by more arguments: void Music (string szSongName, int iLoopCount, int iVolume, bool fforcePlay, bool fhideTitleOnLoop); iVolume will set the volume of the track, fforcePlay will play a track even if the Player disabled music in the menu (default) and fhideTitleOnLoop can suppress logging repeats of the track.

OR

extend SetPlaylist() by iVolume and fhideTitleOnLoop. fforcePlay wouldn't be needed in this case.

maxmitti commented 3 years ago

Example Templepushing: [...]

Iirc, the main reason for going with Sound (+ SoundLevel) was the inability to control music playback per player with Music. The only possibilities with Music are enabling the music for all or none and let the users adjust with F3 / ingame settings to their liking. This would be very annoying because manual intervention would be necessary at the beginning of every round.

With the Sound based implementation the users can set their preference once and it is remembered by storing it in the player. Logging and volume adjustment are just positive side effects.

fforcePlay will play a track even if the Player disabled music in the menu

I would hate that. I already hate it that scenarios (CMC cough) can enable music even though I disabled it (because I am listening to music externally already).

Somebodyisnobody commented 3 years ago

I would hate that. I already hate it that scenarios (CMC cough) can enable music even though I disabled it (because I am listening to music externally already).

I am fully with you and the fforcePlay would be false in temple pushing but I wanted to avoid breaking a function as Music() forces playing the music at the moment according to https://crdocs.clonkspot.org/en/sdk/script/fn/Music.html (A successful call to this function will activate music playback, even if it was turned off in the options.) So I have no problem throwing the argument away and never force music played with Music().

With the Sound based implementation the users can set their preference once and it is remembered by storing it in the player.

With Music based implementation the user could set his preferences in the options menu ingame or in the main menu and it would be stored in the registry. Am I wrong when I say that this is the original idea?

Somebodyisnobody commented 3 years ago

Maybe I should elaborate on why I feel the changes are necessary: As a user, I do not want to hear two tracks of music in parallel at the start of the round. As a user, I want to be able to control the music settings for audio files that, objectively speaking, are to be interpreted as "music" via F3 and the music settings. I do not want to have to control a separate "music menu" for each individual scenario.

Implementing my suggestion (and not implementing fforcePlay) would also take care of your problem: As DerTod, I don't want music to play in CMC when I have explicitly disabled music in the settings.

So we both would be happy...