Skip to Content
⚠ Under Construction
ReferenceC++ APIDamageSource

endstone::DamageSource

Represents a source of damage.

Functions:

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

getActor

Actor *getActor() const

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:

an Actor or null

getDamagingActor

Actor *getDamagingActor() const

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:

an Actor or null

getType

std::string_view getType() const

Get the damage type.

Returns:

the damage type

isIndirect

bool isIndirect() const

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:

true if is indirect, false otherwise.

Last updated on