p_mobj.h 9.4 KB

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