Respawning Items: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created tutorial)
 
m (minor cleanup)
Line 1: Line 1:
=Respawning items=
This is a tutorial for creating respawning items that can be either placed at a position, or dropped from the sky.


This is a tutorial for creating respawning items that can be either placed at a position, or dropped from the sky.
== Step by step ==
First, create your room however you want it, or open up an existing map.


=Entities=
=== Entities ===
The following entities will be used:
The following entities will be used:


    * [[Point_template]] (makes copies of the item to spawn)
* [[point_template]] - makes copies of the item to spawn.
    * [[Env_entity_maker]] (spawns the item in the game)
* [[env_entity_maker]] - spawns the item in the game.
    * [[Logic_case]] (used to trigger the env_entity_maker)
* [[logic_case]] - used to trigger <code>the env_entity_maker</code>.
    * [[Logic_timer]] (used to trigger the logic_case and select a random spawner)
* [[logic_timer]] - used to trigger the <code>logic_case</code> and select a random spawner.
 
=Step by step=
First, create your room however you want, or open up your map.


==Item templates==
== Item templates ==
Now, place into the level the item you want to spawn (eg, [[Item_healthkit]].) Name it <code>spawned1</code>.
Now, place into the level the item you want to spawn (e.g., [[item_healthkit]]) and name it <code>spawned1</code>.


Place near this a '''point_template'''. Name it <code>template1</code> and set the ''Template 1'' property to <code>spawned1</code>.
Place near this a '''point_template''', name it <code>template1</code> and set the ''Template 1'' property to <code>spawned1</code>.


Repeat this process for every other item you want to be able to spawn, remembering to use different names (eg, <code>spawned1</code> becomes <code>spawned2</code> and <code>template1</code> becomes <code>template2</code>.)
Repeat this process for every other item you want to be able to spawn, remembering to use different names (e.g., <code>spawned1</code> becomes <code>spawned2</code> and <code>template1</code> becomes <code>template2</code>).


==Add your entity makers==
== Add your entity makers ==
Place around your map a number of '''env_entity_maker''' entities. The first one should be named <code>spawner1</code> and each should be named in a consecutive manner (''ie, <code>spawner1</code>, <code>spawner2</code>, <code>spawner2</code> and so forth''.)
Place around your map a number of '''env_entity_maker''' entities. The first one should be named <code>spawner1</code> and each should be named in a consecutive manner (i.e., ''<code>spawner1</code>, <code>spawner2</code>, <code>spawner2</code>'' and so forth).


Each of these should have their ''Point_template To Spawn'' property set to the template you want to spawn (''eg, <code>template1</code>''.)
Each of these should have their ''Point_template To Spawn'' property set to the template you want to spawn (e.g., ''<code>template1</code>'').


==Add your logic_case==
== Add your logic_case ==
The '''logic_case''' entity will contain a list of all the '''env_entity_maker''' entities, and will be used to make the entities spawn.
The '''logic_case''' entity will contain a list of all the '''env_entity_maker''' entities, and will be used to make the entities spawn.


Begin by naming your '''logic_case''' <code>logic_spawner</code> and giving a value to each ''Case xx'' property. You can simply put a number in each, counting upwards. Only put as many values in as you have '''env_entity_maker''' entities though.
Begin by naming your '''logic_case''' <code>logic_spawner</code> and giving a value to each ''Case xx'' property. You can simply put a number in each, counting upwards. Only put as many values in as you have '''env_entity_maker''' entities though.


On the '''Output''' tab, add an output for each '''env_entity_maker''' you have. Set each to a different '''OnCaseXX''' output, and put the name of the '''env_entity_maker''' you want to spawn in the target field (''eg, <code>spawner1</code>'') and set the input to be '''ForceSpawn'''.
On the '''Output''' tab, add an output for each '''env_entity_maker''' you have. Set each to a different '''OnCaseXX''' output, and put the name of the '''env_entity_maker''' you want to spawn in the target field (e.g., ''<code>spawner1</code>'') and set the input to be '''ForceSpawn'''.


==Add your timer==
== Add your timer ==
The '''logic_timer''' will be used to make each item spawn. It works by using the '''PickRandomShuffle''' input of the '''logic_case'''.
The '''logic_timer''' will be used to make each item spawn. It works by using the '''PickRandomShuffle''' input of the '''logic_case'''.


Line 43: Line 41:
:'''Via this input:''' <code>PickRandomShuffle</code>
:'''Via this input:''' <code>PickRandomShuffle</code>


==Test your map==
== Test your map ==
Compile and test your map. If something does not work, try downloading the sample map and see if you missed anything.
Compile and test your map. If something does not work, try downloading the sample map and see if you missed anything.


=Sample map=
== Samples ==
A sample map demonstrating this tutorial is [http://members.iinet.net.au/~cradleoffilth/point_template.zip availible for download.]
A sample map demonstrating this tutorial is [http://members.iinet.net.au/~cradleoffilth/point_template.zip available for download.]


[[Category:Tutorials]]
[[Category:Tutorials]]

Revision as of 07:23, 3 October 2007

This is a tutorial for creating respawning items that can be either placed at a position, or dropped from the sky.

Step by step

First, create your room however you want it, or open up an existing map.

Entities

The following entities will be used:

Item templates

Now, place into the level the item you want to spawn (e.g., item_healthkit) and name it spawned1.

Place near this a point_template, name it template1 and set the Template 1 property to spawned1.

Repeat this process for every other item you want to be able to spawn, remembering to use different names (e.g., spawned1 becomes spawned2 and template1 becomes template2).

Add your entity makers

Place around your map a number of env_entity_maker entities. The first one should be named spawner1 and each should be named in a consecutive manner (i.e., spawner1, spawner2, spawner2 and so forth).

Each of these should have their Point_template To Spawn property set to the template you want to spawn (e.g., template1).

Add your logic_case

The logic_case entity will contain a list of all the env_entity_maker entities, and will be used to make the entities spawn.

Begin by naming your logic_case logic_spawner and giving a value to each Case xx property. You can simply put a number in each, counting upwards. Only put as many values in as you have env_entity_maker entities though.

On the Output tab, add an output for each env_entity_maker you have. Set each to a different OnCaseXX output, and put the name of the env_entity_maker you want to spawn in the target field (e.g., spawner1) and set the input to be ForceSpawn.

Add your timer

The logic_timer will be used to make each item spawn. It works by using the PickRandomShuffle input of the logic_case.

Add your logic_timer and set Start Disabled to No. Under Refire Interval set the delay (in seconds) of how often you would like your items to spawn. For testing purposes, I used a value of 2.

Add the following output to your logic_timer:

My output named: OnTimer
Target entities named: logic_spawner
Via this input: PickRandomShuffle

Test your map

Compile and test your map. If something does not work, try downloading the sample map and see if you missed anything.

Samples

A sample map demonstrating this tutorial is available for download.