BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

Name tags: who gets one, when it shows, where it sits

BF22142Heroes

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.

One frame of the name tag manager records one a player, order or tagged object: 64, 2 and 64 slots visibility friends by distance; enemies by a crosshair ray every half second, then a delay style and text colour by team, squad and command; an icon; a request icon for 12 s; name and distance projection over the thing; clamped tags become an arrow on a circle when off screen the text texture one row of 16 pixels a slot, rewritten only when a tag's text changes the draws all text of a kind in one call; then arrows, bars and icons RendDX9.dll!0x10130680 (update), 0x1012e1e0 (style), 0x1012d1f0 (projection), 0x101b2840 (a tag's row), 0x101b4370 (the draws)
One frame of the name tag manager. The upper rows decide; the lower rows draw.

Three kinds, fixed slots#

NametagManager (RendDX9.dll!0x1012fb30) has three kinds of tag, each with a fixed number of slots:

KindSlotsWho
players64every player the client knows, from the moment he is added
orders2the squad's order markers
objects64control 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:

SettingDefaultMeaning
maxFriendlyDistance120 ma team mate's tag beyond this is not shown
deployableDistance40 mthe same for deployed things
maxCallDistance150 mhow far a request icon carries
enemyDotLimit0.99999how squarely you must look at an enemy for his tag
enemyTagDelayTime, FadeInTime, FadeOutTime1 s eachan enemy's tag waits, fades in, and fades out
manDownFadeOutTime14 sa downed soldier's tag fades this slowly
deathFadeOutTime0.6 sa dead one's goes fast
cull distancesplayers 100 to 300 m, orders 100 to 1200, objects 0 to 1200where 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 atColour
an enemyred (or his team's colour)
a team mateblue
a member of your squadgreen
a squad leader, when you are the commandergreen
the commanderblue, 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#

PartState
the projection and the off-screen clampverified
a player's style: colour, icon, request iconsverified
the manager: records, slots, update, alpha, textverified: 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 stateverified the same way
which engine events add and remove tagssurveyed and checked against the original's callers
the crosshair and visibility raysanswered by the port's world queries
2142
Battlefield 2142 and Heroes

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#

WhatWhere
the manager, the renderers, the drawscrates/bf2-hud/src/nametag/ (manager, render, draw)
the frame oracle's testcrates/bf2-hud/tests/nametag_frame.rs
the settings and the icon mapbuilt from nametags.con by the HUD's host
the effectthe game's own Nametag.fx, through crates/bf2-shaders

Notes: notes/subsystems/hud.md ("Nametags", both sections).

Source: docs/dev/ui/nametags.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.