Antlions: Random Spawn: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(23 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{tutorial cleanup}}
{{screenshot}}
== Random Spawns ==
The great thing about these antlions is that they are made to be used with other little 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 theses antlions is that they are made to be used with other litle tools to make them spawn a little randomly when the hero walks on a specified material, can be sand or other!
This tutorial will walk you through the making of a simple example of randomly unburrowing antlions.


So before all, make a map with sand and rocks which we will make here is that, if the player walks on the sand, antlions come out near the player and attack, so he is forced to walk on the rocks.
== Getting started ==
Its fun to make, and fun to play!


You need :
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.


[[npc_antlion]]
These are the entities we are going to need:


[[env_shake]]
* [[npc_antlion]]
* [[env_shake]]
* [[ambient_generic]]
* [[npc_antlion_template_maker]]
* [[logic_relay]]
* [[env_player_surface_trigger]]
* [[info_node_hint]]


[[ambient_generic]]
== Configuring the entities ==


[[npc_antlion_template_maker]]
First create an npc_antlion with the following properties.


2 [[logic_relay]]
{{entity-kvalue-start|[[npc_antlion]]}}
{{entity-kvalue|Name|AntLion|}}
{{entity-kvalue|Start Burrowed|Yes|}}
{{entity-kvalue-end}}


[[env_player_surface_trigger]]
{{entity-flag-start}}
{{entity-flag|Template NPC|on|}}
{{entity-flag-end}}


And a lot of [[info_node_hint]]
Next, configure the entity that triggers inputs when the player walks on the sand:


How to make this up.
{{entity-kvalue-start|[[env_player_surface_trigger]]}}
{{entity-kvalue|Name|SurfaceTrigger|}}
{{entity-kvalue|GameMaterialToWatch|sand|}}
{{entity-kvalue-end}}


Configure the Antlion name it AntLion and Starts Burrowed on yes
{{entity-output-start|}}
{{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||||When the player steps off it, it triggers the relay OnSurfaceChangedFromTarget}}
{{entity-output-end}}


Name the Following like this:
Then you will have to create the entity that creates the noise when the antlions are emerging.


[[env_player_surface_trigger]] : Surface Trigger
{{entity-kvalue-start|[[ambient_generic]]}}
{{entity-kvalue|Name|sound_antlion_spawn|}}
{{entity-kvalue|SoundName|Streetwar.d3_c17_10b_rumble1|}}
{{entity-kvalue|Volume|8|}}
{{entity-kvalue|Fade In Time|1.5|}}
{{entity-kvalue|Fade Out Time|2|}}
{{entity-kvalue|Pitch|120|}}
{{entity-kvalue|Start Pitch|90|}}
{{entity-kvalue|Max Audible Distance|1250|}}
{{entity-kvalue-end}}


[[ambient_generic]] : sound_antlion_spawn
And the one to create the quake.


[[env_shake]] : shake_antlion_spawn
{{entity-kvalue-start|[[env_shake]]}}
{{entity-kvalue|Name|shake_antlion_spawn|}}
{{entity-kvalue|Amplitude|2|}}
{{entity-kvalue|Effect Radius|500|}}
{{entity-kvalue|Duration|3|}}
{{entity-kvalue|Frequency|100|}}
{{entity-kvalue-end}}


[[npc_antlion_template_maker]] : antlion_expanse_spawner
The following entity actually creates the antlions.


[[logic_relay]] 1 : relay_expanse_spawn
{{entity-kvalue-start|[[npc_antlion_template_maker]]}}
{{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|Num. of NPCs||Leave empty because we will check ''Infinite Children'' in flags.}}
{{entity-kvalue|Frequency|0.35|}}
{{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|Spawn On HintGroup|antlion_expanse_spawn_nodes|}}
{{entity-kvalue|Spawn Radius|1000|}}
{{entity-kvalue|Spawn Target|!player|The target that the antlions will attack.}}
{{entity-kvalue|Ignore Bugbait|No|}}
{{entity-kvalue-end}}


[[logic_relay]] 2 : relay_expanse_disablespawn
{{entity-flag-start|}}
{{entity-flag|Infinite Children|on|}}
{{entity-flag-end}}


Lets Start with the [[env_shake]].
{{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-end}}


Name : shake_antlion_spawn
Add the first logic_relay:


Amplitude : 2
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue|Name|relay_expanse_spawn|}}
{{entity-kvalue-end}}


Effect Radius : 500
{{entity-output-start|}}
{{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|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-end}}


Duration : 3
Add another logic_relay...


Frequency : 100
{{entity-kvalue-start|[[logic_relay]]}}
{{entity-kvalue|Name|relay_expanse_disablespawn|}}
{{entity-kvalue-end}}
with the following outputs:
{{entity-output-start|}}
{{entity-output||OnTrigger|sound_antlion_spawn|StopSound||||When this relay is triggered, the sound 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|relay_expanse_spawn|CancelPending||0.50||}}
{{entity-output-end}}


Thats it, the env_shake is just to make the effect better.
Another group of entities are to set where the antlions can spawn, you must put one everywhere 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|Hint|AntLion Burrow Point|}}
{{entity-kvalue|Hint Group|antlion_expanse_spawn_nodes|}}
{{entity-kvalue-end}}


----
== Notes ==


Lets continue with the [[ambient_generic]].
The antlions use [[info_node]] to navigate on the ground, and "fly" by using loose jump parameters.


Name : sound_antlion_spawn
To make them follow a precise path, use [[path_corner]]s and set it to the antlion's path corner, and place [[info_node]]s around the way so the antlions can navigate through them.


SoundName : Streetwar.d3_c17_10b_rumble1
If there is a wall in their way, make sure there is a jump connection, and the antlions will use it to fly above the wall.


Volume : 8
=== Quick tutorial to making antlions follow a path ===


Fade In Time : 1.5
If you want the antlions to run to a precise target, use [[aiscripted_schedule]], name it and configure:


Fade Out Time : 2
{{entity-kvalue-start|[[aiscripted_schedule]]}}
{{entity-kvalue|Target Npc|Antlion |}}
{{entity-kvalue|Search Radius||..if there are more than one target, put 0.}}
{{entity-kvalue|All In Radius||..if there are more than one target, put yes.}}
{{entity-kvalue|Ai State To Set||..choose one}}
{{entity-kvalue|Schedule to run||..choose one}}
{{entity-kvalue|Interruptability||..choose one}}
{{entity-kvalue|Goal Entity||..is the target, it can be one precise or a classname, like [[npc_citizen]]}}
{{entity-kvalue-end}}


Pitch : 120
Then at the [[npc_antlion_template_maker]], add the following output:


Start Pitch : 90
{{entity-output-start|}}
{{entity-output||OnSpawnNpc|AiSchedule|StartSchedule||||}}
{{entity-output-end}}


Max Audible Distance : 1250
[[Category: Level Design]]
 
[[Category: Tutorials]]
Thats it too, the sound is to make a diging sound when the antlions are coming, it is nice and very stressing!
[[Category:Abstract Mapping]]
 
 
----
 
Lets continue with the [[env_player_surface_trigger]], I call it a "material detector" , its to trigger inputs if the player is walking on the specified material, in GameMaterialToWatch, pick sand, then go in the out puts and put this :
 
 
My Output                  Target Entity              Target Input
 
OnSurfaceChangedFromTarget relay_expanse_disablespawn Trigger
 
OnSurfaceChangedToTarget  relay_expanse_spawn        Trigger
 
 
What we just did here is that if the player starts walking on the surface we have chosen, it triggers the relay which enables the template_maker, and that if it stops walking on it, it trigger the relay which disables the spawning.
 
----
 
Lets continue with the [[npc_antlion_template_maker]]
 
In KeyValues :
 
StartDisabled : Yes, we do not want the template_maker to start spawning at the beginning of the map.
 
Num. of NPCs : Not Really Matter because we will check Infinit Children in flags.
 
Frequency : 0.35 is a good speed for this operation
 
Max Live NCPs : How Many Antlions can live in same time, I generally put 8
 
Name Of Template NPC : AntLion, the name of the npc_antlion used
 
Spawn On HintGroup : I will explain later, write antlion_expanse_spawn_nodes
 
Spawn Radius : 1000, read the help for more details
 
Spawn Target : The target that the Antlions will attack, in this case, !player DON'T FORGET THE ! Its not player, its !player
 
Ignore Bugbait : No
 
The rest of the keyvalues doesnt matter, now go in flags, the only flag that needs to be checked is Infinite Children.
 
Almost done, now go in outputs and write :
 
MyOutput          Target Entity            TargetInput    Override Parameter  Delay
 
OnAllSpawnedDead  antlion_expanse_spawner  SetMaxChildren  8                8.00
 
We just made that if all antlions are dead it resets the number to 8 to provide any problems.
 
 
----
 
 
 
Lets continue with the [[logic_relay]] 1 : relay_expanse_spawn
 
Go in the outputs and put this :
 
My Output                  Target Entity              Target Input    Delay
 
OnTrigger                  sound_antlion_spawn        PlaySound      0
 
OnTrigger                  relay_expanse_disablespawn CancelPending  0
 
OnTrigger                  shake_antlion_spawn        StartShake      0.10
 
OnTrigger                  antlion_expanse_spawner    Enable          1
 
 
What we just did here, we made that if this relay is triggered it plays the sound, the ground shakes and the template_maker enables 1 second after we walked on the ground, which makes an effect like the antlions are coming up and its very nice :)
 
 
----
 
Lets continue with the [[logic_relay]] 2 : relay_expanse_disablespawn
 
Go in the outputs and put this :
 
My Output                  Target Entity              Target Input    Delay
 
 
OnTrigger                  sound_antlion_spawn        StopSound      0
 
OnTrigger                  shake_antlion_spawn        StopShake      0
 
OnTrigger                  antlion_expanse_spawner    Disable        0.50   
       
OnTrigger                  relay_expanse_spawn        CancelPending  0.50
 
 
Here we made that if this relay is triggered, the sound stops, the shake stops and the template_maker disables.
 
----
 
 
And now, lets '''Finish''' with the [[info_node_hint]]
Theses 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.
 
All you got to configure are this :
 
Hint : AntLion : Burrow Point
 
Hint Group : antlion_expanse_spawn_nodes
 
 
----
 
== Precise Ways ==
 
The antlions use [[info_node]] to navigate on the ground, and [[info_node_air]] to navigate while flying.
 
To make them follow a precise way, make manually a way with PathCorners and set it to the antlion's path corner, and place [[info_node]] around the way so the antlions can navigate trough them.
 
If there is a wall on their way, put some [[info_node_air]] up the wall about 10 units above it, the antlions will use it to fly above the wall.
 
If you want the antlions to run to a precise target, use [[aiscripted_schedule]], name it, then :
 
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 : Put whatever you want.
 
Schedule to run : Pick one :)
 
Interruptability : You choose
 
Goal Entity : Is the target, it can be one precise or a classname, like npc_citizen...
 
Then at the [[npc_template_maker]] of the Antlion, go in output and put
 
OnSpawnNpc AiSchedule StartSchedule
 
And its good to go.
 
== Example Map ==
 
I made a quick example map of this tutorial, if you are too tired to read all of it, just download the .vmf, copy and past the things I did.
 
http://www.pcgamemods.com/mod/15620.html
 
[[Category:Level Design Tutorials]]

Latest revision as of 00:26, 13 June 2022

Nuvola apps ksnapshot.png
This article or section needs a screenshot to help visually convey the subject.
You can upload screenshots at Special:Upload. For help, see Help:Images.

The great thing about these antlions is that they are made to be used with other little 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
Start Burrowed Yes
Flag
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
Entity-output-icon.png OnSurfaceChangedFromTarget relay_expanse_disablespawn Trigger When the player starts walking on the surface we have chosen, this entity triggers the relay OnSurfaceChangedToTarget.
Entity-output-icon.png OnSurfaceChangedToTarget relay_expanse_spawn Trigger When the player steps off it, it triggers the relay OnSurfaceChangedFromTarget

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
Entity-output-icon.png 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

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
Entity-output-icon.png OnTrigger sound_antlion_spawn PlaySound When this relay is triggered it plays the sound.
Entity-output-icon.png OnTrigger relay_expanse_disablespawn CancelPending
Entity-output-icon.png OnTrigger shake_antlion_spawn StartShake 0.10 The ground shakes.
Entity-output-icon.png 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.

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
Entity-output-icon.png OnTrigger sound_antlion_spawn StopSound When this relay is triggered, the sound stops.
Entity-output-icon.png OnTrigger shake_antlion_spawn StopShake Also, the shake stops..
Entity-output-icon.png OnTrigger antlion_expanse_spawner Disable 0.50 ..and the template_maker disables
Entity-output-icon.png OnTrigger relay_expanse_spawn CancelPending 0.50

Another group of entities are to set where the antlions can spawn, you must put one everywhere 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 "fly" by using loose jump parameters.

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, make sure there is a jump connection, and 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
Entity-output-icon.png OnSpawnNpc AiSchedule StartSchedule