49 Item Definitions
This tour examines weapon definitions in DOOM, showing the weaponinfo_t
struct and weaponinfo
array that define ammo types and animation states.
doomdef.h
- Lines 200–210: ammotype_t
enum defines the ammunition types: bullets, shells, rockets, cells, and am_noammo
. - Lines 190–195: NUMWEAPONS
enum defines the total number of weapon slots in the game.
d_items.h
- Lines 34–43: weaponinfo_t
structure defines each weapon’s ammo type and state indices (raise, lower, ready, fire, flash). - Line 45: weaponinfo
array stores all weapon definitions.
d_items.c
- Lines 47–56: Defines the fist weapon using am_noammo
and associated animation states. - Lines 58–66: Defines the pistol weapon using am_clip
, with entries for all animation states.
49.1 Pattern Summary
Each weapon entry in weaponinfo
: - Specifies the ammo type (ammotype_t
) - Defines five state indices: - Raise - Lower - Ready - Attack - Flash
This enables precise animation and ammo control per weapon.
And that’s it! Each weapon in DOOM pairs its ammo type with five animation states that control how it moves and fires.