DoSpecialDamage

From ZDoom Wiki
Jump to navigation Jump to search

Actor

virtual int DoSpecialDamage (Actor victim, int damage, Name damagetype)

Usage

Called by projectiles whenever they're about to deal damage to an actor. Can be overridden to modify the damage the projectile would deal, or add other custom behavior that should be executed when the projectile hits its victim.

Note, if there's a need to modify the projectile's collision rules, using SpecialMissileHit provides more flexibility.

Parameters

  • Actor victim
The actor about to be hit by the projectile.
  • int damage
The amount of damage to deal. If this value is returned directly (return damage) without being modified first, the projectile's damage will remain unmodified.
  • Name damagetype
The damage type applied to the attack. Regular attacks use 'Normal', hitscan attacks use 'Hitscan'.

Example

Strife's LoreShot uses this virtual to pull the victim towards the shooter:

	override int DoSpecialDamage (Actor victim, int damage, Name damagetype)
	{
		
		if (victim != NULL && target != NULL && !victim.bDontThrust)
		{
			Vector3 thrust = victim.Vec3To(target);
			victim.Vel += thrust.Unit() * (255. * 50 / max(victim.Mass, 1));
		}
		return damage;
	}

(The full code can be seen on the LoreShot page.)

See also