QtCraft API C++ classes QML types Handbook

QcPlayerLaunchers Class

Players drawing and shooting launchers (a bow, decision E-425). More...

Header: #include <server/projectiles/QcPlayerLaunchers.h>

Public Functions

void draw(QcServerClient &client, QcMsg::DrawLauncher::Action action)
bool draws(const QcServerClient &client) const
bool shoot(QcServerClient &client, double power)
void tick()

Static Public Members

QString creativeProjectile(const QcContentRegistry &content, const QcLauncherDefinition &launcher)
const double muzzle

Detailed Description

The server times the draw from the press of the use button (QcMsg::DrawLauncher) to its release in ticks; the release shoots the first ammunition of the inventory the launcher takes (decision E-427; in creative mode, when the inventory has none, creativeProjectile, and nothing is used) at the launcher's speed times the power of the draw. A shot uses one item of ammunition and wears the launcher by one, except in creative mode. Without ammunition a draw does not begin outside creative mode. A draw lets go without a shot when the client cancels it, the selected hotbar slot changes (also to another launcher), the selected item is no launcher any more, the player dies or the power stays below the launcher's minPower. A draw slows the player (draws(), decision E-986).

Member Function Documentation

[static] QString QcPlayerLaunchers::creativeProjectile(const QcContentRegistry &content, const QcLauncherDefinition &launcher)

Returns what creative mode shoots with launcher without ammunition: the projectile of the item of the first kind (in the order of content) the launcher takes; empty when it takes none.

void QcPlayerLaunchers::draw(QcServerClient &client, QcMsg::DrawLauncher::Action action)

The player of client pressed or released the use button with the launcher, or cancelled the draw (action).

bool QcPlayerLaunchers::draws(const QcServerClient &client) const

Returns whether the player of client draws a launcher that is still in the hand, also between the change of the hand and the next tick().

bool QcPlayerLaunchers::shoot(QcServerClient &client, double power)

The player of client shoots with the held launcher at power; returns false when nothing was shot (no launcher, no ammunition, power below its minimum, the projectile limit).

void QcPlayerLaunchers::tick()

Ends draws whose launcher left the hand.

Member Variable Documentation

const double QcPlayerLaunchers::muzzle

How far ahead of the eyes a shot starts (m), so the shooter's box is behind it.