A_DamageTarget

From ZDoom Wiki
Jump to navigation Jump to search

void A_DamageTarget (int amount [, name damagetype [, int flags [, class<Actor> filter [, name species [, int src [, int inflict]]]]]])

Usage

Damages the calling actor's target actor by the specified amount. Negative amounts heal it, instead. This function cannot damage player actors which are under the effect of god2, and they still survive with one point of health if under the effect of buddha2.

Parameters

  • amount: the amount of damage to inflict. Negative amounts heal. An amount of one million or higher is treated specially, and results in killing the actor regardless of health or any damage modifiers that may be in effect.
  • damagetype: the type of damage to inflict. Default is "None".
  • flags: the following flags can be combined using the | character between the constants names:
    • DMSS_FOILINVUL — the actor is damaged even if it is invulnerable. For this flag to work, an inflictor is required (see inflict below). This flag is ignored if the actor is a player.
    • DMSS_FOILBUDDHA — if the damage is enough to kill the actor, it dies even if it is under the effect of buddha. For this flag to work, an inflictor is required (see inflict below). This flag is ignored if the actor is a player.
    • DMSS_NOPROTECT — damage bypasses the damage-modifying capability of items in the actor's inventory. A protection powerup is an example of such items.
    • DMSS_NOFACTOR — damage bypasses the the actor's damage factors.
    • DMSS_AFFECTARMOR — damage does not bypass the damage-absorbing capability of items in the actor's inventory. An armor is an example of such items.
    • DMSS_KILL — inflicts an amount of damage which is equal to the sum of the actor's current health and amount, killing the actor under normal conditions. This flag bypasses the actor's damage factors and the damage-absorbing capability (but not the damage-modifying one) of items in the actor's inventory.
    • DMSS_EXFILTER — inverts the case of the class name filter; the actor is only damaged if its class name does not match the value passed to filter.
    • DMSS_EXSPECIES — inverts the case of the species filter; the actor is only damaged if its species does not match the value passed to species.
    • DMSS_EITHER — the actor is damaged if either its class name or species matches the values passed to filter and species, respectively.
    • DMSS_INFLICTORDMGTYPE — ignores the specified damage type, and instead, uses the damage type of the actor doing the damage (inflictor).
  • filter: the actor class to damage. The actor is only damaged if its class name matches the specified class. Default is null(ZScript only)/"None"(DECORATE only).
  • species: the actor species to damage. The actor is only damaged if its species matches the specified species. Default is "None".
  • src: the actor responsible for the damage (source). This is an actor pointer. If this is set to AAPTR_NULL, the actor is damaged without a source. Default is AAPTR_DEFAULT, which is the calling actor itself.
  • inflict: the actor doing the damage (inflictor). This is an actor pointer. If this is set to AAPTR_NULL, the actor is damaged without an inflictor (note that doing so renders both DMSS_FOILINVUL and DMSS_FOILBUDDHA ineffective). Default is AAPTR_DEFAULT, which is the calling actor itself.

Examples

Taking advantage of the fact that a projectile's target actor is its shooter, this rather weird rocket damages its shooter, instead of performing a radius attack, if it hits a wall, ceiling or floor.

class OddRocket : Rocket
{
    States
    {
    Crash:
    Death.Extreme:
        Goto Super::Death; // Use the parent class's own Death state sequence.

    Death:
        MISL B 8 Bright A_DamageTarget(10, flags: DMSS_AFFECTARMOR, src: AAPTR_TARGET);
        MISL C 6 Bright;
        MISL D 4 Bright;
        Stop;
    }
}

Notice how the source of the damage is set as the rocket's target. This means that the shooter is the one responsible for the damage, not the rocket.