MAPINFO/Damage type definition

From ZDoom Wiki
Jump to navigation Jump to search

A damage type definition begins with the keyword "DamageType". This defines custom damage types. The syntax is as follows:

DamageType <Name>
{
    <properties>
}

DamageType properties

The following properties are supported within a DamageType definition:

Property Description
Factor = <value> When an actor has no specific damage factor for this damage type, the globally defined damage factor is applied. The fallback damage factor (Normal) is also applied if it is defined. Default is 1.0.


ReplaceFactor If specified, the fallback damage factor (Normal) is not applied to this damage type.


NoArmor If specified, damage of this type always bypasses armor.


Obituary = "<string>" The default obituary for this damage type. This is used if the source of damage is unknown or does not define an obituary of its own.


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


Examples

This damage type does no damage unless an actor is explicitly vulnerable to it.

DamageType SpecialDamage
{
    Factor = 0
    ReplaceFactor // Not truly necessary, since we multiply by 0.
}

// In ZScript:
class MySpecialActor : Actor
{
    Default
    {
        DamageFactor 'SpecialDamage', 1.0 // Explicitly vulnerable; global setting does not apply.
    }
}


When you declare a damage type, you reset any existing definitions to defaults. This example redefines "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.
}

This one redefines "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
}
class VulnerableThing : Actor
{
   Default
   {
       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
   }
}


This example demonstrates the use the Obituary property.

DamageType GreenGoo
{
    Obituary = "%o got gooed."
}