Has anyone ever successfully used this function to play a sound during gameplay? After researching everything that's ever been written in our forum on the subject, I have my doubts-- my impression is that this function doesn't work, but that even if it did no one knows how to deploy it. I also noticed that even the hard-core sfall scripting guys like phobos2077 and Jim the Dinosaur are still adding sounds to their mods by modifying sndlst.lst rather than using play_sfall_sound. I've fooled around with it on several occassions, and can't get it to work. For the benefit of everyone (most previous discussion of the matter consists of unanswered queries), I decided to make this post and see if we can get to the bottom of this matter.
In theory, play_sfall_sound could be a great benefit for compatibility between mods. If each modder whose work adds sounds to the game makes acms and includes a custom sndlst.lst with his mod, most end-users won't understand how to combine different mods. For those interested, the Fallout 2 Mapper will make a new sndlst.lst to incorporate all acms it finds in the data\sound\SFX\ directory if the existing copies of sndlst.lst in both data\sound\SFX\ and master.dat\data\sound\SFX\ are deleted or renamed (e.g. old_sndlist.lst).
In any case, I can't get play_sfall_sound to work. For purposes of an example, let's say I have a harmonica item (obj pid 605). When the player-character uses the item, a short sound effect (harmonica.wav) of a harmonica tune is to be played. I put a wav file (22,050 kHz mono) called harmonica.wav in data\sound\SFX\. In the use_obj_on section of obj_dude.int, I include the following code (Ruby format-- FSE/sslc users should get rid of the "op_" prefixes):
Code:
if (op_obj_pid(op_obj_being_used_with()) == 605) then
begin
op_play_sfall_sound("data\\sound\\SFX\\harmonica.wav", 0);
op_script_overrides();
end
For beginners, note that the "op_script_overrides()" is important to prevent a spurious message "That does nothing" from appearing in the message box during gameplay after the item is used.
Anyway, it doesn't work. When the pc uses the item during gameplay, the game crashes. There's nothing wrong with my object proto either, because a test function:
Code:
if (op_obj_pid(op_obj_being_used_with()) == 605) then
begin
op_display_msg("Beep!");
op_script_overrides();
end
works fine.
Apart from a number of questions over time from various people that seem never to have been answered, the only substantive previous discussion of this issue was over here, where we find the following suggestion for using the function:
Timeslip said:Code:variable tmp; tmp:=play_sfall_sound("Patch000.dat\\sound\\SFX\\geigerhigh.wav",1);
But this suggestion makes no sense, because a variable is not an instruction. In this case, the "tmp" would then have to be passed off somewhere else as part of a valid instruction in order to get a sound to actually play. And even if a sound did attempt to play, as I said earlier something is wrong because the game crashes when the function is called.
The function's documentation consists of the following:
sfall function notes.txt said:play_sfall_sound and stop_sfall_sound are used to play mp3/wav/wma files. The path given is relative to the fallout folder. Specify loop as 1 to loop the file continuously, or 0 otherwise. If you don't wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. These functions do not require 'AllowDShowSound' to be set to 1 in ddraw.ini.
If anyone has experience on this issue and has both compiled a script including the function play_sfall_sound and has then seen the function actually work by hearing the sound in question played at the appropriate time during actual gameplay, please comment here for the benefit of all interested parties by including all the relevant code you used to accomplish this as well as any additional caveats (sound file in a certain format, required ddraw.ini settings, etc).
If play_sfall_sound doesn't work, it's no big deal-- we'll always have acms. But if that's the case then we're all better off knowing so no time is squandered messing around with it. Thanks.