Custom damage types

From ZDoom Wiki
Jump to: navigation, search

Users can specify custom damage types using the DamageType actor property along with custom states. A number of damage types are predefined, but you can create more.

You can specify the type of damage a projectile or monster actor inflicts using the DamageType property:

Actor Fireball
    DamageType Fire

You can then create corresponding custom Pain, Death, Wound and Crash states in your actors that are called instead of the normal states when this type of damage is inflicted. You do this by using the form State.DamageType:

Actor MyZombie : ZombieMan
    PainChance "Fire", 255

    States {
              ZMBF AB 3
              ZMBF C 5 A_PlaySound("myzombie/Burn")
              ZMBF D 3
              goto See
              ZMBF EFG 3
              ZMBF H 2 A_PlaySound("myzombie/BurnDeath")
              ZMBF IJ 3
              ZMBF K 3 A_NoBlocking
              ZMBF L -1

As you can see in the above example, you can also specify a pain chance for each type of custom damage you have defined. This can allow enemies that will always be affected by fire damage (as above) but never by ice damage, for example.

Note: The following note only applies on revisions older than 7e6a5c1. In newer revisions, you can use damage-based XDeath states in the same way you would with Death states.

Note that ZDoom does NOT currently support custom XDeath states. However, since a custom Death state supersedes the XDeath state, you can use this to your advantage to simulate the effect.

actor GibZombie : ZombieMan
    States {
              POSS G 0 A_JumpIfHealthLower(-20,"SuperGibDeath")
              goto Death

Here A_JumpIfHealthLower is used to check if the damage incurred on the Zombie has passed its GibHealth value (in this case, 20). If it has, it jumps to a new gib sequence; if not, it goes to a normal death. Via this method, custom gib states that behave the same way as the original Doom ones can be created.

In addition to the above, you can also create monsters that are resistant, or vulnerable, to a particular type of custom damage. You do this with the DamageFactor property, using the format DamageFactor "DamageType", multiplier.

Actor RaiDoom : DoomImp replaces CellPack
  Health 200 
  Speed 16 
  DamageFactor "Pikachu", 0.2  //it's not very effective... 
  DamageFactor "Squirtle", 1.8  //it's super effective! 

Damagetype declarations

(deprecated in development versions r9e2830a+, but still valid in official version 2.4.0.)

Nuvolabomb.png Warning: The feature described on this page has been deprecated, and will no longer be supported or updated by the ZDoom developers. While some functionality may be retained for the purposes of backwards-compatibility, authors are strongly discouraged from utilizing this feature in future maps and to instead use the MAPINFO method. Compatibility with future ZDoom versions is not guaranteed.

You can declare a damagetype and default properties for it with a new decorate syntax "DamageType". Its syntax is:

DamageType <DamageTypeName> { <DamageTypeProperties> }

Damage type properties

  • Factor (default 1.0): When an actor has no specific damagefactor for this damage type, the globally defined damage factor is applied. The fallback damagefactor (Normal) is also applied if it is defined.
  • ReplaceFactor: If specified, the fallback damagefactor (Normal) is not applied to this damagetype.
  • NoArmor: If specified, damage of this type always bypasses armor.

Note: The actor property DamageFactor always applies, unless damage factors are omitted completely. Declaring a damagetype does nothing to change that.

Example: A new damage-type (SpecialDamage) that does no damage unless an actor is explicitly vulnerable.

DamageType SpecialDamage
   Factor 0
   ReplaceFactor // Not truly necessary, since we multiply by 0

Actor SpecialActor
   DamageFactor "SpecialDamage", 1 // explicitly vulnerable, global setting does not apply

When you declare a damagetype, you reset any existing definitions to defaults.

Example: Redefine "Drowning" to affect armor. (Silly, but possible.)

DamageType Drowning
    // Declaring a damagetype with no explicit properties causes
    // it to apply armor, have a default damage factor of 1.0 and
    // apply the fallback damagefactor (Normal) from the victim.

Another trick: Redefine "Drowning" to ignore fallback damage factor.

DamageType Drowning
    NoArmor // Drowning should not affect armor
    ReplaceFactor // All actors that have no explicit damagefactor for drowning should use the global value from this definition
    // Default Factor 1.0
Actor TakesMoreDamage
   DamageFactor "Normal", 1.5 // Takes extra damage for attacks that have no specific damage factor
   // We have changed Drowning so that it ignores DamageFactor "Normal" by ReplaceFactor