NPC movement: Difference between revisions
Jump to navigation
Jump to search
TomEdwards (talk | contribs) |
TomEdwards (talk | contribs) m (→Walk/Run path) |
||
Line 21: | Line 21: | ||
;<code>TASK_RUN_PATH_FLEE <[[unit]]s></code> | ;<code>TASK_RUN_PATH_FLEE <[[unit]]s></code> | ||
:Run this many units. Won't set a goal though, so use it in conjunction with another task. | :Run this many units. Won't set a goal though, so use it in conjunction with another task. | ||
;<code>TASK_WALK_PATH_TIMED <float | ;<code>TASK_WALK_PATH_TIMED <float|seconds></code> | ||
;<code>TASK_RUN_PATH_TIMED <float | ;<code>TASK_RUN_PATH_TIMED <float|seconds></code> | ||
:Wait this many seconds, ''then'' move. Seems broken? | :Wait this many seconds, ''then'' move. Seems broken? | ||
Revision as of 10:20, 7 April 2008
This is a list of important components of an NPC movement schedule and task. One day it may end up as a full tutorial.
Schedule tasks
All of these tasks can be found in CAI_BaseNPC::StartTask()
.
Find targets
TASK_GET_PATH_TO_PLAYER
- Sets the NPC's goal to the player's location at the time of calculation.
Walk/Run path
TASK_WALK_PATH
TASK_RUN_PATH
TASK_WALK_PATH_FOR_UNITS <units>
TASK_RUN_PATH_FOR_UNITS <units>
TASK_WALK_PATH_WITHIN_DIST <units>
TASK_RUN_PATH_WITHIN_DIST <units>
- Basic movement tasks.
WITHIN_DIST
are useful when the target itself isn't accessible, e.g. is an entity's origin. TASK_RUN_PATH_FLEE <units>
- Run this many units. Won't set a goal though, so use it in conjunction with another task.
TASK_WALK_PATH_TIMED <float|seconds>
TASK_RUN_PATH_TIMED <float|seconds>
- Wait this many seconds, then move. Seems broken?
Utility
TASK_WAIT_FOR_MOVEMENT
- Has the NPC wait for any previously-initiated movement to complete before starting the next task or changing schedule. Only your specified interrupts will stop it from moving. Very important!
TASK_SET_ROUTE_SEARCH_TIME <seconds>
- Maximum time to spend building a route. The schedule will fail if it is overrun. Remember that different CPU speeds will give different results - don't use it except as a fail-safe.
Task functions
Basic movement functions.
SetArrivalDirection( vector || qangle || CBaseEntity )
- The direction to face on arrival at the task goal. The NPC will probably begin turning shortly before arrival.
Tip:If a
CBaseEntity
is passed the NPC will turn to look at it. To use an entity's angles themselves, callGetAbsAngles()
.
GetTacticalServices()->
Combat movement functions.