Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
Just like the IE games, battle music is _very_ annoying, cutting in every 3 minutes with a bombastic percussion. The alternative is turning off music altogether, which i'm sure you'll agree is unoptimal.
A patch i made is attached. It has 3 settings, Enabled, Ambient, Silent.
Enabled is as normal.
Ambient is supposed to only allow 'non-combat' music, but for some reason (probably the 'looping' feature), exult opens the Danger music with one of the 'start_music()' functions instead of the 'start_combat_music' function
Silent makes the combat be silent, except for SFX effects, if you have the packs. It pauses the current playing audio and resumes it if the avatar combat schedule is ended with no opponents or with the avatar dying (so music is immediately restored in those cases). If another situation occurs, like running away from opponents, the next time a normal song is queued for playing, it checks that the avatar is not near someone that wants to kill party members or that the avatar doesn't want to kill anyone. This naturally 'resets' the audio once a audio egg is triggered and no combat is occurring later on.
New version corrects the audio unpausing after the game is resumed from 'windows focus-loss pause'.
version 3 of the patch fixes a transition to a combat music using the normal function instead of the dedicated combat one in gamewin.cc. This fixes the ambient mode unconditionally playing the danger music.
version 4 of the patch fixes the small window of time in which the normal music would play in battle silent mode on load of a savegame that was created while in battle. This is probably the last version of the patch.
version 5 makes the load save a bit more safe in case a save was loaded with battle mode silent
and also makes changing the menu from any other to silent mode while on combat 'silence' the song
(the other transitions would require me to guess which music was appropriate and at least on the case of combat music, it gets set anyway on first hit, so i depended on that).
version 6 of the patch is much simpler. It only allows hearing combat music or not, no silence during combat (unless we couldn't capture a adequate loop music, in which case it will play SFX, if it can, until the next music egg/combat).
This allows me to minimize the amount of foreign code touched. In fact, only Audio.cc and AudioOption_gump really have functional code. There are a few touches in gamewin.cc but those are mostly janatorial, making some combat music invocations use the dedicated combat music function.
The patch also fixes the bug i recently reported of music that was played nonlooping, continuing to loop if the Audio Options menu was accessed with the looping option on (it took the global setting and applied it to particular instances it shouldn't like combat music when it tried to restart the currently playing music).
It fixed the bug, but in a very different way than it would be fixed on a exult without the patch. If you don't accept this patch, you can fix it by accessing not only the current_track but also the repeating status, and use that to restart the song:
track_playing = mixer->getMidiPlayer()->get_current_track();
shouldLoop = mixer->getMidiPlayer()->is_repeating();
Anyway, i'm requesting a code review with the intention of merging.
can you add a patch for just the combat looping bug? Because I could add this but this patch is beyond my capabilities and "jurisdiction" :)
Ok then. When you apply it i will have to regenerate this patch because it won't apply cleanly no more, no prob.
And here is the combat song patch that works applied on top of the loop_bug.diff patch, if the powers that be decide it is acceptable later on:
hmm, I actually can't reproduce the looping problem.
Can you give exact steps to reproduce? I tried toggling looping music and then with it on, attacked the outside Trinsic horse. After it died the combat music would eventually stop (regardless whether I exited combat or not).
I looked up the original and actually combat music should not get played when attacking non-hostiles. Neither the theme nor the fanfare on successful kill. IMO Exult should either follow the original in this matter OR at least play the fanfare after successful killing regardless whether the npc was hostile or not.