On this page
Radio, the comm rose and soldiers' voices
"Enemy boat spotted!" is four systems working together: a menu item that is a console command, a network event of a few bytes, a registry that turns a message name into one of several recorded variants in the right team's language, and a rule that decides whether you hear it over the radio with a filter or from the mouth of the soldier next to you. This page follows one call.
The registry#
VoiceMessages is loaded with each level (GameLogic::loadVoiceMessages, BF2.exe!0x004edb40), after the level's Init.con has named the two teams' languages. Common/Sound/VoiceMessages.con fills it:
| Command | What it adds |
|---|---|
addMessage <name> | a message; at most 256 |
addRadioVoice <voice> <radio file> <text> [<local file> [<flags>]] | a variant of the last message for one voice: the file heard over the radio, the text for the chat, and optionally the file a soldier speaks aloud |
addRadioFilter <name> <file> | a noise bed played with a radio line: a cockpit, a tank's interior |
addHelpMessage <name> <file> | a line of the help voice |
setVolumes <radio> <filter> | the two volumes |
There are up to eight voices; the shipped data uses three in earnest: commander, squadleader, grunt. A message can have several variants a voice, and one is drawn at random each time (getSpeechId, 0x004f7590: start + rand() % count), which is why the same call does not sound the same twice.
Two details the notes found:
- At Low sound quality a second variant of a line is refused: the registry keeps one recording a line, 153 fewer with the shipped scripts. Low quality also makes no soldier-voice sounds at all.
- A voice name is case-sensitive, and the shipped data spells
squadLeaderwith a capital L on two lines: that is a fourth voice, used by nobody else.
Languages: the radio speaks each team's language (set by gameLogic.setTeamLanguage), unless the player chose English-only voices; the help voice speaks the player's language, or English when that language ships no voice files. A dedicated server has no audio settings and uses one language for all.
From the rose to the wire#
The comm rose is HUD data. Its scripts map each item to a console command (radioInterface.setStringMap), and a click runs RadioInterface.selectOrder (0x007a0de0): it opens a sub-menu where there is one, else runs the item's command and closes the rose. On foot the items are, in the shipped scripts: spotted, go go go, need a pickup, negative, need ammo, follow me, need a medic, roger that, need backup, thank you, sorry. A vehicle's rose, a squad leader's and the commander's are other files of the same kind. A mod changes the rose by editing them.
Most items run game.radioMessage <channel> <message>. The channel says who should get it: the local team, the whole team, a squad, a vehicle's crew, the team and nearby enemies.
On the wire it is RadioMessageEvent (read 0x0053e8f0, write 0x0053e9e0): the message's id in 8 bits, the sender's player id in 8, the team in 2, a flags byte, the channel and a type. The server's part is to send it on to the players the channel names. It does not pick a variant, a voice or a text: a message id is all that travels.
What the receiver plays#
Game::playbackRadioMessage (0x004441d0), on each client that got the event:
- The voice and the filter. No sender (the game itself speaking): the commander's voice and filter. Otherwise the sender's vehicle decides the filter: the
soundFilterof the first seat up from what he controls. A commander gets the commander's voice and filter; a squad leader the squad leader's voice; anyone elsegrunt. - Your own call is played without a filter.
- Aloud or over the radio. If the sender is a soldier on foot, is not you, and the quality is not Low, the client first tries the soldier's own voice (below). Only if that is refused does the radio play: the variant on the team's radio sound, and under it the filter, looped as many times as it needs to cover the line's length.
- The text goes to the chat with the sender's name, unless the sender is on another team than you.
A commander who sits in a vehicle whose soundFilter is empty ends up on the default filter and not the commander's: the flag for "use the default" is computed before the commander's case and never cleared. The port does the same.
A soldier's own voice#
VoiceMessages::playSoldierVO (0x004f7f90). The line's variant must have a "local" file, and its flags decide who may hear it this way:
- unless the flag says otherwise, only your own team's soldiers are heard aloud;
- unless the flag says otherwise, only a speaker within 15 m of your camera.
Then the speaker needs one of the two voice slots a team (getFreeVOSoundIndex, 0x004f7820): a silent slot is taken; else the slot whose speaker is dead; else the slot of the farthest speaker, and only when the new speaker is strictly closer. So when three soldiers around you shout at once, you hear the two nearest from where they stand, and the third over the radio.
The soldier-voice sound is 3D with a minimum distance of 3 m and reverb, and it follows the soldier (voices and space). A soldier who starts a new line stops his previous one softly.
The help voice and automatic lines#
- Help lines ("press E to enter the vehicle") play on a 2D sound in their own volume group, and only when that group's volume is above 0.05: turning the help voice down in the options to nearly nothing switches them off.
- Automatic lines are the ones the game itself triggers (their own file of the registry). They are radio messages, with no sender or with the soldier concerned as the sender, and follow the same path.
2142 keeps the registry, with its voice files in another folder. Heroes' HUD scripts have emotes and personal message lines in their communication folder (the Heroes HUD); the sweeps have not read Heroes' radio path, so this page says nothing about it.
What the port has#
| Part | State |
|---|---|
| the registry: messages, voices, variants, filters, the Low quality rule | ported (bf2_audio::voice) |
playbackRadioMessage: voice, filter, the commander's quirk, the text | verified against the original function |
| the soldier's voice: flags, the 15 m, the two slots, the farthest gives way | verified against the original functions |
| the event's layout | ported with the network events (packets) |
| the comm rose's menus and sending | ported in the client (bf2_client::radio) |
| bots' radio: the queue, the hub, who answers | ported with the AI (bots) |
One thing the port cannot inherit: a speaker of a team other than 1 or 2 makes the original read before the start of an array. The port answers "no slot".
How it is tested#
- Registration against the original (
crates/bf2-audio/tests/voice_oracle.rs): the original's own methods are run for adding messages and radio voices, with generated input and with the shipped scripts, and the port's registry, the soldier's voice-over and the radio playback must match. - Every shipped voice definition resolves to a file (
retail_voice.rs). - On the wire (
crates/bf2-net/tests/it_bf2/generic_events_bf2.rs): every such event writes and reads back through the event stream's own codec. - 2142: its message count, volumes and filters have tests of their own.
All eight addresses of this page stand in a test's own text.
In the code#
| What | Where |
|---|---|
| the registry and playback | crates/bf2-audio (voice) |
| the comm rose and sending | crates/bf2-client/src/radio.rs |
| the HUD's side of the rose | crates/bf2-hud |
| the event | crates/bf2-net |
Notes: notes/subsystems/audio.md (section 14), notes/subsystems/ai-behaviour.md (section 48), notes/subsystems/network-events.md.
docs/dev/audio/radio.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.