Targetname: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Undo revision 119682 by PatPeter (Talk) - it's not case sensitive)
(→‎Keywords: simplified examples and sorted more logically)
Line 15: Line 15:


== Keywords ==
== Keywords ==
The following generic targetnames can be used in place of entity or class names, for situations where specifying either would be too restrictive:


{| style="margin:auto; width:95%;" {{standard-table}}
The following special targetnames can be used to dynamically select an entity:
!style="width:7em;"| Keyword
 
! Result
; <code>!activator</code>
|-
: The entity that began the current I/O chain. If a player walks into a [[trigger_multiple|trigger]] that fires a [[logic_relay]], the player is the <code>!activator</code> of the relay's output(s).
|!player
; <code>!caller</code>
|The player. Only useful in singleplayer.  {{note|To target all players in a multiplayer game use <code>player</code>. This method can also target the player in a singleplayer game.}}
: 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).
|-
; <code>!self</code>
|!activator
: 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 that started the current I/O chain. For example:
; <code>!player</code>
*If an NPC walks into an appropriately flagged [[trigger_multiple]], that NPC will be the '''!activator''' for the '''[[Trigger]]''' and '''OnStartTouch''' outputs, and any resulting I/O outputs from them.
: The player. Only useful in singleplayer. {{tip|To target all players in a server, use <code>player</code>.}}
*If an entity kills another, it will be the '''!activator''' for its '''OnKilledNPC''' output.
; <code>!pvsplayer</code>
|-
: 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. <code>!player</code>).
|!caller
; <code>!speechtarget</code>
|The entity that triggered the current I/O command. For example:
: The entity at which the <code>!caller</code> is looking due to a [[Choreography creation/Creating Events/Other Events#Look_at_Actor|Look At Actor]] or [[Choreography creation/Creating Events/Other Events#Face_Actor|Face Actor]] choreography event. {{todo|The <code>!caller</code>? Really?}}
*If an NPC walks into an appropriately flagged [[trigger_multiple]], the [[trigger_multiple]] will be the '''!caller''' for the '''[[Trigger]]''' and '''OnStartTouch''' outputs only.
; <code>!picker</code>
|-
: The first entity under the player's crosshair. Only useful in single-player, and mostly only for debugging. {{note|This only finds entities that are solid (i.e. can be hit by the invisible "bullet" that is fired).}}
|!self
|The entity from which the Output originates.
*If a NPC kills another, it will be the '''!self''' for the '''OnKilledNPC''' output.
|-
|!pvsplayer
|The first player found in the entity's [[Potential Visibility Set|PVS]].
*The PVS used is taken from the entity doing the searching, or the activator if no searching entity exists.
*If no activator exists, it returns the first player in the game (equivalent to '''!player''').
|-
|!speechtarget
|The entity at which the caller is looking, as defined by the [[Choreography creation/Creating Events/Other Events#Look_at_Actor|Look At Actor]] and [[Choreography creation/Creating Events/Other Events#Face_Actor|Face Actor]] choreography events.
|-
|!picker
|The entity that the player is looking at. Only useful in single-player, and mostly only for debugging. Note that this only finds entities that are solid (i.e. can be hit by the invisible "bullet" fired to find the entity under the crosshair).
|}


== See also ==
== See also ==

Revision as of 14:05, 3 August 2009

Caveats

  • A targetname is not required for an entity to exist, but in some cases must be present for an entity to play a part in the I/O System.
  • A targetname is required for an entity to be a Parent in the Movement Hierarchy System.
  • 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 .bsp 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 ! or * characters (see below).

Notes

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:

!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).
!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 player.
!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.
Todo: The !caller? Really?
!picker
The first entity under the player's crosshair. Only useful in single-player, and mostly only for debugging.
Note.pngNote:This only finds entities that are solid (i.e. can be hit by the invisible "bullet" that is fired).

See also