QtCraft API C++ classes QML types Handbook

QcArmour Namespace

Armour rules (decision E-234), pure so that the server's damage handling is testable on its own: every armour point takes 4 % off a hit up to 20 points (80 %); each hit wears every worn piece with durability by a quarter of the damage (at least 1), and a piece breaks at its durability. More...

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

Variables

const double damagePerWear
const int maxEffectivePoints
const double reductionPerPoint

Functions

bool fits(const QcContentRegistry &content, const QcItemStack &stack, QcEquipmentSlot slot)
const QcArmourDefinition *of(const QcContentRegistry &content, QcItemId item)
std::optional<QcItemId> placeholder(const QcContentRegistry &content, QcEquipmentSlot slot)
int points(const QcContentRegistry &content, const QcEquipment &equipment)
std::optional<QcItemId> pointsIcon(const QcContentRegistry &content)
double reducedDamage(double damage, int points)
int wearOf(double damage)

Detailed Description

Variable Documentation

const double QcArmour::damagePerWear

Damage per point of wear.

const int QcArmour::maxEffectivePoints

Armour points beyond this count take nothing more off.

const double QcArmour::reductionPerPoint

The share of a hit each armour point takes off.

Function Documentation

bool QcArmour::fits(const QcContentRegistry &content, const QcItemStack &stack, QcEquipmentSlot slot)

Returns whether stack may be worn in slot: one armour item of content made for that slot.

const QcArmourDefinition *QcArmour::of(const QcContentRegistry &content, QcItemId item)

Returns the armour of item in content; null for items that are no armour or unknown.

std::optional<QcItemId> QcArmour::placeholder(const QcContentRegistry &content, QcEquipmentSlot slot)

Returns the item an empty slot shows as a pale placeholder: the first armour item for it in the order of content (mods included); nothing when the content has none.

int QcArmour::points(const QcContentRegistry &content, const QcEquipment &equipment)

Returns the sum of the armour points of the items worn in equipment, as content defines them.

std::optional<QcItemId> QcArmour::pointsIcon(const QcContentRegistry &content)

Returns the item the HUD shows for armour points: the chest piece of content with the most points (the first of equals in content order); nothing without chest armour.

double QcArmour::reducedDamage(double damage, int points)

Returns what is left of a hit of damage against points armour points.

int QcArmour::wearOf(double damage)

Returns the durability lost by every worn piece in a hit of damage (before the reduction).