QcMobSteering Namespace
How creatures of QcMobManager pick a player to chase and strike it. More...
| Header: | #include <server/mobbrains/QcMobSteering.h> |
Classes
| struct | Melee |
Variables
| const double | eyeShare |
| const double | provokedSeconds |
| const double | verticalReach |
Functions
| bool | calm(const QcCreature &mob, const QcMobDefinition &definition, double worldTime) |
| const QcMobManager::PlayerView * | chooseTarget(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players, const QcBlockAccess &world, bool looks) |
| bool | inMelee(const QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target, const QcBlockAccess &world) |
| bool | leap(QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target, QRandomGenerator &random) |
| void | provoke(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players) |
| const QcMobManager::PlayerView * | provoker(const QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players) |
| std::optional<QcMobManager::PlayerHit> | strike(QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target) |
| QcMobSteering::Melee | strikeAdjacent(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players, const QcBlockAccess &world) |
| float | yawTowards(const QcVec3 &direction) |
Detailed Description
Classes
class Melee
A hostile creature without AI of its own (a crowd, QcMobCrowd) strikes the nearest player in melee (inMelee) when its attack is ready, so a knot of creatures is no safe place (a neutral one only the player that provoked it). More...
Variable Documentation
const double QcMobSteering::eyeShare
Eyes of a creature at this share of its height (where its line of sight starts).
const double QcMobSteering::provokedSeconds
Seconds a creature neutral by day stays angry at the player that hurt it (decision E-451).
const double QcMobSteering::verticalReach
Mobs only notice and attack within this vertical distance.
Function Documentation
bool QcMobSteering::calm(const QcCreature &mob, const QcMobDefinition &definition, double worldTime)
Returns whether mob, a creature of the kind definition neutral by day, leaves players alone at worldTime (decision E-451): by day, above ground (not spawned in a cave) and not angry at a player (provoke).
const QcMobManager::PlayerView *QcMobSteering::chooseTarget(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players, const QcBlockAccess &world, bool looks)
Returns the one of players that mob of the kind definition chases this tick in world (QcCreature::chasing), nullptr for none. When it looks, it picks the nearest living, targetable player within the kind's sight range that it sees from its eyes (one ray to the player's eyes, QcLineOfSight::seesPoint) and remembers them for targetMemorySeconds; otherwise, or when it sees none, it keeps its target while it still remembers them and they are a valid target within sight range.
bool QcMobSteering::inMelee(const QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target, const QcBlockAccess &world)
Returns whether target is within the reach of definition and seen from the eyes of mob in world (QcLineOfSight, as for player attacks, decision E-092): no blows through walls or glass.
bool QcMobSteering::leap(QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target, QRandomGenerator &random)
Lets mob, a leaper of the kind definition on the ground, leap at target within its range now and then (chance from random); returns true when it leapt.
void QcMobSteering::provoke(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players)
mob, a creature of the kind definition neutral by day, turns on the one of players whose blow or shot hurt it since it last thought (QcCreature::struckBy, decision E-451) for provokedSeconds; damage without a player (a fall, fire) provokes nobody. The anger ends early when that player is gone, dead or no target.
const QcMobManager::PlayerView *QcMobSteering::provoker(const QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players)
Returns the one of players that mob, an angry creature of the kind definition neutral by day, hunts, whatever the time of day; nullptr for none.
std::optional<QcMobManager::PlayerHit> QcMobSteering::strike(QcCreature &mob, const QcMobDefinition &definition, const QcMobManager::PlayerView &target)
Turns mob of the kind definition towards target in melee (inMelee) and strikes it when the attack is ready; returns the hit, if any.
QcMobSteering::Melee QcMobSteering::strikeAdjacent(QcCreature &mob, const QcMobDefinition &definition, const QList<QcMobManager::PlayerView> &players, const QcBlockAccess &world)
Returns whether mob of the kind definition struck one of players in melee in world, and the blow (Melee).
float QcMobSteering::yawTowards(const QcVec3 &direction)
Returns the yaw in degrees for the horizontal direction (0 looks north, -Z).