QtCraft API C++ classes QML types Handbook

QcAirSupply Class

The air of a player or a creature under water (decision E-955), counted in game ticks. More...

Header: #include <common/gameplay/QcAirSupply.h>

Public Functions

int air() const
void reset()
void restore(int air)
bool tick(bool submerged)

Static Public Members

const int bubbles
int bubblesOf(int air, int full = maxAir)
const int damageIntervalTicks
const double drowningDamage
const int maxAir
const int refillPerTick
bool submergedAt(const QcBlockAccess &world, const QcVec3 &eyes)

Detailed Description

With the eyes under water the air sinks by one each tick; at none the body drowns, one hit of drowningDamage every damageIntervalTicks for as long as it stays down. Out of the water the air comes back by refillPerTick each tick, as in the reference. The HUD shows it as bubbles.

Member Function Documentation

int QcAirSupply::air() const

Returns the air left, 0..maxAir.

[static] int QcAirSupply::bubblesOf(int air, int full = maxAir)

Returns the bubbles the HUD shows for air of a full breath of full: one for every started tenth of it, none only when the air is gone.

void QcAirSupply::reset()

Fills the breath and forgets the drowning rhythm.

void QcAirSupply::restore(int air)

Takes air from a save, clamped to 0..maxAir.

[static] bool QcAirSupply::submergedAt(const QcBlockAccess &world, const QcVec3 &eyes)

Returns whether eyes at eyes are under water in world: their cell holds water and they are below its surface (falling water fills its cell).

bool QcAirSupply::tick(bool submerged)

Advances one tick with the eyes submerged or not. Returns whether a hit of drowning falls due in this tick.

Member Variable Documentation

const int QcAirSupply::bubbles

Bubbles of a full breath in the HUD.

const int QcAirSupply::damageIntervalTicks

Ticks between two hits of drowning once the air is gone.

const double QcAirSupply::drowningDamage

Health one hit of drowning takes (one heart).

const int QcAirSupply::maxAir

The air of a full breath: 15 s.

const int QcAirSupply::refillPerTick

Air that comes back in each tick with the eyes out of the water.