Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
298 | serge | 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 | |||
22 | |||
23 | #ifndef __P_MOBJ__ |
||
24 | #define __P_MOBJ__ |
||
25 | |||
26 | // Basics. |
||
27 | #include "tables.h" |
||
28 | #include "m_fixed.h" |
||
29 | |||
30 | // We need the thinker_t stuff. |
||
31 | #include "d_think.h" |
||
32 | |||
33 | // We need the WAD data structure for Map things, |
||
34 | // from the THINGS lump. |
||
35 | #include "doomdata.h" |
||
36 | |||
37 | // States are tied to finite states are |
||
38 | // tied to animation frames. |
||
39 | // Needs precompiled tables/data structures. |
||
40 | #include "info.h" |
||
41 | |||
42 | |||
43 | |||
44 | #ifdef __GNUG__ |
||
45 | #pragma interface |
||
46 | #endif |
||
47 | |||
48 | |||
49 | |||
50 | // |
||
51 | // NOTES: mobj_t |
||
52 | // |
||
53 | // mobj_ts are used to tell the refresh where to draw an image, |
||
54 | // tell the world simulation when objects are contacted, |
||
55 | // and tell the sound driver how to position a sound. |
||
56 | // |
||
57 | // The refresh uses the next and prev links to follow |
||
58 | // lists of things in sectors as they are being drawn. |
||
59 | // The sprite, frame, and angle elements determine which patch_t |
||
60 | // is used to draw the sprite if it is visible. |
||
61 | // The sprite and frame values are allmost allways set |
||
62 | // from state_t structures. |
||
63 | // The statescr.exe utility generates the states.h and states.c |
||
64 | // files that contain the sprite/frame numbers from the |
||
65 | // statescr.txt source file. |
||
66 | // The xyz origin point represents a point at the bottom middle |
||
67 | // of the sprite (between the feet of a biped). |
||
68 | // This is the default origin position for patch_ts grabbed |
||
69 | // with lumpy.exe. |
||
70 | // A walking creature will have its z equal to the floor |
||
71 | // it is standing on. |
||
72 | // |
||
73 | // The sound code uses the x,y, and subsector fields |
||
74 | // to do stereo positioning of any sound effited by the mobj_t. |
||
75 | // |
||
76 | // The play simulation uses the blocklinks, x,y,z, radius, height |
||
77 | // to determine when mobj_ts are touching each other, |
||
78 | // touching lines in the map, or hit by trace lines (gunshots, |
||
79 | // lines of sight, etc). |
||
80 | // The mobj_t->flags element has various bit flags |
||
81 | // used by the simulation. |
||
82 | // |
||
83 | // Every mobj_t is linked into a single sector |
||
84 | // based on its origin coordinates. |
||
85 | // The subsector_t is found with R_PointInSubsector(x,y), |
||
86 | // and the sector_t can be found with subsector->sector. |
||
87 | // The sector links are only used by the rendering code, |
||
88 | // the play simulation does not care about them at all. |
||
89 | // |
||
90 | // Any mobj_t that needs to be acted upon by something else |
||
91 | // in the play world (block movement, be shot, etc) will also |
||
92 | // need to be linked into the blockmap. |
||
93 | // If the thing has the MF_NOBLOCK flag set, it will not use |
||
94 | // the block links. It can still interact with other things, |
||
95 | // but only as the instigator (missiles will run into other |
||
96 | // things, but nothing can run into a missile). |
||
97 | // Each block in the grid is 128*128 units, and knows about |
||
98 | // every line_t that it contains a piece of, and every |
||
99 | // interactable mobj_t that has its origin contained. |
||
100 | // |
||
101 | // A valid mobj_t is a mobj_t that has the proper subsector_t |
||
102 | // filled in for its xy coordinates and is linked into the |
||
103 | // sector from which the subsector was made, or has the |
||
104 | // MF_NOSECTOR flag set (the subsector_t needs to be valid |
||
105 | // even if MF_NOSECTOR is set), and is linked into a blockmap |
||
106 | // block or has the MF_NOBLOCKMAP flag set. |
||
107 | // Links should only be modified by the P_[Un]SetThingPosition() |
||
108 | // functions. |
||
109 | // Do not change the MF_NO? flags while a thing is valid. |
||
110 | // |
||
111 | // Any questions? |
||
112 | // |
||
113 | |||
114 | // |
||
115 | // Misc. mobj flags |
||
116 | // |
||
117 | typedef enum |
||
118 | { |
||
119 | // Call P_SpecialThing when touched. |
||
120 | MF_SPECIAL = 1, |
||
121 | // Blocks. |
||
122 | MF_SOLID = 2, |
||
123 | // Can be hit. |
||
124 | MF_SHOOTABLE = 4, |
||
125 | // Don't use the sector links (invisible but touchable). |
||
126 | MF_NOSECTOR = 8, |
||
127 | // Don't use the blocklinks (inert but displayable) |
||
128 | MF_NOBLOCKMAP = 16, |
||
129 | |||
130 | // Not to be activated by sound, deaf monster. |
||
131 | MF_AMBUSH = 32, |
||
132 | // Will try to attack right back. |
||
133 | MF_JUSTHIT = 64, |
||
134 | // Will take at least one step before attacking. |
||
135 | MF_JUSTATTACKED = 128, |
||
136 | // On level spawning (initial position), |
||
137 | // hang from ceiling instead of stand on floor. |
||
138 | MF_SPAWNCEILING = 256, |
||
139 | // Don't apply gravity (every tic), |
||
140 | // that is, object will float, keeping current height |
||
141 | // or changing it actively. |
||
142 | MF_NOGRAVITY = 512, |
||
143 | |||
144 | // Movement flags. |
||
145 | // This allows jumps from high places. |
||
146 | MF_DROPOFF = 0x400, |
||
147 | // For players, will pick up items. |
||
148 | MF_PICKUP = 0x800, |
||
149 | // Player cheat. ??? |
||
150 | MF_NOCLIP = 0x1000, |
||
151 | // Player: keep info about sliding along walls. |
||
152 | MF_SLIDE = 0x2000, |
||
153 | // Allow moves to any height, no gravity. |
||
154 | // For active floaters, e.g. cacodemons, pain elementals. |
||
155 | MF_FLOAT = 0x4000, |
||
156 | // Don't cross lines |
||
157 | // ??? or look at heights on teleport. |
||
158 | MF_TELEPORT = 0x8000, |
||
159 | // Don't hit same species, explode on block. |
||
160 | // Player missiles as well as fireballs of various kinds. |
||
161 | MF_MISSILE = 0x10000, |
||
162 | // Dropped by a demon, not level spawned. |
||
163 | // E.g. ammo clips dropped by dying former humans. |
||
164 | MF_DROPPED = 0x20000, |
||
165 | // Use fuzzy draw (shadow demons or spectres), |
||
166 | // temporary player invisibility powerup. |
||
167 | MF_SHADOW = 0x40000, |
||
168 | // Flag: don't bleed when shot (use puff), |
||
169 | // barrels and shootable furniture shall not bleed. |
||
170 | MF_NOBLOOD = 0x80000, |
||
171 | // Don't stop moving halfway off a step, |
||
172 | // that is, have dead bodies slide down all the way. |
||
173 | MF_CORPSE = 0x100000, |
||
174 | // Floating to a height for a move, ??? |
||
175 | // don't auto float to target's height. |
||
176 | MF_INFLOAT = 0x200000, |
||
177 | |||
178 | // On kill, count this enemy object |
||
179 | // towards intermission kill total. |
||
180 | // Happy gathering. |
||
181 | MF_COUNTKILL = 0x400000, |
||
182 | |||
183 | // On picking up, count this item object |
||
184 | // towards intermission item total. |
||
185 | MF_COUNTITEM = 0x800000, |
||
186 | |||
187 | // Special handling: skull in flight. |
||
188 | // Neither a cacodemon nor a missile. |
||
189 | MF_SKULLFLY = 0x1000000, |
||
190 | |||
191 | // Don't spawn this object |
||
192 | // in death match mode (e.g. key cards). |
||
193 | MF_NOTDMATCH = 0x2000000, |
||
194 | |||
195 | // Player sprites in multiplayer modes are modified |
||
196 | // using an internal color lookup table for re-indexing. |
||
197 | // If 0x4 0x8 or 0xc, |
||
198 | // use a translation table for player colormaps |
||
199 | MF_TRANSLATION = 0xc000000, |
||
200 | // Hmm ???. |
||
201 | MF_TRANSSHIFT = 26 |
||
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 | } mobj_t; |
||
287 | |||
288 | |||
289 | |||
290 | #endif |
||
291 | //----------------------------------------------------------------------------- |
||
292 | // |
||
293 | // $Log:$ |
||
294 | // |
||
295 | //----------------------------------------------------------------------------- |