endstone/damage

Classes

NameDescription
DamageSourceRepresents a source of damage.

classDamageSource

Defined in <endstone/damage/damage_source.h>

Represents a source of damage.

Methods

NameDescription
~DamageSource
getTypeGet the damage type.
getActorGet the actor that caused the damage to occur.
getDamagingActorGet the actor that directly caused the damage.
isIndirectGet if this damage is indirect.

meth~DamageSourcevirtual

~DamageSource() =default

methgetTypeabstractconst

std::string_view getType() const =0

Get the damage type.

Returns

TypeDescription
std::string_viewthe damage type

methgetActorabstractconst

Actor* getActor() const =0

Get the actor that caused the damage to occur.

Not to be confused with DamageSource::getDamagingActor(), the returned actor is the actor to which the damage is ultimately attributed if the receiver is killed. If, for example, the receiver was damaged by a projectile, the shooter/thrower would be returned.

Returns

TypeDescription
Actor*an Actor or null

methgetDamagingActorabstractconst

Actor* getDamagingActor() const =0

Get the actor that directly caused the damage.

Not to be confused with DamageSource::getActor(), the returned actor is the actor that actually inflicted the damage. If, for example, the receiver was damaged by a projectile, the projectile would be returned.

Returns

TypeDescription
Actor*an Actor or null

methisIndirectabstractconst

bool isIndirect() const =0

Get if this damage is indirect.

Damage is considered indirect if DamageSource::getActor() is not equal to DamageSource::getDamagingActor(). This will be the case, for example, if a skeleton shot an arrow or a player threw a potion.

Returns

TypeDescription
booltrue if is indirect, false otherwise.

On this page