The weapon system of CryENGINE 3 supports various actions, which are used to trigger actions such as animation, effects, and sounds. Within the weapon system, one-shot, tail, and looping sounds are the typical types of FMOD events used.
GameScriptsEntitiesItemsXMLWeapons
.For this example, we will open the SCAR.xml
file in a text editor.
<action name="fire"> <animation target="firstperson" name="fire_bullets_right_%suffix%01" /> <animation target="owner" name="shoot" /> <sound target="firstperson" name="sounds/weapons:scar:fire_single_fp" radius="200" static="1" /> <sound target="thirdperson" name="sounds/weapons:scar:fire_single_3p" radius="200" static="1" /> </action> <action name="rapid_fire"> <sound target="firstperson" name="Sounds/weapons:scar:fire_loop_fp" radius="200" static="1" synched="1"/> <sound target="thirdperson" name="Sounds/weapons:scar:fire_loop_3p" radius="200" static="1" synched="1"/> </action> <action name="spin_down"> <sound target="firstperson" name="sounds/weapons:scar:fire_tail_fp" radius="200" static="1" /> <sound target="thirdperson" name="sounds/weapons:scar:fire_tail_3p" radius="200" static="1" /> </action>
action name=
property specifies weapon action in conjunction with game code.sound target=
property specifies first person or third person sound in conjunction with game code.name=
property specifies the sound event name starting from the sounds
root folder.radius=
property specifies the radius of the sound to which the AI entity reacts.static=
property specifies whether sound should stop immediately when switching the weapon.synched=
property specifies whether the sound should look for sync points within FMOD and plays until the next marker before stopping.YES
.This directly connects with the Reverb Presets environment's setting. It enables different tail settings, depending on the environmental setup.
The following screenshot shows an example of such a setup:
In each case, the upper layer with just the attack of the single shot is being triggered. The second layer reacts to the environment setting triggering either a long outdoor tail (0 - 1.5) or a shot indoor tail (1.5 - 3).
This system can easily be enhanced by increasing the environment parameter values and adding more sound definitions. To trigger the required tail behavior in the game, the ReverbVolume entity requires the environment entry to be set correctly.
You have now learned about using sounds and weapons together so that you can create your own weapon sounds. You have also seen how you can make them interact with the ReverbVolume entity to make the sound blend into the level more seamlessly, as discussed earlier in the chapter. We also saw where to add sound events so that they are played on certain weapons. Additionally, we discussed the relevant properties used by the sound and weapon system to trigger sound events.
Creating one FMOD project per weapon has proven to be a good choice. It not only helps to keep an eye on the memory budget but also enables multiple designers to work with multiple weapons at the same time. Splitting the FMOD sound banks according to the sound target as well as a "shared" bank for elements, which both targets will use, will decrease the memory usage. It also enables the Audio File Cache Manager (AFCM) to only load the sound bank, which is needed via the gamehint system. Also, reusing the tails on single gunshot sound events does save some memory, since the actual attack of the gun is fairly short and thus requires less memory.
Also, using FMOD's granular functionality helps to save memory while avoiding repetition.By doing this, the original loop gets cut into small pieces of three to six shots and randomized via the Sound Defs property, as shown in the following screenshot:
18.191.235.8