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