p_mobj.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // DESCRIPTION:
  18. // Map Objects, MObj, definition and handling.
  19. //
  20. //-----------------------------------------------------------------------------
  21. #ifndef __P_MOBJ__
  22. #define __P_MOBJ__
  23. // Basics.
  24. #include "tables.h"
  25. #include "m_fixed.h"
  26. // We need the thinker_t stuff.
  27. #include "d_think.h"
  28. // We need the WAD data structure for Map things,
  29. // from the THINGS lump.
  30. #include "doomdata.h"
  31. // States are tied to finite states are
  32. // tied to animation frames.
  33. // Needs precompiled tables/data structures.
  34. #include "info.h"
  35. #ifdef __GNUG__
  36. #pragma interface
  37. #endif
  38. //
  39. // NOTES: mobj_t
  40. //
  41. // mobj_ts are used to tell the refresh where to draw an image,
  42. // tell the world simulation when objects are contacted,
  43. // and tell the sound driver how to position a sound.
  44. //
  45. // The refresh uses the next and prev links to follow
  46. // lists of things in sectors as they are being drawn.
  47. // The sprite, frame, and angle elements determine which patch_t
  48. // is used to draw the sprite if it is visible.
  49. // The sprite and frame values are allmost allways set
  50. // from state_t structures.
  51. // The statescr.exe utility generates the states.h and states.c
  52. // files that contain the sprite/frame numbers from the
  53. // statescr.txt source file.
  54. // The xyz origin point represents a point at the bottom middle
  55. // of the sprite (between the feet of a biped).
  56. // This is the default origin position for patch_ts grabbed
  57. // with lumpy.exe.
  58. // A walking creature will have its z equal to the floor
  59. // it is standing on.
  60. //
  61. // The sound code uses the x,y, and subsector fields
  62. // to do stereo positioning of any sound effited by the mobj_t.
  63. //
  64. // The play simulation uses the blocklinks, x,y,z, radius, height
  65. // to determine when mobj_ts are touching each other,
  66. // touching lines in the map, or hit by trace lines (gunshots,
  67. // lines of sight, etc).
  68. // The mobj_t->flags element has various bit flags
  69. // used by the simulation.
  70. //
  71. // Every mobj_t is linked into a single sector
  72. // based on its origin coordinates.
  73. // The subsector_t is found with R_PointInSubsector(x,y),
  74. // and the sector_t can be found with subsector->sector.
  75. // The sector links are only used by the rendering code,
  76. // the play simulation does not care about them at all.
  77. //
  78. // Any mobj_t that needs to be acted upon by something else
  79. // in the play world (block movement, be shot, etc) will also
  80. // need to be linked into the blockmap.
  81. // If the thing has the MF_NOBLOCK flag set, it will not use
  82. // the block links. It can still interact with other things,
  83. // but only as the instigator (missiles will run into other
  84. // things, but nothing can run into a missile).
  85. // Each block in the grid is 128*128 units, and knows about
  86. // every line_t that it contains a piece of, and every
  87. // interactable mobj_t that has its origin contained.
  88. //
  89. // A valid mobj_t is a mobj_t that has the proper subsector_t
  90. // filled in for its xy coordinates and is linked into the
  91. // sector from which the subsector was made, or has the
  92. // MF_NOSECTOR flag set (the subsector_t needs to be valid
  93. // even if MF_NOSECTOR is set), and is linked into a blockmap
  94. // block or has the MF_NOBLOCKMAP flag set.
  95. // Links should only be modified by the P_[Un]SetThingPosition()
  96. // functions.
  97. // Do not change the MF_NO? flags while a thing is valid.
  98. //
  99. // Any questions?
  100. //
  101. //
  102. // Misc. mobj flags
  103. //
  104. typedef enum
  105. {
  106. // Call P_SpecialThing when touched.
  107. MF_SPECIAL = 1,
  108. // Blocks.
  109. MF_SOLID = 2,
  110. // Can be hit.
  111. MF_SHOOTABLE = 4,
  112. // Don't use the sector links (invisible but touchable).
  113. MF_NOSECTOR = 8,
  114. // Don't use the blocklinks (inert but displayable)
  115. MF_NOBLOCKMAP = 16,
  116. // Not to be activated by sound, deaf monster.
  117. MF_AMBUSH = 32,
  118. // Will try to attack right back.
  119. MF_JUSTHIT = 64,
  120. // Will take at least one step before attacking.
  121. MF_JUSTATTACKED = 128,
  122. // On level spawning (initial position),
  123. // hang from ceiling instead of stand on floor.
  124. MF_SPAWNCEILING = 256,
  125. // Don't apply gravity (every tic),
  126. // that is, object will float, keeping current height
  127. // or changing it actively.
  128. MF_NOGRAVITY = 512,
  129. // Movement flags.
  130. // This allows jumps from high places.
  131. MF_DROPOFF = 0x400,
  132. // For players, will pick up items.
  133. MF_PICKUP = 0x800,
  134. // Player cheat. ???
  135. MF_NOCLIP = 0x1000,
  136. // Player: keep info about sliding along walls.
  137. MF_SLIDE = 0x2000,
  138. // Allow moves to any height, no gravity.
  139. // For active floaters, e.g. cacodemons, pain elementals.
  140. MF_FLOAT = 0x4000,
  141. // Don't cross lines
  142. // ??? or look at heights on teleport.
  143. MF_TELEPORT = 0x8000,
  144. // Don't hit same species, explode on block.
  145. // Player missiles as well as fireballs of various kinds.
  146. MF_MISSILE = 0x10000,
  147. // Dropped by a demon, not level spawned.
  148. // E.g. ammo clips dropped by dying former humans.
  149. MF_DROPPED = 0x20000,
  150. // Use fuzzy draw (shadow demons or spectres),
  151. // temporary player invisibility powerup.
  152. MF_SHADOW = 0x40000,
  153. // Flag: don't bleed when shot (use puff),
  154. // barrels and shootable furniture shall not bleed.
  155. MF_NOBLOOD = 0x80000,
  156. // Don't stop moving halfway off a step,
  157. // that is, have dead bodies slide down all the way.
  158. MF_CORPSE = 0x100000,
  159. // Floating to a height for a move, ???
  160. // don't auto float to target's height.
  161. MF_INFLOAT = 0x200000,
  162. // On kill, count this enemy object
  163. // towards intermission kill total.
  164. // Happy gathering.
  165. MF_COUNTKILL = 0x400000,
  166. // On picking up, count this item object
  167. // towards intermission item total.
  168. MF_COUNTITEM = 0x800000,
  169. // Special handling: skull in flight.
  170. // Neither a cacodemon nor a missile.
  171. MF_SKULLFLY = 0x1000000,
  172. // Don't spawn this object
  173. // in death match mode (e.g. key cards).
  174. MF_NOTDMATCH = 0x2000000,
  175. // Player sprites in multiplayer modes are modified
  176. // using an internal color lookup table for re-indexing.
  177. // If 0x4 0x8 or 0xc,
  178. // use a translation table for player colormaps
  179. MF_TRANSLATION = 0xc000000,
  180. // Hmm ???.
  181. MF_TRANSSHIFT = 26
  182. } mobjflag_t;
  183. // Map Object definition.
  184. typedef struct mobj_s
  185. {
  186. // List: thinker links.
  187. thinker_t thinker;
  188. // Info for drawing: position.
  189. fixed_t x;
  190. fixed_t y;
  191. fixed_t z;
  192. // More list: links in sector (if needed)
  193. struct mobj_s* snext;
  194. struct mobj_s* sprev;
  195. //More drawing info: to determine current sprite.
  196. angle_t angle; // orientation
  197. spritenum_t sprite; // used to find patch_t and flip value
  198. int frame; // might be ORed with FF_FULLBRIGHT
  199. // Interaction info, by BLOCKMAP.
  200. // Links in blocks (if needed).
  201. struct mobj_s* bnext;
  202. struct mobj_s* bprev;
  203. struct subsector_s* subsector;
  204. // The closest interval over all contacted Sectors.
  205. fixed_t floorz;
  206. fixed_t ceilingz;
  207. // For movement checking.
  208. fixed_t radius;
  209. fixed_t height;
  210. // Momentums, used to update position.
  211. fixed_t momx;
  212. fixed_t momy;
  213. fixed_t momz;
  214. // If == validcount, already checked.
  215. int validcount;
  216. mobjtype_t type;
  217. mobjinfo_t* info; // &mobjinfo[mobj->type]
  218. int tics; // state tic counter
  219. state_t* state;
  220. int flags;
  221. int health;
  222. // Movement direction, movement generation (zig-zagging).
  223. int movedir; // 0-7
  224. int movecount; // when 0, select a new dir
  225. // Thing being chased/attacked (or NULL),
  226. // also the originator for missiles.
  227. struct mobj_s* target;
  228. // Reaction time: if non 0, don't attack yet.
  229. // Used by player to freeze a bit after teleporting.
  230. int reactiontime;
  231. // If >0, the target will be chased
  232. // no matter what (even if shot)
  233. int threshold;
  234. // Additional info record for player avatars only.
  235. // Only valid if type == MT_PLAYER
  236. struct player_s* player;
  237. // Player number last looked for.
  238. int lastlook;
  239. // For nightmare respawn.
  240. mapthing_t spawnpoint;
  241. // Thing being chased/attacked for tracers.
  242. struct mobj_s* tracer;
  243. } mobj_t;
  244. #endif
  245. //-----------------------------------------------------------------------------
  246. //
  247. // $Log:$
  248. //
  249. //-----------------------------------------------------------------------------