Author Topic: Adding Sound FX  (Read 1341 times)

0 Members and 1 Guest are viewing this topic.

Hey! I am new to Freespace 2 modding. I recently got the game and cannot believe I just realized how incredible the game is. The modding community really grew this title.
Anyway, I am new to modding and was wondering if it is possible to make a mini mod that either A) modifies sound FX, and/or B) add new parameters of code to insert new sound FX. For example, adding a new string or line of code that plays "sound1.wav" when hull integrity is at 50%. Any help would be appreciated! Thanks!

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
For example, adding a new string or line of code that plays "sound1.wav" when hull integrity is at 50%. Any help would be appreciated! Thanks!

For things like that, in most cases you'd need to implement it as a Lua script. Some would be simple to make, some complicated, depending on exactly what kinds of conditions you need.

Some links to get you started, if you decide to go that route:

http://www.hard-light.net/wiki/index.php/FS2_Open_Lua_Scripting
http://www.hard-light.net/wiki/index.php?title=Scripting.tbl
http://www.hard-light.net/wiki/index.php/Category:Scripting_Examples

 
Thanks for the quick response! Definitely helpful links! Basically, my idea is pretty simple: I just want to add 3 new sound FX when hull reaches 75%, 50%, and 25%, just to alert me to my damage as it is not entirely apparent right away in the heat of a firefight. Having 3 new sounds going off would be a great audio cue for me as to my current ship status.

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Thanks for the quick response! Definitely helpful links! Basically, my idea is pretty simple: I just want to add 3 new sound FX when hull reaches 75%, 50%, and 25%, just to alert me to my damage as it is not entirely apparent right away in the heat of a firefight. Having 3 new sounds going off would be a great audio cue for me as to my current ship status.

That should be very easy to implement. Basically, you could do it as an $On Frame hook, which runs every frame, keeps track of the player's ship's hull integrity in some variable, compares the current integrity to what it was last frame, and plays the appropriate sound if it's dropped below the given threshold.

You should find plenty of examples of $On Frame hooks which do things based on the player ship's attributes. The Velocity Indicator in the examples page would be one. Usually the trickiest part ends up being making sure that a script doesn't barf any error messages when the player is dying, at mission start, restart, quick restart on death, and that sort of situations when the player ship handle can be in unexpected states.

 
So I would create a sounds.tbl and include the 3 new sound FX. How would I go about making a $on frame hook which keeps track of the ship's hull?