Author Topic: [committed r9988] Custom sound for SSM strikes  (Read 2487 times)

0 Members and 1 Guest are viewing this topic.

[committed r9988] Custom sound for SSM strikes
I would like to submit the following patch for review. This features would allow modders to assign an alarm sound to be played when SSM strikes are being called, on a strike-type basis. The idea is to give the player an audio cue A) that a strike is inbound and B) what kind of strike is inbound.
It adds an optional "+Alarm Sound:" entry in ssm.tbl, which takes a sound index from the sound table.

Thoughts? Comments? Suggestions?

Attached files:
-the .patch file (identical to what's in code below)
-a small mod including table files and a simplistic test mission (using FS2 retail data)
-FSO & FRED builds

Code: [Select]
Index: hudartillery.cpp
===================================================================
--- hudartillery.cpp (revision 9788)
+++ hudartillery.cpp (working copy)
@@ -22,8 +22,9 @@
 #include "globalincs/alphacolors.h"
 #include "network/multi.h"
 #include "hud/hudmessage.h"
+#include "sound/sound.h"
+#include "gamesnd/gamesnd.h"
 
-
 // -----------------------------------------------------------------------------------------------------------------------
 // ARTILLERY DEFINES/VARS
 //
@@ -116,6 +117,10 @@
  stuff_string(s->message, F_NAME, NAME_LENGTH);
  s->use_custom_message = true;
  }
+ if (optional_string("+Alarm Sound:"))
+ stuff_sound(&s->sound_index);
+ else
+ s->sound_index = -1;
 
  // see if we have a valid weapon
  s->weapon_info_index = -1;
@@ -239,6 +244,9 @@
  else
  HUD_printf(Ssm_info[ssm_index].message);
  }
+ if (Ssm_info[ssm_index].sound_index >= 0) {
+ snd_play(&Snds[Ssm_info[ssm_index].sound_index]);
+ }
 }
 
 // delete a finished ssm effect
Index: hudartillery.h
===================================================================
--- hudartillery.h (revision 9788)
+++ hudartillery.h (working copy)
@@ -34,6 +34,7 @@
  char message[NAME_LENGTH];
  bool use_custom_message;
  bool send_message;
+ int sound_index;
 } ssm_info;
 
 // creation info for the strike (useful for multiplayer)

EDIT - changed entry name from "+Custom Sound:" to "+Alarm Sound:"

EDIT 2 - patch committed, updated thread title
« Last Edit: October 29, 2013, 10:38:04 am by X3N0-Life-Form »

 

Offline m!m

  • 211
Re: [patch submission] Custom sound for SSM strikes
Two things I noticed:
  • You have the wrong slash type in one of your includes, gamesnd\gamesnd.h should be gamesnd/gamesnd.h
  • There is a specialized function to parse sounds, I think its something like stuff_sound or parse_sound which should be used in place of your stuff_int as sounds may also be referenced by name.
Apart from that I don't see anything wrong with the patch although I didn't test it.

 
Re: [patch submission] Custom sound for SSM strikes
Roger that. I blame Visual Studio for #1 :P
stuff_sound seems to do the trick. Thank you.
OP updated.

 

Offline m!m

  • 211
Re: [patch submission] Custom sound for SSM strikes
Roger that. I blame Visual Studio for #1 :P
stuff_sound seems to do the trick. Thank you.
OP updated.
You can actually configure Visual Studio to use normal slashes somewhere. Also stuff_sound also has an optional parameter which lets you specify a string displayed in case something goes wrong.

 

Offline AndrewofDoom

  • In A.D. 2366 war was beginning
  • 29
  • Permanent yuri goggles.
    • Skype
    • Steam
    • Twitter
Re: [patch submission] Custom sound for SSM strikes
While having a different SSM sound is nice, I want to also be able to define the SSM's warp in type, just like a ship. Dimensional Eclipse uses SSMs and while I was able to make it warp in in a not FS way by making the warp effect so tiny, it still doesn't work as well if I could define it to be like the rest of the ships. Glorious HYPERSPACE.
My Efforts:
SF Knight

20:08:19   AndrewofDoom: Though I find it mildly disturbing that a loli is giggling to mass destruction.
20:10:01   Spoon: I find it mildly arrousing
20:10:07   AndrewofDoom: Woah
20:10:15   Spoon: sound like my kind of loli
20:10:21   Spoon: and im not even a lolicon

 
Re: [patch submission] Custom sound for SSM strikes
Bump.
Changed entry name from "+Custom Sound:" to "+Alarm Sound:", I think it describes better what the patch does.

@AndrewofDoom: I had  a quick look at warp effect creation without much luck so far. I'll probably look into it again at some point, then I'll ask someone more knowledgeable than myself regarding this part of the engine to point me in the right direction.

 

Offline niffiwan

  • 211
  • Eluder Class
Re: [patch submission] Custom sound for SSM strikes
The new patch looks fine to me, although I'd like to compile & run it as well to be sure :) Could you please re-attach the example table & test mission to make that easier for me?
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

  
Re: [patch submission] Custom sound for SSM strikes

 

Offline niffiwan

  • 211
  • Eluder Class
Re: [patch submission] Custom sound for SSM strikes
This may sound very odd... but where on earth is stuff_sound implemented?  I can find the definition in code/parse/parselo.h (added in r1697), but no implementation.  I've even checked the release branches back as far as 3.6.9 and there's no trace of it.   :confused:
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline m!m

  • 211
Re: [patch submission] Custom sound for SSM strikes
There is a parse_sound function in gamesnd.cpp, maybe the wrong function was used. We probably should remove stuff_sound if it doesn't have an implementation...

 

Offline niffiwan

  • 211
  • Eluder Class
Re: [patch submission] Custom sound for SSM strikes
OK, the stuff_sound declaration is gone.

I've tested the patch (updated to use parse_sound instead of stuff_sound) with a variety of sounds, specified by index / name / "rubbish data".  It works as advertised so I've committed the patch.

https://svn.icculus.org/fs2open?limit_changes=100&view=rev&revision=9988
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...