QtCraft API C++ classes QML types Handbook

QcGolemBrain Class

The brain of golems (QcMobDefinition::Ai::Golem, decision E-471): an iron golem guards the villagers. More...

Header: #include <server/golems/QcGolemBrain.h>
Inherits: QcPassiveBrain

Reimplemented Public Functions

virtual QcPhysics::Steering think(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, int thinkTicks) override

Static Public Members

const QcMobManager::PlayerView *enemy(const QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context)
const double homeReach
const QcCreature *prey(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, bool looks)
const double verticalSight

Detailed Description

It hunts the nearest hostile creature it sees within its sight range and strikes it in melee, throwing it upwards (QcGolemDefinition::lift); it attacks a player only while it is angry with them (they hurt it) or while the village whose area it stands in holds a grudge against them (they hurt its villagers or golems, QcGolemGrudges), and never when a player built it. Without a target it strolls slowly like a passive creature and never flees; a village golem keeps its strolls within the area of its village and walks back to it when outside (the nearest village within homeReach; like the reference's stroll in the village and move back to the village).

Member Function Documentation

[static] const QcMobManager::PlayerView *QcGolemBrain::enemy(const QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context)

Returns the player the golem mob of the kind definition attacks in the tick of context, nullptr for none: one it is angry with, else one the village it stands in holds a grudge against, alive, targetable and within its sight range.

[static] const QcCreature *QcGolemBrain::prey(QcCreature &mob, const QcMobDefinition &definition, const QcMobBrain::Context &context, bool looks)

Returns the hostile creature the golem mob of the kind definition hunts in the tick of context: its prey while that is awake and within sight, else, when it looks, the nearest hostile creature it sees (nullptr: none).

[override virtual] QcPhysics::Steering QcGolemBrain::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).

Member Variable Documentation

const double QcGolemBrain::homeReach

A village golem outside every village walks back to the one whose centre lies within this distance.

const double QcGolemBrain::verticalSight

It sees prey at most this far above or below its feet.