MiniDoom

src/p_pspr.ml

Drives first-person weapon sprites, ammo/state transitions, hitscan attacks, and player-fired projectiles.

Package
(global)
Reachable
Yes

Imports

Declarations

_ensurePsprites

function _ensurePsprites(player)

Ensures every player owns initialized weapon and flash sprite slots without replacing existing state.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

_PS_AmmoIndex

inline function _PS_AmmoIndex(a)

Maps clip, shell, cell, or missile ammo identifiers to the player's four ammo slots.

ParameterTypeDefaultDescription
adynamic—First input operand.

View source

_PS_ANG90_DIV20

const _PS_ANG90_DIV20 = 53687091

Defines ps ang90 div20 for the p pspr subsystem.

View source

_PS_ANG90_DIV21

const _PS_ANG90_DIV21 = 51130563

Defines ps ang90 div21 for the p pspr subsystem.

View source

_PS_ANG90_DIV40

const _PS_ANG90_DIV40 = 26843545

Defines ps ang90 div40 for the p pspr subsystem.

View source

_PS_DiagFireEnabled

function _PS_DiagFireEnabled()

Lazily parses the -diagfire option once and announces whether throttled weapon-fire tracing is enabled.

View source

_PS_DiagFireLog

inline function _PS_DiagFireLog(msg)

Emits bounded diagnostic fire messages for the first 120 events and every 256th event thereafter.

ParameterTypeDefaultDescription
msgdynamic—Msg value supplied to `_PS_DiagFireLog`.

View source

_PS_GetAmmoCount

inline function _PS_GetAmmoCount(player, ammoType)

Reads a player's validated ammo slot as an integer count, accepting legacy boolean entries.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
ammoTypedynamic—Ammo type value supplied to `_PS_GetAmmoCount`.

View source

_PS_HALF_FINEANGLES

const _PS_HALF_FINEANGLES = 4096

Defines ps half fineangles for the p pspr subsystem.

View source

_PS_HasWeapon

inline function _PS_HasWeapon(player, weaponType)

Tests a validated weapon-owned slot without assuming the ownership table is present or complete.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
weaponTypedynamic—Weapon type value supplied to `_PS_HasWeapon`.

View source

_PS_MobjInState

inline function _PS_MobjInState(mo, stnum)

Tests whether an mobj currently references the resolved state for a state identifier.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.
stnumdynamic—Index identifying st.

View source

_PS_PlaySound

inline function _PS_PlaySound(origin, sfx)

Starts a weapon sound when the audio subsystem is linked, otherwise leaves weapon logic unaffected.

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

View source

_PS_PowerIndex

function _PS_PowerIndex(pw)

Maps a player power enum or validated integer to its six-entry powers array slot.

ParameterTypeDefaultDescription
pwdynamic—Pw value supplied to `_PS_PowerIndex`.

View source

_PS_PSpriteInState

inline function _PS_PSpriteInState(psp, stnum)

Tests whether a player-sprite currently references the resolved state for a state identifier.

ParameterTypeDefaultDescription
pspdynamic—Psp value supplied to `_PS_PSpriteInState`.
stnumdynamic—Index identifying st.

View source

_PS_SetAmmoCount

inline function _PS_SetAmmoCount(player, ammoType, value)

Stores a non-negative integer in a validated player ammo slot.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
ammoTypedynamic—Ammo type value supplied to `_PS_SetAmmoCount`.
valuedynamic—Value consumed by the operation.

View source

_PS_StateObjectIndex

function _PS_StateObjectIndex(stobj)

Finds a state object's identity-based index in the global states table, returning -1 if absent.

ParameterTypeDefaultDescription
stobjdynamic—Stobj value supplied to `_PS_StateObjectIndex`.

View source

_PS_SWINGSTEP

const _PS_SWINGSTEP = 117

Defines ps swingstep for the p pspr subsystem.

View source

_PS_WeaponIndex

function _PS_WeaponIndex(w)

Maps either a weapon enum or validated integer to the nine-entry weapon table, returning -1 on failure.

ParameterTypeDefaultDescription
wdynamic—W value supplied to `_PS_WeaponIndex`.

View source

_PS_WeaponInfo

inline function _PS_WeaponInfo(w)

Resolves a validated weapon identifier to its weaponinfo entry.

ParameterTypeDefaultDescription
wdynamic—W value supplied to `_PS_WeaponInfo`.

View source

_psDiagFire

_psDiagFire

Tracks whether ps diag fire is active in the p pspr subsystem.

View source

_psDiagFireCount

_psDiagFireCount

Tracks the mutable ps diag fire count value used by the p pspr subsystem.

View source

_psDiagFireInit

_psDiagFireInit

Tracks whether ps diag fire init is active in the p pspr subsystem.

View source

A_BFGsound

function A_BFGsound(player, psp)

Starts the BFG firing sound at the player's mobj during the weapon animation.

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

View source

A_BFGSpray

function A_BFGSpray(mo)

Traces forty rays across a 90-degree arc, spawning impact effects and applying fifteen-die damage to each target.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

A_CheckReload

function A_CheckReload(player, psp)

Rechecks the current weapon's ammo at a reload state and initiates fallback selection when empty.

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

View source

A_FireBFG

function A_FireBFG(player, psp)

Consumes BFGCELLS cells and spawns the BFG projectile from the player mobj.

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

View source

A_FireCGun

function A_FireCGun(player, psp)

Consumes one bullet, selects the alternating chaingun flash, and fires one refire-sensitive hitscan.

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

View source

A_FireMissile

function A_FireMissile(player, psp)

Consumes one rocket and spawns a player-owned rocket projectile.

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

View source

A_FirePistol

function A_FirePistol(player, psp)

Consumes one bullet, plays the pistol/flash animations, computes auto-aim, and fires one refire-sensitive hitscan.

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

View source

A_FirePlasma

function A_FirePlasma(player, psp)

Consumes one cell, randomly selects one of two flash states, and spawns a plasma projectile.

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

View source

A_FireShotgun

function A_FireShotgun(player, psp)

Consumes one shell and fires seven spread hitscans after starting the shotgun sound and flash.

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

View source

A_FireShotgun2

function A_FireShotgun2(player, psp)

Consumes two shells and fires twenty independently randomized damage, angle, and slope pellets.

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

View source

A_GunFlash

function A_GunFlash(player, psp)

Switches the player mobj to its flash attack pose and starts the ready weapon's muzzle-flash sprite.

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

View source

A_Light0

function A_Light0(player, psp)

Restores the player's weapon-flash extra light to zero.

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

View source

A_Light1

function A_Light1(player, psp)

Sets the player's weapon-flash extra light to level one.

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

View source

A_Light2

function A_Light2(player, psp)

Sets the player's weapon-flash extra light to level two.

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

View source

A_Lower

function A_Lower(player, psp)

Moves the weapon toward the screen bottom, then removes it on death or commits and raises the pending weapon.

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

View source

A_Punch

function A_Punch(player, psp)

Performs a randomized melee hitscan, applies berserk damage scaling, and turns toward a struck target.

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

View source

A_Raise

function A_Raise(player, psp)

Moves the weapon toward WEAPONTOP and enters its ready state when fully raised.

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

View source

A_ReFire

function A_ReFire(player, psp)

Continues held-trigger fire while alive and not switching, otherwise resets refire spread and rechecks ammo.

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

View source

A_Saw

function A_Saw(player, psp)

Performs the chainsaw melee trace, selects idle/hit audio, steers toward a target, and sets the just-attacked flag.

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

View source

A_WeaponReady

function A_WeaponReady(player, psp)

Restores the player idle state, handles attack/switch input, and applies the ready weapon's bobbing offsets.

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

View source

BFGCELLS

const BFGCELLS = 40

Defines bfgcells for the p pspr subsystem.

View source

bulletslope

bulletslope

Tracks the mutable bulletslope value used by the p pspr subsystem.

View source

FF_FRAMEMASK

const FF_FRAMEMASK = 32767

Defines ff framemask for the p pspr subsystem.

View source

FF_FULLBRIGHT

const FF_FULLBRIGHT = 32768

Defines ff fullbright for the p pspr subsystem.

View source

LOWERSPEED

const LOWERSPEED = 393216

Defines lowerspeed for the p pspr subsystem.

View source

NUMPSPRITES

NUMPSPRITES

Tracks the mutable numpsprites value used by the p pspr subsystem.

View source

P_BringUpWeapon

function P_BringUpWeapon(player)

Commits the pending weapon, lowers its sprite origin to WEAPONBOTTOM, clears flash state, and enters its raise state.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_BulletSlope

function P_BulletSlope(mo)

Computes the shared hitscan auto-aim slope, retrying slightly right and left when the forward trace finds no target.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.

View source

P_CalcSwing

function P_CalcSwing(player)

Computes fixed-point weapon sway from player bob amplitude and level-time sine phases.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_CheckAmmo

function P_CheckAmmo(player)

Verifies the ready weapon's per-shot ammo cost or selects a usable fallback and starts lowering the empty weapon.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_DropWeapon

function P_DropWeapon(player)

Starts the ready weapon's lowering state, typically during death or an explicit switch.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_FireWeapon

function P_FireWeapon(player)

After an ammo check, enters attack states and alerts nearby monsters unless persistent notarget is active.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_GunShot

function P_GunShot(mo, accurate)

Fires one randomized-damage hitscan at the cached bullet slope, adding horizontal spread unless accurate is true.

ParameterTypeDefaultDescription
modynamic—Map object affected by the operation.
accuratedynamic—Accurate value supplied to `P_GunShot`.

View source

P_MovePsprites

function P_MovePsprites(player)

Advances weapon/flash state tics and keeps the flash layer aligned to the weapon sprite.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

P_SetPsprite

function P_SetPsprite(player, position, stnum)

Enters a player-sprite state, applies offsets and actions, and immediately follows zero-tic transitions until stable or null.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.
positiondynamic—Position value supplied to `P_SetPsprite`.
stnumdynamic—Index identifying st.

View source

P_SetupPsprites

function P_SetupPsprites(player)

Clears both player-sprite layers and initializes the ready weapon through the normal bring-up transition.

ParameterTypeDefaultDescription
playerdynamic—Player state affected by the operation.

View source

ps_flash

ps_flash

Tracks the mutable ps flash value used by the p pspr subsystem.

View source

ps_weapon

ps_weapon

Tracks the mutable ps weapon value used by the p pspr subsystem.

View source

pspdef_t struct

psprnum_t enum

RAISESPEED

const RAISESPEED = 393216

Defines raisespeed for the p pspr subsystem.

View source

swingx

swingx

Tracks the mutable swingx value used by the p pspr subsystem.

View source

swingy

swingy

Tracks the mutable swingy value used by the p pspr subsystem.

View source

WEAPONBOTTOM

const WEAPONBOTTOM = 8388608

Defines weaponbottom for the p pspr subsystem.

View source

WEAPONTOP

const WEAPONTOP = 2097152

Defines weapontop for the p pspr subsystem.

View source