MovementPolicy
This type represents a movement policy. A movement policy is either a chase, follow or move policy that builds a series of movement actions that are iterated by the main thread. A chase, follow, or move policy is initiated through Player.chase
, Player.follow
, or Player.move
respectively.
All movement policies generate a movement plan for a bot over time. playerbot-lua
enables the user to set a new policy for a given bot in the same way that regular creatures and pets configure movement. Once the policy is set, the main thread will operate on the current policy by handling moving the unit through each path node generated by the policy to reach its destination. Path nodes are generated in such a way so as to allow pathfinding to the destination.
Since policies work over time and are not meant to be rapidly changed, policies for each bot are throttled to only allow policy updates every 500ms. This frequency was chosen as it strikes a good balance between responsiveness and performance. Lower times often result in movement animation glitches on the client side, and higher times make the bots too unresponsive. Throttling is tracked per bot across all policy types.
Policy updates are also not applied if the new policy is the same as the old policy in order to avoid the overhead of initializing a new policy. Certain parameters are also checked to ensure that parameter changes are not trivial. For example, given a move policy, if the distance between the old destination and the new destination are less than .5 units, it will not initialize the policy.
All members are read-only.
Members
The following are members of MovementPolicy
. For example:
print("current follow target: " .. some_bot.movement_policy.follow_target.name)
Name | Description | Return Type | Tested? |
---|---|---|---|
follow_target | the target the player is following | Unit |
No |
follow_distance | the distance at which the player is following the follow target | number |
No |
follow_angle | the angle at which the player is following the follow target | number |
No |
chase_target | the target the player is chasing | Unit |
No |
chase_distance | the distance at which the player is chasing the chase target | number |
No |
chase_angle | the angle at which the player is chasing the chase target | number |
No |
move_destination | the destination the player is currently heading towards | Position |
No |