• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Need Help Adding SFX when sea battle

Benouyt

HoO Team Member
Provisional
Hello !

I would like to know how can i do for when my ship is in battle, the game would play some random (or loop, i dont know yet) sfx. Ex: sounds with peoples running, metals sound, wood, repair, etc...

Also, how can i do for add sfx when i sail up (like someone yelling) or when battle start ? (like a bell at beginning of the battle)

Thank you for your help !
 
Those are all different questions, and they need to be tackled separately, as the functions that make those events happen are located apart.

The simplest (and most performance-friendly) way to accomplish the in-battle sounds would be to create a long sound file of a battle for yourself and play that like background music, in a loop.

The command to do that is:
Code:
PlayStereoSoundLooped("mysound");
Where "mysound" is a sound file, or a series of sound files you have set to play under that name/label/alias in "RESOURCE/INI/aliases/sound_alias.ini", like in this example:
Code:
[mysound]
volume = 1.5
name = peoplefight\boarding_people_01.wav
name = peoplefight\boarding_people_02.wav

Note that your sound file(s) need(s) to be in "RESOURCE/Sounds" (or where the rest of the sound files are), and your path to it in the INI needs to be correct for the audio file to play, naturally.
 
Thanks for answer ! Where can i get a list or something like that where i can see how actions is called ? (like sail up, sea battles etc....)?
 
That single function call line is the entire call. It makes the sound start playing and loop it. You need to place this line where the event initialises/starts that you want to play the sound at.

You can have a look in "Program/sound.c" for a complete list of sound playback functions, and at the "SetMusicAlarm" function there on how to implement.

If you just want to play a simple interface sound (like audio feedback for the player when sails are raised), you can use:
Code:
PlaySound("interface\mysoundfile.wav");

To implement this for the sails actions, look in "Program/battle_interface/BattleInterface.c". (Search for "sail_none".)
 
Actually, i don't understand in wich file i must put those lines,

I edited sound alias and putted this :
Code:
[bseabattle]
prior = 10
minDistance = 50.0
maxDistance = 185.0
volume = 0.0
name = Sea Battles\actions.wav
for battle but i guess it miss the trigger part in "program" ? and i don't know how where search.

Also for the raise up sail i did that
Code:
        case "sail_midi":
            Ship_SetSailState(charIdx,0.5);
            PlaySound("interface\raise.wav");
        break;
but it don't work neither
 
I'm not certain but you may have to start a new game for changes to the sound file to take effect.
 
I'm not certain but you may have to start a new game for changes to the sound file to take effect.

No, that's not necessary in this instance. That mostly applies to dialog file changes.

Actually, i don't understand in wich file i must put those lines,

I edited sound alias and putted this :
Code:
[bseabattle]
prior = 10
minDistance = 50.0
maxDistance = 185.0
volume = 0.0
name = Sea Battles\actions.wav
for battle but i guess it miss the trigger part in "program" ? and i don't know how where search.

1. Make sure that volume is not "0.0", or you won't hear a thing play. Set it to "1.0".

2. Make sure that "actions.wav" is actually to be located in the "RESOURCE/Sounds/Sea Battles/" folder.

3. Make sure that there is only one "bseabattle" entry in the INI file. If there is another one, rename your one to something else.

4. Put
Code:
PlayStereoSoundLooped("bseabattle");
inside the a function where "abordage" (boarding battle) is starting, and
Code:
StopSound("bseabattle", 0);
when the player enters the captain's cabin to fight the enemy captain.

Also for the raise up sail i did that
Code:
        case "sail_midi":
            Ship_SetSailState(charIdx,0.5);
            PlaySound("interface\raise.wav");
        break;
but it don't work neither

That looks fine. Is "raise.wav" located in "RESOURCE/Sounds/Interface/"?
 
No, that's not necessary in this instance. That mostly applies to dialog file changes.
Huh? In PotC, you don't even need to close the game at all for dialog changes to take effect. :shock
 
Thanks for the help, i got my ambient sound work for sea battle (now peoples is yelling and stuff when i shoot on ships, yay !)

But but, i still don't get the sail sfx to work. I don't understand why... Maybe its because BattleInterface is already used by hooks mod ?
 
Tried in another file but doesn't work neither.

I put here the code if maybe someone understand (i changed the files names)
Code:
case "BI_Speed":
        switch(locName)
        {
        case "sail_none":
            PlaySound("interface\saildown.wav");
            Ship_SetSailState(charIdx,0.0);
            
        break;
        case "sail_midi":
            PlaySound("interface\sailup.wav");
            Ship_SetSailState(charIdx,0.5);
            
            
        break;
        case "sail_fast":
            Ship_SetSailState(charIdx,1.0);
        break;
        
        }
        break;
 
If you're using Hookmod, feel free to make your changes to my version of BattleInterface. Unfortunately, only one mod can change a file.

Good luck.

Hook
 
Tried in another file but doesn't work neither.

I know why. (I realised it earlier today.) It does work, I just forgot to mention that this is for making it play when you select the sails setting in the actions menu, not when you quick-set it by pressing the forwards and backwards buttons. Sorry... :oops:

You can implement it for the quick-setting as well, I'm just not sure where the function for that lies. Possibly somewhere in "controls.c"?

Huh? In PotC, you don't even need to close the game at all for dialog changes to take effect. :shock

CT (and onwards) saves all currently loaded character settings and dialog, as well as world settings such as weather profiles and map/level locators, into the game save file. This makes it impossible to make on-the-fly changes to this content. All character dialog is loaded when the new game runs for the first time. Once you save, that's it. Or at least that has been my practical experience while developing for it and testing.
 
CT (and onwards) saves all currently loaded character settings and dialog, as well as world settings such as weather profiles and map/level locators, into the game save file. This makes it impossible to make on-the-fly changes to this content. All character dialog is loaded when the new game runs for the first time. Once you save, that's it. Or at least that has been my practical experience while developing for it and testing.
PotC also sets a whole bunch of things at game start, such as characters, ships, islands, etc.
But the dialog files are only loaded when the dialog is started and reloaded when it is started again.
Is that really different in the later games? I wonder why they changed that; seems needlessly inconvenient to me. :shock
 
Thank you for your help ! i'll try all that when i'll have time !

Also, simple question i wanted use play3dsound instead of playstereosoundfor my battle loop, i get it to work but the loop is like really short (1 milisec ?) how can i get it to work looped correctly ?
 
PotC also sets a whole bunch of things at game start, such as characters, ships, islands, etc.
But the dialog files are only loaded when the dialog is started and reloaded when it is started again.
Is that really different in the later games? I wonder why they changed that; seems needlessly inconvenient to me. :shock

Now you made me curious. I'll have to double-check and get back to you on this one.

It does indeed make not much sense other than to force the player's story character dialogue to be consistent within a game. I imagine it would bloat the save file considerably...

Also, simple question i wanted use play3dsound instead of playstereosoundfor my battle loop, i get it to work but the loop is like really short (1 milisec ?) how can i get it to work looped correctly ?

I'm not sure. I've never used "Play3DSoundComplex", but it seems hard-coded. Or is there a "Play3DSoundLooped" in TEHO?
 
Now you made me curious. I'll have to double-check and get back to you on this one.

This is indeed how it works. The dialog scripts are loaded with a loadsegment command so you can make changes when outside the dialog with the game paused, then enter the dialog again and see any changes you have made. I do this all the time with edits to my console.c file, which is also a loadsegment.

Hook
 
Which dialog file gets loaded for a character to speak gets frozen in the save
That makes sense; that's part of the character initialization.
But of course it is possible to override that if you want to. :yes
 
Back
Top