A_CustomMeleeAttack

From ZDoom Wiki
Jump to navigation Jump to search

Actor

void A_CustomMeleeAttack(int damage = 0, sound meleesound = "", sound misssound = "", name damagetype = "none", bool bleed = true)

Usage

A customizable melee attack for monsters. Causes the actor to execute a melee attack with the specified parameters.

The function calls A_FaceTarget and checks if the caller's target is within melee range, damaging it if it is and playing meleesound. If the target is outside melee range, however, misssound sound is played and no damage is dealt to the target. If there is no target, the function does nothing when it is called.

Both meleesound and missound are played on the "weapon" channel (CHAN_WEAPON).

Parameters

  • int damage
The amount of damage to perform. This can be an exact value or an expression. Default is 0.
  • sound meleesound
The sound to make when the melee successfully hits. Default is "", for no sound.
  • sound misssound
The sound to make when the melee attack misses. Default is "", for no sound.
  • name damagetype
The type of damage to do. Default is "Melee".
  • bool bleed
If true, target bleeds when hit. This only produces blood decals on nearby walls. Default is true.

Examples

This is the revenant's melee sequence:

 Melee:
   SKEL G 1 A_FaceTarget;
   SKEL G 6 A_SkelWhoosh;
   SKEL H 6 A_FaceTarget;
   SKEL I 6 A_SkelFist;
   goto See;

The same sequence could be simulated this way:

 Melee:
   SKEL G 1 A_FaceTarget;
   SKEL G 6 A_SkelWhoosh;
   SKEL H 6 A_FaceTarget;
   SKEL I 6 A_CustomMeleeAttack(random(1, 10) * 6, "skeleton/melee"); // Does not make any sound when missing