QtCraft API C++ classes QML types Handbook

QcHurtWindow Class

The short invulnerability of a player or creature after a hurt (decision E-429), counted in game ticks (the server's simulation ticks, independent of /tick rate). More...

Header: #include <server/entities/QcHurtWindow.h>

Public Types

enum class Take { Ignored, Fresh, Stronger }

Public Functions

bool active() const
void clear()
double force(double amount, int ticks)
bool knockedBack() const
double lastAmount() const
void limit(int ticks)
double take(double amount, int ticks)
void tick()
int ticksLeft() const
QcHurtWindow::Take wouldTake(double amount) const

Static Public Members

const int defaultTicks
const int knockbackTicks
const int maxTicks

Detailed Description

A hit with damage outside the window deals all of it and opens the window for the game rule's number of ticks (playerInvulnerabilityTicks, mobInvulnerabilityTicks; 0: the window never opens and every hit counts). During the window, as in the reference, a hit only takes when it is stronger than the strongest hit of the window so far and then deals only the difference; it does not lengthen the window. A hit without damage opens no window (decision E-427). The state is not saved.

Member Type Documentation

enum class QcHurtWindow::Take

How a hit would take: not at all, as a fresh hit (knockback, hurt sound and flash) or as a stronger hit during the window (only the difference, silent and without knockback).

ConstantValueDescription
QcHurtWindow::Take::Ignored0It does not take.
QcHurtWindow::Take::Fresh1A fresh hit.
QcHurtWindow::Take::Stronger2A stronger hit during the window.

Member Function Documentation

bool QcHurtWindow::active() const

Returns whether the window is open.

void QcHurtWindow::clear()

Ends the window (commands such as /kill).

double QcHurtWindow::force(double amount, int ticks)

Takes a hit whatever the window (the void): returns all of amount as the damage and opens the window anew for ticks.

bool QcHurtWindow::knockedBack() const

Returns whether the last fresh hit with damage is so recent that the body is still knocked back.

double QcHurtWindow::lastAmount() const

Returns the strongest hit of the open window (0 when closed).

void QcHurtWindow::limit(int ticks)

Shortens an open window to at most ticks (a game rule was lowered); 0 ends it.

double QcHurtWindow::take(double amount, int ticks)

Takes a hit of amount: returns the damage it deals (0 when ignored) and opens the window for ticks on a fresh hit with damage.

void QcHurtWindow::tick()

One game tick passes.

int QcHurtWindow::ticksLeft() const

Returns the ticks the window stays open.

QcHurtWindow::Take QcHurtWindow::wouldTake(double amount) const

Returns how a hit of amount would take now (a hit without damage takes fresh outside the window).

Member Variable Documentation

const int QcHurtWindow::knockbackTicks

Ticks after a fresh hit with damage during which a creature does not steer (knocked back).