Sound
Sound is a feature that goes inside the features code block.
It would look like this:
{
"type": "Sound",
"fireSounds": [
{
}
]
}At first glance, there’s not a lot. But it’s a substantial and necessary feature.
Now ordinarily, you specify the shooting sound of the gun outside of the feature segment. Like this:
"compatibleAmmo": [
"ammocreative",
"ammo46"
],
"damage": 4,
"fireSound": "hl_mp7",
"fireModes": [
"SINGLE"
]Alongside other lines like compatibleAmmo and damage.
But fireSound will only define one firing sound for the gun. Let’s say you’re working on multiple firemodes for a gun, and you want the gun to sound different depending on the firemode.
Like, let’s say: an assault rifle that uses its regular side, but then when switching to the grenade firemode, it should fire with a grenade sound effect.
Or even some more mundane and basic: a gun that needs to use a different firing sound if it has a suppressor attachment on.
That’s where the Sound feature becomes useful.
Inside the feature, you define new sound effects and conditions. Here’s a complete example:
{
"type": "Sound",
"fireSounds": [
{
"sound": "spas12_silenced",
"volume": 1,
"condition": {
"hasAttachment": "sg_suppressor"
}
}
]
}Here, a new sound effect is defined, spas12_silenced, and it plays under condition hasAttachment sg_suppressor.
If the gun has the attachment sg_suppressor (Shotgun Suppressor), the gun will play the silenced gun sound.
There’s also a volume control. Since the gun is suppressed, it should sound quieter. Suppressed guns are usually at volume 1.
Let’s add more to the example:
{
"type": "Sound",
"fireSounds": [
{
"sound": "spas12_silenced",
"volume": 1,
"condition": {
"hasAttachment": "sg_suppressor"
}
},
{
"sound": "hl_spas12alt",
"volume": 6,
"condition": {
"selectedFireMode": "secondary"
}
}
]
}Here, we define two sounds. The first sound is the same as the one we just looked at. The second one plays a different sound under a new condition: selected fire mode.
If the gun is currently using fire mode Secondary, the gun will play this new sound when firing.
Now, let’s take a look at a complete example:
{
"type": "Sound",
"fireSounds": [
{
"sound": "mp7a2devgru",
"volume": 1,
"condition": {
"allOf": [
{
"unselectedFireMode": "grenade"
},
{
"hasAttachmentGroup": "smg_suppressors"
}
]
}
},
{
"sound": "mgl_shoot",
"volume": 6,
"condition": {
"selectedFireMode": "grenade"
}
}
]
}Here yet again, two sounds. This time, we have more conditions.
The second sound is what we’d expect. Play sound mgl_shoot at condition selectedFireMode grenade.
The first sound has condition ‘allOf’ meaning all conditions defined inside of that must be true all at once for the sound to play. Here, the sound mp7a2devgru plays when two conditions are true: unselected firemode is grenade, and has smg_suppressor. So the sound will play if the firemode is anything other than grenade, and also if it has an attachment from the attachment Group smg_suppressors.