Antlions: Random Spawn: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 32: Line 32:
{{entity-flag-end}}
{{entity-flag-end}}


===env_player_surface_trigger===
{{entity-kvalue-start|[[env_player_surface_trigger]]}}
 
{{entity-kvalue|Name|SurfaceTrigger|}}
:Name: SurfaceTrigger
{{entity-kvalue|GameMaterialToWatch|sand|}}
:GameMaterialToWatch: sand
{{entity-kvalue-end}}


This entity triggers inputs if the player is walking on the specified material.
This entity triggers inputs if the player is walking on the specified material.
Line 41: Line 41:
Create the following outputs:
Create the following outputs:


OnSurfaceChangedFromTarget, relay_expanse_disablespawn, Trigger<br />
{{entity-output-start|}}
OnSurfaceChangedToTarget, relay_expanse_spawn, Trigger
{{entity-output|OnSurfaceChangedFromTarget|relay_expanse_disablespawn|Trigger||||}}
{{entity-output|OnSurfaceChangedToTarget|relay_expanse_spawn|Trigger||||}}
{{entity-output-end}}


Those mean that if the player starts walking on the surface we have chosen, it triggers the relay OnSurfaceChangedToTarget which enables the npc_antlion_template_maker, and after that that when (or if) the player steps off it, it triggers the relay OnSurfaceChangedFromTarget which stops the spawning.
Those mean that if the player starts walking on the surface we have chosen, it triggers the relay OnSurfaceChangedToTarget which enables the npc_antlion_template_maker, and after that that when (or if) the player steps off it, it triggers the relay OnSurfaceChangedFromTarget which stops the spawning.


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


This entity creates the noise when the antlions are emerging.
This entity creates the noise when the antlions are emerging.


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


This entity creates the quake when the antlions are emerging.
This entity creates the quake when the antlions are emerging.
Line 71: Line 73:
===npc_antlion_template_maker===
===npc_antlion_template_maker===


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


Now, remember to check ''Infinite Children''.
Now, remember to check:
 
{{entity-flag-start|}}
{{entity-flag|Infinite Children|on|}}
{{entity-flag||off|}}
{{entity-flag-end}}


Then, add the following output:
Then, add the following output:
 
{{entity-output-start|}}
OnAllSpawnedDead, antlion_expanse_spawner, SetMaxChildren, 8, 8.00
{{entity-output|OnAllSpawnedDead|antlion_expanse_spawner|SetMaxChildren|8|9.00||}}
{{entity-output|||||||}}
{{entity-output-end}}


That means if all antlions are dead it resets the max number to 8 to prevent any problems.
That means if all antlions are dead it resets the max number to 8 to prevent any problems.


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


Add the following outputs, the numbers this time meaning Delay:
Add the following outputs, the numbers this time meaning Delay:


OnTrigger, sound_antlion_spawn, PlaySound<br />
{{entity-output-start|}}
OnTrigger, relay_expanse_disablespawn, CancelPending<br />
{{entity-output|OnTrigger|sound_antlion_spawn|PlaySound||||}}
OnTrigger, shake_antlion_spawn, StartShake, 0.10<br />
{{entity-output|OnTrigger|relay_expanse_disablespawn|CancelPending||||}}
OnTrigger, antlion_expanse_spawner, Enable, 1.00
{{entity-output|OnTrigger|shake_antlion_spawn|StartShake||0.10||}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Enable||1.00||}}
{{entity-output-end}}


This means if this relay is triggered it plays the sound, the ground shakes 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.
This means if this relay is triggered it plays the sound, the ground shakes 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.


===Another logic_relay===
Another...
 
{{entity-kvalue-start|[[logic_relay]]}}
:Name: relay_expanse_disablespawn
{{entity-kvalue|Name|relay_expanse_disablespawn|}}
 
{{entity-kvalue-end}}
Add the following outputs, the numbers meaning Delay again:


OnTrigger, sound_antlion_spawn, StopSound<br />
Add the following outputs:
OnTrigger, shake_antlion_spawn, StopShake<br />
{{entity-output-start|}}
OnTrigger, antlion_expanse_spawner, Disable, 0.50<br />
{{entity-output|OnTrigger|sound_antlion_spawn|StopSound||||}}
OnTrigger, relay_expanse_spawn, CancelPending, 0.50
{{entity-output|OnTrigger|shake_antlion_spawn|StopShake||||}}
{{entity-output|OnTrigger|antlion_expanse_spawner|Disable||0.50||}}
{{entity-output|OnTrigger|relay_expanse_spawn|CancelPending||0.50||}}
{{entity-output-end}}


This means if this relay is triggered, the sound stops, the shake stops and the template_maker disables.
This means if this relay is triggered, the sound stops, the shake stops and the template_maker disables.


===info_node_hint===
Another group of entities:
{{entity-kvalue-start|[[info_node_hint]]}}
{{entity-kvalue|Hint|AntLion Burrow Point|}}
{{entity-kvalue|Hint Group|antlion_expanse_spawn_nodes|}}
{{entity-kvalue-end}}


These 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.
These 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.
:Hint: AntLion Burrow Point
:Hint Group: antlion_expanse_spawn_nodes


== Notes ==
== Notes ==

Revision as of 06:06, 12 March 2006

Template: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.

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

Italicized text is a flag. ---

Class: npc_antlion
Keyvalues Comments
Name AntLion

---

Flag
File:Checkbox-yes.png Start Burrowed
File:Checkbox-yes.png Template NPC
Class: env_player_surface_trigger
Keyvalues Comments
Name SurfaceTrigger
GameMaterialToWatch sand

This entity triggers inputs if the player is walking on the specified material.

Create the following outputs:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnSurfaceChangedFromTarget.png relay_expanse_disablespawn Trigger {{{8}}}
File:Entity-output-iconOnSurfaceChangedToTarget.png relay_expanse_spawn Trigger {{{8}}}

Those mean that if the player starts walking on the surface we have chosen, it triggers the relay OnSurfaceChangedToTarget which enables the npc_antlion_template_maker, and after that that when (or if) the player steps off it, it triggers the relay OnSurfaceChangedFromTarget which stops the spawning.

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

This entity creates the noise when the antlions are emerging.

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

This entity creates the quake when the antlions are emerging.

npc_antlion_template_maker

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

Now, remember to check:

Flag
Checkbox-on.png Infinite Children
Checkbox-off.png

Then, add the following output:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnAllSpawnedDead.png antlion_expanse_spawner SetMaxChildren 8 9.00 {{{8}}}
Entity-output-icon.png {{{8}}}

That means if all antlions are dead it resets the max number to 8 to prevent any problems.

Class: logic_relay
Keyvalues Comments
Name relay_expanse_spawn

Add the following outputs, the numbers this time meaning Delay:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnTrigger.png sound_antlion_spawn PlaySound {{{8}}}
File:Entity-output-iconOnTrigger.png relay_expanse_disablespawn CancelPending {{{8}}}
File:Entity-output-iconOnTrigger.png shake_antlion_spawn StartShake 0.10 {{{8}}}
File:Entity-output-iconOnTrigger.png antlion_expanse_spawner Enable 1.00 {{{8}}}

This means if this relay is triggered it plays the sound, the ground shakes 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.

Another...

Class: logic_relay
Keyvalues Comments
Name relay_expanse_disablespawn

Add the following outputs:

My output Target entity Target input Parameter Delay Only once Comments
File:Entity-output-iconOnTrigger.png sound_antlion_spawn StopSound {{{8}}}
File:Entity-output-iconOnTrigger.png shake_antlion_spawn StopShake {{{8}}}
File:Entity-output-iconOnTrigger.png antlion_expanse_spawner Disable 0.50 {{{8}}}
File:Entity-output-iconOnTrigger.png relay_expanse_spawn CancelPending 0.50 {{{8}}}

This means if this relay is triggered, the sound stops, the shake stops and the template_maker disables.

Another group of entities:

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

These 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.

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:

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:

OnSpawnNpc, AiSchedule, StartSchedule

Example Map

Example map