This article's documentation is for anything that uses the Source engine. Click here for more information.

Point template: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added sprite from GMod)
 
(29 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{otherlang2|
{{LanguageBar}}
|zh-cn =Point_template:zh-cn
{{CD|CPointTemplate|file1=1}}
}}
[[File:Point template.png|frameless|link=]][[File:Point template classic.png|frameless|link=]]{{this is a|point entity|name=point_template}}
[[File:Point_template.png|left]]
{{base point|point_template}} It turns an entity, or set of entities, into a single template that can be instanced anywhere, and multiple times. When activated, this entity will spawn the entities in the template at the same positions, relative to this entity, that they had when this entity was created. This will be their original positions if the point_template has not been moved. To spawn the template in other places, an [[env_entity_maker]] can be used. For any [[logic_relay]] entities within a template, will fire its OnSpawn output when spawned.
 
 
{{bug|In {{insurgency}}{{doi}}, this entity is broken and will usually crash the game. Although if the gamemode is set to training in {{insurgency}}, it will work normally.}}
{{bug|In {{csgo}}, spawning a [[func_breakable_surf]] with this entity will crash the game.}}
{{note|Any entity from [[S_PreserveEnts]] cannot be instanced.}}


== Entity Description ==
{{ent|point_template}} turns an [[entity]] or set of entities into a single template that can be instanced anywhere and multiple times. When activated (<tt>ForceSpawn</tt>), it will spawn the entities in the template at the same positions, relative to itself, that they had when this entity was created. This will be their original positions if the <code>point_template</code> has not been moved. To spawn the template in other places, an {{ent|env_entity_maker}} can be used.
{{tip|Any {{ent|logic_relay}} entities within a template will fire their <tt>OnSpawn</tt> output when spawned. This behavior can be used to make templated entities do things when they spawn.}}
{{bug|hidetested=1|{{insurgency}}{{doi}} This entity is broken and will usually crash the game. If the gamemode is set to training in {{insurgency}}, it will work normally.}}
{{bug|hidetested=1|{{csgo}} Spawning a {{ent|func_breakable_surf}} with this entity will crash the game.}}
{{note|Any entity from [[S_PreserveEnts]] cannot be instanced by default. This can be workarounded by making the point_template a preserved entity itself at map load which can be done by using [[logic_auto]] to change the classname of the template with AddOutput to one from S_PreserveEnts. When spawning this template a message will be shown that there are no templated entities, however it will work anyways.}}
{{warning|Entities that have a <code>globalname</code> will not spawn if they have been killed previously.}}
<!--{{Important|{{l4d2}} Do NOT spawn a map's only <kbd>trigger_finale</kbd> via <kbd>point_template</kbd>! Late spawning it with a template results in poor VScript compatibility and other issues. See {{ent|trigger_finale}} for more info.}}-->
Before using this entity, consider sections like [[#Name Fix-up|Name Fix-up]] and [[#FGD Enhancement(s)|FGD Enhancement(s)]] first.
Before using this entity, consider sections like [[#Name Fix-up|Name Fix-up]] and [[#FGD Enhancement(s)|FGD Enhancement(s)]] first.


=== Name Fix-up ===
=== Name Fix-up ===
To prevent interdependencies (entity I/O, hierarchy, or other name references) between entities, the entities in the template will have their names changed, with the interdependencies outputs reconnected to the changed names. The name change format is as follows: '<original name>&XXXX', where the '&XXXX' will be replaced with the current global template instance spawn count, so wildcard searches for '<original name>&*' will still find them. Name fixing is ''only'' for template entities spawned by output; The outputs of the point_template are ''not'' name fixed, and neither are the outputs of other objects referring to template entities.
To prevent interdependencies (entity I/O, hierarchy, or other name references) between entities, the entities in the template will have their names changed, with any interdependent outputs reconnected to the changed names. The name change format is as follows: '<original name>&XXXX', where the '&XXXX' will be replaced with the current global template instance spawn count, so wildcard searches for '<original name>&*' will still find them. Name fixing is ''only'' for template entities spawned by output; The outputs of the point_template are ''not'' name fixed, and neither are the outputs of other objects referring to template entities.


The special [[targetname|targetnames]] (!self and such) work on spawned objects, so a [[trigger_multiple]] with an output to<code>!activator</code>can be used to affect individual spawned objects. Wildcards can refer to all entities spawned by a fix-up-enabled point_template.
The special [[targetname]]s (<code>!self</code> and such) work on spawned objects, so a {{ent|trigger_multiple}} with an output to <code>!activator</code> can be used to affect individual spawned objects. Wildcards can refer to all entities spawned by a fix-up-enabled point_template.


Note that if '"Don't remove template entities"' flag is active, the first (batch of) entities spawned will be postfixed<code>&0002</code>. If you don't want the name fixup to happen, because you're only spawning the template once, or you want inputs to trigger all instances of the template, check the 'Preserve entity names' spawnflag.
Note that if '"Don't remove template entities"' flag is active, the first (batch of) entities spawned will be postfixed<code>&0002</code>. If you don't want the name fixup to happen, because you're only spawning the template once, or you want inputs to trigger all instances of the template, check the 'Preserve entity names' spawnflag.
{{confirm|If<code>spawnflag 2</code>is active, will the unremoved entity have its name postfixed with<code>&0001?</code>}}
{{Confirm|If<code>spawnflag 2</code>is active, will the unremoved entity have its name postfixed with<code>&0001?</code>}}
{{warning| Point_template ''will not'' do any name fixuppance in the parameter override boxes of its templated entities.}}
{{warning|<code>point_template</code> ''will not'' do any name fixing-up in the parameter override boxes of its templated entities.}}
=== Tutorial ===
{{note|Entities must be referenced by name in a keyvalue or external I/O connection to get fixed up. If neither is present, then the name is preserved. If this isn't desired, a easy fix is to add a dummy keyvalue in the entity that references it's own name. It doesn't even have to be a keyvalue that really exists on the entity.}}
A [[Respawning_Items|tutorial]] has been created for respawning items using this entity.


== Keyvalues ==
== Keyvalues ==
{{KV PointTemplate}}
{{KV Targetname}}
{{KV|Template 1|intn=Template01|to=Template 16|intn2=Template16|target_destination| [[Targetname]](s) to search for entities to template. These can be exact matches, or wildcards (*). If multiple entities are matched, all entities will be included in the template.}}


== Flags ==
== Flags ==
{{Fl PointTemplate}}
{{fl|1|Don't remove template entities|Prevent template entities being removed automatically.}}
{{fl|2|Preserve entity names (Don't do name fixup)|Causes the spawned entities to be named exactly as their templates were (as opposed to renamed).}}


== Inputs ==
== Inputs ==
{{I PointTemplate}}
{{I|ForceSpawn|Spawn an instance of the template at the original position.}}


== Outputs ==
== Outputs ==
{{O PointTemplate}}
{{O|OnEntitySpawned|ac-is-this=1|Fired after spawning an instance of this template.}}


== FGD Enhancement(s) ==
== FGD Enhancement(s) ==
Line 62: Line 64:


== See also ==
== See also ==
* [[env_entity_maker]] - automatic respawning and/or spawning at a different location
* [[Respawning Items|tutorial for respawning items using this entity]]
* [[npc_maker]] - an alternative spawning entity, also with optional automatic respawning
* {{ent|env_entity_maker}} - Automatic respawning and/or spawning at a different location
* {{l4d2}} [[point_script_template]] - version of point_template catered to VScripting
* {{ent|npc_maker}} - An alternative spawning entity, also with optional automatic respawning
* {{l4d2}} {{ent|point_script_template}} - Version of <code>point_template</code> catered to [[VScript]]ing

Latest revision as of 21:16, 28 May 2025

English (en)中文 (zh)Translate (Translate)
C++ Class hierarchy
CPointTemplate
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ point_template.cpp

Point template.pngPoint template classic.pngpoint_template is a point entity available in all Source Source games.

Entity Description

point_template turns an entity or set of entities into a single template that can be instanced anywhere and multiple times. When activated (ForceSpawn), it will spawn the entities in the template at the same positions, relative to itself, that they had when this entity was created. This will be their original positions if the point_template has not been moved. To spawn the template in other places, an env_entity_maker can be used.

Tip.pngTip:Any logic_relay entities within a template will fire their OnSpawn output when spawned. This behavior can be used to make templated entities do things when they spawn.
Icon-Bug.pngBug:InsurgencyDay of Infamy This entity is broken and will usually crash the game. If the gamemode is set to training in Insurgency, it will work normally.
Icon-Bug.pngBug:Counter-Strike: Global Offensive Spawning a func_breakable_surf with this entity will crash the game.
Note.pngNote:Any entity from S_PreserveEnts cannot be instanced by default. This can be workarounded by making the point_template a preserved entity itself at map load which can be done by using logic_auto to change the classname of the template with AddOutput to one from S_PreserveEnts. When spawning this template a message will be shown that there are no templated entities, however it will work anyways.
Warning.pngWarning:Entities that have a globalname will not spawn if they have been killed previously.

Before using this entity, consider sections like Name Fix-up and FGD Enhancement(s) first.

Name Fix-up

To prevent interdependencies (entity I/O, hierarchy, or other name references) between entities, the entities in the template will have their names changed, with any interdependent outputs reconnected to the changed names. The name change format is as follows: '<original name>&XXXX', where the '&XXXX' will be replaced with the current global template instance spawn count, so wildcard searches for '<original name>&*' will still find them. Name fixing is only for template entities spawned by output; The outputs of the point_template are not name fixed, and neither are the outputs of other objects referring to template entities.

The special targetnames (!self and such) work on spawned objects, so a trigger_multiple with an output to !activator can be used to affect individual spawned objects. Wildcards can refer to all entities spawned by a fix-up-enabled point_template.

Note that if '"Don't remove template entities"' flag is active, the first (batch of) entities spawned will be postfixed&0002. If you don't want the name fixup to happen, because you're only spawning the template once, or you want inputs to trigger all instances of the template, check the 'Preserve entity names' spawnflag.

Confirm:Ifspawnflag 2is active, will the unremoved entity have its name postfixed with&0001?
Warning.pngWarning:point_template will not do any name fixing-up in the parameter override boxes of its templated entities.
Note.pngNote:Entities must be referenced by name in a keyvalue or external I/O connection to get fixed up. If neither is present, then the name is preserved. If this isn't desired, a easy fix is to add a dummy keyvalue in the entity that references it's own name. It doesn't even have to be a keyvalue that really exists on the entity.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Template 1 (Template01) to Template 16 (Template16) <targetname>
Targetname(s) to search for entities to template. These can be exact matches, or wildcards (*). If multiple entities are matched, all entities will be included in the template.

Flags

Don't remove template entities : [1]
Prevent template entities being removed automatically.
Preserve entity names (Don't do name fixup) : [2]
Causes the spawned entities to be named exactly as their templates were (as opposed to renamed).

Inputs

ForceSpawn
Spawn an instance of the template at the original position.

Outputs

OnEntitySpawned
!activator = !caller = this entity
Fired after spawning an instance of this template.

FGD Enhancement(s)

From TeamSpen210's Hammer Addons,point_templatecan be made to show connecting lines to all entities part of its template.

First, go to this line in yourbase.fgdand highlight the same characters:

@PointClass base(Targetname) iconsprite("editor/point_template.vmt") = point_template :

Then copy all of this, and paste all of this over it:

@PointClass base(BaseEntityPoint) 
	iconsprite("editor/point_template.vmt")
	line(255 255 0, targetname, Template01)
	line(255 255 0, targetname, Template09)
	line(255 255 0, targetname, Template02)
	line(255 255 0, targetname, Template10)
	line(255 255 0, targetname, Template03)
	line(255 255 0, targetname, Template11)
	line(255 255 0, targetname, Template04)
	line(255 255 0, targetname, Template12)
	line(255 255 0, targetname, Template05)
	line(255 255 0, targetname, Template13)
	line(255 255 0, targetname, Template06)
	line(255 255 0, targetname, Template14)
	line(255 255 0, targetname, Template07)
	line(255 255 0, targetname, Template15)
	line(255 255 0, targetname, Template08)
	line(255 255 0, targetname, Template16)
= point_template:

See also