Creating an activity

From Valve Developer Community
Jump to navigation Jump to search

Declaration

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

Once the activity is added, you must use the DECLARE_ACTIVITY macro in the AI_BEGIN_CUSTOM_NPC section.

Here's an example of the DECLARE_ACTIVITY code:

	DECLARE_ACTIVITY( ACT_NEWNPC_ACTIVITY )
Note.pngNote:It is not necessary to declare shared activities.

Implementation

Activities are used in schedules and utilize one of these 2 tasks:

  • TASK_PLAY_SEQUENCE
  • TASK_SET_ACTIVITY

Examples

	DEFINE_SCHEDULE
	(
		SCHED_COMBINE_BUGBAIT_DISTRACTION,

		"	Tasks"
		"		TASK_STOP_MOVING		0"
		"		TASK_RESET_ACTIVITY		0"
		"		TASK_PLAY_SEQUENCE		ACTIVITY:ACT_COMBINE_BUGBAIT"
		""
		"	Interrupts"
		""
	)
	DEFINE_SCHEDULE
	(
		SCHED_COMBINE_BURNING_STAND,

		"	Tasks"
		"		TASK_WAIT_RANDOM		0.3"
		"		TASK_SET_ACTIVITY		ACTIVITY:ACT_COMBINE_BUGBAIT"
		"		TASK_WAIT			2"
		"		TASK_WAIT_RANDOM		3"
		"		TASK_COMBINE_DIE_INSTANTLY	DMG_BURN"
		"		TASK_WAIT			1.0"
		""
		"	Interrupts"
		""
	)

TASK_PLAY_SEQUENCE

This task does not reset the activity, but it does factor in AutoMovement capabilities.

TASK_SET_ACTIVITY

This task resets the activity, but it does not factor in AutoMovement capabilities.