I played around with it for a couple hours and put together a demo script for Arrival (the first level of the original Marathon scenario). Grab the latest version of the Aleph One package for Marathon and run the attached script as a solo script. I chose the original Marathon scenario because it already comes with music tracks that are played during the levels. Arrival is nice because apart from being the first level, it doesn't take long to play through if you know what you are doing.
What it does is change the music track that is played when certain actions occur:
* Entering certain polygons. The 3 areas are the starting area, the area with the narrow corridors, and the secret room.
* While reading terminals, reverts back when done
* Activating the switch that reveals the exit terminal. Once this event is triggered, the music no longer changes.
I verified that it works even when restoring a saved game. I did not try it in a network game.
PerseusSpartacus wrote:I'm sad that these functions have not been taken advantage of in any Marathon scenarios, and I'm somewhat curious as to how they work. What exactly are their abilities and limitations?
The limitations I found are that you can only play a song starting from the beginning of a track. So if you want to play a track briefly then switch back to the previous track, it isn't possible to pick up where you left off in the middle of the previous track. It also means you can't do cool things like have two versions of the same track at different tempos or have one in a major key and the other in the minor key and switch seemlessly between the two during a big fight or when the player is low in health, for example.
It also isn't possible to read what tracks are currently in the playlist, so in my sample script, for example, I had to hard-code the track that normally plays at the beginning of the level and then manually note of the track currently playing each time I changed tracks. This worked because I only ever had one track in the playlist at a time. If I had used multiple tracks, then it wouldn't have been possible to keep track of the current track and be able to switch back to it.
PerseusSpartacus wrote:For example, suppose I had a set-piece battle in my map. Suppose I then had a Lua trigger which checked to see whether the player has entered the room where that set-piece battle is supposed to take place - if that condition is met, the game will start playing music using the .play function given above. I assume I could then have another trigger which checks to see if all the enemies in that room are dead, and if they are, it uses the .fade function to stop the music I started when the player entered the room.
Yes, this is possible. The .fade() function not only stops the current song but clears the playlist too, resulting in silence after. You would then have to call .play() again to go back to the original track.
PerseusSpartacus wrote:Would the music, once started, continually loop? Given that those triggers above mention 'playlists', I assume it's possible to trigger a whole string of songs in order?
From my experimentation, it seems that once the last song in the playlist is reached, it will play that last song in a continuous loop.
I suggest you load the original Marathon scenario in Aleph One then play around with the commands yourself in the console. The tricky part for me was figuring out the names of the tracks, which are "Music/00.ogg" thru "Music/15.ogg"