Antlions: Random Spawn: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Some minor formatting →‎Configuring the entities)
Line 1: Line 1:
{{tutorial cleanup}}
The great thing about these antlions is that they are made to be used with other litle tools to make them spawn randomly when the player walks on a specified material, be it sand or any other material.
The great thing about these antlions is that they are made to be used with other litle tools to make them spawn randomly when the player walks on a specified material, be it sand or any other material.


Line 21: Line 19:
==Configuring the entities==
==Configuring the entities==


First create an Antlion entity:
First create an npc_antlion with the following properties.
 
{{entity-kvalue-start|[[npc_antlion]]}}
{{entity-kvalue-start|[[npc_antlion]]}}
{{entity-kvalue|Name|AntLion|}}
{{entity-kvalue|Name|AntLion|}}
{{entity-kvalue-end}}
{{entity-kvalue-end}}
with the following flags set:
 
{{entity-flag-start}}
{{entity-flag-start}}
{{entity-flag|Start Burrowed|on|}}
{{entity-flag|Start Burrowed|on|}}
{{entity-flag|''Template NPC''|on|}}
{{entity-flag|Template NPC|on|}}
{{entity-flag-end}}
{{entity-flag-end}}
Next, configure an entity that triggers inputs if the player is walking on the specified material:
 
Next, configure the entity that triggers inputs when the player walks on the sand:
 
{{entity-kvalue-start|[[env_player_surface_trigger]]}}
{{entity-kvalue-start|[[env_player_surface_trigger]]}}
{{entity-kvalue|Name|SurfaceTrigger|}}
{{entity-kvalue|Name|SurfaceTrigger|}}
{{entity-kvalue|GameMaterialToWatch|sand|}}
{{entity-kvalue|GameMaterialToWatch|sand|}}
{{entity-kvalue-end}}
{{entity-kvalue-end}}
and add the following outputs:
 
{{entity-output-start|}}
{{entity-output-start|}}
{{entity-output|OnSurfaceChangedFromTarget|relay_expanse_disablespawn|Trigger||||..if the player starts walking on the surface we have chosen, it triggers the relay OnSurfaceChangedToTarget which enables the npc_antlion_template_maker}}
{{entity-output|OnSurfaceChangedFromTarget|relay_expanse_disablespawn|Trigger||||When the player starts walking on the surface we have chosen, this entity triggers the relay OnSurfaceChangedToTarget.}}
{{entity-output|OnSurfaceChangedToTarget|relay_expanse_spawn|Trigger||||..and after that that when (or if) the player steps off it, it triggers the relay OnSurfaceChangedFromTarget which stops the spawning}}
{{entity-output|OnSurfaceChangedToTarget|relay_expanse_spawn|Trigger||||When the player steps off it, it triggers the relay OnSurfaceChangedFromTarget}}
{{entity-output-end}}
{{entity-output-end}}


This entity creates the noise when the antlions are emerging:
Then you will have to create the entity that creates the noise when the antlions are emerging.
 
{{entity-kvalue-start|[[ambient_generic]]}}
{{entity-kvalue-start|[[ambient_generic]]}}
{{entity-kvalue|Name|sound_antlion_spawn|}}
{{entity-kvalue|Name|sound_antlion_spawn|}}
Line 53: Line 55:
{{entity-kvalue-end}}
{{entity-kvalue-end}}


This entity creates the quake when the antlions are emerging:
And the one to create the quake.
 
{{entity-kvalue-start|[[env_shake]]}}
{{entity-kvalue-start|[[env_shake]]}}
{{entity-kvalue|Name|shake_antlion_spawn|}}
{{entity-kvalue|Name|shake_antlion_spawn|}}
Line 62: Line 65:
{{entity-kvalue-end}}
{{entity-kvalue-end}}


This entity actually creates antlions:
The following entity actually creates the antlions.
 
{{entity-kvalue-start|[[npc_antlion_template_maker]]}}  
{{entity-kvalue-start|[[npc_antlion_template_maker]]}}  
{{entity-kvalue|Name|antlion_expanse_spawner|}}  
{{entity-kvalue|Name|antlion_expanse_spawner|}}  
{{entity-kvalue|StartDisabled|Yes |..we do not want the template_maker to start spawning at the beginning of the map}}  
{{entity-kvalue|StartDisabled|Yes |We do not want the template_maker to start spawning at the beginning of the map.}}  
{{entity-kvalue|Num. of NPCs||..leave empty because we will check ''Infinite Children'' in flags}}  
{{entity-kvalue|Num. of NPCs||Leave empty because we will check ''Infinite Children'' in flags.}}  
{{entity-kvalue|Frequency|0.35|}}  
{{entity-kvalue|Frequency|0.35|}}  
{{entity-kvalue|Max Live NCPs||..how many antlions can live at same time, 8 for example}}  
{{entity-kvalue|Max Live NCPs||How many antlions can live at same time, 8 for example.}}  
{{entity-kvalue|Name Of Template NPC|AntLion|}}  
{{entity-kvalue|Name Of Template NPC|AntLion|}}  
{{entity-kvalue|Spawn On HintGroup|antlion_expanse_spawn_nodes|}}  
{{entity-kvalue|Spawn On HintGroup|antlion_expanse_spawn_nodes|}}  
{{entity-kvalue|Spawn Radius|1000|}}  
{{entity-kvalue|Spawn Radius|1000|}}  
{{entity-kvalue|Spawn Target|!player|t..he target that the antlions will attack}}  
{{entity-kvalue|Spawn Target|!player|The target that the antlions will attack.}}  
{{entity-kvalue|Ignore Bugbait|No|}}  
{{entity-kvalue|Ignore Bugbait|No|}}  
{{entity-kvalue-end}}  
{{entity-kvalue-end}}  


Now, remember to check the following flag:
{{entity-flag-start|}}
{{entity-flag-start|}}
{{entity-flag|Infinite Children|on|}}
{{entity-flag|Infinite Children|on|}}
{{entity-flag-end}}
{{entity-flag-end}}


Then, add the following output:
{{entity-output-start|}}
{{entity-output-start|}}
{{entity-output|OnAllSpawnedDead|antlion_expanse_spawner|SetMaxChildren|8|9.00||..that means if all antlions are dead it resets the max number to 8 to prevent any problems}}
{{entity-output|OnAllSpawnedDead|antlion_expanse_spawner|SetMaxChildren|8|9.00||..that means if all antlions are dead it resets the max number to 8 to prevent any problems}}
{{entity-output-end}}
{{entity-output-end}}


Add first logic_relay:
Add the first logic_relay:
 
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue|Name|relay_expanse_spawn|}}
{{entity-kvalue|Name|relay_expanse_spawn|}}
{{entity-kvalue-end}}
{{entity-kvalue-end}}


with the following outputs:
{{entity-output-start|}}
{{entity-output-start|}}
{{entity-output|OnTrigger|sound_antlion_spawn|PlaySound||||..if this relay is triggered it plays the sound}}
{{entity-output|OnTrigger|sound_antlion_spawn|PlaySound||||When this relay is triggered it plays the sound.}}
{{entity-output|OnTrigger|relay_expanse_disablespawn|CancelPending||||}}
{{entity-output|OnTrigger|relay_expanse_disablespawn|CancelPending||||}}
{{entity-output|OnTrigger|shake_antlion_spawn|StartShake||0.10||..the ground shakes}}
{{entity-output|OnTrigger|shake_antlion_spawn|StartShake||0.10||The ground shakes.}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Enable||1.00||..and the npc_antlion_template_maker enables 1 second after we walked on the ground, which makes an effect like the antlions are coming up}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Enable||1.00||And the npc_antlion_template_maker enables 1 second after we walked on the ground, which makes an effect like the antlions are coming up.}}
{{entity-output-end}}
{{entity-output-end}}


Add another logic_relay...
Add another logic_relay...
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue|Name|relay_expanse_disablespawn|}}
{{entity-kvalue|Name|relay_expanse_disablespawn|}}
Line 105: Line 108:
with the following outputs:
with the following outputs:
{{entity-output-start|}}
{{entity-output-start|}}
{{entity-output|OnTrigger|sound_antlion_spawn|StopSound||||..if this relay is triggered, the sound stops}}
{{entity-output|OnTrigger|sound_antlion_spawn|StopSound||||When this relay is triggered, the sound stops.}}
{{entity-output|OnTrigger|shake_antlion_spawn|StopShake||||..the shake stops}}
{{entity-output|OnTrigger|shake_antlion_spawn|StopShake||||Also, the shake stops..}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Disable||0.50||..and the template_maker disables}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Disable||0.50||..and the template_maker disables}}
{{entity-output|OnTrigger|relay_expanse_spawn|CancelPending||0.50||}}
{{entity-output|OnTrigger|relay_expanse_spawn|CancelPending||0.50||}}
{{entity-output-end}}
{{entity-output-end}}


Another group of entities are to set where the antlions can spawn, you must put one everywere that the antlion can possibly spawn, and the [[npc_antlion_template_maker]] will pick the one nearest the player:
Another group of entities are to set where the antlions can spawn, you must put one everywere that the antlion can possibly spawn, and the [[npc_antlion_template_maker]] will pick the one nearest the player.
 
{{entity-kvalue-start|[[info_node_hint]]}}
{{entity-kvalue-start|[[info_node_hint]]}}
{{entity-kvalue|Hint|AntLion Burrow Point|}}
{{entity-kvalue|Hint|AntLion Burrow Point|}}
Line 149: Line 153:


[http://www.pcgamemods.com/mod/15620.html Example map]
[http://www.pcgamemods.com/mod/15620.html Example map]


[[Category:Level Design Tutorials]]
[[Category:Level Design Tutorials]]
[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Abstract Mapping]]
[[Category:Abstract Mapping]]

Revision as of 06:42, 12 March 2006

The great thing about these antlions is that they are made to be used with other litle tools to make them spawn randomly when the player walks on a specified material, be it sand or any other material.

This tutorial will walk you through the making of a simple example of randomly unburrowing antlions.

Getting started

First, make a map with sand and rocks. The situation we are attempting to create is that if the player walks on the sand, antlions come out near the player and attack, and the player is forced to walk on the rocks.

These are the entities we are going to need:

Configuring the entities

First create an npc_antlion with the following properties.

Class: npc_antlion
Keyvalues Comments
Name AntLion
Flag
Checkbox-on.png Start Burrowed
Checkbox-on.png Template NPC

Next, configure the entity that triggers inputs when the player walks on the sand:

Class: env_player_surface_trigger
Keyvalues Comments
Name SurfaceTrigger
GameMaterialToWatch sand
My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnSurfaceChangedFromTarget.png relay_expanse_disablespawn Trigger When the player starts walking on the surface we have chosen, this entity triggers the relay OnSurfaceChangedToTarget. {{{8}}}
File:Entity-output-iconOnSurfaceChangedToTarget.png relay_expanse_spawn Trigger When the player steps off it, it triggers the relay OnSurfaceChangedFromTarget {{{8}}}

Then you will have to create the entity that creates the noise when the antlions are emerging.

Class: ambient_generic
Keyvalues Comments
Name sound_antlion_spawn
SoundName Streetwar.d3_c17_10b_rumble1
Volume 8
Fade In Time 1.5
Fade Out Time 2
Pitch 120
Start Pitch 90
Max Audible Distance 1250

And the one to create the quake.

Class: env_shake
Keyvalues Comments
Name shake_antlion_spawn
Amplitude 2
Effect Radius 500
Duration 3
Frequency 100

The following entity actually creates the antlions.

Class: npc_antlion_template_maker
Keyvalues Comments
Name antlion_expanse_spawner
StartDisabled Yes We do not want the template_maker to start spawning at the beginning of the map.
Num. of NPCs Leave empty because we will check Infinite Children in flags.
Frequency 0.35
Max Live NCPs How many antlions can live at same time, 8 for example.
Name Of Template NPC AntLion
Spawn On HintGroup antlion_expanse_spawn_nodes
Spawn Radius 1000
Spawn Target !player The target that the antlions will attack.
Ignore Bugbait No
Flag
Checkbox-on.png Infinite Children
My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnAllSpawnedDead.png antlion_expanse_spawner SetMaxChildren 8 9.00 ..that means if all antlions are dead it resets the max number to 8 to prevent any problems {{{8}}}

Add the first logic_relay:

Class: logic_relay
Keyvalues Comments
Name relay_expanse_spawn
My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnTrigger.png sound_antlion_spawn PlaySound When this relay is triggered it plays the sound. {{{8}}}
File:Entity-output-iconOnTrigger.png relay_expanse_disablespawn CancelPending {{{8}}}
File:Entity-output-iconOnTrigger.png shake_antlion_spawn StartShake 0.10 The ground shakes. {{{8}}}
File:Entity-output-iconOnTrigger.png antlion_expanse_spawner Enable 1.00 And the npc_antlion_template_maker enables 1 second after we walked on the ground, which makes an effect like the antlions are coming up. {{{8}}}

Add another logic_relay...

Class: logic_relay
Keyvalues Comments
Name relay_expanse_disablespawn

with the following outputs:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnTrigger.png sound_antlion_spawn StopSound When this relay is triggered, the sound stops. {{{8}}}
File:Entity-output-iconOnTrigger.png shake_antlion_spawn StopShake Also, the shake stops.. {{{8}}}
File:Entity-output-iconOnTrigger.png antlion_expanse_spawner Disable 0.50 ..and the template_maker disables {{{8}}}
File:Entity-output-iconOnTrigger.png relay_expanse_spawn CancelPending 0.50 {{{8}}}

Another group of entities are to set where the antlions can spawn, you must put one everywere that the antlion can possibly spawn, and the npc_antlion_template_maker will pick the one nearest the player.

Class: info_node_hint
Keyvalues Comments
Hint AntLion Burrow Point
Hint Group antlion_expanse_spawn_nodes

Notes

The antlions use info_node to navigate on the ground, and info_node_air to navigate while flying.

To make them follow a precise path, use path_corners and set it to the antlion's path corner, and place info_nodes around the way so the antlions can navigate through them.

If there is a wall in their way, put some info_node_airs about 10 units above it, the antlions will use it to fly above the wall.

Quick tutorial to making antlions follow a path

If you want the antlions to run to a precise target, use aiscripted_schedule, name it and configure:

Class: aiscripted_schedule
Keyvalues Comments
Target Npc Antlion
Search Radius ..if there are more than one target, put 0.
All In Radius ..if there are more than one target, put yes.
Ai State To Set ..choose one
Schedule to run ..choose one
Interruptability ..choose one
Goal Entity ..is the target, it can be one precise or a classname, like npc_citizen

Then at the npc_antlion_template_maker, add the following output:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnSpawnNpc.png AiSchedule StartSchedule {{{8}}}
Entity-output-icon.png {{{8}}}

Example Map

Example map