TakeSpecialDamage

From ZDoom Wiki
Jump to navigation Jump to search


Actor

virtual int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype)

Usage

A virtual function called by actors when when they're about to receive damage but haven't yet. The return value is the new damage to be taken. This occurs after all forms of damage modifiers are applied. This virtual is called automatically as part of the base DamageMobj call, and thus can modify whatever value DamageMobj will return.

NOTE: If the actor taking damage isn't damageable (for example due to flags like DORMAT, INVULNERABLE, NODAMAGE, or, if it's a PlayerPawn, due to console cheats) this function will not be called.

Parameters

  • Actor inflictor
The actor dealing the damage. This is the missile for projectiles and the puff for hitscan attacks. For monster melee attacks this is the same as the source.
  • Actor source
The actor responsible for the inflictor.
  • int damage
The amount of damage to deal.
  • Name damagetype
The name of the damage type to apply.

Examples

This version of the Zombieman will take no damage from fire attacks:

class FireproofZombieman : Zombieman
{
	override int TakeSpecialDamage(Actor inflictor, Actor source, int damage, Name damagetype)
	{
		if (damagetype == 'Fire')
		{
			return 0;
		}
		
		return super.TakeSpecialDamage(inflictor, source, damage, damagetype);
	}
}