On this page
Heroes' vehicles: seats, the seated look, planes, the team's vehicle limits
Heroes drives on Battlefield 2142's vehicle code: the same springs, engines, seats and spawners. What it adds is small and specific: a seated hero looks around inside limits his seat sets, a tank has two seats and no third, a plane's engine forgets its throttle when the pilot leaves, and a level caps how many tanks and jeeps a team may have. This page is those differences, as the port's notes have them.
Everything shared with the other two games is on the vehicle pages: physics and springs, the drivetrain, seats and cameras, spawners and wrecks, boats and aircraft. Pocket vehicles, which a hero calls from his item bar, are on widgets.
The seated look#
A seated soldier of Battlefield 2 or 2142 has one pair of limits (how far the seat lets him turn left and right). Heroes no longer has those two lines. Its seat template carries six instead (BFHeroes.exe@bfh126!0x00767140 hands out the interface that holds them):
| Line of the seat's template | What it is |
|---|---|
seatLookLimitLeft, seatLookLimitRight | the stops of the view's yaw: the body's yaw plus the head's |
seatLookLimitUp, seatLookLimitDown (each with an optional "ducked" value) | the pitch stops, one pair standing and one pair ducked |
seatRotateBodyStartRight, seatRotateBodyStartLeft | the head yaw past which the body turns too |
A seat without the lines has zeros. What the data of version 1.126 sets, by the notes' scan:
| Seat | Left / right | Up / down | Body band |
|---|---|---|---|
| Kubelwagen and Willys, co-driver | -45 / 90 | -25 / 15 | ±25 |
| the same jeeps, rear passenger | -90 / 90 | -25 / 15 | |
| a plane's wing seats | -50 / 35 or -35 / 50 | -30 / 50 | |
| a helicopter's side seats | -90 / 80 or -80 / 90 | -90 / 50 | |
| the parachute | -30 / 30 | -45 / 65 | |
| a tank's hatch | free (±361) | -45 / 35, and -5 / 5 ducked | |
| driver seats (jeep, tank, pilot) | none set |
How the input uses them (0x007220df, the soldier's input step, and 0x0072021e, the camera's):
- The stored pitch is clamped to the up and down stop of the duck state right after the mouse's pitch.
- The head takes the yaw input. If head plus body would pass a stop, the head is put at the stop and the body does not turn.
- Inside the stops, while the head is outside the body band, the body turns by the input too: there the view turns at twice the mouse's rate. The notes mark that as the original's behaviour, not a fault.
- A limit of 360 or more means free: the head stays at 0 and the body turns (the tank's hatch, the landing craft).
Battlefield 2 (bf2_w32ded.exe!0x005a8630) and 2142 (BF2142.exe!0x005890a0) clamp both stored values always and pull the yaw back against their one pair.
The hero's own body follows his look. A player reported that, riding as a passenger, his own hero kept facing the car's front while the camera looked around, though other players saw him turn. The cause, as the notes have it: a client is never sent its own soldier as a remote object, and the port aimed every seated body from the remote object's state, which is zero for the owner. The original's soldier is one object and reads its own camera (0x007912db). The Heroes arm now aims the local hero's seated body from the prediction's camera. The notes leave open that Battlefield 2's and 2142's arms still do it the old way.
Seats per vehicle#
By the notes' sweep over every vehicle of version 1.126: jeeps (the night ones too), planes, helicopters and the landing craft have 3 seats; tanks have 2; the anti-aircraft gun and three special objects have 1. No vehicle has more than 8.
A tank's second seat is under the cupola: no weapon and no camera of its own. The hero stands in the hatch with his own items.
That was a player's report, and the answer is that there is none. In the original, run for the comparison, the tank's seat list shows F1 and F2 only; F3 at the wheel leaves the driver where he is; F2 puts him in the hatch. The server's seat-key block (0x00532663) finds no third position and sends nothing. What the port did wrong was the list: it wrote one key label per seat and cleared none, so after a jeep the tank's HUD still showed "F3". The original clears all ten labels first (0x008f0c40); the port now does the same.
Engines when a seat changes#
When a driver leaves, the seat's parts get two messages; when he enters, two others. As read (0x008200ed, 0x0069df15):
- Leaving: the input is zeroed. An engine with
restoreRotationOnExitsets its rotation back to the one it was created with, which is 0. Then it keeps updating for 0.5 s and stops. - Entering: the engine runs at once. There is no delay.
In the 1.126 data only the two planes' engines and one special object's have the restore line. No jeep or tank engine has it, so a jeep's next driver gets the throttle the last one left. Battlefield 2 and 2142 have the same code and no engine in their data that sets the line.
So a pilot who moves to a wing seat and back gets an engine that runs at once but from zero throttle. The Spitfire's engine climbs at 375 a second to its maximum of 5000; the propeller's speed runs from 55 to 300 at 20 a second. Before the port restored the rotation, the plane had full power at once.
Planes that veered#
A player reported that planes turned right with no rudder input. The notes' measurement (a trace of every wing's torque about the plane's up axis, each plane 450 m up with throttle only):
- The rudder input was exactly 0. Heroes maps yaw to the keyboard alone; the mouse is pitch and roll; a released key ramps to exactly 0.
- The planes are symmetric left and right in their data. At zero sideslip every wing's torque about the up axis is 0.
- It was the propeller. The original (
0x00820e44) applies the engine's thrust at a point, and the lever arm is taken with the centre-of-mass offset turned by the body's rotation (0x00968de1). The port sent every engine's force through Battlefield 2's function (bf2_w32ded.exe!0x006a6440), which subtracts the offset unturned. The planes' offset is 0.29 m; a plane heading across the world's z axis got a sideways lever on its own thrust and turned hands-off at up to 7.4 degrees a second.
The port now picks the function by game: Battlefield 2 keeps its own, 2142 and Heroes take the turned offset. After: a hands-off drift of -0.007 degrees a second for the Spitfire and +0.017 for the Messerschmitt. 2142's planes with such an offset had the same fault (Battlefield 2142 by area).
Open in the notes: with full throttle and no hands both planes nose up and loop after about 20 s (a matter of pitch trim, not compared with the original); a take-off from a runway was not traced.
The team's vehicle limits#
A level's script caps the vehicles of a type for each team: gameLogic.setVehiclePrioAndMax <size> <team> <type> <max>. Three of the levels allow 4 light tanks and 4 scout cars a team; one allows 10 light tanks; one 6 scout cars; one 6 scout cars and no light tank.
As read:
- The server keeps one list a team: size, priority in line order, type, maximum (
0x00531674). The round's reset (0x0052dd9d) empties it, and the countdown's start runs the level's script again, so the lists hold for the round. - In team deathmatch a spawner of a limited type spawns only when granted (
0x007329d0); the spawn uses the grant up. - A player's spawn grants (
0x00530015): at the control point of his spawn group, by priority, to a spawner of the type that is free and has no grant, while the team counts fewer than the maximum (0x0073de29). - A spawn counts the vehicle for the team; a wreck that frees its place counts it out.
The size a grant asks with is the map list entry's player count, not the loaded layer's. By the notes' count every level and every map list entry in the tree has size 16, so on the port's servers the two are the same.
In a player's words#
| Feature | For a player |
|---|---|
| Self-view camera | Hold F and the camera swings round to look at your own hero from the front, for as long as the key is held: it stands a little in front of him and above, looks back at him, and is pulled in where something is in the way. It works for a living hero who is not down and whose weapon in hand is not zoomed; each stance and each vehicle has its own distance and height for it |
The checklists#
Each of these has a checklist in the feature ledger: every step of the original's code behind it and every situation it must work in. None is called done until every line is checked.
| Feature | Checked | What it does | What you see |
|---|---|---|---|
| Plane guns (the wing guns of the Spitfire and the Messerschmitt) | 8 of 64 lines checked | 5 of 29 | 0 of 29 |
| Tank shell (the cannon of the Sherman and the Panzer) | 18 of 64 lines checked | 15 of 29 | 0 of 29 |
The self-view camera, which a seat changes, has one:
Each of these has a checklist in the feature ledger: every step of the original's code behind it and every situation it must work in. None is called done until every line is checked.
| Feature | Checked | What it does | What you see |
|---|---|---|---|
| Self-view camera (F) | 9 of 43 lines checked | 2 of 14 | 2 of 14 |
The widgets that are vehicles or act on one (the jeep's jump and ram, the tank's shield, the plane's stealth) have theirs among the widgets' checklists.
What the port has#
| Part | State |
|---|---|
| the six look limits, on the server and in the client's prediction | ported; a scenario turns a co-driver to each stop (yaw 90 and -45, pitch 15 and -25, never outside) and compares the server's blocks with the prediction's |
| the local hero's seated body | ported for Heroes; open for Battlefield 2 and 2142 |
| a ladder climber's camera against the ladder's zero limits | open: not measured |
| two seats in a tank, the seat list's labels | ported; the original was run beside it |
| a free seat that refuses the player (a pocket vehicle's lock) at a seat key | ported, and played |
| engines at a seat change | ported; a scenario switches a pilot's seat and reads the engine's and the propeller's trace |
| the propeller's lever arm | ported for 2142 and Heroes; the rotor's torque path still uses the unturned offset (Heroes has no rotor engine) |
| a plane's pitch trim hands-off | not compared with the original |
| the team's vehicle limits | ported, with a scenario on one level |
How it is tested#
- Scenarios (the scenario runner):
bfh_client_kubel_seat_look(the look's stops, with a second client watching the hero's body),bfh_client_tank_seats(the seats and each seat's camera),bfh_client_plane_seat_switch(the engine and the propeller),bfh_client_plane_yaw_drift(eight assertions on the drift),bfh_vehicle_limits_village. - Library tests: the Kubelwagen's limits in both arms of the look (
bf2-physics), the limits read from the vehicles' own files (bfh-data), the grant's size (bf2-server, a Heroes program). - The original, run: the tank's seat keys were pressed in the original on the rig and its pictures kept beside the port's.
In the code#
| What | Where |
|---|---|
the seat's look (HeroesSeatLook) | crates/bf2-physics/src/soldier_control.rs |
| the limits from the templates | seat_look in crates/bfh-data/src/templates.rs |
| the seat list's labels | crates/bfh-client/src/seat_list.rs |
| the vehicle limits | crates/bfh-server/src/vehicle_limits.rs, crates/bf2-server/src/vehicle_limits_heroes.rs |
| the engine's force by game | crates/bf2-world/src/vehicle_control.rs (RootHost::add_world_force) |
Notes: notes/bfheroes/vehicles.md, notes/bfheroes/carryover.md. See also Heroes by area, the Heroes HUD.
docs/dev/heroes/vehicles.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.