Assault: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎Structure: Unicodifying, replaced: [[Image: → [[File:)
 
(26 intermediate revisions by 14 users not shown)
Line 1: Line 1:
An assault consists of two or three component types:
The purpose of an assault is to make one or more NPC(s) tactically advance along a predesigned route, securing tactical points along the way. It is much more flexible than a [[path_corner]] entity.


* '''ai_goal_assault''' (1 per assault, optional)
An assault consists of two or three component entities:
* '''assault_rallypoint''' (1 per NPC)
* '''assault_assaultpoint''' (any number)


Its purpose is to make a NPC follow a predesigned route. In this regard it is quite similar to '''[[path_corner]]''': the differences revolve around assaults being designed for combat situations and through that their increased flexibility. This article will detail how to use them.
* [[ai_goal_assault]] (1 per assault, optional)
* [[assault_rallypoint]] (1 per NPC)
* [[assault_assaultpoint]] (any number)


==Structure==
This article will show you the overall picture on how to set up an assault. (For entity specific information, see the related entity.)
<center>[[Image:Assault_diagram.png]]</center>


An assault consists of a rally point followed by a string of consecutive assault points. An assault point must be 'cleared' before continuing: clearing a point by default consists of standing on it and ensuring there are no hostiles in sight for the timeout period, but is completely configurable.
{{tip|Use the console command <code>ai_debug_assault</code> for basic visual information about where NPCs are headed to.}}


Assaults can be triggered in one of two ways:
{{tip|Note that assaults don't seem to work with all NPCs, such as fast zombies. You may need to use the [[aiscripted_schedule]] or [[scripted_sequence]] entities instead.}}


# An '''ai_goal_assault''' fires, forcibly attaching NPCs to '''assault_rallypoints'''.
__TOC__
# A NPC chooses an '''assault_rallypoint''' on its own when it receives the '''Assault''' input through the [[Entity_I/O_-_How_to_hook_up_entity_inputs_and_outputs.|I/O system]].
----
===ai_goal_assault===
This entity specifies what NPCs are to carry out the assault and triggers it when any conditions given are met. One goal can handle multiple rally points. Must be '''Active''' before being triggered.


====Keyvalues====
==Structure==
* '''Actor(s) to affect:''' Enter the name of the NPCs that will perform the assault. This field supports wildcards, should they be needed.
* '''Rally Point Set:''' The name of the '''assault_rallypoint''' at which this assault will begin. This field can also support wildcards.
* '''Search Type:''' It is also possible to specify classes. If your NPCs do not have names, or you want all NPCs of a certain type to join the assault, you can set this to 'Classname' and make the appropriate changes to '''Actor(s) to affect'''.
* '''Start Active:''' Should this goal be active when the map begins?
* '''Assault Cue: ''' The goal can be set immediately after being activated, after it has received an input through the [[Entity_I/O_-_How_to_hook_up_entity_inputs_and_outputs.|I/O system]], or when the entity 'hears' gunfire depending on the setting here. Requires the goal to be '''Active''' first.


====Inputs====
An assault consists of an AI goal (the [[ai_goal_assault]] entity) gathering a set of one or more NPCs (called ''actor(s)'') to one or more "rally point" locations ([[assault_rallypoint]] entities) where they will normally await a cue to commence the assault. On this cue, they will proceed to the first "assault point" location ([[assault_assaultpoint]] entity) to secure, or 'clear' it, and then proceed on to the next assault point (if any), clear it, and then proceed to the next, and so on.
* '''BeginAssault:''' If the entity is '''Active''' and '''Assault Cue''' is set to '''Entity System Input''', begin the assault(s).
Clearing an assault point, by default, consists of standing on its location and ensuring that there are no hostiles in sight for the timeout period, but this is completely configurable.
----
===NPC===
NPCs can handle their own assaults.


====Inputs====
<center>[[File:Assault_diagram.png]]</center>
'''Assault:''' When a NPC receives this input, it will search for the best assault available. Use the ‘‘‘assault_rallypoint’’’ keyvalue '''Priority''' to influence this decision.
----
===assault_rallypoint===
All assaults begin at a rallypoint.  


====Keyvalues====
Assaults can be triggered in one of two ways:
* '''Assault Point:''' The first assault_assaultpoint in the chain.
* '''Assault Delay:''' The amount of time to wait here once the assault has begun before moving to the first assault_assaultpoint.
* '''Rally Sequence:''' Set a specific animation sequence for NPCs waiting to begin the assault.
* '''Priority:''' When a NPC receives the '''Assault''' input it will choose a suitable rallypoint from those available to it. '''Priority''' allows the mapper to influence this decision. Higher numbers make a rallypoint more appealing.


====Outputs====
# When activated, an '''ai_goal_assault''' entity can send its ''actor(s)'' to the associated ''assault_rallypoint(s)'', where they wait for the assault cue. This is the most common usage. The ''ai_goal_assault'' entity can either be activated by an ''Activate'' input, or set to start active through its ''Start Active'' keyvalue, which causes the assault to begin as soon as the map is loaded.
* '''OnArrival:''' Fires when the NPC arrives.
# [[npc_combine_s|Combine soldiers]] may be instantly associated with a rally point without the use of an ''ai_goal_assault'' entity. Using the entity [[Inputs and Outputs|I/O system]], you can fire the '''Assault''' input on the soldier, providing the name of the ''assault_rallypoint'' as an input parameter. When a Combine soldier receives this input, it will search for the specified [[assault_rallypoint]] entity, move to it, and then proceed immediately to the associated ''assault_assaultpoint''. Please note that although the ''Assault'' input can be sent to any NPC ''it is only ''supported'' for Combine soldiers''. You may use wildcards when specifying the rally point in the parameter. You may also use the ''priority'' keyvalue of an ''assault_rallypoint'' entity as a parameter to influence this decision, if providing a wildcard which specifies more than one ''assault_rallypoint'' entity.
----
===assault_assaultpoint===
The body of an assault chain. Specifies where the assault should go once it has begun. There can be any number of assault_assaultpoints in each chain.


'''It is important to remember that assaultpoints affect the journey ''to'' them, not ''from'' them.'''
==Advantages==
While an assault requires extra work to set up, and the end result is very similar to other ai entities, such as [[aiscripted_schedule]], assaults do allow for more flexibility than other scripting entities.
* You can select a group of NPCs
** Other scripting options can do this too, but this often results in the entire group heading toward a specific point, or only one member of the group moving. To create similar results, each individual npc would need to be scripted.
* More control
** With options such as "allow diversion" and "clear on contact", the mapper has more control of when an ai stops moving. Unlike an [[aiscripted_schedule]] set to interrupt on "general", which can be broken by gunfire or other sounds.
* An NPC will realistically stick to one place
** Without a combination of hintgrouping and moving to a [[path_corner]] there aren't any other options to have an ai stay at one point. Also, unlike the hintgroup set up, the ai will move to avoid grenades or reload.


====Keyvalues====
==Major options==
* '''Assault Hint Group:''' Constrain NPCs in the assault to this [[info_hint|hint]] group.
The assault behaviour offers a flexible degree of customisation among the entities that make up an assault. This list's purpose is to provide an overview of the major options (beyond entity placement). Consult each entity's individual page for more detailed information.
* '''Assault time out:''' How long to wait with no activity at this assaultpoint before moving on.
* '''ai_goal_assault''':
* '''Clear on contact with enemies:''' If the assault meets enemies on its way to this point, it will consider it cleared and target the next point in the chain.
:Keyvalue '''AssaultCue''': Determines what will cause the NPC to move off their rally point and begin the assault.
* '''Allow diversion:''' If the assault comes into contact with hostiles on the way to the point, divert to kill them and resume once the area appears clear.
* '''assault_rallypoint''':
**If it set to '''Yes''' NPCs will chase any hostiles until they are dead or out of sight for the period set in '''Assault time out'''.
:Keyvalue '''priority''': Determines how appealing the rally point will be to an NPC when it has multiple rally points to choose between.
**If this is set to '''No''' assaulting NPCs will run non-stop to the next point, attacking enemies they can see but not chasing them.  
:Keyvalue '''assaultdelay''': Time to wait at rally point after assault cue, before beginning assault.
* '''Never Timeout:''' Force NPCs to try and reach this point forever, with no timeouts.
{{Note|If '''allowdiversion''' is set on the next [[assault_assaultpoint|assault point]], an NPC can divert from the [[assault_rallypoint|rally point]] as well.}}
* '''assault_assaultpoint''':
:Keyvalue '''assaultgroup''': Constrain an NPC's hint node use to this hint group.
:Keyvalue '''assaulttimeout''', '''nevertimeout''': How long to wait without seeing enemies before considering the point cleared.
:Keyvalue '''clearoncontact''': Whether to clear assault point if the NPC encounters enemies while moving to it.
:Keyvalue '''allowdiversion''': Whether the NPC should move to engage enemies it encounters or ignore them and follow the assault points.
:Spawnflag '''1''': Clear point upon arrival, unconditionally.


====Flags====
==Examples==
* '''Clear this point on arrival, UNCONDITIONALLY:''' Move on to the next point once reaching this one regardless of any other influences.
===Example map===
 
[http://www.steamreview.org/external/vdc/assaults/assault_simple.zip This example map] contains a single NPC on a linear chain using all the major options available to designers when moving NPCs from assaultpoint to assaultpoint. There are four points, and each is configured differently:
====Inputs====
* '''SetClearOnContact:''' Sets the '''Clear on contact with enemies''' keyvalue.
** Accepts '''1/0''' or '''Yes/No'''.
* '''SetAllowDiversion:''' Sets the '''Allow diversion''' keyvalue.
** Accepts '''1/0''' or '''Yes/No'''.
 
====Outputs====
* '''OnArrival:''' Fires when a NPC arrives.
* '''OnAssaultClear:''' Fires when the point is cleared.
 
==Limitations and bugs==
* When moving to an assaultpoint part way through a chain, the NPC will go to the standing posture for a moment before continuing. This looks unnatural.
 
* NPCs will always arrive at a rally or assault point and turn to face in the direction the entity is set to. This is again unnatural in some cases.
 
* NPCs must stand directly on an assaultpoint to clear it without timeout if '''Clear on contact with enemies''' is not set and triggered. This can result in illogical backtracking and means that groups of NPCs moving together each need their own assaultpoint to maintain the illusion.
 
* A rallypoint can only serve one NPC per assault. If multiple NPCs are required to assault at the same time, each needs their own rallypoint. There may be a solution to this but it is not yet documented.
 
* If enemies are in view of an assaultpoint, they will be seen just before the point is reached and probably calculated using the wrong (previous) settings. To avoid this, try to ensure assaultpoints are always in 'safe' areas.
 
* Linking an assaultpoint to a rallypoint crashes the game.
 
==Example==
This example map contains a single NPC on a linear chain using all the major options available to designers when moving NPCs from assaultpoint to assaultpoint. There are four points, and each is configured differently:


# '''Clear on contact with enemies''' is enabled. When the NPC sees the hostiles, it clears out the assaultpoint and continues to 2.
# '''Clear on contact with enemies''' is enabled. When the NPC sees the hostiles, it clears out the assaultpoint and continues to 2.
Line 98: Line 62:
Note that the Metropolice cannot harm the NPC and will not attack the player in this example.
Note that the Metropolice cannot harm the NPC and will not attack the player in this example.


[http://www.btinternet.com/~varsity_uk/VDC/Assaults/assault_simple.zip Example (VMF)]
===Prefabs===
The [[npc_metrocop_assault]] and the [[npc_soldier_assault]] prefabs contains complete setups of a mass assault of metrocops and soldiers respectively.
 
==Notes==
* If "clear on contact" is set, a single enemy might clear not only the current assaultpoint but the next one(s). A consequence of this is that if an NPC encounters an enemy on the way to a "clear on contact" assaultpoint the assaulting NPC may never proceed to another rallypoint. This occurs regardless of the subsequent assaultpoints "Clear on contact" and "Allow diversion" settings.
* If "allow diversion" is set and the NPC encounters an enemy, the assaulting NPC will pause for a while after killing the enemy before proceeding. The article says that this pause is the length of the "timeout" setting, but in my tests it was several times as long.
* If an NPC encounters an enemy on the way to an assaultpoint marked "allow diversion" but not "clear on arrival" the assaulting NPC will be pausing twice. Mappers might need to consider this if timing is important.
* An assaultpoint with both "clear on contact" and "allow diversion" causes weirdness: if an enemy is encountered on the way to the assaultpoint the assaulting NPC will kill it, but then upon reaching the assaultpoint will not pursue or return fire from other enemies until the ''next'' assaultpoint is reached. In fact, the assaulting NPC doesn't even change direction to face the fire. This happens regardless of the "clear on arrival" or "never time out" settings.
* I didn't observe any effect of the "never time out" setting. However, all firefights were fairly brief, so it might not have had a chance to come into effect.
* All-settings-off is great for making the NPC dash to a point regardless of enemy fire and then attack everyone at the point.
* Having only "clear on arrival" on is great for making the NPC dash from point to point without pausing, regardless of enemy fire.
* The OnAssaultClear output is only fired for the ''last'' assaultpoint in a chain. All assaultpoints will fire their OnArrival output, however.
* The delay after a "Allow diversions" diversion is about 18 seconds for a 3-second "timeout" time.
* A diversion causes another such delay immediately upon reaching the assaultpoint, and then the assaultpoint OnArrive ''re''-fires. If the NPC is again diverted before the timeout, the OnArrive output will fire again, ''ad infinitum''. So don't spawn enemies during from the OnArrive output.
* If the first assaultpoint is set to "Clear on contact" and an enemy is sighted before reaching the assaultpoint, the assaulting NPC will never make it to the assaultpoint. If the subsequent assaultpoint has "Allow diversion" off, this will cause ''that'' (or perhaps the final) assaultpoint to fire the OnArrival output&mdash;despite the assaulting NPC being nowhere nearby and having not even gotten to the first assaultpoint, nor having yet finished dealing with the enemies. If, on the other hand, the second assaultpoint has "Allow diversion" on, no messages are sent whatsoever.
* In [[Half-Life 2: Episode One]] and [[Half-Life 2: Episode Two]] rally points behave differently than in [[Half-Life 2]]. If there is an assault point with "Never Time Out" in the assault chain connecting to a rally point, than that rally point will be "locked" and unusable until the NPC on the chain dies.
 
==See also==
 
* [[Dynamic assaults]] - A simpler system, for assaulting the player or other NPCs.
 


[[Category:AI]]
[[Category:AI]]

Latest revision as of 06:27, 8 January 2024

The purpose of an assault is to make one or more NPC(s) tactically advance along a predesigned route, securing tactical points along the way. It is much more flexible than a path_corner entity.

An assault consists of two or three component entities:

This article will show you the overall picture on how to set up an assault. (For entity specific information, see the related entity.)

Tip.pngTip:Use the console command ai_debug_assault for basic visual information about where NPCs are headed to.
Tip.pngTip:Note that assaults don't seem to work with all NPCs, such as fast zombies. You may need to use the aiscripted_schedule or scripted_sequence entities instead.

Structure

An assault consists of an AI goal (the ai_goal_assault entity) gathering a set of one or more NPCs (called actor(s)) to one or more "rally point" locations (assault_rallypoint entities) where they will normally await a cue to commence the assault. On this cue, they will proceed to the first "assault point" location (assault_assaultpoint entity) to secure, or 'clear' it, and then proceed on to the next assault point (if any), clear it, and then proceed to the next, and so on. Clearing an assault point, by default, consists of standing on its location and ensuring that there are no hostiles in sight for the timeout period, but this is completely configurable.

Assault diagram.png

Assaults can be triggered in one of two ways:

  1. When activated, an ai_goal_assault entity can send its actor(s) to the associated assault_rallypoint(s), where they wait for the assault cue. This is the most common usage. The ai_goal_assault entity can either be activated by an Activate input, or set to start active through its Start Active keyvalue, which causes the assault to begin as soon as the map is loaded.
  2. Combine soldiers may be instantly associated with a rally point without the use of an ai_goal_assault entity. Using the entity I/O system, you can fire the Assault input on the soldier, providing the name of the assault_rallypoint as an input parameter. When a Combine soldier receives this input, it will search for the specified assault_rallypoint entity, move to it, and then proceed immediately to the associated assault_assaultpoint. Please note that although the Assault input can be sent to any NPC it is only supported for Combine soldiers. You may use wildcards when specifying the rally point in the parameter. You may also use the priority keyvalue of an assault_rallypoint entity as a parameter to influence this decision, if providing a wildcard which specifies more than one assault_rallypoint entity.

Advantages

While an assault requires extra work to set up, and the end result is very similar to other ai entities, such as aiscripted_schedule, assaults do allow for more flexibility than other scripting entities.

  • You can select a group of NPCs
    • Other scripting options can do this too, but this often results in the entire group heading toward a specific point, or only one member of the group moving. To create similar results, each individual npc would need to be scripted.
  • More control
    • With options such as "allow diversion" and "clear on contact", the mapper has more control of when an ai stops moving. Unlike an aiscripted_schedule set to interrupt on "general", which can be broken by gunfire or other sounds.
  • An NPC will realistically stick to one place
    • Without a combination of hintgrouping and moving to a path_corner there aren't any other options to have an ai stay at one point. Also, unlike the hintgroup set up, the ai will move to avoid grenades or reload.

Major options

The assault behaviour offers a flexible degree of customisation among the entities that make up an assault. This list's purpose is to provide an overview of the major options (beyond entity placement). Consult each entity's individual page for more detailed information.

  • ai_goal_assault:
Keyvalue AssaultCue: Determines what will cause the NPC to move off their rally point and begin the assault.
  • assault_rallypoint:
Keyvalue priority: Determines how appealing the rally point will be to an NPC when it has multiple rally points to choose between.
Keyvalue assaultdelay: Time to wait at rally point after assault cue, before beginning assault.
Note.pngNote:If allowdiversion is set on the next assault point, an NPC can divert from the rally point as well.
  • assault_assaultpoint:
Keyvalue assaultgroup: Constrain an NPC's hint node use to this hint group.
Keyvalue assaulttimeout, nevertimeout: How long to wait without seeing enemies before considering the point cleared.
Keyvalue clearoncontact: Whether to clear assault point if the NPC encounters enemies while moving to it.
Keyvalue allowdiversion: Whether the NPC should move to engage enemies it encounters or ignore them and follow the assault points.
Spawnflag 1: Clear point upon arrival, unconditionally.

Examples

Example map

This example map contains a single NPC on a linear chain using all the major options available to designers when moving NPCs from assaultpoint to assaultpoint. There are four points, and each is configured differently:

  1. Clear on contact with enemies is enabled. When the NPC sees the hostiles, it clears out the assaultpoint and continues to 2.
  2. Clear this point on arrival, UNCONDITIONALLY is flagged. When the NPC reaches this point it clears it regardless of the fact that there are still hostiles in sight and begins to move towards 3.
  3. Allow diversion is set to No. The NPC will charge towards the assaultpoint without stopping or giving chase. It will however attack enemies in view.
  4. Allow diversion is set to Yes. The NPC will divert from moving to this point until there are no hostiles visible.

Note that the Metropolice cannot harm the NPC and will not attack the player in this example.

Prefabs

The npc_metrocop_assault and the npc_soldier_assault prefabs contains complete setups of a mass assault of metrocops and soldiers respectively.

Notes

  • If "clear on contact" is set, a single enemy might clear not only the current assaultpoint but the next one(s). A consequence of this is that if an NPC encounters an enemy on the way to a "clear on contact" assaultpoint the assaulting NPC may never proceed to another rallypoint. This occurs regardless of the subsequent assaultpoints "Clear on contact" and "Allow diversion" settings.
  • If "allow diversion" is set and the NPC encounters an enemy, the assaulting NPC will pause for a while after killing the enemy before proceeding. The article says that this pause is the length of the "timeout" setting, but in my tests it was several times as long.
  • If an NPC encounters an enemy on the way to an assaultpoint marked "allow diversion" but not "clear on arrival" the assaulting NPC will be pausing twice. Mappers might need to consider this if timing is important.
  • An assaultpoint with both "clear on contact" and "allow diversion" causes weirdness: if an enemy is encountered on the way to the assaultpoint the assaulting NPC will kill it, but then upon reaching the assaultpoint will not pursue or return fire from other enemies until the next assaultpoint is reached. In fact, the assaulting NPC doesn't even change direction to face the fire. This happens regardless of the "clear on arrival" or "never time out" settings.
  • I didn't observe any effect of the "never time out" setting. However, all firefights were fairly brief, so it might not have had a chance to come into effect.
  • All-settings-off is great for making the NPC dash to a point regardless of enemy fire and then attack everyone at the point.
  • Having only "clear on arrival" on is great for making the NPC dash from point to point without pausing, regardless of enemy fire.
  • The OnAssaultClear output is only fired for the last assaultpoint in a chain. All assaultpoints will fire their OnArrival output, however.
  • The delay after a "Allow diversions" diversion is about 18 seconds for a 3-second "timeout" time.
  • A diversion causes another such delay immediately upon reaching the assaultpoint, and then the assaultpoint OnArrive re-fires. If the NPC is again diverted before the timeout, the OnArrive output will fire again, ad infinitum. So don't spawn enemies during from the OnArrive output.
  • If the first assaultpoint is set to "Clear on contact" and an enemy is sighted before reaching the assaultpoint, the assaulting NPC will never make it to the assaultpoint. If the subsequent assaultpoint has "Allow diversion" off, this will cause that (or perhaps the final) assaultpoint to fire the OnArrival output—despite the assaulting NPC being nowhere nearby and having not even gotten to the first assaultpoint, nor having yet finished dealing with the enemies. If, on the other hand, the second assaultpoint has "Allow diversion" on, no messages are sent whatsoever.
  • In Half-Life 2: Episode One and Half-Life 2: Episode Two rally points behave differently than in Half-Life 2. If there is an assault point with "Never Time Out" in the assault chain connecting to a rally point, than that rally point will be "locked" and unusable until the NPC on the chain dies.

See also