This article is obsolete and has been replaced here: Weapons and Sound.
The weapon system of CryENGINE 3 supports various actions which are also used to trigger sounds.
Core of the system are the weapon scripts stored under \Game\Scripts\Entities\Items\XML\Weapons
. When looking inside there are many actions triggered by Game Code also a sound can be attached:
<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>
Parameter | Description |
---|---|
action name | Specifies weapon action in conjunction with game code. |
sound target | Specifies first person or third person sound in conjunction with game code. |
name | Specifies sound event name starting from sound root folder. |
radius | Specifies radius of the sound the AI reacts to it. |
static | Specifies whether sound should stop immediately when switching the weapon. |
synched | Specifies whether sound should look for sync points within FMOD and plays until the next marker before stopping. |
For sync points the asset and FMOD have to be prepared accordingly. The asset requires markers to be placed at the position of the sync point:
Also the Soundbank has to be flagged accordingly inside the FMOD Designer:
To set up different tail sounds based on the environment the FMOD event requires the “environment_sound” parameter. Once created, it will take the “environment” value from the ReverbVolume entity to allow modification in real time using FMOD effects.
The image below shows a oneshot gunfire.
If the gun is fired in an area with the ReverbVolume environment value=1, it will pick the outdoor tail sound definition.
If the gun is fired in an area with the ReverbVolume environment value=2, it will pick the indoor tail sound definition.
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 enhance by increasing the environment parameter values and add more sound definitions. To trigger the wanted tail behavior in game the ReverbVolume entity requires the Environment entry to be set correctly.
In this example the outdoor tail is being set (environment = 1).
Creating one FMOD project per weapon has proven to be a good choice. It not only helps keeping an eye on memory budget it also enables multiple designers to work at multiple weapons at the time.
Splitting the FMOD soundbanks according to the sound target as well as a "shared" bank for elements both targets use will decrease memory usage and also enables the AFCM to only load the soundbank which is needed via the gamehint system.
Also reusing the tails on single gunshot SoundEvents do save some memory since the actual attack of the gun is fairly short from an asset perspective.
Also using FMODs granular functionality helps to save memory while avoiding repetition. By this the original loop gets cut into small pieces of three to six shots and randomized via the SoundDefinition property as shown in the example below.
i_reload is an important CVar. It will reload all weapon scripts.