Table of Contents

Class DamageSource

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public class DamageSource
Inheritance
DamageSource
Inherited Members
Extension Methods

Fields

CauseEntity

The entity that caused this damage, e.g. the entity that threw the SourceEntity projectile, if any
NOTE: will be null for non-projectile damage e.g. melee attacks: to get the attacking entity properly for both melee and projectile damage, use GetCauseEntity()

public Entity CauseEntity

Field Value

Entity

DamageOverTimeType

If Duration greater than zero, this damage will be turned into damage overt time effect with this type.
This is used to look for specific types of DoT effects. For example it can be used to stop bleeding with bandages.

public int DamageOverTimeType

Field Value

int

DamageTier

Tier of the weapon used to damage the entity, if any

public int DamageTier

Field Value

int

Duration

If is greater than zero, damage will be turned into damage over time and will be fully applied over this time.
If TicksPerDuration is set to 1, it will mean that damage will just be delayed by Duration.

public TimeSpan Duration

Field Value

TimeSpan

HitPosition

The relative hit position of where the damage occured.

public Vec3d HitPosition

Field Value

Vec3d

IgnoreInvFrames

public bool IgnoreInvFrames

Field Value

bool

KnockbackStrength

The amount of knockback this damage will incur

public float KnockbackStrength

Field Value

float

Source

The type of source the damage came from.

public EnumDamageSource Source

Field Value

EnumDamageSource

SourceBlock

The source block the damage came from, if any

public Block SourceBlock

Field Value

Block

SourceEntity

The source entity the damage came from, if any

public Entity SourceEntity

Field Value

Entity

SourcePos

the location of the damage source.

public Vec3d SourcePos

Field Value

Vec3d

TicksPerDuration

If Duration greater than zero, total damage will be split into this many portions, each applied in Duration/TicksPerDuration time after another.

public int TicksPerDuration

Field Value

int

Type

The type of damage that was taken.

public EnumDamageType Type

Field Value

EnumDamageType

YDirKnockbackDiv

public float YDirKnockbackDiv

Field Value

float

Properties

DamageOverTimeTypeEnum

public EnumDamageOverTimeEffectType DamageOverTimeTypeEnum { get; set; }

Property Value

EnumDamageOverTimeEffectType

Methods

GetAttackAngle(Vec3d, out double, out double)

If we have a hitposition this returns the pitch between the attacker and the attacked position

public bool GetAttackAngle(Vec3d attackedPos, out double attackYaw, out double attackPitch)

Parameters

attackedPos Vec3d
attackYaw double
attackPitch double

Returns

bool

GetCauseEntity()

Get the entity that caused the damage. If a projectile like a stone was thrown this will return the entity that threw the stone instead of the stone.

public Entity GetCauseEntity()

Returns

Entity

The entity that caused the damage

GetSourcePosition()

Fetches the location of the damage source from either SourcePos or SourceEntity

public Vec3d GetSourcePosition()

Returns

Vec3d