Quote Originally Posted by Saffith View Post
I would say that giving scripts access to change the user's settings is pretty high on the list of things you should never do. If you want to give access to volume control, it should be something temporary that will automatically reset on quitting the quest. I'd also suggest that it be a 0..1 multiplier. That way, the same numbers will work consistently regardless of settings, and it will still make sense if the internal volume handling ever changes.
I did add a mechanic to clear it on quest exit. The issue with the volume controls, is that I see no way around calling master_volume(digi,midi) and similar. Anything that modifies volume would ultimately write to the base variables. (e.g., There is no mid-level interface to adjust the volume of a stream as it is playing, because the audio API is awful.)

Instead, I cached the user settings, and restore them on exit, winning the game, and so forth. When a script changes any volume setting, the script instruction sets an FFCore flag for that setting, and stores the original volume. When any end-the-game event occurs, the stored values are restored for each component for which a flag was set.

Allegro does not have any mid-level access to volume settings. i wish that it did, so that I could use an offset instead, but the way that the system works, an offset would still write to midi_volume, digi_volume, emusic_volume, whatever.

I also set up an event that occurs if ZC is not in alpha/beta status, whereby opening the sound prefs dialogue automatically reverts the values to the user settings, so that the change is completely transparent, and so that the user can override it.