Die

From ZDoom Wiki
Jump to navigation Jump to search


Actor

virtual void Die(Actor source, Actor inflictor, int dmgflags = 0, Name MeansOfDeath = 'none')

Usage

Called when an actor is killed (a damaging attack causes an actor's health to fall less than or equal to 0).

Parameters

  • Actor source
The actor responsible for the inflictor.
  • Actor inflictor
The actor that dealt the damage of the killing blow, i.e. a projectile or a puff.
  • int dmgflags
The damage flags that were used in the killing blow:
  • DMG_NO_ARMOR - The attack won't call AbsorbDamage on any of the victim's inventory items.
  • DMG_NO_PAIN - The attack will not cause the victim to enter their Pain state sequence.
  • DMG_INFLICTOR_IS_PUFF - Used by ApplyKickback to determine whether the origin should be the source (if the flag is set) or the inflictor. Automatically set by hitscan attacks.
  • DMG_THRUSTLESS - The attack won't call ApplyKickback on the victim.
  • DMG_FORCED - The attack ignores all damage negation flags/properties the victim has, such as NODAMAGE, and doesn't call special damage functions e.g. TakeSpecialDamage. Players with the NODAMAGE flag, god2, or buddha2 cheats are immune due to potential abuse.
  • DMG_NO_FACTOR - The attack won't apply the victim's damage factors.
  • DMG_PLAYERATTACK - Set if the attack came from a hitscan weapon fired by a player.
  • DMG_FOILINVUL - The attack ignores the INVULNERABLE flag if the victim has it set.
  • DMG_FOILBUDDHA - The attack ignores the BUDDHA flag if the victim has it set.
  • DMG_NO_PROTECT - The attack won't call ModifyDamage or AbsorbDamage on any of the victim's inventory items.
  • DMG_NO_ENHANCE - The attack won't call ModifyDamage on any of the source's inventory items.
  • DMG_USEANGLE - The attack will use the angle parameter when applying kickback instead of having ApplyKickback calculate the angle from the origin of the attack.
  • DMG_EXPLOSION - The attack will be marked as splash damage from an explosion. This is set automatically if the damage came from an explosive projectile.
  • Name MeansOfDeath
The damage type of the damage that killed the actor.

Examples

This version of the Zombieman will spawn explosive barrels every 70 tics while it's alive in its Tick() override. The barrels are put into a dynamic array. Once the monster is killed, all those barrels will be damaged to explode in its Die() override:

class BarrelZombie : Zombieman
{
	array <Actor> barrels;

	override void Tick()
	{
		super.Tick();
		if (health > 0 && !isFrozen() && GetAge() % 70 == 0)
		{
			let bar = Spawn("ExplosiveBarrel", pos, ALLOW_REPLACE);
			if (bar)
			{
				barrels.Push(bar);
			}
		}
	}

	override void Die(Actor source, Actor inflictor, int dmgflags, Name MeansOfDeath)
	{
		for (int i = 0; i < barrels.Size(); i++)
		{
			let bar = barrels[i];
			if (bar && bar.health > 0)
			{
				bar.DamageMobj(self, self, bar.health, 'normal');
			}
		}
		super.Die(source, inflictor, dmgflags, MeansOfDeath);
	}
}