AbsorbDamage

virtual void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor = null, Actor source = null, int flags = 0)

Usage

Allows inventory items to manipulate the damage an actor receives. It is called when an actor is damaged, provided the damage is not set up to bypass armor and is greater than zero. Note that the function is called after ModifyDamage, another similar function for damage manipulation.

This function's main usage is with armor, but could be used with any inventory item.

Parameters

  • damage: the damage before modification. This may not necessarily be the raw damage of the attack.
  • damageType: the damage type of the attack.
  • newdamage: the damage after modification. After the damage is modified, it is to be stored in this variable. Unmodified, this holds the same value as damage.

Examples

This item fully absorbs damage from fire-based attacks, and half damage from ice-based attacks.

override void AbsorbDamage (int damage, Name damageType, out int newdamage, Actor inflictor, Actor source, int flags)
{
    if (damageType == 'Fire')
    {
        newdamage = 0;
    }
    else if (damageType == 'Ice')
    {
        newdamage = damage / 2;
    }
}

See also

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.