Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: X3N0-Life-Form on September 16, 2013, 06:28:56 am

Title: [committed r9988] Custom sound for SSM strikes
Post by: X3N0-Life-Form on September 16, 2013, 06:28:56 am
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
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: m!m on September 16, 2013, 07:03:05 am
Two things I noticed:
Apart from that I don't see anything wrong with the patch although I didn't test it.
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: X3N0-Life-Form on September 16, 2013, 07:54:27 am
Roger that. I blame Visual Studio for #1 :P
stuff_sound seems to do the trick. Thank you.
OP updated.
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: m!m on September 16, 2013, 07:59:34 am
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.
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: AndrewofDoom on September 16, 2013, 10:03:39 am
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.
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: X3N0-Life-Form on October 16, 2013, 04:12:52 am
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.
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: niffiwan on October 27, 2013, 09:52:38 pm
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?
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: X3N0-Life-Form on October 28, 2013, 12:59:22 am
There it is:
http://www.mediafire.com/?y1ku2v744d8jc69
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: niffiwan on October 28, 2013, 04:54:58 am
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:
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: m!m on October 28, 2013, 04:57:34 am
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...
Title: Re: [patch submission] Custom sound for SSM strikes
Post by: niffiwan on October 28, 2013, 05:53:36 am
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