[Feature Suggestion/Request] Default Music/Ambience option in room properties.

Started by Stranga, Tue 30/11/2021 05:21:33

Previous topic - Next topic

Stranga

Not sure if this has been mentioned before but I thought it may be nice to add an option to the room's settings in the editor to select an ambient/music track to play for that room only and stop playing when exiting. It's not a major thing just a suggestion :)

Like somewhere here:
Spoiler
[close]

Crimson Wizard

There have been such setting before, in the older versions of AGS, called "Play music on room load", but it has been removed in favor of using script commands.

Anything automatic (sound start/stop) in the current audio system tends to increase chances of unintended behavior conflicting with script, because it's unclear how to track such sound.
- If there are multiple music channels, how do you find the one where this "room music" is played on?
- If the "room music" was interrupted by something else (another music, e.g. played during an event), should it restart from beginning / restart from the same position / not restart at all?
- If the "room music" was stopped by a script command, then run again by a script command, should it be considered "same" music or a different one that engine should not stop on room exit now?

If there were a concept of "sound instances", where a playback is an object, that is explicit, may be addressed and tracked, that perhaps would be simplier to handle.




Note that it's relatively simple to script such system for your own game case. Imagine you add a custom property to rooms, called "RoomMusic", you may then use on_event in a global script to catch room enter/leave events and handle this "room music", for example:
Code: ags

AudioChannel *roomMusic;

function on_event (EventType event, int data) {
    if (event == eEventEnterRoomBeforeFadein) {
        int music = Room.GetProperty("RoomMusic");
        if (music >= 0) {
             roomMusic = Game.AudioClips[music].Play();
        }
    } else if (event == eEventLeaveRoom) {
        int music = Room.GetProperty("RoomMusic");
        if (music >= 0) {
             Game.AudioClips[music].Stop();
        }
    }
}

Stranga



SMF spam blocked by CleanTalk