QtCraft API C++ classes QML types Handbook

QcEffectDefinition Struct

A kind of status effect (decision E-450), from effects/<name>.json: what it does to a body while it lasts (poison: damage now and then, never below minHealth) and how the HUD shows it (icon, colour, hearts in the colour). More...

Header: #include <common/content/items/QcEffectDefinition.h>

Public Functions

double damageTo(double health) const
bool hurtsAt(int level, int ticksLeft) const
int periodAt(int level) const
double speedFactorAt(int level) const

Public Variables

quint32 colour
double damage
double exhaustion
QString icon
double minHealth
QString name
int periodTicks
double speed
bool tintsHearts
QString translationKey

Static Public Members

const int maxLevel

Detailed Description

Players and creatures carry effects of these kinds (QcStatusEffects); the content sync sends every field but exhaustion: the HUD needs the looks, the client's prediction the speed.

Member Function Documentation

double QcEffectDefinition::damageTo(double health) const

Returns the damage it deals to a body with health, never leaving it below minHealth; 0 when there is no room.

bool QcEffectDefinition::hurtsAt(int level, int ticksLeft) const

Returns whether it hurts at level in the tick in which ticksLeft ticks remain.

int QcEffectDefinition::periodAt(int level) const

Returns the ticks between two of its hurts at level (1 = level I).

double QcEffectDefinition::speedFactorAt(int level) const

Returns the factor on a body's speed at level.

Member Variable Documentation

quint32 QcEffectDefinition::colour

0xRRGGBB of the badge and, with tintsHearts, of the hearts while it lasts.

double QcEffectDefinition::damage

Damage dealt every periodTicks ticks at level 1; each level above halves the period (the reference's 25 >> (level - 1) for poison), at least one tick.

double QcEffectDefinition::exhaustion

Food exhaustion per second at level I (hunger: 0.1 like the reference's 0.005 per tick, decision E-838), times the level; players only. Server side only.

QString QcEffectDefinition::icon

Item whose picture the HUD shows beside the remaining time; empty for a plain badge.

const int QcEffectDefinition::maxLevel

The highest level an effect may have (/effect, onHit "effect", saved effects).

double QcEffectDefinition::minHealth

Its damage never takes the health below this (poison: 1, it never kills).

QString QcEffectDefinition::name

Qualified name of the effect ("name", required).

int QcEffectDefinition::periodTicks

Ticks between two hurts at level 1 ("periodTicks", 1 to 72000).

double QcEffectDefinition::speed

Share of the speed it adds per level, in [-1, 1] (slowness: -0.15 like the reference, decision E-838): walking, swimming and chasing bodies move at 1 + speed × level of their speed, at least 0. Flying players are not slowed.

bool QcEffectDefinition::tintsHearts

Whether the hearts take colour while it lasts ("tintsHearts").

QString QcEffectDefinition::translationKey

Translation key of its display name ("translation"); defaults to effect.<namespace>.<name>.