rmp::behavior::Chase
Sees a target and goes after it. It sees it within sight units, inside a cone of fov degrees around the way it faces, and — with line_of_sight — when no solid map cell stands between them. While it chases, a Patrol on the same object is paused, and a Pathfind, when there is one, finds the way; without one it runs straight at the target. After lose_after seconds without seeing it, it gives up: on_lose, back home with return_home, and the Patrol resumes.
From the editor: "speed" (Float), "sight" (Float), "fov" (Float).
Added to an object with add<rmp::behavior::Chase>(); the framework calls its _ready, _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
target | Handle<Object> | Whom it looks for; the game sets it, usually the player | |
speed | float | 120 | Units per second while it chases |
sight | float | 160 | How far it sees; 0 = any distance |
fov | float | 360 | Degrees of its view, centred on the way it faces |
line_of_sight | bool | true | Solid map cells hide the target |
lose_after | float | 2 | Seconds without seeing it before it gives up |
return_home | bool | true | Goes back where it started after giving up |
stop_distance | float | 0 | Stops this close to the target |
on_spot | Callback<Object &, Object &> | (the chaser, the target), when a chase starts | |
on_lose | Callback<Object &> | When it gives up | |
ours | struct { … } | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then |
chasing
Whether it is chasing now.
sees
Whether it saw the target at its last update.
from
A Chase with the fields the map's entity has by these names — speed, sight, fov — and the defaults for the rest. See "FROM THE EDITOR" at the top of this file.