Mann vs. Machine runs asDocumentation 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.
TF_GAMETYPE_MVM within CTFGameRules. Its core systems live under game/server/tf/player_vs_environment/. A popfile (KeyValues text) is parsed at level load to define all waves, sub-waves, robot types, and currency budgets. The round state machine uses GR_STATE_BETWEEN_RNDS between waves and GR_STATE_RND_RUNNING during active robot pushes.
System components
CPopulationManager
Parses the
.pop popfile, owns the wave list, and drives wave start/end transitions. Defined in tf_population_manager.h.tf_populators / tf_populator_spawners
WaveSpawnPopulator and related classes read per-wave spawn definitions and schedule robot spawns at nav mesh spawn points.CTFTankBoss
The tank enemy (
tf_tank_boss.cpp/h). Follows a path to the bomb hole; damage tracking and death logic are separate from normal bot behavior.CTFBaseBoss / boss_alpha
Base class for giant/boss robots (
tf_base_boss.h). boss_alpha/ holds the Merasmus/Monoculus boss logic. monster_resource replicates boss health to clients.CMannVsMachineLogic
Map entity (
tf_mann_vs_machine_logic.cpp) that wires MvM-specific map I/O: bomb deployment zones, gate, and alarm triggers.CUpgrades
Server-side upgrade shop handler (
tf_upgrades.cpp/h). Validates purchases, applies attribute modifiers to player items, and persists upgrade state across waves.Wave system
The popfile defines a tree ofWave → WaveSpawn → TFBot entries. CPopulationManager iterates this list each wave, handing spawn tasks to tf_populator_spawners.
Robot types
Three enemy categories are tracked byeMvMEnemyTypes in tf_mann_vs_machine_stats.h:
CTFBot instances with scaled attributes. Boss-tier enemies (e.g. Merasmus) use CTFBaseBoss and replicate health through monster_resource.
Currency and upgrades
When robots are killed they drop currency packs. Collected currency is tracked inCTFObjectiveResource::m_nMvMWorldMoney (networked). Between waves, players spend currency at the upgrade shop.
CMannVsMachineUpgradeManager::LoadUpgradesFile() reads items_game.txt upgrade blocks at level init. GetUpgradeStepData() computes the player’s current step and whether they are over the cap for a given weapon slot and upgrade index.
Stats tracking
CMannVsMachineStats (shared, tf_mann_vs_machine_stats.h) records per-wave and per-player events and syncs them to clients using eMannVsMachineEvent:
CMannVsMachineWaveStats aggregates nCreditsDropped and nCreditsAcquired per wave, which drive the end-of-wave summary panel.