Tf logic training mode: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
 
 Tip:This entity, as well as most of its Inputs, can be used on any multiplayer map by spawning this entity after map load and setting the
Tip:This entity, as well as most of its Inputs, can be used on any multiplayer map by spawning this entity after map load and setting the  Workaround:Many of these issues have workarounds:
Workaround:Many of these issues have workarounds:
 Warning:
Warning:
		
	
|  (-added class hierarchy, cleanup) |  (Big info dump, works in multiplayer.) | ||
| Line 3: | Line 3: | ||
| {{This is a|point entity|name=tf_logic_training_mode|game=Team Fortress 2}} | {{This is a|point entity|name=tf_logic_training_mode|game=Team Fortress 2}} | ||
| Handles outputs and and messages for training, mainly for the [[player]]. | Handles outputs and and messages for training, mainly for the [[player]]. | ||
| {{ | {{tip|This entity, as well as most of its Inputs, can be used on any multiplayer map by spawning this entity after map load and setting the <code>m_bIsInTraining</code> NetProp on [[tf_gamerules]] to true with [[VScript]], however there are multiple caveats: | ||
| # Players loadout will be replaced with stock items | |||
| # The server will be hidden from the server browser, this will persist for the entire duration of the map | |||
| # Achievement tracking is disabled | |||
| # Doesn't print player join or team switch chat messages (they can still be seen when opening chat) | |||
| # Team and class switching menus will be disabled, however <code>join_class</code> and <code>autoteam</code> will still work | |||
| # Autobalance is disabled | |||
| # Domination/Revenge logic is disabled | |||
| {{workaround|Many of these issues have workarounds: | |||
| {{ExpandBox| | |||
| # Iterate player items and store them in an array/table in player scope first, then re-equip them using [[Team_Fortress_2/Scripting/VScript_Examples#Giving_a_weapon|this method]] after they are stripped. | |||
| # For custom servers, the <code>hide_server</code> cvar must be added to the vscript cvar allowlist, or <code>sv_allow_point_servercommand</code> must be set to <code>always</code> for <code>SendToServerConsole</code> | |||
| # Set <code>m_bAllowTrainingAchievements</code> to true on [[tf_gamerules]] | |||
| # Set <code>m_bIsInTraining</code> to false on player_connect or player_team and set back to true shortly after.  However this will disable any active training HUD elements | |||
| {{todo|No known workaround, need to enable/disable the NetProp or use the console commands for class/team switching}} | |||
| {{todo|No known workaround}} | |||
| {{todo|Potentially send the <code>player_death</code> event manually with domination/revenge death flags, or <code>player_domination</code>, untested.}} | |||
| }} | |||
| }} | |||
| }} | |||
| == Keyvalues == | == Keyvalues == | ||
| Line 10: | Line 31: | ||
| == Inputs == | == Inputs == | ||
| {{warning|<code>EndTraining</code>, <code>PlaySoundOnPlayer</code>, and <code>ForcePlayerSwapToWeapon</code> will not work on dedicated servers.}} | |||
| {{I|ShowTrainingMsg|Show a training message, for training mode. The parameter should be the string entry in tf_english.txt|param=string}} | {{I|ShowTrainingMsg|Show a training message, for training mode. The parameter should be the string entry in tf_english.txt|param=string}} | ||
| {{I|ShowTrainingObjective|param=string|Sets a training objective to show to the player.}} | {{I|ShowTrainingObjective|param=string|Sets a training objective to show to the player.}} | ||
| Line 22: | Line 44: | ||
| == Outputs == | == Outputs == | ||
| {{todo|See which outputs work in multiplayer}} | |||
| {{O|OnPlayerSpawnAsScout|Fired when the player spawns as a Scout.}} | {{O|OnPlayerSpawnAsScout|Fired when the player spawns as a Scout.}} | ||
| {{O|OnPlayerSpawnAsSniper|Fired when the player spawns as a Sniper.}} | {{O|OnPlayerSpawnAsSniper|Fired when the player spawns as a Sniper.}} | ||
Revision as of 13:49, 7 May 2025

 
|  Class hierarchy | 
|---|
| CTrainingModeLogic | 
|  tf_gamerules.cpp | 
tf_logic_training_mode  is a   point entity  available in  Team Fortress 2.
Handles outputs and and messages for training, mainly for the player.
 Team Fortress 2.
Handles outputs and and messages for training, mainly for the player.
 Tip:This entity, as well as most of its Inputs, can be used on any multiplayer map by spawning this entity after map load and setting the
Tip:This entity, as well as most of its Inputs, can be used on any multiplayer map by spawning this entity after map load and setting the m_bIsInTraining NetProp on tf_gamerules to true with VScript, however there are multiple caveats:
- Players loadout will be replaced with stock items
- The server will be hidden from the server browser, this will persist for the entire duration of the map
- Achievement tracking is disabled
- Doesn't print player join or team switch chat messages (they can still be seen when opening chat)
- Team and class switching menus will be disabled, however join_classandautoteamwill still work
- Autobalance is disabled
- Domination/Revenge logic is disabled
 Workaround:Many of these issues have workarounds:
Workaround:Many of these issues have workarounds:
- Iterate player items and store them in an array/table in player scope first, then re-equip them using this method after they are stripped.
- For custom servers, the hide_servercvar must be added to the vscript cvar allowlist, orsv_allow_point_servercommandmust be set toalwaysforSendToServerConsole
- Set m_bAllowTrainingAchievementsto true on tf_gamerules
- Set m_bIsInTrainingto false on player_connect or player_team and set back to true shortly after. However this will disable any active training HUD elements
Todo: No known workaround, need to enable/disable the NetProp or use the console commands for class/team switching
Todo: No known workaround
Todo: Potentially send the 
player_death event manually with domination/revenge death flags, or player_domination, untested.
Keyvalues
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentnameortarget).
 Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Next Map (nextMap) <string>
- Next map to load when the current one is finished. Default choices are tr_dustbowlandtr_target, although any map is accepted.
Inputs
 Warning:
Warning:EndTraining, PlaySoundOnPlayer, and ForcePlayerSwapToWeapon will not work on dedicated servers.- ShowTrainingMsg <string>
- Show a training message, for training mode. The parameter should be the string entry in tf_english.txt
- ShowTrainingObjective <string>
- Sets a training objective to show to the player.
- KickBots
- Kicks all bots from the server.
- ShowTrainingHUD
- Makes the training objective HUD visible.
- HideTrainingHUD
- Makes the training objective HUD hidden.
- EndTraining <string>
- Ends training mode. The parameter is for displaying ending text from tf_english.txt
- PlaySoundOnPlayer <string>
- Play a sound on the player.
- WaitForTimerOrKeypress <string>
- Wait for the specified logic_timer entity to fire on its interval or for a keypress from the player.
- SetNextMap <string>
- Set the next map for training.
- ForcePlayerSpawnAsClassOutput
- Force the appropriate output to fire for the player spawning as a class. You can use this to essentially ask what class the player is.
Outputs
Todo: See which outputs work in multiplayer
- OnPlayerSpawnAsScout
- Fired when the player spawns as a Scout.
- OnPlayerSpawnAsSniper
- Fired when the player spawns as a Sniper.
- OnPlayerSpawnAsSoldier
- Fired when the player spawns as a Soldier.
- OnPlayerSpawnAsDemoman
- Fired when the player spawns as a Demoman.
- OnPlayerSpawnAsMedic
- Fired when the player spawns as a Medic.
- OnPlayerSpawnAsHeavy
- Fired when the player spawns as a Heavy.
- OnPlayerSpawnAsPyro
- Fired when the player spawns as a Pyro.
- OnPlayerSpawnAsSpy
- Fired when the player spawns as a Spy.
- OnPlayerSpawnAsEngineer
- Fired when the player spawns as an Engineer.
- OnPlayerDied
- Fired when the player dies.
- OnBotDied
- Fired when a bot dies.
- OnPlayerSwappedToPrimary
- Fired when the player swaps to the item in their primary weapon slot.
- OnPlayerSwappedToSecondary
- Fired when the player swaps to the item in their secondary weapon slot.
- OnPlayerSwappedToMelee
- Fired when the player swaps to the item in their melee weapon slot.
- OnPlayerSwappedToBuilding
- Fired when the player swaps to the item in their building weapon slot.
- OnPlayerSwappedToPDA
- Fired when the player swaps to the item in their PDA weapon slot.
- OnBuildOutsideArea
- Fired when the player builds an object outside a suggested area.
- OnPlayerDetonateBuilding
- Sent when the player manually detonates one of their buildings.























