QtCraft API C++ classes QML types Handbook

QcClientVitals Class

What the server last told the player about themselves (QcClientSession::vitals): health and whether they burn or are dead, food, experience (decision E-398) and air under water (decision E-955). More...

Header: #include <clientcore/player/QcClientVitals.h>

Public Types

enum class Change { None, Health, Food, Experience, Air }

Public Functions

double air() const
int airBubbles() const
bool airShown() const
QcClientVitals::Change apply(const QcMessage &message)
bool bubblePopped() const
bool burning() const
const QList<QcStatusEffect> &effects() const
int experienceForNext() const
int experienceLevel() const
int experiencePoints() const
double experienceProgress() const
int food() const
double health() const
bool healthKnown() const
bool hurt() const
std::optional<float> hurtFrom() const
bool isDead() const
int maxFood() const
double maxHealth() const

Detailed Description

Member Type Documentation

enum class QcClientVitals::Change

Which of the vitals a message changed.

ConstantValueDescription
QcClientVitals::Change::None0nothing
QcClientVitals::Change::Health1health, burning, dead or the effects
QcClientVitals::Change::Food2food
QcClientVitals::Change::Experience3experience
QcClientVitals::Change::Air4air under water

Member Function Documentation

double QcClientVitals::air() const

Returns the share of a full breath left, 0..1, as the server last told (in steps of a bubble).

int QcClientVitals::airBubbles() const

Returns the bubbles of the air left (QcAirSupply::bubblesOf).

bool QcClientVitals::airShown() const

Returns whether the HUD shows the air: with the eyes under water and until the breath is full again.

QcClientVitals::Change QcClientVitals::apply(const QcMessage &message)

Takes over message when it is PlayerHealth, PlayerFood, PlayerExperience or PlayerAir. Returns what changed; Change::None for other messages.

bool QcClientVitals::bubblePopped() const

Returns whether the last PlayerAir took a bubble under water (the client plays a pop).

bool QcClientVitals::burning() const

Returns whether the player is on fire (decision E-393): the HUD shows flames at the edge of the view.

const QList<QcStatusEffect> &QcClientVitals::effects() const

Returns the status effects with their ticks left when the server last told (decision E-450).

int QcClientVitals::experienceForNext() const

Returns the points the current level needs for the next one.

int QcClientVitals::experienceLevel() const

Returns the experience level.

int QcClientVitals::experiencePoints() const

Returns the experience points within the current level.

double QcClientVitals::experienceProgress() const

Returns the share of the way to the next level, 0..1 (the bar in the HUD).

int QcClientVitals::food() const

Returns the player's food points.

double QcClientVitals::health() const

Returns the player's health in points.

bool QcClientVitals::healthKnown() const

Returns whether the server told the health at least once (before, the vitals are the full defaults).

bool QcClientVitals::hurt() const

Returns whether the last PlayerHealth told of a fresh hit (decision E-971).

std::optional<float> QcClientVitals::hurtFrom() const

Returns the world yaw towards where that hit came from; none without a direction.

bool QcClientVitals::isDead() const

Returns whether the player is dead.

int QcClientVitals::maxFood() const

Returns the most food points.

double QcClientVitals::maxHealth() const

Returns the most health the player can have.