A_MonsterMeleeAttack
From DoomWiki.org
A_MonsterMeleeAttack(damagebase, damagedice, sound, range) is a generic monster melee attack function that is part of the MBF21 specification. It has four parameters, using the values provided in the "Args" fields as arguments.
The first argument sets the base damage for the attack, which defaults to 3 if not provided. The second argument defines the damage multiplier, which will default to 8 if not set. The damage is calculated using the following formula:
damage = (damagebase * random(1, damagedice))
The third argument determines the sound that is played if the attack connects with a target; if not provided, no sound will be played. The fourth argument defines the maximum range of the attack in map units; if not set, the default melee range of the calling actor will be used instead (which can be customized in the "melee range" field in the "Thing" definition for the calling actor). The fourth argument has to be provided in fixed point, meaning the intended value has to be multiplied by 65536 (FRACUNIT), while all other arguments use integer values instead, meaning the intended values can be input as is. Note also that the function will add the target's radius minus 20 to the specified melee range, mirroring the code of Doom's native monster melee attack functions. However, this means the actual melee range is 20 map units shorter than the value specified as the fourth argument. (So in order to emulate the default melee range of 64 map units one would have to input a value of 84 * FRACUNIT.)
A_MonsterMeleeAttack
also calls the A_FaceTarget function, ensuring the calling actor is facing its target when the melee attack is executed.
Example[edit]
The following is an example of how to set the A_MonsterMeleeAttack
code pointer in a DeHackEd file using BEX syntax:
Frame 487 Args1 = 4 Args2 = 10 Args3 = 0 Args4 = 5505024 [CODEPTR] FRAME 487 = MonsterMeleeAttack
Or using DECOHack syntax:
state 487 { SARG G 8 A_MonsterMeleeAttack(4, 10, "", 84) goto See }
In the above example, A_MonsterMeleeAttack
is used to replace the A_SargAttack code pointer in the demon's attack animation. (No sound needs to be called since the demon's bite sound is its regular "attack sound" that is hardcoded to be played on the first state of a monster's melee attack sequence.)
External links[edit]
- A_MonsterMeleeAttack in the DSDA-Doom source code, hosted on GitHub.
- MBF21 specification, hosted on GitHub.