Player (Team Fortress 2): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Aaaaaaaaaaa now we can show off TF2's code!!!)
m (→‎Inputs: Substituted IO templates)
Line 10: Line 10:


==Inputs==
==Inputs==
{{IO|SetHealth|param=integer|Sets the player's health. Values clamped between 0 and <code>max_health</code> (the latter being normally set up for each individual class in {{code|scripts/playerclasses}}).}}
{{I|SetHealth|param=integer|Sets the player's health. Values clamped between 0 and <code>max_health</code> (the latter being normally set up for each individual class in {{code|scripts/playerclasses}}).}}
{{IO|HandleMapEvent|param=string|Tells the game to perform a function, such as unlock an achievement. Hardcoded for specific map names.}}
{{I|HandleMapEvent|param=string|Tells the game to perform a function, such as unlock an achievement. Hardcoded for specific map names.}}
{{IO|SetHUDVisibility|param=boolean|Hides or displays the HUD.}}
{{I|SetHUDVisibility|param=boolean|Hides or displays the HUD.}}
:{{note|The menu can still be accessed, and some HUD elements such as kill-icons may still be visible.}}
:{{note|The menu can still be accessed, and some HUD elements such as kill-icons may still be visible.}}
:{{warning|Will disable any weapon-switching of the target}}
:{{warning|Will disable any weapon-switching of the target}}
{{IO|SetFogController|param=string|Sets the {{ent|env_fog_controller}} to use.}}
{{I|SetFogController|param=string|Sets the {{ent|env_fog_controller}} to use.}}
{{IO|SpeakResponseConcept|param=string|Speak the specified [[Response System|response concept]] immediately. This is what's used to make players scream when falling into pits (using <code>HalloweenLongFall</code> response). Additional context can be passed using space-delimited key:value pairs. Example: <code>TLK_MVM_TANK_CALLOUT IsMvMDefender:1 randomnum:100</code>. For a list of [[Response_System|response rules]], see the txt files in <code>scripts/talker/</code> located in <code>tf2_misc</code> [[VPK]]. {{ExpandBox|title=List of Responses|
{{I|SpeakResponseConcept|param=string|Speak the specified [[Response System|response concept]] immediately. This is what's used to make players scream when falling into pits (using <code>HalloweenLongFall</code> response). Additional context can be passed using space-delimited key:value pairs. Example: <code>TLK_MVM_TANK_CALLOUT IsMvMDefender:1 randomnum:100</code>. For a list of [[Response_System|response rules]], see the txt files in <code>scripts/talker/</code> located in <code>tf2_misc</code> [[VPK]]. {{ExpandBox|title=List of Responses|
* TLK_FIREWEAPON
* TLK_FIREWEAPON
* TLK_HURT
* TLK_HURT
Line 196: Line 196:
* TLK_MATCH_OVER_COMP
* TLK_MATCH_OVER_COMP
}}}}
}}}}
{{IO|IgnitePlayer|param=integer|Ignites the player with a specified lifetime and causes a reaction (sound and speech).}}
{{I|IgnitePlayer|param=integer|Ignites the player with a specified lifetime and causes a reaction (sound and speech).}}
:{{note|Does not fire the <code>OnIgnite</code> output.}}
:{{note|Does not fire the <code>OnIgnite</code> output.}}
:{{bug|Broken since the [https://wiki.teamfortress.com/wiki/Jungle_Inferno_Update Jungle Inferno] update, initiating sound and speech but no actual fire. Use {{ent|trigger_ignite}} as a workaround.}}
:{{bug|Broken since the [https://wiki.teamfortress.com/wiki/Jungle_Inferno_Update Jungle Inferno] update, initiating sound and speech but no actual fire. Use {{ent|trigger_ignite}} as a workaround.}}
{{IO|ExtinguishPlayer|Extinguishes the player.}}
{{I|ExtinguishPlayer|Extinguishes the player.}}
{{IO|BleedPlayer|param=integer|Bleeds the player with a specified length.}}
{{I|BleedPlayer|param=integer|Bleeds the player with a specified length.}}
{{IO|RollRareSpell|Forces the player to roll a rare spell. Only available if spells are enabled on the map.}}
{{I|RollRareSpell|Forces the player to roll a rare spell. Only available if spells are enabled on the map.}}
{{IO|SetCustomModel|param=string|Set a custom player model ''without'' animations.}}
{{I|SetCustomModel|param=string|Set a custom player model ''without'' animations.}}
:{{note|Using <code>""</code> as the model argument will instead clear the target's custom model, returning the player to normal.}}
:{{note|Using <code>""</code> as the model argument will instead clear the target's custom model, returning the player to normal.}}
{{IO|SetCustomModelWithClassAnimations|param=string|Set a custom player model '''with''' animations.}}
{{I|SetCustomModelWithClassAnimations|param=string|Set a custom player model '''with''' animations.}}
{{IO|SetCustomModelOffset|param=vector|Set a custom player model position on the player.}}
{{I|SetCustomModelOffset|param=vector|Set a custom player model position on the player.}}
{{IO|SetCustomModelRotation|param=vector|Set a custom player model rotation on the player.}}
{{I|SetCustomModelRotation|param=vector|Set a custom player model rotation on the player.}}
{{IO|ClearCustomModelRotation|Clears the custom player model rotation.}}
{{I|ClearCustomModelRotation|Clears the custom player model rotation.}}
{{IO|SetCustomModelRotates|param=boolean|Set if the custom model rotates or not to the player's angles.}}
{{I|SetCustomModelRotates|param=boolean|Set if the custom model rotates or not to the player's angles.}}
{{IO|SetCustomModelVisibleToSelf|param=boolean|Set if the custom model is visible to the player, in thirdperson.}}
{{I|SetCustomModelVisibleToSelf|param=boolean|Set if the custom model is visible to the player, in thirdperson.}}
{{IO|SetForcedTauntCam|param=boolean|Forces the player into thirdperson mode.}}
{{I|SetForcedTauntCam|param=boolean|Forces the player into thirdperson mode.}}
{{IO|SetScriptOverlayMaterial|Sets a custom [[screen overlay]] material. This overlay is separate from normal screen overlays (e.g. burning or [[env_screenoverlay]]) and will not get overriden.}}
{{I|SetScriptOverlayMaterial|Sets a custom [[screen overlay]] material. This overlay is separate from normal screen overlays (e.g. burning or [[env_screenoverlay]]) and will not get overriden.}}
{{IO|TriggerLootIslandAchievement|{{todo}}.}}
{{I|TriggerLootIslandAchievement|{{todo}}.}}
{{IO|TriggerLootIslandAchievement2|{{todo}}.}}
{{I|TriggerLootIslandAchievement2|{{todo}}.}}
{{IO|RoundSpawn|Clears any [https://wiki.teamfortress.com/wiki/Magic_spells magic spell] within the player's current spell book.}}
{{I|RoundSpawn|Clears any [https://wiki.teamfortress.com/wiki/Magic_spells magic spell] within the player's current spell book.}}


==See Also==
==See Also==
* [[Team Fortress 2/Scripting/Script Functions#CTFPlayer|CTFPlayer vscript functions]]
* [[Team Fortress 2/Scripting/Script Functions#CTFPlayer|CTFPlayer vscript functions]]

Revision as of 11:12, 21 April 2025

English (en)Translate (Translate)
edit
Icon-NotInFGD.png
This entity is not in the FGD by default.
It should not be put directly in a map.
C++ Class hierarchy
CTFPlayer
CBaseMultiplayerPlayer
CBasePlayer
CBaseCombatCharacter
CBaseFlex
CBaseAnimatingOverlay
CBaseAnimating
CBaseEntity
C++ tf_player.cpp

player is an entity available in Team Fortress 2 Team Fortress 2. The player itself or a bot. NPCs are not players. This entity still exists even if the player is dead.

Icon-Important.pngImportant:This is a preserved entity.
If the game has round restart mechanics this entity may not behave as expected:
More info
  • On a new round entities with this classname will intentionally not reset. You can use logic_auto to emulate resetting it.
  • Killing it removes it forever, as it is not respawned on a new round.
  • It cannot be spawned with a point_template.
  • Parenting this with non-preserved entities may have undesirable effects.

Limitations/Bugs

Icon-Important.pngImportant:This entity is not intended to be placed in a map manually. Doing so will result in an instant fatal error on map load!

Inputs

SetHealth <integerRedirectInput/integer>
Sets the player's health. Values clamped between 0 and max_health (the latter being normally set up for each individual class in scripts/playerclasses).
HandleMapEvent <stringRedirectInput/string>
Tells the game to perform a function, such as unlock an achievement. Hardcoded for specific map names.
SetHUDVisibility <booleanRedirectInput/boolean>
Hides or displays the HUD.
Note.pngNote:The menu can still be accessed, and some HUD elements such as kill-icons may still be visible.
Warning.pngWarning:Will disable any weapon-switching of the target
SetFogController <stringRedirectInput/string>
Sets the env_fog_controller to use.
SpeakResponseConcept <stringRedirectInput/string>
Speak the specified response concept immediately. This is what's used to make players scream when falling into pits (using HalloweenLongFall response). Additional context can be passed using space-delimited key:value pairs. Example: TLK_MVM_TANK_CALLOUT IsMvMDefender:1 randomnum:100. For a list of response rules, see the txt files in scripts/talker/ located in tf2_misc VPK.
List of Responses 
  • TLK_FIREWEAPON
  • TLK_HURT
  • TLK_PLAYER_EXPRESSION
  • TLK_WINDMINIGUN
  • TLK_FIREMINIGUN
  • TLK_PLAYER_MEDIC
  • TLK_DETONATED_OBJECT
  • TLK_KILLED_PLAYER
  • TLK_KILLED_OBJECT
  • TLK_PLAYER_PAIN
  • TLK_PLAYER_ATTACKER_PAIN
  • TLK_PLAYER_TAUNT
  • TLK_PLAYER_HELP
  • TLK_PLAYER_GO
  • TLK_PLAYER_MOVEUP
  • TLK_PLAYER_LEFT
  • TLK_PLAYER_RIGHT
  • TLK_PLAYER_YES
  • TLK_PLAYER_NO
  • TLK_PLAYER_INCOMING
  • TLK_PLAYER_CLOAKEDSPY
  • TLK_PLAYER_SENTRYAHEAD
  • TLK_PLAYER_TELEPORTERHERE
  • TLK_PLAYER_DISPENSERHERE
  • TLK_PLAYER_SENTRYHERE
  • TLK_PLAYER_ACTIVATECHARGE
  • TLK_PLAYER_CHARGEREADY
  • TLK_PLAYER_TAUNTS
  • TLK_PLAYER_BATTLECRY
  • TLK_PLAYER_CHEERS
  • TLK_PLAYER_JEERS
  • TLK_PLAYER_POSITIVE
  • TLK_PLAYER_NEGATIVE
  • TLK_PLAYER_NICESHOT
  • TLK_PLAYER_GOODJOB
  • TLK_MEDIC_STARTEDHEALING
  • TLK_MEDIC_CHARGEREADY
  • TLK_MEDIC_STOPPEDHEALING
  • TLK_MEDIC_CHARGEDEPLOYED
  • TLK_FLAGPICKUP
  • TLK_FLAGCAPTURED
  • TLK_ROUND_START
  • TLK_SUDDENDEATH_START
  • TLK_ONFIRE
  • TLK_STALEMATE
  • TLK_BUILDING_OBJECT
  • TLK_LOST_OBJECT
  • TLK_SPY_SAPPER
  • TLK_TELEPORTED
  • TLK_LOST_CONTROL_POINT
  • TLK_CAPTURED_POINT
  • TLK_CAPTURE_BLOCKED
  • TLK_HEALTARGET_STARTEDHEALINGING
  • TLK_HEALTARGET_CHARGEREADY
  • TLK_HEALTARGET_STOPPEDHEALINGING
  • TLK_HEALTARGET_CHARGEDEPLOYEDYED
  • TLK_MINIGUN_FIREWEAPON
  • TLK_DIED
  • TLK_PLAYER_THANKS
  • TLK_CART_MOVING_FORWARD
  • TLK_CART_MOVING_BACKWARD
  • TLK_CART_STOP
  • TLK_ATE_FOOD
  • TLK_DOUBLE_JUMP
  • TLK_DODGING
  • TLK_DODGE_SHOT
  • TLK_GRAB_BALL
  • TLK_REGEN_BALL
  • TLK_DEFLECTED
  • TLK_BALL_MISSED
  • TLK_STUNNED
  • TLK_STUNNED_TARGET
  • TLK_TIRED
  • TLK_BAT_BALL
  • TLK_ACHIEVEMENT_AWARD
  • TLK_JARATE_HIT
  • TLK_JARATE_LAUNCH
  • TLK_HIGHFIVE_SUCCESS
  • TLK_HIGHFIVE_SUCCESS_FULL
  • TLK_HIGHFIVE_FAILURE
  • TLK_HIGHFIVE_FAILURE_FULL
  • TLK_PLAYER_TAUNT2
  • TLK_PICKUP_BUILDING
  • TLK_REDEPLOY_BUILDING
  • TLK_CARRYING_BUILDING
  • TLK_REQUEST_DUEL
  • TLK_REJECT_DUEL
  • TLK_DUEL_WAS_REJECTED
  • TLK_ACCEPT_DUEL
  • TLK_DUEL_WAS_ACCEPTED
  • TLK_PLAYER_SHOW_ITEM_TAUNT
  • TLK_TAUNT_REPLAY
  • TLK_TAUNT_LAUGH
  • TLK_TAUNT_HEROIC_POSE
  • TLK_PARTNER_TAUNT_READY
  • TLK_PLAYER_HOLDTAUNT
  • TLK_TAUNT_PYRO_ARMAGEDDON
  • TLK_ROCKET_DESTOYED
  • TLK_MVM_BOMB_DROPPED
  • TLK_MVM_BOMB_CARRIER_UPGRADE1DE1
  • TLK_MVM_BOMB_CARRIER_UPGRADE2DE2
  • TLK_MVM_BOMB_CARRIER_UPGRADE3DE3
  • TLK_MVM_DEFENDER_DIED
  • TLK_MVM_FIRST_BOMB_PICKUP
  • TLK_MVM_BOMB_PICKUP
  • TLK_MVM_SENTRY_BUSTER
  • TLK_MVM_SENTRY_BUSTER_DOWN
  • TLK_MVM_SNIPER_CALLOUT
  • TLK_MVM_LAST_MAN_STANDING
  • TLK_MVM_ENCOURAGE_MONEY
  • TLK_MVM_MONEY_PICKUP
  • TLK_MVM_ENCOURAGE_UPGRADE
  • TLK_MVM_UPGRADE_COMPLETE
  • TLK_MVM_GIANT_CALLOUT
  • TLK_MVM_GIANT_HAS_BOMB
  • TLK_MVM_GIANT_KILLED
  • TLK_MVM_GIANT_KILLED_TEAMMATETE
  • TLK_MVM_SAPPED_ROBOT
  • TLK_MVM_CLOSE_CALL
  • TLK_MVM_TANK_CALLOUT
  • TLK_MVM_TANK_DEAD
  • TLK_MVM_TANK_DEPLOYING
  • TLK_MVM_ATTACK_THE_TANK
  • TLK_MVM_TAUNT
  • TLK_MVM_WAVE_START
  • TLK_MVM_WAVE_WIN
  • TLK_MVM_WAVE_LOSE
  • TLK_MVM_DEPLOY_RAGE
  • TLK_MAGIC_BIGHEAD
  • TLK_MAGIC_SMALLHEAD
  • TLK_MAGIC_GRAVITY
  • TLK_MAGIC_GOOD
  • TLK_MAGIC_DANCE
  • HalloweenLongFall
  • TLK_TAUNT_GUITAR_RIFF
  • TLK_PLAYER_CAST_FIREBALL
  • TLK_PLAYER_CAST_MERASMUS_ZAP
  • TLK_PLAYER_CAST_SELF_HEAL
  • TLK_PLAYER_CAST_MIRV
  • TLK_PLAYER_CAST_BLAST_JUMP
  • TLK_PLAYER_CAST_STEALTH
  • TLK_PLAYER_CAST_TELEPORT
  • TLK_PLAYER_CAST_LIGHTNING_BALL
  • TLK_PLAYER_CAST_MOVEMENT_BUFF
  • TLK_PLAYER_CAST_MONOCULOUS
  • TLK_PLAYER_CAST_METEOR_SWARM
  • TLK_PLAYER_CAST_SKELETON_HORDE
  • TLK_PLAYER_CAST_BOMB_HEAD_CURSE
  • TLK_PLAYER_SPELL_FIREBALL
  • TLK_PLAYER_SPELL_MERASMUS_ZAP
  • TLK_PLAYER_SPELL_SELF_HEAL
  • TLK_PLAYER_SPELL_MIRV
  • TLK_PLAYER_SPELL_BLAST_JUMP
  • TLK_PLAYER_SPELL_STEALTH
  • TLK_PLAYER_SPELL_TELEPORT
  • TLK_PLAYER_SPELL_LIGHTNING_BALL
  • TLK_PLAYER_SPELL_MOVEMENT_BUFF
  • TLK_PLAYER_SPELL_MONOCULOUS
  • TLK_PLAYER_SPELL_METEOR_SWARM
  • TLK_PLAYER_SPELL_SKELETON_HORDE
  • TLK_PLAYER_SPELL_BOMB_HEAD_CURSE
  • TLK_PLAYER_SPELL_PICKUP_COMMON
  • TLK_PLAYER_SPELL_PICKUP_RARE
  • TLK_PLAYER_HELLTOWER_MIDNIGHT
  • TLK_PLAYER_SKELETON_KING_APPEAR
  • TLK_MANNHATTAN_GATE_ATK
  • TLK_MANNHATTAN_GATE_TAKE
  • TLK_RESURRECTED
  • TLK_MVM_LOOT_COMMON
  • TLK_MVM_LOOT_RARE
  • TLK_MVM_LOOT_ULTRARARE
  • TLK_MEDIC_HEAL_SHIELD
  • TLK_TAUNT_EUREKA_EFFECT
  • TLK_COMBO_KILLED
  • TLK_PLAYER_ASK_FOR_BALL
  • TLK_ROUND_START_COMP
  • TLK_GAME_OVER_COMP
  • TLK_MATCH_OVER_COMP
IgnitePlayer <integerRedirectInput/integer>
Ignites the player with a specified lifetime and causes a reaction (sound and speech).
Note.pngNote:Does not fire the OnIgnite output.
Icon-Bug.pngBug:Broken since the Jungle Inferno update, initiating sound and speech but no actual fire. Use trigger_ignite as a workaround.  [todo tested in ?]
ExtinguishPlayer
Extinguishes the player.
BleedPlayer <integerRedirectInput/integer>
Bleeds the player with a specified length.
RollRareSpell
Forces the player to roll a rare spell. Only available if spells are enabled on the map.
SetCustomModel <stringRedirectInput/string>
Set a custom player model without animations.
Note.pngNote:Using "" as the model argument will instead clear the target's custom model, returning the player to normal.
SetCustomModelWithClassAnimations <stringRedirectInput/string>
Set a custom player model with animations.
SetCustomModelOffset <vectorRedirectInput/Vector>
Set a custom player model position on the player.
SetCustomModelRotation <vectorRedirectInput/Vector>
Set a custom player model rotation on the player.
ClearCustomModelRotation
Clears the custom player model rotation.
SetCustomModelRotates <booleanRedirectInput/boolean>
Set if the custom model rotates or not to the player's angles.
SetCustomModelVisibleToSelf <booleanRedirectInput/boolean>
Set if the custom model is visible to the player, in thirdperson.
SetForcedTauntCam <booleanRedirectInput/boolean>
Forces the player into thirdperson mode.
SetScriptOverlayMaterial
Sets a custom screen overlay material. This overlay is separate from normal screen overlays (e.g. burning or env_screenoverlay) and will not get overriden.
TriggerLootIslandAchievement
[Todo].
TriggerLootIslandAchievement2
[Todo].
RoundSpawn
Clears any magic spell within the player's current spell book.

See Also