On this page
Name tags: who gets one, when it shows, where it sits
The names over soldiers' heads are not part of the HUD's node tree. They belong to the renderer, in a manager of their own that keeps a record for every player, every order and every object worth a label, decides each frame whether each is visible and how strongly, and draws them all in a handful of calls. The rules are small and exact, and they shape play more than most: when you can see an enemy's name is when you know he is one.
Three kinds, fixed slots#
NametagManager (RendDX9.dll!0x1012fb30) has three kinds of tag, each with a fixed number of slots:
| Kind | Slots | Who |
|---|---|---|
| players | 64 | every player the client knows, from the moment he is added |
| orders | 2 | the squad's order markers |
| objects | 64 | control points, strategic objects, supply crates, deployables, a dropped vehicle, the UAV, some projectiles |
A slot is one entry of three arrays the shader reads: a transformation, an alpha and a colour index. A freed slot's transformation is parked behind the camera.
When a tag shows#
Each frame the manager's update (0x10130680) runs for every record: its timer, its distance, its visibility, its projection, its alpha, its style and its text. The settings are nametags.* properties, with these defaults:
| Setting | Default | Meaning |
|---|---|---|
maxFriendlyDistance | 120 m | a team mate's tag beyond this is not shown |
deployableDistance | 40 m | the same for deployed things |
maxCallDistance | 150 m | how far a request icon carries |
enemyDotLimit | 0.99999 | how squarely you must look at an enemy for his tag |
enemyTagDelayTime, FadeInTime, FadeOutTime | 1 s each | an enemy's tag waits, fades in, and fades out |
manDownFadeOutTime | 14 s | a downed soldier's tag fades this slowly |
deathFadeOutTime | 0.6 s | a dead one's goes fast |
| cull distances | players 100 to 300 m, orders 100 to 1200, objects 0 to 1200 | where each kind's text fades and ends |
Friends are tagged by distance. Enemies are tagged by aim: every half second the manager casts a ray along the crosshair (0x1012d590), and an enemy's tag appears only for one it finds, after the delay. By these settings, glancing past an enemy shows nothing and holding the crosshair on him for a second shows his name; the alpha function itself (0x1012ec10) is cited in the notes and not spelled out, so take the sentence as a reading. A game setting can turn the arrows, bars and icons off altogether.
Distances shown in a tag are rounded with hysteresis, in steps of 2, 5 and 9 metres by range, so the number does not flicker.
The style: colour and icon#
0x1012e1e0 picks them for a player's tag:
| You look at | Colour |
|---|---|
| an enemy | red (or his team's colour) |
| a team mate | blue |
| a member of your squad | green |
| a squad leader, when you are the commander | green |
| the commander | blue, with his icon |
The icon in front of the name says what he is: on foot, a squad leader with his squad's number, the commander, or the category of the vehicle he sits in (a table of about twenty vehicle icons). The rank icon comes from his score data.
Requests override it. When a player calls for a medic, ammunition or repairs, his tag carries that icon for 12 seconds. As read, which request shows goes by a kit: medic first, then engineer, then support.
Bars for those who can help#
Three extra draws exist only for certain viewers:
- a health bar under friendly soldiers on foot below half health, for a viewer whose kit heals (
0x101b1710); - an ammunition bar for a viewer whose kit resupplies, on team mates whose vehicle's ammunition is below half (
0x101b1bd0); - an armor bar on friendly vehicles below half health for an engineer, with small icons of the occupants' kits above it (
0x101b38c0).
A medic's screen and a sniper's screen show different things over the same soldier: this is where.
The text#
0x101300b0 builds it. A player: his name, with [+N] when N more sit in his vehicle; with the distance in front ([57m] Name) for tags that carry a distance, within 300 m; the distance alone when off screen. An object: its name and distance, or the distance alone.
How it is tested#
- Against the original renderer's own manager (
crates/bf2-hud/tests/nametag_frame.rs): the port's name tag records and update are compared with the original's manager over the same made-up world: the frames, the layout and the draws. - Per game: 2142's added tags and the squad radar's three-second reveal (
nametag_2142.rs), Heroes' flag tags (nametag_bfh.rs), each in a process of its own.
None of this page's twelve addresses stands in a test's text: the comparison above runs the original's functions without naming their addresses in the test, so the count holds them as weaker than strict.
Where it sits#
The projection (0x1012d1f0) puts the tag over the thing's position plus an offset (a vehicle's tag sits higher: vehicleNametagOffset 0.45). Tags of the kind that must never be lost (orders, requests) carry a clamp flag: when the thing is outside a central region of the screen, or behind the camera, the tag is replaced by an arrow on a circle of radius 0.65 of the half screen, pointing toward it.
How it is drawn#
All tags of a kind are drawn in one call per technique (0x101b4370):
- The text of every tag lives in one texture of 512 x 1024: a row of 16 pixels a slot. When a tag's text changes, its row is cleared, the icon is copied to the row's start and the glyphs of the game's font behind it (
0x101b2840). Sixty-four names are sixty-four rows of one texture, not sixty-four draws. - Each slot has 8 vertices (an icon quad and a text quad) that carry only the slot number; the shader takes the place, the alpha and the colour from the three arrays.
- Then, unless the server forbids them: arrows for off-screen tags, the bars, and the icons, each its own technique of the same effect file.
The text fades out between the kind's two cull distances, and one cross-fade value of the manager (0.5 - cos(t) / 2) scales every tag.
What the port has#
| Part | State |
|---|---|
| the projection and the off-screen clamp | verified |
| a player's style: colour, icon, request icons | verified |
| the manager: records, slots, update, alpha, text | verified: everything between the engine's calls and the device was compared with the original's code run natively, frame by frame |
| the renderers: text rows, layout, the draws and their effect state | verified the same way |
| which engine events add and remove tags | surveyed and checked against the original's callers |
| the crosshair and visibility rays | answered by the port's world queries |
2142 uses the same manager. Heroes draws a bar over a hero's head with the same renderer: the bar's value is read from an atlas entry, and a level line and a prestige line stand with the name (the Heroes HUD); the sweeps have the player's tag as the same, and the prestige line as read in outline only.
In the code#
| What | Where |
|---|---|
| the manager, the renderers, the draws | crates/bf2-hud/src/nametag/ (manager, render, draw) |
| the frame oracle's test | crates/bf2-hud/tests/nametag_frame.rs |
| the settings and the icon map | built from nametags.con by the HUD's host |
| the effect | the game's own Nametag.fx, through crates/bf2-shaders |
Notes: notes/subsystems/hud.md ("Nametags", both sections).
docs/dev/ui/nametags.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.