Log in

View Full Version : How do I trigger sounds etc.?


Vorkapitan
09-03-10, 07:37 PM
Ok Mates,

I searched everything on "sound" but am at a loss as to what/how to do sound triggers...

ist. What triggers a sound?...I see text like "tube 1 flooding" but there is no sound triggered for it (there is a sound wav for it.)

2nd. Is there a way to trigger this sound based on a menu switch?

3rd. if there is no sound for this, is there a way to "add" a sound?

4th. Can this be done via a script?

I need all the help I can get. :damn::damn::damn::damn::damn:

Thank you.

Venatore
09-03-10, 07:47 PM
I'll will be watching this Thread closely as I too am curious about this.....example; you hear the periscope going up down mechanically whilst inside, however; standing out in the conning tower if the scopes go up/down you hear nothing :hmmm:

Bump:-:damn:

Vorkapitan
09-03-10, 08:09 PM
Venatore,

When I did a search on all of Subsim radio room forums, I thought I saw an explanation of the problem you are describing.

I'm not sure that it will help.

Venatore
09-03-10, 08:37 PM
Vorkapitan,

Hey matey, it was in discussions within my mod thread. I'm as keen as you are to find out the mystery of the triggers for sound :06:

Bump :damn:

skwasjer
09-03-10, 08:44 PM
Ok Mates,

I searched everything on "sound" but am at a loss as to what/how to do sound triggers...

ist. What triggers a sound?...I see text like "tube 1 flooding" but there is no sound triggered for it (there is a sound wav for it.)

2nd. Is there a way to trigger this sound based on a menu switch?

3rd. if there is no sound for this, is there a way to "add" a sound?

4th. Can this be done via a script?

I need all the help I can get. :damn::damn::damn::damn::damn:

Thank you.
1) Crew speech can be added in .aix files (SH5 only, quite possible the preferred method since you can add variation and choose sounds depending on scenario) and/or via StateMachineClass (SH3/SH4, not sure about SH5), and I'm guessing some of it still is hardcoded too.
2/3) Yes, of course: <Button>.OnClickSoundName = "<SDL-identifier>" (to override default button sound) or Menu.PlaySound("<SDL-identifier>")
4) Yes, (see 2/3) but when called from script it is not 3D aware, meaning if you order it from the bridge, it will be as loud as if you were in the torpedo room. This is fine for crew speech (check SubmarineCommandsWrapper.CommandWasGiven-event for the handler to use in such scenario's), but not for location specific sounds.

I have not looked into SH5 to closely, but in SH4, the technique for events like this (since it lacks a script engine), is to trigger them from StateMachineClass controller. You will first need to put an aud node where you want the sound to be heared in the DAT-file, and add the associated SoundInfo controller for it (DSD). And of course add an SDL-sound entry (toggling 3D to make it location aware, 2D for a global sound). Then, in the StateMachineClass controller (can build it from scratch for this purpose alone, but can also reuse the generic sub StateMachineClass DAT-file) you add a handler for the Open/Close tube SH-command, and trigger the sound from there (by calling the node label using PlayAnim or PlaySound, i don't remember).

Vorkapitan
09-03-10, 09:21 PM
SKWASJER,

Thank you very much for the detailed info, now if someone could explain what you said....:rotfl2: I'm not sure where to begin...maybe I can get some help from DW or Reaper or anyone else who cares to get involved.

Thanks again for the quick response. :know:

skwasjer
09-03-10, 09:57 PM
Ok, heh...

Well, in the question you only asked for how to add a sound to a command. This in particular could be implemented via different ways, so I just threw in the approaches I could think of.

Using script is probably the easiest, but it may not cover all the situations you want to implement, and as said is not 3D-aware.


from game import Game
from menu import Menu

def sc_CommandWasGiven( e ):
if e.CommandText == "Open_torpedo_tube":
Menu.PlaySound( "<sdl-identifier>" ) # Needs an SDL-identifier f.ex.: torpedo.openTube. This is a generic message.
elif e.CommandText == "Open_sel_torpedo_tube":
Menu.PlaySound( "<sdl-identifier>" + ( e.Param1 + 1 ).ToString() ) # Needs an SDL-identifier f.ex.: torpedo.openTube1, torpedo.openTube2, etc. This is a message per tube index (Param1 is 0-based tube index).

def InitializeScript():
Game.SubmarineCommands.CommandWasGiven += sc_CommandWasGiven

def UnloadScript():
Game.SubmarineCommands.CommandWasGiven -= sc_CommandWasGiven

I have not tested this script, as this was written outside of the game, but this is roughly what you need...

Vorkapitan
09-03-10, 10:03 PM
SKWASJER,

As you will see in the PM I sent, I was more definitive in what I was trying to accomplish.

Your script will give me a base to start with...so thank you very much.

:salute::salute::salute: