A_CustomPunch

From ZDoom Wiki
Jump to: navigation, search

A_CustomPunch (int damage [, bool norandom [, int flags [, string pufftype, [float range[, float lifesteal]]]]])

Defines a custom punch attack. Damage can either be random or fixed and it is possible to specify whether ammo is used or the puff that is spawned when hitting the wall or a non-bleeding actor. It is also possible to define the maximum distance of the attack and its capacity to steal life from the target.

  • Damage can be a number or expression. If the second argument, norandom, is false then whatever number is given in damage is then the base damage for Doom's native punch damage randomizer whose formula is damage * random(1,8). If you want the number in damage to be the final damage output of the punch, or to use your own custom expression, set norandom to true.
  • Flags The following flags can be combined by using the | character between the constant names:
    • CPF_USEAMMO — Use ammo: the attack drains ammo as indicated by the appropriate Weapon.AmmoUse property.
    • CPF_DAGGER — Act like a PunchDagger: Monsters with the SEESDAGGERS flag are woken up if they see the attack, even if the weapon has the WEAPON.NOALERT flag. This replicates an element of A_JabDagger. Note that using this flag will cause struck enemies to be unconditionally placed into their pain state. (Or Pain.Dagger if they have it defined. (New from 2.7.1))
    • CPF_PULLIN — Pull in: Successful hit pulls the player forward like Doom's Chainsaw or Heretic's Gauntlets. It's important to note that a successful melee attack, regardless of this flag, will always turn the player's facing angle towards their struck target but the player's velocity will only be affected if the flag is set.
    • CPF_NORANDOMPUFFZ — The random z offset given to the puff when spawned is disabled. (New from 2.7.1)
  • PuffType is the puff actor to use when striking a wall or non-bleeding actor. The default is BulletPuff.
  • Range is the range of the attack. The default value is 64 (actually the value is 0, but since a range of 0 would be a worthless attack A_CustomPunch will interpret a range of 0 as 64.)
  • Lifesteal, if positive, is the value used as a factor for giving back the inflicted damage as hit points to the actor using the calling weapon.

Please note that the Berserk powerup will not work with A_CustomPunch. However, you can emulate the effect using A_JumpIfInventory and A_SelectWeapon (see the third example, below).

Examples

Fire:
   KNIF B 4
   KNIF C 4 A_CustomPunch (20,0,0,0,0,0) // 20*random(1,8) since norandom is false, uses no ammo, will 
                                         // spawn BulletPuffs, has a range of 64, and doesn't steal life.
   KNIF D 5
   KNIF C 4
   KNIF B 5 A_ReFire
   goto Ready
 Fire:
   SWRD B 4
   SWRD C 4 A_CustomPunch (random(4,8)*10,1,0,"SwordPuff",96,0) // Uses a custom damage formula, spawns
                                                                // custom puffs, and has a longer range of 96
   SWRD D 4
   SWRD C 6
   SWRD B 6 A_ReFire
   goto Ready

As mentioned above, A_CustomPunch does not work with berserk pack "out of the box". The following example provides a workaround for this using Doom's fist as an example:

ACTOR CustomFist : Fist
{
  States
  {
  Fire:
    PUNG B 4
    TNT1 A 0 A_JumpIfInventory("PowerStrength", 1, "Berserked")
  Normal:
    PUNG C 4 A_CustomPunch(2*random(1, 10), TRUE)
    Goto FireEnd
  Berserked:
    PUNG C 4 A_CustomPunch(20*random(1, 10), TRUE)
  FireEnd:
    PUNG D 5
    PUNG C 4
    PUNG B 5 A_ReFire
    Goto Ready
  }
}

By checking for the presence of the PowerStrength powerup in the player's inventory, which is given by the berserk pack, the damage of the punch can be "adjusted".