Targetname: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(Cleaned up the page, added a brand new section for Player Events (game_playerdie, etc))
Line 1: Line 1:
A '''targetname''' is the name of an entity. A targetname is not required for an entity to exist, but generally must be present for an entity to play a part in the [[Inputs_and_Outputs|I/O System]]
A '''targetname''' (also known simply as '''Name''') is the name of an entity. A targetname is not required for an entity to exist, but generally must be present for an entity to play a part in the [[Inputs_and_Outputs|I/O System]]
 
=== Notes ===
=== Tips ===
* Entities may also be targeted by their [[classname]] (e.g. prop_dynamic).
 
* Targetnames do not need to be unique, they can be shared (and inputs will be sent to each one). Duplicated targetnames are displayed in bold font.
Also known as '''name''' when smartedit is on
 
* It is sometimes possible to target entites by classname (e.g. prop_dynamic).
* A targetname must be stored in the map's entity data block, so avoid naming entities that don't need a name (i.e. aren't ever referenced by another entity). The comment field in Hammer is useful for describing entities that don't need targetnames, and doesn't get saved into the <code>.bsp</code> entity data block.
* Targetnames do not need to be unique. As many entities as the mapper wants can share the same name, and they will all respond to the same inputs. Duplicated targetnames are displayed in bold font.
* Targetnames are also useful for categorizing entities (area1_name, area2_name, etc.).
* Targetnames cannot contain <code>!</code> or <code>*</code> characters (see below).
* Targetnames cannot contain <code>!</code> or <code>*</code> characters (see below).
 
=== Instances ===
=== Notes ===
* [[Instance]]s may use prefix or postfix name fixups, and will auto-generate a prefix if no parameters are specified.  
 
==== Instances ====
 
* Instances may use prefix or postfix name fixups, and will auto-generate a prefix if no parameters are specified.  
* Prefixes and Postfixes are separated by a single dash e.g. '''hall_a3-door_02'''.
* Prefixes and Postfixes are separated by a single dash e.g. '''hall_a3-door_02'''.
*Placing an <code>@</code> symbol at the beginning of a targetname (e.g. '''@exit_door''') will bypass a naming fixup for that particular entity. If '''@exit_door''' and '''exit_door_relay''' were part of an instance prefixed as '''Door_01''', the names of the entities would be '''@exit_door''' and '''Door_01-exit_door_relay'''.
*Placing an <code>@</code> symbol at the beginning of a targetname (e.g. '''@exit_door''') will bypass a naming fixup for that particular entity. If '''@exit_door''' and '''exit_door_relay''' were part of an instance prefixed as '''Door_01''', the names of the entities would be '''@exit_door''' and '''Door_01-exit_door_relay'''.
 
=== Player Events ===
==== Name Searching ====
Any entity with the following targetnames will have a [[Use]] input sent to them when that event occurs.
 
* <code>game_playerdie</code> - Fires every time a [[player]] dies. The player who died is the [[!activator]].
* <code>game_playerkill</code> - Fires every time a [[player]] kills another player, the killer is the [[!activator]].
* <code>game_playerjoin</code> - Fires every time a [[player]] joins the game, the joining player is the [[!activator]]. {{bug|<code>game_playerjoin</code> is not fired by [[bot]]s.}}
* <code>game_playerspawn</code> - Fires every time a [[player]] spawns, the spawning player is the [[!activator]]. {{bug|<code>game_playerspawn</code> does not function in {{csgo}} and {{tf2}}.}}
* <code>game_playerleave</code> - Fires every time a [[player]] leaves the game, [[!activator]] will not work in this case as the [[player]] [[entity]] no longer exists.
=== Name Searching ===
There are several extended features to name searches that are useful in a variety of situations. The most common use is to target an entity with an unknown name that is somehow involved in the current I/O chain. The extended features are:
There are several extended features to name searches that are useful in a variety of situations. The most common use is to target an entity with an unknown name that is somehow involved in the current I/O chain. The extended features are:


Line 27: Line 22:
*The [[Inputs_and_Outputs|I/O System]] is classname friendly, but Hammer isn't.  This is the case that doesn't require a targetname for the [[Inputs_and_Outputs|I/O System]].
*The [[Inputs_and_Outputs|I/O System]] is classname friendly, but Hammer isn't.  This is the case that doesn't require a targetname for the [[Inputs_and_Outputs|I/O System]].
:An example of this is use of [[ent_fire]] with a classname as opposed to a targetname.
:An example of this is use of [[ent_fire]] with a classname as opposed to a targetname.
 
=== Keywords ===
== Keywords ==
 
The following special targetnames can be used to dynamically select an entity.
The following special targetnames can be used to dynamically select an entity.


Line 40: Line 33:
; <code>!caller</code>
; <code>!caller</code>
: The previous entity in the current I/O chain. If a player walks into a trigger that that fires a logic_relay, the trigger is the <code>!caller</code> of the relay's output(s).  
: The previous entity in the current I/O chain. If a player walks into a trigger that that fires a logic_relay, the trigger is the <code>!caller</code> of the relay's output(s).  
{{bug|This does not appear to work correctly in {{tf2}}, instead selecting any entity in the I/O chain.}}
; <code>!self</code>
; <code>!self</code>
: The entity from which the current output originates. If a player walks into a trigger that that fires a logic_relay, the relay is the <code>!self</code> of its output(s).
: The entity from which the current output originates. If a player walks into a trigger that that fires a logic_relay, the relay is the <code>!self</code> of its output(s).
Line 54: Line 48:
; <code>!picker</code>
; <code>!picker</code>
: The first entity under the player's crosshair. Only useful in single-player, and mostly only for debugging. Entities without collision can only be selected by aiming at their origin.
: The first entity under the player's crosshair. Only useful in single-player, and mostly only for debugging. Entities without collision can only be selected by aiming at their origin.
== See also ==
== See also ==
* [[Client Command by Trigger proximity]], a mini-tutorial explaining the process of letting the player(s) in your game execute a Client Command by a trigger.
* [[Client Command by Trigger proximity]], a mini-tutorial explaining the process of letting the player(s) in your game execute a Client Command by a trigger.
* [[User_Inputs_and_Outputs| User Inputs and Outputs]]
* [[User_Inputs_and_Outputs| User Inputs and Outputs]]
* <code>[[GetDebugName()]]</code>, for accessing an entity's targetname in C++.
* <code>[[GetDebugName()]]</code>, for accessing an entity's targetname in C++.


[[Category:Level Design]]
[[Category:Level Design]]
[[Category:Technical]]
[[Category:Technical]]

Revision as of 16:00, 22 January 2019

A targetname (also known simply as Name) is the name of an entity. A targetname is not required for an entity to exist, but generally must be present for an entity to play a part in the I/O System

Notes

  • Entities may also be targeted by their classname (e.g. prop_dynamic).
  • Targetnames do not need to be unique, they can be shared (and inputs will be sent to each one). Duplicated targetnames are displayed in bold font.
  • Targetnames cannot contain ! or * characters (see below).

Instances

  • Instances may use prefix or postfix name fixups, and will auto-generate a prefix if no parameters are specified.
  • Prefixes and Postfixes are separated by a single dash e.g. hall_a3-door_02.
  • Placing an @ symbol at the beginning of a targetname (e.g. @exit_door) will bypass a naming fixup for that particular entity. If @exit_door and exit_door_relay were part of an instance prefixed as Door_01, the names of the entities would be @exit_door and Door_01-exit_door_relay.

Player Events

Any entity with the following targetnames will have a Use input sent to them when that event occurs.

  • game_playerdie - Fires every time a player dies. The player who died is the !activator.
  • game_playerkill - Fires every time a player kills another player, the killer is the !activator.
  • game_playerjoin - Fires every time a player joins the game, the joining player is the !activator.
    Icon-Bug.pngBug:game_playerjoin is not fired by bots.  [todo tested in ?]
  • game_playerspawn - Fires every time a player spawns, the spawning player is the !activator.
    Icon-Bug.pngBug:game_playerspawn does not function in Counter-Strike: Global Offensive and Team Fortress 2.  [todo tested in ?]
  • game_playerleave - Fires every time a player leaves the game, !activator will not work in this case as the player entity no longer exists.

Name Searching

There are several extended features to name searches that are useful in a variety of situations. The most common use is to target an entity with an unknown name that is somehow involved in the current I/O chain. The extended features are:

  • Wildcards
Name searching supports trailing * wildcards only. So searching for area1* will match any targetnames that start with area1 (i.e. area1_portal and area1_door, but not area2_door).
  • The I/O System is classname friendly, but Hammer isn't. This is the case that doesn't require a targetname for the I/O System.
An example of this is use of ent_fire with a classname as opposed to a targetname.

Keywords

The following special targetnames can be used to dynamically select an entity.

Note.pngNote:Not all entity parameters can evaluate these targetnames.
Note.pngNote:When used in an output's parameter override field, targetnames are evaluated by the entity that receives the output, not the one that sends it. This can change what is pointed to.
!activator
The entity that began the current I/O chain. If a player walks into a trigger that fires a logic_relay, the player is the !activator of the relay's output(s).
!caller
The previous entity in the current I/O chain. If a player walks into a trigger that that fires a logic_relay, the trigger is the !caller of the relay's output(s).
Icon-Bug.pngBug:This does not appear to work correctly in Team Fortress 2, instead selecting any entity in the I/O chain.  [todo tested in ?]
!self
The entity from which the current output originates. If a player walks into a trigger that that fires a logic_relay, the relay is the !self of its output(s).
!player
The player. Only useful in singleplayer.
Tip.pngTip:To target all players in a server, use the player classname.
!player_bluePortal 2
In Portal 2 Coop, this targets ATLAS (player 1).
!player_orangePortal 2
In Portal 2 Coop, this targets P-Body (player 2).
!pvsplayer
The first player found in the entity's Potential Visibility Set. The PVS used is taken from the entity doing the searching, or the activator if no searching entity exists. If no activator exists either, the first player in the game is returned (i.e. !player).
!speechtarget
The entity at which the !caller is looking due to a Look At Actor or Face Actor choreography event.
!picker
The first entity under the player's crosshair. Only useful in single-player, and mostly only for debugging. Entities without collision can only be selected by aiming at their origin.

See also