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

Kits, pickups and supplies

BF22142Heroes

A kit is not a property of a soldier. It is an object the soldier holds: it has a template, a team and a mesh, it can lie on the ground, and somebody else can pick it up. The things that give a soldier back what he used up (an ammunition bag, a medic's pack, a supply crate, a repair station) are one more kind of object with one loop. This page covers both.

A kit's life held the soldier's weapons and items are its children dropped at death lies on the ground for 30 s picked up within 3 m, the same team, 2 s after the last pickup removed when its time to live is over A supply object, every 0.2 s whose side a team, everyone, or the nearest control point's owner who is in reach soldiers; vehicles of the listed kinds give ammunition first, then health (or damage: a fire) storage drained by giving; refilled by restoreSpeed; gone when empty bf2_w32ded.exe!0x0055c790 (drop), 0x00456010 (find a kit), 0x0059b6a0 (the supply loop), 0x0059ae40 (give)
A kit's life, and beside it the loop of everything that heals or resupplies.

The kit#

ObjectTemplate.Kit (template bf2_w32ded.exe!0x0055d2a0, object 0x0055dac0) is an item whose children are the weapons and gadgets of the class. Its own properties:

PropertyDefaultMeaning
kitTypeunknownassault, medic, sniper ..: what the HUD's icon and the scripts' statistics go by
kitTeam0which team's kit it is
unlockIndex-1which unlock gives it
defaultWeaponIndex3the weapon in hand at the spawn
timeToLiveAfterDeath30.0seconds a dropped kit lies before it is removed
sprintStaminaDissipationFactor1.0the likely source of the sprint's drain factor; the notes mark the link as unverified
abilityRestoreRate-1.0how fast the kit's ability (the medic's or engineer's aura in a vehicle) recovers
abilityInVehicleMaterial, ...Strength, ...Radius0the kit's ability while its holder sits in a vehicle: a material, a strength, a radius
geometry.kit, geometry.dropGeom0, 1which mesh the soldier wears and which lies on the ground

No shipped script sets timeToLiveAfterDeath, so every dropped kit lies for exactly 30 seconds.

Dropping and picking up#

  • At death the soldier drops his kit (Kit::scheduleDespawn, 0x0055c790); the server schedules its removal after the time to live, and the script hears DropKit(player, kit).
  • The pickup key (the server's input processor, 0x004580c0): for a standing soldier, more than 2 seconds after his last pickup, the server looks for kits within 3 m that lie on the ground (0x00456010), takes the nearest, and hands it over only when the kit's team is the soldier's. The script hears PickupKit(player, kit); the clients get a pickup event.
  • A kit of the other team within reach still counts as found, and nothing happens: an enemy's kit cannot be taken.
  • The same key also tries ziplines and grappling-hook ropes near the soldier.

The key is refused, like the use key and the seat keys, while the weapon in hand cannot be put away: firing or reloading.

Read, not run

The notes mark the pickup path as a draft: read from the listing, not executed against the original. Open there: what the inventory does with the kit the soldier held, and where the unlock is enforced.

Supply objects#

A SupplyObject (template 0x0059b860) is anything that gives or takes health and ammunition in a radius: the medic's pack, the ammunition bag, the commander's supply crate, a repair station, and also a fire, which is a supply object with a damage speed.

PropertyMeaning
radiusreach, added to the receiver's own bounding radius
team, teamFromClosestCPwhom it serves: a team, everyone (0), or whoever holds the nearest control point
workOnSoldiers, workOnVehicles, addVehicleTypewhat it serves; an empty type list is every vehicle
healSpeed, refillAmmoSpeed, damageSpeedper second
healStorageSize, ammoStorageSizehow much it holds
restoreSpeedhow fast the storage refills: size x restoreSpeed x dt x 0.05 a step
destroyWhenEmptyStoragea bag that is used up disappears

Its loop (0x0059b6a0, on the server) runs from one second after the object appears, then every 0.2 seconds:

  1. take the team from the nearest control point, when the template says so;
  2. remove itself when its storage is empty and it is the kind that goes;
  3. soldiers: every living player's soldier of its team (or any, for team 0) within reach. A soldier in a vehicle is served only by a supply object on that same vehicle;
  4. vehicles: every vehicle of its team or of none, of a listed category, within reach;
  5. for each: ammunition first, then health. Health is healSpeed x 0.2 through the game logic's heal and repair, damage damageSpeed x 0.2 through the common damage function (damage and armor);
  6. refill the storages.

A SupplyDepot is the fixed version at a base: a radius, a team, lists of ammunition and vehicle types.

Healing itself is armor repair by a share of the maximum hit points, scaled by a material pair: the healer's material against the receiver's. What heals what is, again, a number in the material table.

2142
Battlefield 2142 and Heroes

Both later games keep the kit object and the supply object. What a hero carries in Heroes, and how he is healed, is on abilities and widgets and Heroes: damage.

What the port has#

PartState
kit templates and the kit as an object; the drop at deathported; the client's side of a kit dropped at death is ported for Battlefield 2 and 2142
the pickupported from the listing (a draft in the notes); the two-second and three-metre rules as read
supply objects on soldiers: the timer, damage and healingported; the health part verified on burning fires against the original server
supply objects' ammunition refill and the vehicle passnot yet, as the notes say of the server's file
the amounts inside the heal and refill callsopen in the notes

How it is tested#

  • Kits, from Battlefield 2's listing, each in a process of its own: a dropped kit's despawn schedule and what a kit gives a soldier (dropped_kit_bf2.rs), a soldier who takes a kit dropping his own first (soldier_pickup_kit_bf2.rs), a fire arm's pickup (fire_arm_pickup_bf2.rs); 2142's pickup and a dropped weapon's magazines in a 2142 process.
  • Supply objects (crates/bf2-server/src/damage_supply.rs): a heal that worked drains the storage, a heal that did not is not paid for.

Three of seven addresses stand in a test's text. As the table above says, the pickup is a draft in the notes and the supply objects' refill and vehicle pass are not done: those have no test against the original.

In the code#

WhatWhere
ladders and ziplines (the other soldier systems)crates/bf2-gameplay/src/soldier_systems/
supply objects on the servercrates/bf2-server/src/damage_supply.rs
kit templates in the dataCON scripts
the pickup's events in Pythonthe Python layer

Notes: notes/subsystems/gameplay-soldier-systems.md (sections 1, 2 and 5), notes/subsystems/players.md.

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