QtCraft API C++ classes QML types Handbook

QcMobBehaviour Class

What the awake creatures of QcMobManager do each tick (decision E-400): each thinks with the brain of its AI (QcMobDefinition::ai, decision E-423: QcPassiveBrain, QcHostileBrain, the villagers' QcVillagerBehaviour, QcArcherBrain, QcNeutralBrain, QcGolemBrain, QcGuardianBrain); flyers drift above the ground, hoverers (QcMobHover) float after their brain's wish. More...

Header: #include <server/mobs/QcMobBehaviour.h>

Public Types

struct Clock
struct TierCounts

Public Functions

QcMobBrain &brainOf(QcCreatureKindId type) const
const QcMobCrowd &crowd() const
void leave(const QcCreature &mob) const
const QcPathPlanner &paths() const
void setCrowdLimits(qint64 throttled, qint64 idle)
void setGriefing(bool on)
void setPathLimits(qint64 nodesPerTick, qint64 nodesPerSearch, qint64 pathLength)
QList<QcMobManager::BlockAction> takeBlockActions()
QList<QcMobManager::CreatureHit> takeCreatureHits()
QList<QcProjectileManager::Launch> takeLaunches()
QList<QcMobManager::PlayerHit> tick(std::span<QcCreature> mobs, QcServerWorld &world, const QList<QcMobManager::PlayerView> &players, QcMobBehaviour::Clock clock)
QcMobBehaviour::TierCounts tiersLastTick() const
QcVillagerBehaviour &villagers()
const QcVillagerBehaviour &villagers() const

Detailed Description

Walkers follow their paths (QcMobNavigator) with the shared physics and are pushed apart by their crowd (QcMobCrowd), whose density also decides how much they think (QcMobCrowd::Tier); the path searches of all of them share a budget per tick (QcPathPlanner).

Member Function Documentation

QcMobBrain &QcMobBehaviour::brainOf(QcCreatureKindId type) const

Returns the brain of the creatures of kind type.

const QcMobCrowd &QcMobBehaviour::crowd() const

Returns the crowds as the last tick counted them.

void QcMobBehaviour::leave(const QcCreature &mob) const

The creature mob leaves the world for good (QcMobManager::Departure other than Unloaded): its brain lets go of what it held (a villager's open door).

const QcPathPlanner &QcMobBehaviour::paths() const

Returns the path searches of the creatures.

void QcMobBehaviour::setCrowdLimits(qint64 throttled, qint64 idle)

Sets the thresholds of the AI tiers to throttled and idle (QcServerLimits crowdThrottled, crowdIdle).

void QcMobBehaviour::setGriefing(bool on)

Sets the game rule mobGriefing to on (QcMobBrain::Context::griefing).

void QcMobBehaviour::setPathLimits(qint64 nodesPerTick, qint64 nodesPerSearch, qint64 pathLength)

Sets the budgets of the path searches: nodesPerTick and nodesPerSearch nodes, paths of at most pathLength cells (QcPathPlanner::setLimits).

QList<QcMobManager::BlockAction> QcMobBehaviour::takeBlockActions()

Returns the blocks the creatures took and put down since the last call (decision E-460).

QList<QcMobManager::CreatureHit> QcMobBehaviour::takeCreatureHits()

Returns the blows of creatures at creatures since the last call (QcMobBrain::Context::creatureHits).

QList<QcProjectileManager::Launch> QcMobBehaviour::takeLaunches()

Returns the shots of the creatures since the last call (QcMobBrain::Context::launches, decision E-425).

QList<QcMobManager::PlayerHit> QcMobBehaviour::tick(std::span<QcCreature> mobs, QcServerWorld &world, const QList<QcMobManager::PlayerView> &players, QcMobBehaviour::Clock clock)

One tick of the awake creatures of mobs in world among players at the world time of clock: the waiting path searches, then each decides and moves. Returns the blows they dealt to players; their shots wait in takeLaunches.

QcMobBehaviour::TierCounts QcMobBehaviour::tiersLastTick() const

Returns the creatures per AI tier in the last tick.

QcVillagerBehaviour &QcMobBehaviour::villagers()

Returns what villagers do (decision E-411).

const QcVillagerBehaviour &QcMobBehaviour::villagers() const

Returns what villagers do, read-only.