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
-
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
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
-
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.
-
Roger that. I blame Visual Studio for #1 :P
stuff_sound seems to do the trick. Thank you.
OP updated.
-
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.
-
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.
-
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.
-
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?
-
There it is:
http://www.mediafire.com/?y1ku2v744d8jc69
-
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:
-
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...
-
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