QtCraft API C++ classes QML types Handbook

QcMonsterCap Class

How many monsters may live around the players (decision E-836), by the original game's formula: every living player spans an area of 17 × 17 chunks around its own; the world as a whole holds at most perArea monsters (QcServerLimits monstersPer289Chunks, 70) for every 289 loaded chunks of all areas together, so players far apart each bring a full share and players close together share one. More...

Header: #include <server/spawning/QcMonsterCap.h>

Public Functions

QcMonsterCap(int perArea, const QList<QcChunkPos> &playerChunks, const std::function<bool (QcChunkPos)> &loaded)
QcMonsterCap(int perArea, const QList<QcChunkPos> &playerChunks, qsizetype loadedChunks)
void add(QcChunkPos chunk)
int count() const
int countAround(qsizetype index) const
bool hasRoom() const
int roomIn(QcChunkPos chunk) const
int worldCap() const

Static Public Members

const int areaChunks
qsizetype loadedChunksOf(const QList<QcChunkPos> &playerChunks, const std::function<bool (QcChunkPos)> &loaded)
const int reach

Detailed Description

On top of that a monster appears in a chunk only while some player whose area holds the chunk has fewer than perArea monsters in its own area, so one crowded player does not take the share of another.

Member Function Documentation

QcMonsterCap::QcMonsterCap(int perArea, const QList<QcChunkPos> &playerChunks, const std::function<bool (QcChunkPos)> &loaded)

The areas around playerChunks, the chunks of the living players, with a cap of perArea monsters per area; loaded tells which chunks count.

QcMonsterCap::QcMonsterCap(int perArea, const QList<QcChunkPos> &playerChunks, qsizetype loadedChunks)

The areas around playerChunks with a cap of perArea monsters per area and loadedChunks, the number of loaded chunks of the areas already counted (loadedChunksOf).

void QcMonsterCap::add(QcChunkPos chunk)

Counts one monster in chunk: the ones alive at the start and every one that appears.

int QcMonsterCap::count() const

Returns the monsters in the areas.

int QcMonsterCap::countAround(qsizetype index) const

Returns the monsters in the area of the player at index of the constructor's list.

bool QcMonsterCap::hasRoom() const

Returns whether any monster may still appear anywhere.

[static] qsizetype QcMonsterCap::loadedChunksOf(const QList<QcChunkPos> &playerChunks, const std::function<bool (QcChunkPos)> &loaded)

Returns the number of chunks of the areas around playerChunks together, each once, that loaded tells are loaded.

int QcMonsterCap::roomIn(QcChunkPos chunk) const

Returns the monsters that may still appear in chunk: room in the world and in the emptiest area holding it; 0 outside every area.

int QcMonsterCap::worldCap() const

Returns the world's cap (perArea for every areaChunks loaded chunks of the areas).