37 Interactions & Damage
This tour examines Doom’s pickup, damage, and death mechanics in p_inter.h and p_inter.c, including power-ups, ammo, weapons, health, armor, and combat processing.
37.0.1 Header Overview
p_inter.hcontains declarations likeP_GivePower, used to grant power-up effects to players.
37.0.2 Ammo Logic (P_GiveAmmo)
- Rejects no-ammo types.
- Converts clips to ammo count, handles half-clip and difficulty bonuses.
- Clamps ammo to
maxammo. - Selects weapon when empty and gaining ammo.
- Uses
clipammofor actual unit conversion.
37.0.3 Weapon Logic (P_GiveWeapon)
- Differentiates dropped vs found weapons.
- In netgames, grants ammo/bonuses on first pickup.
- Triggers ownership and weapon switching via
pendingweapon.
37.0.4 Health & Armor (P_GiveBody, P_GiveArmor)
- Health pickups boost HP, some beyond 100%.
- Armor logic compares pickup vs current armor.
37.0.5 Item Pickup (P_TouchSpecialThing)
- Maps sprite types (e.g.,
SPR_BON1,SPR_PSTR,SPR_CLIP) to gameplay effects. - Plays sounds, updates inventory, adjusts ammo or health.
- Handles dropped flags and netgame logic.
37.0.6 Damage Logic (P_DamageMobj)
- Applies damage, knockback (excluding chainsaw), and armor absorption.
- Processes power-ups like invulnerability.
- Skips invalid targets.
37.0.7 Death Logic (P_KillMobj)
- Sets object corpse state (
MF_CORPSE, clearsMF_SHOOTABLE). - Updates player kills, frags.
- Chooses death or extreme-death animations.
- Handles dropped items and player-specific death behavior.
And that’s how Doom handles pickups, damage, and death.