DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

p_mobj.h (9598B)


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