# _ensurePsprites
function _ensurePsprites(player)Ensures every player owns initialized weapon and flash sprite slots without replacing existing state.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
src/p_pspr.mlDrives first-person weapon sprites, ammo/state transitions, hitscan attacks, and player-fired projectiles.
d_event.ml → src/d_event.mldoomdef.ml → src/doomdef.mldoomstat.ml → src/doomstat.mlinfo.ml → src/info.mlm_argv.ml → src/m_argv.mlm_fixed.ml → src/m_fixed.mlm_random.ml → src/m_random.mlp_enemy.ml → src/p_enemy.mlp_inter.ml → src/p_inter.mlp_local.ml → src/p_local.mlp_map.ml → src/p_map.mlp_mobj.ml → src/p_mobj.mlp_pspr.ml → src/p_pspr.mlr_main.ml → src/r_main.mls_sound.ml → src/s_sound.mlsounds.ml → src/sounds.mltables.ml → src/tables.mlfunction _ensurePsprites(player)Ensures every player owns initialized weapon and flash sprite slots without replacing existing state.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
inline function _PS_AmmoIndex(a)Maps clip, shell, cell, or missile ammo identifiers to the player's four ammo slots.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | dynamic | — | First input operand. |
const _PS_ANG90_DIV20 = 53687091Defines ps ang90 div20 for the p pspr subsystem.
const _PS_ANG90_DIV21 = 51130563Defines ps ang90 div21 for the p pspr subsystem.
const _PS_ANG90_DIV40 = 26843545Defines ps ang90 div40 for the p pspr subsystem.
function _PS_DiagFireEnabled()Lazily parses the -diagfire option once and announces whether throttled weapon-fire tracing is enabled.
inline function _PS_DiagFireLog(msg)Emits bounded diagnostic fire messages for the first 120 events and every 256th event thereafter.
| Parameter | Type | Default | Description |
|---|---|---|---|
msg | dynamic | — | Msg value supplied to `_PS_DiagFireLog`. |
inline function _PS_GetAmmoCount(player, ammoType)Reads a player's validated ammo slot as an integer count, accepting legacy boolean entries.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
ammoType | dynamic | — | Ammo type value supplied to `_PS_GetAmmoCount`. |
const _PS_HALF_FINEANGLES = 4096Defines ps half fineangles for the p pspr subsystem.
inline function _PS_HasWeapon(player, weaponType)Tests a validated weapon-owned slot without assuming the ownership table is present or complete.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
weaponType | dynamic | — | Weapon type value supplied to `_PS_HasWeapon`. |
inline function _PS_MobjInState(mo, stnum)Tests whether an mobj currently references the resolved state for a state identifier.
| Parameter | Type | Default | Description |
|---|---|---|---|
mo | dynamic | — | Map object affected by the operation. |
stnum | dynamic | — | Index identifying st. |
inline function _PS_PlaySound(origin, sfx)Starts a weapon sound when the audio subsystem is linked, otherwise leaves weapon logic unaffected.
| Parameter | Type | Default | Description |
|---|---|---|---|
origin | dynamic | — | Origin value supplied to `_PS_PlaySound`. |
sfx | dynamic | — | Sound-effect descriptor to process. |
function _PS_PowerIndex(pw)Maps a player power enum or validated integer to its six-entry powers array slot.
| Parameter | Type | Default | Description |
|---|---|---|---|
pw | dynamic | — | Pw value supplied to `_PS_PowerIndex`. |
inline function _PS_PSpriteInState(psp, stnum)Tests whether a player-sprite currently references the resolved state for a state identifier.
| Parameter | Type | Default | Description |
|---|---|---|---|
psp | dynamic | — | Psp value supplied to `_PS_PSpriteInState`. |
stnum | dynamic | — | Index identifying st. |
inline function _PS_SetAmmoCount(player, ammoType, value)Stores a non-negative integer in a validated player ammo slot.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
ammoType | dynamic | — | Ammo type value supplied to `_PS_SetAmmoCount`. |
value | dynamic | — | Value consumed by the operation. |
function _PS_StateObjectIndex(stobj)Finds a state object's identity-based index in the global states table, returning -1 if absent.
| Parameter | Type | Default | Description |
|---|---|---|---|
stobj | dynamic | — | Stobj value supplied to `_PS_StateObjectIndex`. |
const _PS_SWINGSTEP = 117Defines ps swingstep for the p pspr subsystem.
function _PS_WeaponIndex(w)Maps either a weapon enum or validated integer to the nine-entry weapon table, returning -1 on failure.
| Parameter | Type | Default | Description |
|---|---|---|---|
w | dynamic | — | W value supplied to `_PS_WeaponIndex`. |
inline function _PS_WeaponInfo(w)Resolves a validated weapon identifier to its weaponinfo entry.
| Parameter | Type | Default | Description |
|---|---|---|---|
w | dynamic | — | W value supplied to `_PS_WeaponInfo`. |
_psDiagFireTracks whether ps diag fire is active in the p pspr subsystem.
_psDiagFireCountTracks the mutable ps diag fire count value used by the p pspr subsystem.
_psDiagFireInitTracks whether ps diag fire init is active in the p pspr subsystem.
function A_BFGsound(player, psp)Starts the BFG firing sound at the player's mobj during the weapon animation.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_BFGsound`. |
function A_BFGSpray(mo)Traces forty rays across a 90-degree arc, spawning impact effects and applying fifteen-die damage to each target.
| Parameter | Type | Default | Description |
|---|---|---|---|
mo | dynamic | — | Map object affected by the operation. |
function A_CheckReload(player, psp)Rechecks the current weapon's ammo at a reload state and initiates fallback selection when empty.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_CheckReload`. |
function A_FireBFG(player, psp)Consumes BFGCELLS cells and spawns the BFG projectile from the player mobj.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FireBFG`. |
function A_FireCGun(player, psp)Consumes one bullet, selects the alternating chaingun flash, and fires one refire-sensitive hitscan.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FireCGun`. |
function A_FireMissile(player, psp)Consumes one rocket and spawns a player-owned rocket projectile.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FireMissile`. |
function A_FirePistol(player, psp)Consumes one bullet, plays the pistol/flash animations, computes auto-aim, and fires one refire-sensitive hitscan.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FirePistol`. |
function A_FirePlasma(player, psp)Consumes one cell, randomly selects one of two flash states, and spawns a plasma projectile.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FirePlasma`. |
function A_FireShotgun(player, psp)Consumes one shell and fires seven spread hitscans after starting the shotgun sound and flash.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FireShotgun`. |
function A_FireShotgun2(player, psp)Consumes two shells and fires twenty independently randomized damage, angle, and slope pellets.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_FireShotgun2`. |
function A_GunFlash(player, psp)Switches the player mobj to its flash attack pose and starts the ready weapon's muzzle-flash sprite.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_GunFlash`. |
function A_Light0(player, psp)Restores the player's weapon-flash extra light to zero.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Light0`. |
function A_Light1(player, psp)Sets the player's weapon-flash extra light to level one.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Light1`. |
function A_Light2(player, psp)Sets the player's weapon-flash extra light to level two.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Light2`. |
function A_Lower(player, psp)Moves the weapon toward the screen bottom, then removes it on death or commits and raises the pending weapon.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Lower`. |
function A_Punch(player, psp)Performs a randomized melee hitscan, applies berserk damage scaling, and turns toward a struck target.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Punch`. |
function A_Raise(player, psp)Moves the weapon toward WEAPONTOP and enters its ready state when fully raised.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Raise`. |
function A_ReFire(player, psp)Continues held-trigger fire while alive and not switching, otherwise resets refire spread and rechecks ammo.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_ReFire`. |
function A_Saw(player, psp)Performs the chainsaw melee trace, selects idle/hit audio, steers toward a target, and sets the just-attacked flag.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_Saw`. |
function A_WeaponReady(player, psp)Restores the player idle state, handles attack/switch input, and applies the ready weapon's bobbing offsets.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
psp | dynamic | — | Psp value supplied to `A_WeaponReady`. |
const BFGCELLS = 40Defines bfgcells for the p pspr subsystem.
bulletslopeTracks the mutable bulletslope value used by the p pspr subsystem.
const FF_FRAMEMASK = 32767Defines ff framemask for the p pspr subsystem.
const FF_FULLBRIGHT = 32768Defines ff fullbright for the p pspr subsystem.
const LOWERSPEED = 393216Defines lowerspeed for the p pspr subsystem.
NUMPSPRITESTracks the mutable numpsprites value used by the p pspr subsystem.
function P_BringUpWeapon(player)Commits the pending weapon, lowers its sprite origin to WEAPONBOTTOM, clears flash state, and enters its raise state.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
function P_BulletSlope(mo)Computes the shared hitscan auto-aim slope, retrying slightly right and left when the forward trace finds no target.
| Parameter | Type | Default | Description |
|---|---|---|---|
mo | dynamic | — | Map object affected by the operation. |
function P_CalcSwing(player)Computes fixed-point weapon sway from player bob amplitude and level-time sine phases.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
function P_CheckAmmo(player)Verifies the ready weapon's per-shot ammo cost or selects a usable fallback and starts lowering the empty weapon.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
function P_DropWeapon(player)Starts the ready weapon's lowering state, typically during death or an explicit switch.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
function P_FireWeapon(player)After an ammo check, enters attack states and alerts nearby monsters unless persistent notarget is active.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
function P_GunShot(mo, accurate)Fires one randomized-damage hitscan at the cached bullet slope, adding horizontal spread unless accurate is true.
| Parameter | Type | Default | Description |
|---|---|---|---|
mo | dynamic | — | Map object affected by the operation. |
accurate | dynamic | — | Accurate value supplied to `P_GunShot`. |
function P_MovePsprites(player)Advances weapon/flash state tics and keeps the flash layer aligned to the weapon sprite.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
position | dynamic | — | Position value supplied to `P_SetPsprite`. |
stnum | dynamic | — | Index identifying st. |
function P_SetupPsprites(player)Clears both player-sprite layers and initializes the ready weapon through the normal bring-up transition.
| Parameter | Type | Default | Description |
|---|---|---|---|
player | dynamic | — | Player state affected by the operation. |
ps_flashTracks the mutable ps flash value used by the p pspr subsystem.
ps_weaponTracks the mutable ps weapon value used by the p pspr subsystem.
pspdef_t struct
psprnum_t enum
const RAISESPEED = 393216Defines raisespeed for the p pspr subsystem.
swingxTracks the mutable swingx value used by the p pspr subsystem.
swingyTracks the mutable swingy value used by the p pspr subsystem.
const WEAPONBOTTOM = 8388608Defines weaponbottom for the p pspr subsystem.
const WEAPONTOP = 2097152Defines weapontop for the p pspr subsystem.