All three Engineer buildings share a common base class,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sr2echa/TF2-Source-Code/llms.txt
Use this file to discover all available pages before exploring further.
CBaseObject, defined in game/server/tf/tf_obj.h. It extends CBaseCombatCharacter and implements IHasBuildPoints and IScorer. Each building goes through a well-defined lifecycle — placement, construction, active operation, upgrade, and destruction — controlled by virtual methods that each subclass overrides.
CBaseObject base class
Key constants and virtual methods fromtf_obj.h:
| Method | Purpose |
|---|---|
StartBuilding(CBaseEntity*) | Transitions the object from placement to active construction |
FinishedBuilding() | Called when construction health reaches 100% |
DetonateObject() | Engineer-triggered self-destruct |
DestroyObject() | Silent cleanup (no explosion) |
Killed(CTakeDamageInfo&) | Handles death from enemy damage |
OnWrenchHit(CTFPlayer*, CTFWrench*, Vector) | Processes wrench repair and upgrade hits |
CheckUpgradeOnHit(CTFPlayer*) | Returns true if enough metal was contributed to level up |
IsCarried() | True when the Engineer is hauling the building |
SetHealth, AddHealth, RemoveHealth, Enable, and Disable, all wired through DECLARE_DATADESC().
The three buildings
Sentry Gun
CObjectSentrygun — tf_obj_sentrygun.hMax health: 150 (mini: 100). Range: 1100 units (SENTRY_MAX_RANGE).Levels 1–3 defined as SENTRY_LEVEL_1/2/3. Level 3 adds rockets (FireRocket()). Networked ammo: m_iAmmoShells, m_iAmmoRockets.Dispenser
CObjectDispenser — tf_obj_dispenser.hMax health: 150 (mini: 100). Proximity healing via CDispenserTouchTrigger — a CBaseTrigger that forwards StartTouch/EndTouch to the dispenser.Healing: GetHealRate(), DispenseAmmo(), DispenseMetal(). Separate RefillThink and DispenseThink callbacks.Teleporter
CObjectTeleporter — tf_obj_teleporter.hMax health: 150. Two instances linked by type: TTYPE_ENTRANCE / TTYPE_EXIT. Partners found via FindMatch() and stored in m_hMatchingTeleporter.Networked state: m_iState, m_flRechargeTime, m_flCurrentRechargeDuration, m_iTimesUsed.Construction and upgrade flow
Placement
StartPlacement(CTFPlayer*) validates position using IsPlacementPosValid() and VerifyCorner(). The object spawns with OBJECT_CONSTRUCTION_STARTINGHEALTH (0.1).Building
Each wrench hit calls
Construct(float flHealth) which advances construction health. BuildingThink() runs on a 0.1 s interval until FinishedBuilding() fires.Upgrading
CheckUpgradeOnHit accumulates metal. When enough metal is deposited (via GetUpgradeMetalRequired()), StartUpgrading() → FinishUpgrading() transitions the building to the next level and swaps the model.Hauling
When an Engineer picks up a building,IsCarried() returns true and IsDisabled() is forced true for the duration. The sentry overrides MakeCarriedObject(CTFPlayer*) to clear its current target and ammo via RemoveAllAmmo(). On placement, OnEndBeingCarried(CBaseEntity*) is called to restore state.
The
SF_SENTRY_INFINITE_AMMO spawn flag is available for map-placed sentries and bypasses normal ammo depletion entirely.