QcTameBrain Class
The brain of tameable creatures (QcMobDefinition::tameable, decision E-480): a wild one thinks with the brain of its AI (wild: a wolf is neutral, a cat passive); a tame one belongs to its owner (QcTameState::owner, a player identity). More...
| Header: | #include <server/mobbrains/QcTameBrain.h> |
| Inherits: | QcPassiveBrain |
Reimplemented Public Functions
| virtual void | leave(const QcCreature &mob) override |
| virtual QcPhysics::Steering | think(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, int thinkTicks) override |
Static Public Members
| const QcMobManager::PlayerView * | ownerOf(const QcTameState &tame, const QcMobBrain::Context &context) |
| const double | targetRange |
| const double | targetSeconds |
| const int | teleportAttempts |
| bool | teleportNear(QcCreature &mob, const QcMobDefinition &definition, const QcBlockAccess &world, QRandomGenerator &random, const QcVec3 &owner) |
| const double | teleportRange |
Detailed Description
It sits while told to; otherwise it attacks what hurt its owner or what its owner struck (QcTameDefinition::defends; never a pet, its owner's nor another player's), teleports next to its owner when far (only to a safe place in loaded chunks, never while confined), follows its owner when farther than the follow distance until close, and stands while its owner is offline.
Member Function Documentation
[override virtual] void QcTameBrain::leave(const QcCreature &mob)
Reimplements: QcMobBrain::leave(const QcCreature &).
[static] const QcMobManager::PlayerView *QcTameBrain::ownerOf(const QcTameState &tame, const QcMobBrain::Context &context)
Returns the owner of a tame creature of tame among the players of context online and alive; nullptr while offline.
[static] bool QcTameBrain::teleportNear(QcCreature &mob, const QcMobDefinition &definition, const QcBlockAccess &world, QRandomGenerator &random, const QcVec3 &owner)
Teleports mob, a pet of the kind definition, next to its owner at owner in world: a cell drawn from random within teleportRange around the owner's, at most one cell up or down and not the owner's own or next to it, where it can stand (QcSafeSpot::canStand: only loaded chunks), in teleportAttempts tries; returns false when none fits.
[override virtual] QcPhysics::Steering QcTameBrain::think(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, int thinkTicks)
Reimplements: QcPassiveBrain::think(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, int thinkTicks).