Mobj

Revision as of 15:06, 15 September 2021 by DragonHawk (talk | contribs) (External links: link to actual id Doom source (no disrespect to Chocolate intended))


Revision as of 15:06, 15 September 2021 by DragonHawk (talk | contribs) (External links: link to actual id Doom source (no disrespect to Chocolate intended))


A mobj, short for map object, is a type of thinker that roughly corresponds to things: players, monsters, items, obstacles and decorations, map spots such as teleport destinations or boss shooter destinations, and so on, are all map objects. Mobjs are also frequently called actors. Code comments present them as such:

//  MapObj data. Map Objects or mobjs are actors, entities,
//  thinker, take-your-pick... anything that moves, acts, or
//  suffers state changes of more or less violent nature.

In the source code, mobjs are represented by the mobjtype_t enum and the mobj_t and mobjinfo_t structures. The order in which the mobj types are declared in the info.h and info.c files corresponds to their DeHackEd number, and most DeHackEd changes consist in altering the values of the mobjinfos' properties. The mobjinfo corresponds to the "class" of a mobj (for example, imp) whereas the mobj corresponds to a particular "instance" of the class (for example, the imp that waits in the exit room of E1M1). The mobjinfo_t structure determines how many hit points a mobj starts with, which states it uses, what its flags are, what sounds it makes, what is its reaction time, its movement speed, and so on. The mobj_t structure stores its current position and momentum, which sector it is in, what is its current state, its current target, where it should respawn in Nightmare! mode, and so on.

Flags

The original Doom source code defined the following mobj flags (as enum mobjflag_t in file p_mobj.h).[1]

Symbolic constant Bit(s) [2] Value (decimal) Value (hex) Source code comment [3]
MF_SPECIAL 0 1 0x1 Call P_SpecialThing when touched.
MF_SOLID 1 2 0x2 Blocks.
MF_SHOOTABLE 2 4 0x4 Can be hit.
MF_NOSECTOR 3 8 0x8 Don't use the sector links (invisible but touchable).
MF_NOBLOCKMAP 4 16 0x10 Don't use the blocklinks (inert but displayable)
MF_AMBUSH 5 32 0x20 Not to be activated by sound, deaf monster.
MF_JUSTHIT 6 64 0x30 Will try to attack right back.
MF_JUSTATTACKED 7 128 0x80 Will take at least one step before attacking.
MF_SPAWNCEILING 8 256 0x100 On level spawning (initial position), hang from ceiling instead of stand on floor.
MF_NOGRAVITY 9 512 0x200 Don't apply gravity (every tic), that is, object will float, keeping current height or changing it actively.
MF_DROPOFF 10 1024 0x400 This allows jumps from high places.
MF_PICKUP 11 2048 0x800 For players, will pick up items.
MF_NOCLIP 12 4096 0x1000 Player cheat. ???
MF_SLIDE 13 8192 0x2000 Player: keep info about sliding along walls.
MF_FLOAT 14 16384 0x4000 Allow moves to any height, no gravity. For active floaters, e.g. cacodemons, pain elementals.
MF_TELEPORT 15 32768 0x8000 Don't cross lines or ??? look at heights on teleport.
MF_MISSILE 16 65536 0x10000 Don't hit same species, explode on block. Player missiles as well as fireballs of various kinds.
MF_DROPPED 17 131072 0x20000 Dropped by a demon, not level spawned. E.g. ammo clips dropped by dying former humans.
MF_SHADOW 18 262144 0x40000 Use fuzzy draw (shadow demons or spectres), temporary player invisibility powerup.
MF_NOBLOOD 19 524288 0x80000 Flag: don't bleed when shot (use puff), barrels and shootable furniture shall not bleed.
MF_CORPSE 20 1048576 0x100000 Don't stop moving halfway off a step, that is, have dead bodies slide down all the way.
MF_INFLOAT 21 2097152 0x200000 Floating to a height for a move, ??? don't auto float to target's height.
MF_COUNTKILL 22 4194304 0x400000 On kill, count this enemy object towards intermission kill total. Happy gathering.
MF_COUNTITEM 23 8388608 0x800000 On picking up, count this item object towards intermission item total.
MF_SKULLFLY 24 16777216 0x1000000 Special handling: skull in flight. Neither a cacodemon nor a missile.
MF_NOTDMATCH 25 33554432 0x2000000 Don't spawn this object in death match mode (e.g. key cards).
MF_TRANSLATION 26, 27 201326592 0xC000000 Player sprites in multiplayer modes are modified using an internal color lookup table for re-indexing. If 0x4 0x8 or 0xc, use a translation table for player colormaps
MF_TRANSSHIFT 1, 3, 4 26 0x1A Hmm ???.

References and notes

  1. File p_mobj.h, dated 1997 December 22, 8966 bytes, MD5 98518af2f9fc2cb5d5d7bde8901e5bb6
  2. Bits are conventionally numbered from zero. The first bit is bit 0, the second bit is bit 1, and so on.
  3. Question marks and other indications of uncertainty are as given in the original code.

External links