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 116 // Blocks. 117 MF_SOLID = 2, 118 119 // Can be hit. 120 MF_SHOOTABLE = 4, 121 122 // Don't use the sector links (invisible but touchable). 123 MF_NOSECTOR = 8, 124 125 // Don't use the blocklinks (inert but displayable) 126 MF_NOBLOCKMAP = 16, 127 128 // villsa [STRIFE] Stand around until alerted 129 MF_STAND = 32, 130 131 // Will try to attack right back. 132 MF_JUSTHIT = 64, 133 134 // Will take at least one step before attacking. 135 MF_JUSTATTACKED = 128, 136 137 // On level spawning (initial position), 138 // hang from ceiling instead of stand on floor. 139 MF_SPAWNCEILING = 256, 140 141 // Don't apply gravity (every tic), 142 // that is, object will float, keeping current height 143 // or changing it actively. 144 MF_NOGRAVITY = 512, 145 146 // Movement flags. 147 // This allows jumps from high places. 148 MF_DROPOFF = 0x400, 149 150 // villsa [STRIFE] For players, count as quest item 151 MF_GIVEQUEST = 0x800, 152 153 // Player cheat. ??? 154 MF_NOCLIP = 0x1000, 155 156 // villsa [STRIFE] are feet clipped into water/slude floor? 157 MF_FEETCLIPPED = 0x2000, 158 159 // Allow moves to any height, no gravity. 160 // For active floaters, e.g. cacodemons, pain elementals. 161 MF_FLOAT = 0x4000, 162 163 // villsa [STRIFE] can NPC talk? 164 MF_NODIALOG = 0x8000, 165 166 // Don't hit same species, explode on block. 167 // Player missiles as well as fireballs of various kinds. 168 MF_MISSILE = 0x10000, 169 170 // Dropped by a demon, not level spawned. 171 // E.g. ammo clips dropped by dying former humans. 172 MF_DROPPED = 0x20000, 173 174 // Use fuzzy draw (shadow demons or spectres), 175 // temporary player invisibility powerup. 176 MF_SHADOW = 0x40000, 177 178 // Flag: don't bleed when shot (use puff), 179 // barrels and shootable furniture shall not bleed. 180 MF_NOBLOOD = 0x80000, 181 182 // Don't stop moving halfway off a step, 183 // that is, have dead bodies slide down all the way. 184 MF_CORPSE = 0x100000, 185 186 // Floating to a height for a move, ??? 187 // don't auto float to target's height. 188 MF_INFLOAT = 0x200000, 189 190 // On kill, count this enemy object 191 // towards intermission kill total. 192 // Happy gathering. 193 MF_COUNTKILL = 0x400000, 194 195 // Not to be activated by sound, deaf monster. 196 MF_AMBUSH = 0x800000, 197 198 // villsa [STRIFE] flag used for bouncing projectiles 199 MF_BOUNCE = 0x1000000, 200 201 // Don't spawn this object 202 // in death match mode (e.g. key cards). 203 MF_NOTDMATCH = 0x2000000, 204 205 // villsa [STRIFE] friendly towards player with matching flag 206 MF_ALLY = 0x4000000, 207 208 // villsa [STRIFE] 75% or 25% transparency? -- NEEDS VERIFICATION 209 MF_MVIS = 0x8000000, 210 211 // villsa [STRIFE] color translation 212 MF_COLORSWAP1 = 0x10000000, 213 214 // villsa [STRIFE] color translation 215 MF_COLORSWAP2 = 0x20000000, 216 217 // villsa [STRIFE] color translation 218 MF_COLORSWAP3 = 0x40000000, 219 220 // villsa [STRIFE] spectral entity, only damaged by spectral missiles 221 MF_SPECTRAL = 0x80000000, 222 223 // Player sprites in multiplayer modes are modified 224 // using an internal color lookup table for re-indexing. 225 // haleyjd 09/06/10: redid for Strife translations 226 MF_TRANSLATION = (MF_COLORSWAP1|MF_COLORSWAP2|MF_COLORSWAP3), 227 228 // Turns 0x10000000 into 0x01 to get a translation index. 229 // villsa [STRIFE] change from 26 to 28 230 MF_TRANSSHIFT = 28 231 232 } mobjflag_t; 233 234 235 // Map Object definition. 236 // 237 // [STRIFE]: Amazingly, only one modification was made to mobj_t over DOOM 238 // 1.666, and that was the addition of the single-byte allegiance field for 239 // tracking with which player friendly monsters are allied. 240 // 241 typedef struct mobj_s 242 { 243 // List: thinker links. 244 thinker_t thinker; 245 246 // Info for drawing: position. 247 fixed_t x; 248 fixed_t y; 249 fixed_t z; 250 251 // More list: links in sector (if needed) 252 struct mobj_s* snext; 253 struct mobj_s* sprev; 254 255 //More drawing info: to determine current sprite. 256 angle_t angle; // orientation 257 spritenum_t sprite; // used to find patch_t and flip value 258 int frame; // might be ORed with FF_FULLBRIGHT 259 260 // Interaction info, by BLOCKMAP. 261 // Links in blocks (if needed). 262 struct mobj_s* bnext; 263 struct mobj_s* bprev; 264 265 struct subsector_s* subsector; 266 267 // The closest interval over all contacted Sectors. 268 fixed_t floorz; 269 fixed_t ceilingz; 270 271 // For movement checking. 272 fixed_t radius; 273 fixed_t height; 274 275 // Momentums, used to update position. 276 fixed_t momx; 277 fixed_t momy; 278 fixed_t momz; 279 280 // If == validcount, already checked. 281 int validcount; 282 283 mobjtype_t type; 284 mobjinfo_t* info; // &mobjinfo[mobj->type] 285 286 int tics; // state tic counter 287 state_t* state; 288 int flags; 289 int health; 290 291 // Movement direction, movement generation (zig-zagging). 292 int movedir; // 0-7 293 int movecount; // when 0, select a new dir 294 295 // Thing being chased/attacked (or NULL), 296 // also the originator for missiles. 297 struct mobj_s* target; 298 299 // Reaction time: if non 0, don't attack yet. 300 // Used by player to freeze a bit after teleporting. 301 int reactiontime; 302 303 // If >0, the target will be chased 304 // no matter what (even if shot) 305 int threshold; 306 307 // Additional info record for player avatars only. 308 // Only valid if type == MT_PLAYER 309 struct player_s* player; 310 311 // Player number last looked for. 312 int lastlook; 313 314 // For nightmare respawn. 315 mapthing_t spawnpoint; 316 317 // Thing being chased/attacked for tracers. 318 struct mobj_s* tracer; 319 320 // [STRIFE] haleyjd 09/05/10: 321 // * In multiplayer this stores allegiance, for friends and teleport beacons 322 // * In single-player this tracks dialog state. 323 byte miscdata; 324 325 } mobj_t; 326 327 // haleyjd [STRIFE] Exported 328 void P_CheckMissileSpawn (mobj_t* th); 329 330 #endif 331