Creating an activity: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
	
 Note:It is not necessary to declare shared activities.
Note:It is not necessary to declare shared activities.
		
	
| No edit summary | mNo edit summary | ||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| {{npc tut}} | {{npc tut}} | ||
| 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  | ==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  | 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: | Here's an example of the DECLARE_ACTIVITY code: | ||
| <pre>	DECLARE_ACTIVITY(  | <pre>	DECLARE_ACTIVITY( ACT_NEWNPC_ACTIVITY )</pre> | ||
| {{note|It is not necessary to declare shared activities.}} | {{note|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. | |||
| {{navbar|Creating a task|Creating an NPC|Creating an animevent}} | {{navbar|Creating a task|Creating an NPC|Creating an animevent}} | ||
| [[Category:AI Programming]] | |||
Latest revision as of 23:57, 17 June 2006
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:It is not necessary to declare shared activities.
Note: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.