Creating a squadslot: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{npc tut}}
{{npc tut}}
{{stub}}
==Declaration==
Squadslots are useful for assigning NPCs to perform specific actions in a squad.
Squadslots are useful for assigning NPCs to perform specific actions in a squad.


To give an NPC the ability to be in a squad, you must add the following to the <code>Spawn</code> function:
To give an NPC the ability to be in a squad, you must add the following to the <code>Spawn</code> function:
CapabilitiesAdd( bits_CAP_SQUAD);
CapabilitiesAdd( bits_CAP_SQUAD);
 
 
This code will make sure the squadmates won't try to shoot through each other to attack enemies.
This code will make sure the squadmates won't try to shoot through each other to attack enemies.
CapabilitiesAdd( bits_CAP_NO_HIT_SQUADMATES );
CapabilitiesAdd( bits_CAP_NO_HIT_SQUADMATES );


The first step to creating a squadslot for your NPC is to create a name for it and add it to the enum. Here's an example name for a squadslot: '''SQUAD_SLOT_GRENADE1'''.
The first step to creating a squadslot for your NPC is to create a name for it and add it to the <code>SquadSlot_T</code> enum. Here's an example name for a squadslot: '''SQUAD_SLOT_GRENADE1'''.


Once the activity is added to the enum, you must use the '''DECLARE_SQUADSLOT''' macro in the '''AI_BEGIN_CUSTOM_NPC''' section.
Once the activity is added to the enum, you must use the '''DECLARE_SQUADSLOT''' macro in the '''AI_BEGIN_CUSTOM_NPC''' section.


Here's an example of the DECLARE_SQUADSLOT code:
Here's an example of the DECLARE_SQUADSLOT code:
<pre> DECLARE_SQUADSLOT( SQUAD_SLOT_EXAMPLE )</pre>
DECLARE_SQUADSLOT( SQUAD_SLOT_EXAMPLE )
 
==Implementation==
{{TODO|Implementation}}
{{navbar|Creating an animevent|Creating an NPC|Creating an interaction}}
{{navbar|Creating an animevent|Creating an NPC|Creating an interaction}}
[[Category:AI Programming]]

Latest revision as of 18:03, 27 September 2019

Stub

This article or section is a stub. You can help by expanding it.

Declaration

Squadslots are useful for assigning NPCs to perform specific actions in a squad.

To give an NPC the ability to be in a squad, you must add the following to the Spawn function:

	CapabilitiesAdd( bits_CAP_SQUAD);


This code will make sure the squadmates won't try to shoot through each other to attack enemies.

	CapabilitiesAdd( bits_CAP_NO_HIT_SQUADMATES );

The first step to creating a squadslot for your NPC is to create a name for it and add it to the SquadSlot_T enum. Here's an example name for a squadslot: SQUAD_SLOT_GRENADE1.

Once the activity is added to the enum, you must use the DECLARE_SQUADSLOT macro in the AI_BEGIN_CUSTOM_NPC section.

Here's an example of the DECLARE_SQUADSLOT code:

	DECLARE_SQUADSLOT( SQUAD_SLOT_EXAMPLE )

Implementation

Todo: Implementation