Respawning props - the hard way
by venomus (view all articles)

unrated
How to make stuff respawn if the conventional ways fail.
by venomus (view all articles)

unrated

Here is a scenario: say you had a big pit of doom in your map and you wanted anything that fell down there to vaporise with that cool plasma effect, and then a while later you wanted it to reappear at its starting position. If you made that prop a prop_physics_respawnable, that should work right? Nope, not yet anyway (maybe valve will fix minor things like this in future updates).
So you'll just have to use the powerful entity input/output system to get the job done in the meantime.
Firstly we need to make our prop. Since I'm assuming you are making a multiplayer map this prop will be a prop_physics_multiplayer. I'm setting the world model (model) to models/props_combine/cell_01_pod.mdl, which is a good thing to have lying around any citadel map. Set the name (targetname) to pod1_prop.
When the pod falls into the pit o' doom which we will shortly be creating, we will use an env_entity_maker to recreate it at its original position. But for the env_entity_maker to work it need a template of the pod. So create a point_template and place it somewhere near the pod. Set following key/values on it:
name (targetname) : pod1_template
Template 1 (Template01) : pod1_prop
Now create an env_entity_maker and place it nearby. Give it the following key/value pairs:
name (targetname) : pod1_maker
point_template to spawn (EntityTemplate) : pod1_template
And set the ForceSpawn: only if there's room spawnflag (spawnflag 8). This doesn't appear to actually work (if you get stuck on a respawning prop, use the gravity gun to blast it away) but tick the spawnflag anyway.
Now we create a logic_auto to create a our first instance of the prop when the level loads. This is because templated entities get removed. Alternatively you could tick the Don't remove template entities spawnflag (spawnflag 1) on the point_template, but I decided to do it this way for some reason. Set the following output for the logic_auto:
My Output : OnMapSpawn
Target Entity : pod1_maker
Target Input : ForceSpawn
Delay : 0.5 (Always a good call to delay things slightly if they are set to occur at the map spawn, there is less chance of them going wrong that way)
Right now we need to create a filter_activator_name. You will see why in a minute. Give it the following key/value pairs:
name (targetname) : pod1_filter
filter name (filtername) : pod1_prop
filter mode (Negated) : Allow entities that match criteria
Give it the following output:
My Output : OnPass
Target Entity : pod1_maker
Target Input : ForceSpawn
Delay : 5 (set this to whatever you want the respawn time of the prop to be)
Only Once : No
Finally we need to set up the thing which kills the prop in the first place. This will be a trigger_physics_trap if you want the vaporising effect, but other entities might also work (trigger_remove comes to mind). Obviously this is a brush based entity and you place it to cover the bottom of you pit or wherever. Once you have created it give it the following key/value pairs:
Start disabled (StartDisabled) : No (0)
Filter Name (filtername) : pod1_filter
Dissolve Type (dissolve type) : Heavy Electrical (1) this is the effect which looks coolest IMO
Now give it the following spawnflags: Clients, NPCs and Physics Objects (which adds up to 11). Physics Objects obviously is the important one here but the other spawnflags will ensure players and any monsters die.
Now you need to give it this output:
My Output : OnStartTouch
Target Entity : pod1_filter
Target Input : TestActivator
Delay : 0
Only Once : No
What this will do is when something touches the trigger, as well as getting owned, it will have its targetname checked against the filter. If it matches, the filter tells the env_entity_maker to create a clone of it, effectively respawning it.
This method is not really the ideal way, that would be if the respawning code for the prop_physics_respawnable worked in the first place, at the moment it only seems to work if the prop is blown up or broken. You will also need to add new outputs to the trigger_physics_trap for every respawning prop which could be thrown in the pit as well as do all the stuff in this tutorial. Apart from being a pain to set up it might also be a lot of overhead for the server. I don't know this for sure because I never created a map that had so much stuff in it as say dm_overwatch, but you might want to keep it in mind.
So you'll just have to use the powerful entity input/output system to get the job done in the meantime.
Firstly we need to make our prop. Since I'm assuming you are making a multiplayer map this prop will be a prop_physics_multiplayer. I'm setting the world model (model) to models/props_combine/cell_01_pod.mdl, which is a good thing to have lying around any citadel map. Set the name (targetname) to pod1_prop.
When the pod falls into the pit o' doom which we will shortly be creating, we will use an env_entity_maker to recreate it at its original position. But for the env_entity_maker to work it need a template of the pod. So create a point_template and place it somewhere near the pod. Set following key/values on it:
name (targetname) : pod1_template
Template 1 (Template01) : pod1_prop
Now create an env_entity_maker and place it nearby. Give it the following key/value pairs:
name (targetname) : pod1_maker
point_template to spawn (EntityTemplate) : pod1_template
And set the ForceSpawn: only if there's room spawnflag (spawnflag 8). This doesn't appear to actually work (if you get stuck on a respawning prop, use the gravity gun to blast it away) but tick the spawnflag anyway.
Now we create a logic_auto to create a our first instance of the prop when the level loads. This is because templated entities get removed. Alternatively you could tick the Don't remove template entities spawnflag (spawnflag 1) on the point_template, but I decided to do it this way for some reason. Set the following output for the logic_auto:
My Output : OnMapSpawn
Target Entity : pod1_maker
Target Input : ForceSpawn
Delay : 0.5 (Always a good call to delay things slightly if they are set to occur at the map spawn, there is less chance of them going wrong that way)
Right now we need to create a filter_activator_name. You will see why in a minute. Give it the following key/value pairs:
name (targetname) : pod1_filter
filter name (filtername) : pod1_prop
filter mode (Negated) : Allow entities that match criteria
Give it the following output:
My Output : OnPass
Target Entity : pod1_maker
Target Input : ForceSpawn
Delay : 5 (set this to whatever you want the respawn time of the prop to be)
Only Once : No
Finally we need to set up the thing which kills the prop in the first place. This will be a trigger_physics_trap if you want the vaporising effect, but other entities might also work (trigger_remove comes to mind). Obviously this is a brush based entity and you place it to cover the bottom of you pit or wherever. Once you have created it give it the following key/value pairs:
Start disabled (StartDisabled) : No (0)
Filter Name (filtername) : pod1_filter
Dissolve Type (dissolve type) : Heavy Electrical (1) this is the effect which looks coolest IMO
Now give it the following spawnflags: Clients, NPCs and Physics Objects (which adds up to 11). Physics Objects obviously is the important one here but the other spawnflags will ensure players and any monsters die.
Now you need to give it this output:
My Output : OnStartTouch
Target Entity : pod1_filter
Target Input : TestActivator
Delay : 0
Only Once : No
What this will do is when something touches the trigger, as well as getting owned, it will have its targetname checked against the filter. If it matches, the filter tells the env_entity_maker to create a clone of it, effectively respawning it.
This method is not really the ideal way, that would be if the respawning code for the prop_physics_respawnable worked in the first place, at the moment it only seems to work if the prop is blown up or broken. You will also need to add new outputs to the trigger_physics_trap for every respawning prop which could be thrown in the pit as well as do all the stuff in this tutorial. Apart from being a pain to set up it might also be a lot of overhead for the server. I don't know this for sure because I never created a map that had so much stuff in it as say dm_overwatch, but you might want to keep it in mind.