MiniDoom

src/p_enemy.ml

Implements monster perception, chase movement, attack actions, resurrection, boss triggers, and Icon of Sin spawning.

Package
(global)
Reachable
Yes

Imports

Declarations

_PE_Abs

inline function _PE_Abs(v)

Returns the non-negative magnitude of an enemy movement or distance scalar.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_PE_brain_easy

_PE_brain_easy

Tracks the mutable pe brain easy value used by the p enemy subsystem.

View source

_PE_DropHiddenTarget

function _PE_DropHiddenTarget(actor)

Cancels a monster's lock, movement, and queued attack when its player target has persistent notarget enabled.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `_PE_DropHiddenTarget`.

View source

_PE_HasOtherAliveType

function _PE_HasOtherAliveType(exceptMo, moType)

Scans registered thinkers for another living mobj of the requested type, excluding the supplied actor.

ParameterTypeDefaultDescription
exceptModynamic—Except mo value supplied to `_PE_HasOtherAliveType`.
moTypedynamic—Mo type value supplied to `_PE_HasOtherAliveType`.

View source

_PE_IDiv

inline function _PE_IDiv(a, b)

Divides integer AI values with truncation toward zero, returning zero for invalid operands or a zero divisor.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_PE_IsNoTargetMobj

inline function _PE_IsNoTargetMobj(mo)

Reports whether a player actor is hidden from monster sight and sound acquisition.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

_PE_JunkLineWithTag

inline function _PE_JunkLineWithTag(tag)

Constructs a minimal synthetic linedef carrying a tag for boss-death floor and door event APIs.

ParameterTypeDefaultDescription
tagdynamic—Zone-memory or resource-lifetime tag.

View source

_PE_PainShootSkull

function _PE_PainShootSkull(actor, angle)

Enforces the Lost Soul population cap, validates a spawn point, creates a soul, and starts its charge at the target.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `_PE_PainShootSkull`.
angledynamic—Doom binary-angle measurement.

View source

_PE_ResolveThinkerMobj

inline function _PE_ResolveThinkerMobj(cur)

Resolves a thinker-list node to its registered mobj owner, accepting direct mobj-shaped nodes as fallback.

ParameterTypeDefaultDescription
curdynamic—Cur value supplied to `_PE_ResolveThinkerMobj`.

View source

_PE_StartSound

inline function _PE_StartSound(origin, sfx)

Starts an actor sound when the audio subsystem is linked, otherwise leaves AI state unchanged.

ParameterTypeDefaultDescription
origindynamic—Origin value supplied to `_PE_StartSound`.
sfxdynamic—Sound-effect descriptor to process.

View source

A_BabyMetal

function A_BabyMetal(mo)

Plays the Arachnotron walking sound and continues chase processing.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BossDeath

function A_BossDeath(mo)

After validating map/type, living players, and last-boss status, triggers the canonical tagged floor/door action or exits.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainAwake

function A_BrainAwake(mo)

Collects all boss-target map objects, resets the target cursor, and starts the Icon of Sin wake sound.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainDie

function A_BrainDie(mo)

Completes the Icon of Sin sequence by exiting the level.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainExplode

function A_BrainExplode(mo)

Spawns one randomized explosion/fireball above the Icon of Sin during its death sequence.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainPain

function A_BrainPain(mo)

Plays the Icon of Sin pain sound globally.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainScream

function A_BrainScream(mo)

Spawns a row of randomized explosions above the Icon of Sin and starts its death sound.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BrainSpit

function A_BrainSpit(mo)

Cycles boss targets, applies the easy-skill cadence, and launches a spawn cube timed to its destination.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_BruisAttack

function A_BruisAttack(actor)

Faces the target, performs a Baron/Hell Knight melee strike, or launches a green plasma projectile.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_BruisAttack`.

View source

A_BspiAttack

function A_BspiAttack(actor)

Faces the target and launches an arachnotron plasma projectile.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_BspiAttack`.

View source

A_Chase

function A_Chase(actor)

Turns and pursues the target, retargets when needed, selects melee/missile attacks, and chooses new paths when blocked.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Chase`.

View source

A_CloseShotgun2

function A_CloseShotgun2(player, psp)

Plays the super-shotgun closing sound and immediately re-enters refire logic.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
pspdynamic—Psp value supplied to `A_CloseShotgun2`.

View source

A_CPosAttack

function A_CPosAttack(actor)

Faces the target and fires one chaingunner hitscan with pistol audio, spread, and randomized damage.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_CPosAttack`.

View source

A_CPosRefire

function A_CPosRefire(actor)

Continues chaingunner fire while the random check and target visibility pass, otherwise returns to seestate.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_CPosRefire`.

View source

A_CyberAttack

function A_CyberAttack(actor)

Faces the target and launches one Cyberdemon rocket.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_CyberAttack`.

View source

A_Explode

function A_Explode(thingy)

Applies the standard 128-damage, 128-radius explosion centered on the actor.

ParameterTypeDefaultDescription
thingydynamic—Thingy value supplied to `A_Explode`.

View source

A_FaceTarget

function A_FaceTarget(actor)

Clears ambush, aims exactly at the target, and adds random angular jitter when the target is shadowed.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FaceTarget`.

View source

A_Fall

function A_Fall(actor)

Clears MF_SOLID from a dead actor so corpses no longer block movement.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Fall`.

View source

A_FatAttack1

function A_FatAttack1(actor)

Turns slightly right and launches the first two-projectile Mancubus spread pair.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FatAttack1`.

View source

A_FatAttack2

function A_FatAttack2(actor)

Turns left and launches the second two-projectile Mancubus spread pair.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FatAttack2`.

View source

A_FatAttack3

function A_FatAttack3(actor)

Launches the final Mancubus pair on diverging angles around the target direction.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FatAttack3`.

View source

A_FatRaise

function A_FatRaise(actor)

Faces the target and plays the Mancubus weapon-raise sound before its volley.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FatRaise`.

View source

A_Fire

function A_Fire(actor)

Keeps an Arch-vile fire actor in front of its traced victim while the owner retains line of sight.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Fire`.

View source

A_FireCrackle

function A_FireCrackle(actor)

Plays the Arch-vile flame crackle and updates the fire actor's attachment to its victim.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_FireCrackle`.

View source

A_HeadAttack

function A_HeadAttack(actor)

Faces the target, bites in melee, or launches a cacodemon projectile at range.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_HeadAttack`.

View source

A_Hoof

function A_Hoof(mo)

Plays the Cyberdemon hoofstep and continues chase processing.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_KeenDie

function A_KeenDie(mo)

Makes a Keen corpse non-solid and opens tagged door 666 only after the last living Keen dies.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_LoadShotgun2

function A_LoadShotgun2(player, psp)

Plays the super-shotgun shell-loading sound during the player's reload animation.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
pspdynamic—Psp value supplied to `A_LoadShotgun2`.

View source

A_Look

function A_Look(actor)

Leaves a monster idle until it hears a valid target or sees a player, then plays its wake sound and enters seestate.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Look`.

View source

A_Metal

function A_Metal(mo)

Plays the Spider Mastermind metal step and continues chase processing.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_OpenShotgun2

function A_OpenShotgun2(player, psp)

Plays the super-shotgun breech-opening sound during the player's reload animation.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
pspdynamic—Psp value supplied to `A_OpenShotgun2`.

View source

A_Pain

function A_Pain(actor)

Plays the actor type's configured pain sound.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Pain`.

View source

A_PainAttack

function A_PainAttack(actor)

Faces the target and emits one Lost Soul straight ahead.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_PainAttack`.

View source

A_PainDie

function A_PainDie(actor)

Makes the Pain Elemental corpse non-solid and emits three Lost Souls in separated directions.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_PainDie`.

View source

A_PainShootSkull

function A_PainShootSkull(actor, angle)

Public action wrapper that spawns and launches one Lost Soul at the requested angle.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_PainShootSkull`.
angledynamic—Doom binary-angle measurement.

View source

A_PlayerScream

function A_PlayerScream(mo)

Selects the normal or commercial extreme player death scream from the victim's health and plays it at the corpse.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_PosAttack

function A_PosAttack(actor)

Faces the target, plays the pistol sound, and fires one spread hitscan with randomized bullet damage.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_PosAttack`.

View source

A_SargAttack

function A_SargAttack(actor)

Faces the target and applies the demon's randomized melee bite when in range.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SargAttack`.

View source

A_Scream

function A_Scream(actor)

Selects variant death audio for certain monster families and plays boss deaths at full-volume origin.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Scream`.

View source

A_SkelFist

function A_SkelFist(actor)

Faces the target and applies the Revenant's randomized punch damage when still in melee range.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SkelFist`.

View source

A_SkelMissile

function A_SkelMissile(actor)

Faces the target, launches a Revenant tracer missile, and advances it outward from the actor before homing begins.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SkelMissile`.

View source

A_SkelWhoosh

function A_SkelWhoosh(actor)

Faces the target and plays the Revenant melee swing sound.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SkelWhoosh`.

View source

A_SkullAttack

function A_SkullAttack(actor)

Faces the target, enters MF_SKULLFLY, plays attack audio, and sets charge momentum toward target center.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SkullAttack`.

View source

A_SpawnFly

function A_SpawnFly(mo)

Advances a spawn cube's countdown, teleports in a weighted-random monster at its target, and removes the cube.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_SpawnSound

function A_SpawnSound(mo)

Plays the spawn-cube travel sound and advances its spawn countdown/action.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_SpidRefire

function A_SpidRefire(actor)

Continues Spider Mastermind fire while its randomized stop check and target visibility pass.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SpidRefire`.

View source

A_SPosAttack

function A_SPosAttack(actor)

Faces the target, plays the shotgun sound, and fires three independent spread hitscans.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_SPosAttack`.

View source

A_StartFire

function A_StartFire(actor)

Starts the Arch-vile flame sound and immediately positions its fire actor relative to the victim.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_StartFire`.

View source

A_Tracer

function A_Tracer(actor)

Periodically spawns smoke and steers a Revenant missile's angle and vertical momentum toward its live tracer target.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_Tracer`.

View source

A_TroopAttack

function A_TroopAttack(actor)

Faces the target, performs an imp claw attack in melee, or launches an imp fireball at range.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_TroopAttack`.

View source

A_VileAttack

function A_VileAttack(actor)

Applies the Arch-vile blast, vertical thrust, radius damage, and final fire placement when sight remains clear.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_VileAttack`.

View source

A_VileChase

function A_VileChase(actor)

Searches the next movement block for a raisable corpse, resurrects it when found, otherwise runs normal chase logic.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_VileChase`.

View source

A_VileStart

function A_VileStart(actor)

Plays the Arch-vile's attack-start sound.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_VileStart`.

View source

A_VileTarget

function A_VileTarget(actor)

Faces the victim, spawns the Arch-vile fire actor, and links owner/victim references used by later fire actions.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_VileTarget`.

View source

A_XScream

function A_XScream(actor)

Plays the universal gib/slop sound for an extreme death animation.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `A_XScream`.

View source

braintargeton

braintargeton

Tracks the mutable braintargeton value used by the p enemy subsystem.

View source

braintargets

braintargets

Stores the braintargets collection used by the p enemy subsystem.

View source

corpsehit

corpsehit

Holds the optional corpsehit resource used by the p enemy subsystem.

View source

DI_EAST

const DI_EAST = 0

Defines di east for the p enemy subsystem.

View source

DI_NODIR

const DI_NODIR = 8

Defines di nodir for the p enemy subsystem.

View source

DI_NORTH

const DI_NORTH = 2

Defines di north for the p enemy subsystem.

View source

DI_NORTHEAST

const DI_NORTHEAST = 1

Defines di northeast for the p enemy subsystem.

View source

DI_NORTHWEST

const DI_NORTHWEST = 3

Defines di northwest for the p enemy subsystem.

View source

DI_SOUTH

const DI_SOUTH = 6

Defines di south for the p enemy subsystem.

View source

DI_SOUTHEAST

const DI_SOUTHEAST = 7

Defines di southeast for the p enemy subsystem.

View source

DI_SOUTHWEST

const DI_SOUTHWEST = 5

Defines di southwest for the p enemy subsystem.

View source

DI_WEST

const DI_WEST = 4

Defines di west for the p enemy subsystem.

View source

diags

diags

Stores the diags collection used by the p enemy subsystem.

View source

FATSPREAD

const FATSPREAD = ANG90 >> 3

Defines fatspread for the p enemy subsystem.

View source

numbraintargets

numbraintargets

Tracks the mutable numbraintargets value used by the p enemy subsystem.

View source

opposite

opposite

Stores the opposite collection used by the p enemy subsystem.

View source

P_CheckMeleeRange

function P_CheckMeleeRange(actor)

Requires a live target within radius-adjusted melee distance, modest vertical separation, and line of sight.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_CheckMeleeRange`.

View source

P_CheckMissileRange

function P_CheckMissileRange(actor)

Applies sight, reaction, distance, melee-capability, and randomized aggression rules before a monster fires.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_CheckMissileRange`.

View source

P_ForgetPlayerTarget

function P_ForgetPlayerTarget(playerMo)

Makes active monsters and sector sound emitters immediately forget one newly hidden player.

ParameterTypeDefaultDescription
playerModynamic—Player mo value supplied to `P_ForgetPlayerTarget`.

View source

P_LookForPlayers

function P_LookForPlayers(actor, allaround)

Cycles active living players, enforcing field-of-view unless allaround, and acquires the first visible target.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_LookForPlayers`.
allarounddynamic—Allaround value supplied to `P_LookForPlayers`.

View source

P_Move

function P_Move(actor)

Attempts one movedir step, adjusts floating monsters, and activates crossed special lines when blocked.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_Move`.

View source

P_NewChaseDir

function P_NewChaseDir(actor)

Chooses diagonal or cardinal movement toward the target while avoiding immediate turnaround and blocked directions.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_NewChaseDir`.

View source

P_NoiseAlert

function P_NoiseAlert(target, emmiter)

Starts a new sound-validity flood from the emitter's sector so monsters acquire target as their sound target.

ParameterTypeDefaultDescription
targetdynamic—Target value supplied to `P_NoiseAlert`.
emmiterdynamic—Emmiter value supplied to `P_NoiseAlert`.

View source

P_RecursiveSound

function P_RecursiveSound(sec, soundblocks)

Floods a noise target through open two-sided sectors, crossing at most one sound-blocking line.

ParameterTypeDefaultDescription
secdynamic—Sec value supplied to `P_RecursiveSound`.
soundblocksdynamic—Soundblocks value supplied to `P_RecursiveSound`.

View source

P_TryWalk

function P_TryWalk(actor)

Performs one monster move and randomizes the number of tics before its next chase-direction choice.

ParameterTypeDefaultDescription
actordynamic—Actor value supplied to `P_TryWalk`.

View source

PE_FRACUNIT

const PE_FRACUNIT = 65536

Defines pe fracunit for the p enemy subsystem.

View source

PIT_VileCheck

function PIT_VileCheck(thing)

Tests whether a nearby corpse is raiseable at the Arch-vile destination and records the first valid resurrection candidate.

ParameterTypeDefaultDescription
thingdynamic—World object affected by the operation.

View source

SKULLSPEED

const SKULLSPEED = 20 * PE_FRACUNIT

Defines skullspeed for the p enemy subsystem.

View source

soundtarget

soundtarget

Holds the optional soundtarget resource used by the p enemy subsystem.

View source

TRACEANGLE

const TRACEANGLE = 201326592

Defines traceangle for the p enemy subsystem.

View source

vileobj

vileobj

Holds the optional vileobj resource used by the p enemy subsystem.

View source

viletryx

viletryx

Tracks the mutable viletryx value used by the p enemy subsystem.

View source

viletryy

viletryy

Tracks the mutable viletryy value used by the p enemy subsystem.

View source

xspeed

xspeed

Stores the xspeed collection used by the p enemy subsystem.

View source

yspeed

yspeed

Stores the yspeed collection used by the p enemy subsystem.

View source