SectorDamage

From ZDoom Wiki
Jump to navigation Jump to search

void SectorDamage (int tag, int amount, str type, str protection_item, int flags)

Usage

Does the damage only when the function is called, and damages everything in the tagged sector.

Parameters

  • tag: The tag of the affected sector or sectors.
  • amount: The amount of damage to deal.
  • type: The damage type; this can either be a built-in damage type or any further custom-defined one.
  • protection_item: The item that when present in an actor's inventory, will protect said actor from the damage. Passing an empty string "" as the parameter can be used to not specify an item.
  • flags: The following flags are supported for this function and can be combined using the bitwise OR operator | :
    • DAMAGE_PLAYERS — Players in the sector are damaged.
    • DAMAGE_NONPLAYERS — Shootable non-players in the sector are damaged.
    • DAMAGE_IN_AIR — Damage actors in the air as well as those on the ground or in the water.
    • DAMAGE_SUBCLASSES_PROTECT — If an actor is carrying an item derived from the specified protection item, they will be immune to damage. Otherwise, they are only offered protection if they have that exact kind of item.
    • DAMAGE_NO_ARMOR — Damage ignores armor.

At a minimum, you must specify DAMAGE_PLAYERS and/or DAMAGE_NONPLAYERS, or nothing will actually receive damage.

Examples

This example kills non-player actors who enter the sector where this script is run. Assign it to run from an Actor Enters Sector thing placed in the sector with the matching tag.

script 1 (int tag)
{
  if (PlayerNumber() < 0)
  {
    PrintBold(s:"Kill the non-players!!!");
    Sector_SetFade(tag, 255, 0, 0);
    
    while (GetActorProperty(0, APROP_HEALTH) > 0)
    {
      SectorDamage(tag, 100, "Fire", "", DAMAGE_NONPLAYERS | DAMAGE_IN_AIR);
      delay(5);
    }
    
    Sector_SetFade(tag, 0, 0, 0);
  }
}