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

Stances and states: stand, crouch, prone, swim, climb, fall

BF22142Heroes

A soldier has four stances (stand, crouch, prone, swim) and seven speed states derived from them. Around those are the states in which something else moves him: a ladder, a parachute, free fall, a seat. And one state in which nothing does: man down. This page is the map; the input handling tick by tick is on the page before this one.

Input and sprint, tick by tick: the soldier's input.

Who moves the soldier his own movement (input, stance, speed state) stand run 3, walk 2, sprint 4 crouch 1 prone crawl 0 swim 5, fast 6 stance keys with their delay timers; a ramp of 0.25 or 0.5 s between speed states falling faster than 10 m/s: sky diving, the keys off water: the stance is swim, whatever the keys say a ladder its container moves him a parachute a small vehicle with a wing a seat the vehicle moves him man down a ragdoll; nothing moves him bf2_w32ded.exe!0x0054de30 (speed state), 0x0054fbb0 (stance keys), 0x005533c0 (the ramp), 0x0059e3c0 (ladder)
The soldier's states. The inner box is his own movement; the outer ones take the movement over.

Stance and speed state#

The stance is what the player asks for; the speed state is what the movement code uses (updateSpeedState, bf2_w32ded.exe!0x0054de30):

StanceSpeed state
stand4 sprint while sprinting; 2 walk while the weapon is zoomed; else 3 run
crouch1
prone0 crawl
swim6 while sprinting, else 5

Each speed state has a speed in the soldier's template (getSoldierSpeed, 0x0054e830); crouched, it is also scaled by the mouse speed modifier of a zoomed weapon.

The ramp#

A stance change does not switch the speed. executePoseChange (0x005533c0) starts a ramp: from the speed the soldier had to the new state's speed, in a straight line, over a time from a table of 7 x 7 entries indexed by the old and the new speed state (0x00885970). The entries are 0.25 s among crouch, walk, run and sprint, and 0.5 s for everything into or out of prone and the water.

Two things about that table

It is copied once, at start-up, from engine variables named pose-<from>-<to>: changing a variable later has no effect. And the two swim rows were registered under the sprint row's names by mistake, so they hold the sprint row's values in its column order: leaving the water to a run takes 0.25 s where the default written for it says 0.5. The port keeps the table as the original computes it; a played spot in the water measured the 0.25.

The stance keys#

updateSoldierPose(lie, crouch) (0x0054fbb0) does nothing while swimming or sky diving. Otherwise:

  • Prone key, at its press: from prone the request is stand; from stand or crouch it is prone, when soldierCanGoProne (0x0054e990) allows.
  • Crouch key: held, it requests crouch; released, a crouching soldier stands.
  • A latch per key makes a held key count once.

The timers that make the stances feel the way they do (engine variables; defaults):

TimerDefaultEffect
prone-delay-after-jump1.0 sno going prone behind a jump (no "dolphin dive")
jump-delay-after-prone1.0 sno jump right after standing up
stand-delay-from-prone1.0 sonce prone, no standing up at once
prone-delay-from-stand1.0 sonce up, no going prone again at once
fire-delay-from-prone0.6 sno shot right after leaving prone
fire-delay-after-jump1.0 sno shot right after a jump
sprint-recharge-delay-after-jump1.0 sstamina does not recover right after a jump

Mods change these: the notes record that the Special Forces mod sets prone-delay-after-jump to 0.7.

2142
Battlefield 2142

2142 registers prone-delay-after-jump as 0.2 and the three camera speeds as 0.2, and lifts a standing soldier who goes prone by 0.3 m first (g_addedHeightOnProne, BF2142.exe!0x008e07d0). The port has all three as 2142's values with their addresses.

A prone soldier cannot stay prone in water deeper than soldier-prone-inwater-limit (1.1): he drowns, dt / 8 x 100 hit points a tick, 12.5 a second.

The camera's height#

Each stance has an eye position in the soldier's template (poseCameraPosition; the setter keeps only the height). On a stance change the camera moves from one to the other at a fraction a tick (camera-movement-speed-on-stand, -crouch, -prone: 0.5 each): fast, but not a cut. Shots start at the camera, so the stance decides where a bullet leaves (projectiles).

Swimming#

There is no key for it. While the soldier's physics node reports water, the stance is 3: the stance keys and the jump are refused, and the sprint key swims faster.

Ladders#

A ladder is an object with a thin collision plate. When the soldier's collision pass touches the plate, Ladder::handleCollision (0x0059e3c0) attaches him: from then on he is the occupant of a ladder container, like a seat. The container takes his input (up, down; the sprint key slides down) and moves him; his own physics does not run. He leaves at the top, at the bottom, behind, or by the use key, and gets the exit position and angles from the container.

Falling#

Falling faster than phy-soldier-skydiveat-speed (-10 m/s) the soldier is sky diving: the stance keys are off and the input steers the fall at up to phy-soldier-skydive-speed (15 m/s). The parachute is an object the soldier enters like a vehicle: a small tree with a wing that makes its lift (wings), steered by pitch. Hitting the ground fast costs fall damage through the soldier's collision response.

Man down and revive#

A soldier's health is an armor component like a vehicle's (damage and armor). The shipped soldiers have 100 hit points and a wreck health of 320 (as the notes read the templates):

StateHit points
aliveabove 0
man down, revivablefrom 0 down to above -320
deadat -320

One hit on a living soldier leaves him at worst at 0.8 of the way down: a soldier always goes man down first, however large the hit. Damage while down is not limited. There is no bleeding out; the body waits. A revive adds hit points through the armor; enough of them and the soldier stands up with full health and his input off for 2.1 seconds. A new spawn cannot be hurt for 1 second.

How it is tested#

WhatCheck
handlePlayerInput, handleUpdate and their helpersthe original's functions in the emulator against the port, both precisions
a walk, a climb, a slide, a swim, a fallthe same recorded input on the original server and the port's: 380 of 380 ticks, 386 of 386, 420 of 420, 119 of 119 identical, the fall's damage equal (611.794)
the pose change tableread from the static initializer; the swim rows confirmed by a played spot
the parachuterecorded runs, compared tick by tick with the input phase aligned

Open in the notes: the formulas of fall and collision damage, and who writes the sprint's dissipation factor.

In the code#

WhatWhere
input, stance, speed state, the ramp, the timerscrates/bf2-physics/src/soldier_control.rs
ladderscrates/bf2-physics/src/soldier_ladder.rs, crates/bf2-server/src/soldier_phys_ladder.rs
the parachutecrates/bf2-server/src/soldier_phys_parachute.rs
sprintcrates/bf2-gameplay/src/soldier/sprint.rs
drowningcrates/bf2-gameplay/src/kills/drowning.rs

Notes: notes/subsystems/gameplay-soldier.md, notes/subsystems/physics-soldier.md (sections 9 to 11).

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