Skip to main content

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.

Each of the nine player classes in TF2 has a dedicated set of weapons implemented as separate C++ files under game/shared/tf/. The naming convention is tf_weapon_<name>.cpp/.h. All weapons ultimately derive from CTFWeaponBase; most ranged weapons extend CTFWeaponBaseGun and melee weapons extend CTFWeaponBaseMelee.

Weapons by class

FileWeapon
tf_weapon_scattergunScattergun (shotgun variant)
tf_weapon_pistolPistol
tf_weapon_batBat
tf_weapon_lunchboxSandvich / Bonk drink items
tf_weapon_grapplinghookGrappling Hook
FileWeapon
tf_weapon_rocketlauncherRocket Launcher
tf_weapon_shotgunShotgun
tf_weapon_shovelShovel
tf_weapon_buff_itemBuff Banner / War Banner
tf_weapon_rocketpackThermal Thruster
tf_weapon_parachuteBASE Jumper
FileWeapon
tf_weapon_flamethrowerFlamethrower
tf_weapon_shotgunShotgun (shared)
tf_weapon_fireaxeFire Axe
tf_weapon_flaregunFlare Gun
tf_weapon_jarJarate / Gas Passer
tf_weapon_throwableThermal Thruster throwables
FileWeapon
tf_weapon_grenadelauncherGrenade Launcher
tf_weapon_pipebomblauncherStickybomb Launcher
tf_weapon_bottleBottle
tf_weapon_swordEyelander / Claymore
tf_weapon_stickbombUllapool Caber
tf_weapon_grenade_pipebombPipebomb projectile
FileWeapon
tf_weapon_minigunMinigun
tf_weapon_shotgunShotgun (shared)
tf_weapon_fistsFists
tf_weapon_lunchboxSandvich (shared item slot)
FileWeapon
tf_weapon_shotgunShotgun (shared)
tf_weapon_pistolPistol (shared)
tf_weapon_wrenchWrench
tf_weapon_pdaBuild/Destroy PDA
tf_weapon_laser_pointerWrangler
tf_weapon_mechanical_armGunslinger
FileWeapon
tf_weapon_syringegunSyringe Gun
tf_weapon_medigunMedi Gun
tf_weapon_bonesawBonesaw
FileWeapon
tf_weapon_sniperrifleSniper Rifle
tf_weapon_smgSMG
tf_weapon_clubKukri
tf_weapon_compound_bowHuntsman
tf_weapon_jarJarate (shared)
tf_weapon_decoyDecoy
FileWeapon
tf_weapon_revolverRevolver
tf_weapon_invisInvisibility Watch
tf_weapon_knifeKnife
tf_weapon_pdaSapper (PDA variant)

Notable implementation patterns

Medi Gun — beam healing

CWeaponMedigun (in tf_weapon_medigun.h) extends CTFWeaponBaseGun and supports four weapon sub-types:
enum medigun_weapontypes_t
{
    MEDIGUN_STANDARD = 0,  // stock Medi Gun
    MEDIGUN_UBER,          // Kritzkrieg / Vaccinator
    MEDIGUN_QUICKFIX,      // Quick-Fix
    MEDIGUN_RESIST,        // Vaccinator resist types
};
Resistance type is tracked separately:
enum medigun_resist_types_t
{
    MEDIGUN_BULLET_RESIST = 0,
    MEDIGUN_BLAST_RESIST,
    MEDIGUN_FIRE_RESIST,
    MEDIGUN_NUM_RESISTS
};
ÜberCharge activation and deactivation sounds are stored in MedigunEffects_t structs keyed by charge type. The weapon maintains a beam to a single healing target (MAX_HEALING_TARGETS 1) and tracks the target via a CTFReviveMarker handle for MvM revival.

Flamethrower — state machine and airblast

CTFFlameThrower (in tf_weapon_flamethrower.h) extends CTFWeaponBaseGun and on the server also implements CGameEventListener. Firing is controlled by a four-state enum:
enum FlameThrowerState_t
{
    FT_STATE_IDLE = 0,
    FT_STATE_STARTFIRING,
    FT_STATE_FIRING,
    FT_STATE_SECONDARY,   // airblast
};
Airblast functions are bitflags, allowing per-weapon control over which secondary behaviors are active:
enum EFlameThrowerAirblastFunction
{
    TF_FUNCTION_AIRBLAST_PUSHBACK               = 0x01,
    TF_FUNCTION_AIRBLAST_PUT_OUT_TEAMMATES      = 0x02,
    TF_FUNCTION_AIRBLAST_REFLECT_PROJECTILES    = 0x04,
    TF_FUNCTION_AIRBLAST_PUSHBACK__STUN         = 0x08,
    TF_FUNCTION_AIRBLAST_PUSHBACK__VIEW_PUNCH   = 0x10,
};
Each flame particle spawned is a CTFFlameRocket entity, not a hitscan trace, which is why flames have travel time and can be reflected.

Build docs developers (and LLMs) love