diff options
Diffstat (limited to 'src/p_mobj.h')
-rw-r--r-- | src/p_mobj.h | 403 |
1 files changed, 403 insertions, 0 deletions
diff --git a/src/p_mobj.h b/src/p_mobj.h new file mode 100644 index 0000000..ccd66f3 --- /dev/null +++ b/src/p_mobj.h | |||
@@ -0,0 +1,403 @@ | |||
1 | /* Emacs style mode select -*- C++ -*- | ||
2 | *----------------------------------------------------------------------------- | ||
3 | * | ||
4 | * | ||
5 | * PrBoom: a Doom port merged with LxDoom and LSDLDoom | ||
6 | * based on BOOM, a modified and improved DOOM engine | ||
7 | * Copyright (C) 1999 by | ||
8 | * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman | ||
9 | * Copyright (C) 1999-2000 by | ||
10 | * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze | ||
11 | * Copyright 2005, 2006 by | ||
12 | * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
27 | * 02111-1307, USA. | ||
28 | * | ||
29 | * DESCRIPTION: | ||
30 | * Map Objects, MObj, definition and handling. | ||
31 | * | ||
32 | *-----------------------------------------------------------------------------*/ | ||
33 | |||
34 | #ifndef __P_MOBJ__ | ||
35 | #define __P_MOBJ__ | ||
36 | |||
37 | // Basics. | ||
38 | #include "tables.h" | ||
39 | #include "m_fixed.h" | ||
40 | |||
41 | // We need the thinker_t stuff. | ||
42 | #include "d_think.h" | ||
43 | |||
44 | // We need the WAD data structure for Map things, | ||
45 | // from the THINGS lump. | ||
46 | #include "doomdata.h" | ||
47 | |||
48 | // States are tied to finite states are | ||
49 | // tied to animation frames. | ||
50 | // Needs precompiled tables/data structures. | ||
51 | #include "info.h" | ||
52 | |||
53 | // | ||
54 | // NOTES: mobj_t | ||
55 | // | ||
56 | // mobj_ts are used to tell the refresh where to draw an image, | ||
57 | // tell the world simulation when objects are contacted, | ||
58 | // and tell the sound driver how to position a sound. | ||
59 | // | ||
60 | // The refresh uses the next and prev links to follow | ||
61 | // lists of things in sectors as they are being drawn. | ||
62 | // The sprite, frame, and angle elements determine which patch_t | ||
63 | // is used to draw the sprite if it is visible. | ||
64 | // The sprite and frame values are allmost allways set | ||
65 | // from state_t structures. | ||
66 | // The statescr.exe utility generates the states.h and states.c | ||
67 | // files that contain the sprite/frame numbers from the | ||
68 | // statescr.txt source file. | ||
69 | // The xyz origin point represents a point at the bottom middle | ||
70 | // of the sprite (between the feet of a biped). | ||
71 | // This is the default origin position for patch_ts grabbed | ||
72 | // with lumpy.exe. | ||
73 | // A walking creature will have its z equal to the floor | ||
74 | // it is standing on. | ||
75 | // | ||
76 | // The sound code uses the x,y, and subsector fields | ||
77 | // to do stereo positioning of any sound effited by the mobj_t. | ||
78 | // | ||
79 | // The play simulation uses the blocklinks, x,y,z, radius, height | ||
80 | // to determine when mobj_ts are touching each other, | ||
81 | // touching lines in the map, or hit by trace lines (gunshots, | ||
82 | // lines of sight, etc). | ||
83 | // The mobj_t->flags element has various bit flags | ||
84 | // used by the simulation. | ||
85 | // | ||
86 | // Every mobj_t is linked into a single sector | ||
87 | // based on its origin coordinates. | ||
88 | // The subsector_t is found with R_PointInSubsector(x,y), | ||
89 | // and the sector_t can be found with subsector->sector. | ||
90 | // The sector links are only used by the rendering code, | ||
91 | // the play simulation does not care about them at all. | ||
92 | // | ||
93 | // Any mobj_t that needs to be acted upon by something else | ||
94 | // in the play world (block movement, be shot, etc) will also | ||
95 | // need to be linked into the blockmap. | ||
96 | // If the thing has the MF_NOBLOCK flag set, it will not use | ||
97 | // the block links. It can still interact with other things, | ||
98 | // but only as the instigator (missiles will run into other | ||
99 | // things, but nothing can run into a missile). | ||
100 | // Each block in the grid is 128*128 units, and knows about | ||
101 | // every line_t that it contains a piece of, and every | ||
102 | // interactable mobj_t that has its origin contained. | ||
103 | // | ||
104 | // A valid mobj_t is a mobj_t that has the proper subsector_t | ||
105 | // filled in for its xy coordinates and is linked into the | ||
106 | // sector from which the subsector was made, or has the | ||
107 | // MF_NOSECTOR flag set (the subsector_t needs to be valid | ||
108 | // even if MF_NOSECTOR is set), and is linked into a blockmap | ||
109 | // block or has the MF_NOBLOCKMAP flag set. | ||
110 | // Links should only be modified by the P_[Un]SetThingPosition() | ||
111 | // functions. | ||
112 | // Do not change the MF_NO? flags while a thing is valid. | ||
113 | // | ||
114 | // Any questions? | ||
115 | // | ||
116 | |||
117 | // | ||
118 | // Misc. mobj flags | ||
119 | // | ||
120 | |||
121 | // Call P_SpecialThing when touched. | ||
122 | #define MF_SPECIAL (uint_64_t)(0x0000000000000001) | ||
123 | // Blocks. | ||
124 | #define MF_SOLID (uint_64_t)(0x0000000000000002) | ||
125 | // Can be hit. | ||
126 | #define MF_SHOOTABLE (uint_64_t)(0x0000000000000004) | ||
127 | // Don't use the sector links (invisible but touchable). | ||
128 | #define MF_NOSECTOR (uint_64_t)(0x0000000000000008) | ||
129 | // Don't use the blocklinks (inert but displayable) | ||
130 | #define MF_NOBLOCKMAP (uint_64_t)(0x0000000000000010) | ||
131 | |||
132 | // Not to be activated by sound, deaf monster. | ||
133 | #define MF_AMBUSH (uint_64_t)(0x0000000000000020) | ||
134 | // Will try to attack right back. | ||
135 | #define MF_JUSTHIT (uint_64_t)(0x0000000000000040) | ||
136 | // Will take at least one step before attacking. | ||
137 | #define MF_JUSTATTACKED (uint_64_t)(0x0000000000000080) | ||
138 | // On level spawning (initial position), | ||
139 | // hang from ceiling instead of stand on floor. | ||
140 | #define MF_SPAWNCEILING (uint_64_t)(0x0000000000000100) | ||
141 | // Don't apply gravity (every tic), | ||
142 | // that is, object will float, keeping current height | ||
143 | // or changing it actively. | ||
144 | #define MF_NOGRAVITY (uint_64_t)(0x0000000000000200) | ||
145 | |||
146 | // Movement flags. | ||
147 | // This allows jumps from high places. | ||
148 | #define MF_DROPOFF (uint_64_t)(0x0000000000000400) | ||
149 | // For players, will pick up items. | ||
150 | #define MF_PICKUP (uint_64_t)(0x0000000000000800) | ||
151 | // Player cheat. ??? | ||
152 | #define MF_NOCLIP (uint_64_t)(0x0000000000001000) | ||
153 | // Player: keep info about sliding along walls. | ||
154 | #define MF_SLIDE (uint_64_t)(0x0000000000002000) | ||
155 | // Allow moves to any height, no gravity. | ||
156 | // For active floaters, e.g. cacodemons, pain elementals. | ||
157 | #define MF_FLOAT (uint_64_t)(0x0000000000004000) | ||
158 | // Don't cross lines | ||
159 | // ??? or look at heights on teleport. | ||
160 | #define MF_TELEPORT (uint_64_t)(0x0000000000008000) | ||
161 | // Don't hit same species, explode on block. | ||
162 | // Player missiles as well as fireballs of various kinds. | ||
163 | #define MF_MISSILE (uint_64_t)(0x0000000000010000) | ||
164 | // Dropped by a demon, not level spawned. | ||
165 | // E.g. ammo clips dropped by dying former humans. | ||
166 | #define MF_DROPPED (uint_64_t)(0x0000000000020000) | ||
167 | // Use fuzzy draw (shadow demons or spectres), | ||
168 | // temporary player invisibility powerup. | ||
169 | #define MF_SHADOW (uint_64_t)(0x0000000000040000) | ||
170 | // Flag: don't bleed when shot (use puff), | ||
171 | // barrels and shootable furniture shall not bleed. | ||
172 | #define MF_NOBLOOD (uint_64_t)(0x0000000000080000) | ||
173 | // Don't stop moving halfway off a step, | ||
174 | // that is, have dead bodies slide down all the way. | ||
175 | #define MF_CORPSE (uint_64_t)(0x0000000000100000) | ||
176 | // Floating to a height for a move, ??? | ||
177 | // don't auto float to target's height. | ||
178 | #define MF_INFLOAT (uint_64_t)(0x0000000000200000) | ||
179 | |||
180 | // On kill, count this enemy object | ||
181 | // towards intermission kill total. | ||
182 | // Happy gathering. | ||
183 | #define MF_COUNTKILL (uint_64_t)(0x0000000000400000) | ||
184 | |||
185 | // On picking up, count this item object | ||
186 | // towards intermission item total. | ||
187 | #define MF_COUNTITEM (uint_64_t)(0x0000000000800000) | ||
188 | |||
189 | // Special handling: skull in flight. | ||
190 | // Neither a cacodemon nor a missile. | ||
191 | #define MF_SKULLFLY (uint_64_t)(0x0000000001000000) | ||
192 | |||
193 | // Don't spawn this object | ||
194 | // in death match mode (e.g. key cards). | ||
195 | #define MF_NOTDMATCH (uint_64_t)(0x0000000002000000) | ||
196 | |||
197 | // Player sprites in multiplayer modes are modified | ||
198 | // using an internal color lookup table for re-indexing. | ||
199 | // If 0x4 0x8 or 0xc, | ||
200 | // use a translation table for player colormaps | ||
201 | #define MF_TRANSLATION (uint_64_t)(0x000000000c000000) | ||
202 | #define MF_TRANSLATION1 (uint_64_t)(0x0000000004000000) | ||
203 | #define MF_TRANSLATION2 (uint_64_t)(0x0000000008000000) | ||
204 | // Hmm ???. | ||
205 | #define MF_TRANSSHIFT 26 | ||
206 | |||
207 | #define MF_UNUSED2 (uint_64_t)(0x0000000010000000) | ||
208 | #define MF_UNUSED3 (uint_64_t)(0x0000000020000000) | ||
209 | |||
210 | // Translucent sprite? // phares | ||
211 | #define MF_TRANSLUCENT (uint_64_t)(0x0000000040000000) | ||
212 | |||
213 | // this is free LONGLONG(0x0000000100000000) | ||
214 | |||
215 | // these are greater than an int. That's why the flags below are now uint_64_t | ||
216 | |||
217 | #define MF_TOUCHY LONGLONG(0x0000000100000000) | ||
218 | #define MF_BOUNCES LONGLONG(0x0000000200000000) | ||
219 | #define MF_FRIEND LONGLONG(0x0000000400000000) | ||
220 | |||
221 | // killough 9/15/98: Same, but internal flags, not intended for .deh | ||
222 | // (some degree of opaqueness is good, to avoid compatibility woes) | ||
223 | |||
224 | enum { | ||
225 | MIF_FALLING = 1, // Object is falling | ||
226 | MIF_ARMED = 2, // Object is armed (for MF_TOUCHY objects) | ||
227 | }; | ||
228 | |||
229 | // Map Object definition. | ||
230 | // | ||
231 | // | ||
232 | // killough 2/20/98: | ||
233 | // | ||
234 | // WARNING: Special steps must be taken in p_saveg.c if C pointers are added to | ||
235 | // this mobj_s struct, or else savegames will crash when loaded. See p_saveg.c. | ||
236 | // Do not add "struct mobj_s *fooptr" without adding code to p_saveg.c to | ||
237 | // convert the pointers to ordinals and back for savegames. This was the whole | ||
238 | // reason behind monsters going to sleep when loading savegames (the "target" | ||
239 | // pointer was simply nullified after loading, to prevent Doom from crashing), | ||
240 | // and the whole reason behind loadgames crashing on savegames of AV attacks. | ||
241 | // | ||
242 | |||
243 | // killough 9/8/98: changed some fields to shorts, | ||
244 | // for better memory usage (if only for cache). | ||
245 | /* cph 2006/08/28 - move Prev[XYZ] fields to the end of the struct. Add any | ||
246 | * other new fields to the end, and make sure you don't break savegames! */ | ||
247 | |||
248 | typedef struct mobj_s | ||
249 | { | ||
250 | // List: thinker links. | ||
251 | thinker_t thinker; | ||
252 | |||
253 | // Info for drawing: position. | ||
254 | fixed_t x; | ||
255 | fixed_t y; | ||
256 | fixed_t z; | ||
257 | |||
258 | // More list: links in sector (if needed) | ||
259 | struct mobj_s* snext; | ||
260 | struct mobj_s** sprev; // killough 8/10/98: change to ptr-to-ptr | ||
261 | |||
262 | //More drawing info: to determine current sprite. | ||
263 | angle_t angle; // orientation | ||
264 | spritenum_t sprite; // used to find patch_t and flip value | ||
265 | int frame; // might be ORed with FF_FULLBRIGHT | ||
266 | |||
267 | // Interaction info, by BLOCKMAP. | ||
268 | // Links in blocks (if needed). | ||
269 | struct mobj_s* bnext; | ||
270 | struct mobj_s** bprev; // killough 8/11/98: change to ptr-to-ptr | ||
271 | |||
272 | struct subsector_s* subsector; | ||
273 | |||
274 | // The closest interval over all contacted Sectors. | ||
275 | fixed_t floorz; | ||
276 | fixed_t ceilingz; | ||
277 | |||
278 | // killough 11/98: the lowest floor over all contacted Sectors. | ||
279 | fixed_t dropoffz; | ||
280 | |||
281 | // For movement checking. | ||
282 | fixed_t radius; | ||
283 | fixed_t height; | ||
284 | |||
285 | // Momentums, used to update position. | ||
286 | fixed_t momx; | ||
287 | fixed_t momy; | ||
288 | fixed_t momz; | ||
289 | |||
290 | // If == validcount, already checked. | ||
291 | int validcount; | ||
292 | |||
293 | mobjtype_t type; | ||
294 | mobjinfo_t* info; // &mobjinfo[mobj->type] | ||
295 | |||
296 | int tics; // state tic counter | ||
297 | state_t* state; | ||
298 | uint_64_t flags; | ||
299 | int intflags; // killough 9/15/98: internal flags | ||
300 | int health; | ||
301 | |||
302 | // Movement direction, movement generation (zig-zagging). | ||
303 | short movedir; // 0-7 | ||
304 | short movecount; // when 0, select a new dir | ||
305 | short strafecount; // killough 9/8/98: monster strafing | ||
306 | |||
307 | // Thing being chased/attacked (or NULL), | ||
308 | // also the originator for missiles. | ||
309 | struct mobj_s* target; | ||
310 | |||
311 | // Reaction time: if non 0, don't attack yet. | ||
312 | // Used by player to freeze a bit after teleporting. | ||
313 | short reactiontime; | ||
314 | |||
315 | // If >0, the current target will be chased no | ||
316 | // matter what (even if shot by another object) | ||
317 | short threshold; | ||
318 | |||
319 | // killough 9/9/98: How long a monster pursues a target. | ||
320 | short pursuecount; | ||
321 | |||
322 | short gear; // killough 11/98: used in torque simulation | ||
323 | |||
324 | // Additional info record for player avatars only. | ||
325 | // Only valid if type == MT_PLAYER | ||
326 | struct player_s* player; | ||
327 | |||
328 | // Player number last looked for. | ||
329 | short lastlook; | ||
330 | |||
331 | // For nightmare respawn. | ||
332 | mapthing_t spawnpoint; | ||
333 | |||
334 | // Thing being chased/attacked for tracers. | ||
335 | struct mobj_s* tracer; | ||
336 | |||
337 | // new field: last known enemy -- killough 2/15/98 | ||
338 | struct mobj_s* lastenemy; | ||
339 | |||
340 | // killough 8/2/98: friction properties part of sectors, | ||
341 | // not objects -- removed friction properties from here | ||
342 | // e6y: restored friction properties here | ||
343 | // Friction values for the sector the object is in | ||
344 | int friction; // phares 3/17/98 | ||
345 | int movefactor; | ||
346 | |||
347 | // a linked list of sectors where this object appears | ||
348 | struct msecnode_s* touching_sectorlist; // phares 3/14/98 | ||
349 | |||
350 | fixed_t PrevX; | ||
351 | fixed_t PrevY; | ||
352 | fixed_t PrevZ; | ||
353 | |||
354 | fixed_t pad; // cph - needed so I can get the size unambiguously on amd64 | ||
355 | |||
356 | // SEE WARNING ABOVE ABOUT POINTER FIELDS!!! | ||
357 | } mobj_t; | ||
358 | |||
359 | // External declarations (fomerly in p_local.h) -- killough 5/2/98 | ||
360 | |||
361 | #define VIEWHEIGHT (41*FRACUNIT) | ||
362 | |||
363 | #define GRAVITY FRACUNIT | ||
364 | #define MAXMOVE (30*FRACUNIT) | ||
365 | |||
366 | #define ONFLOORZ INT_MIN | ||
367 | #define ONCEILINGZ INT_MAX | ||
368 | |||
369 | // Time interval for item respawning. | ||
370 | #define ITEMQUESIZE 128 | ||
371 | |||
372 | #define FLOATSPEED (FRACUNIT*4) | ||
373 | #define STOPSPEED (FRACUNIT/16) | ||
374 | |||
375 | // killough 11/98: | ||
376 | // For torque simulation: | ||
377 | |||
378 | #define OVERDRIVE 6 | ||
379 | #define MAXGEAR (OVERDRIVE+16) | ||
380 | |||
381 | // killough 11/98: | ||
382 | // Whether an object is "sentient" or not. Used for environmental influences. | ||
383 | #define sentient(mobj) ((mobj)->health > 0 && (mobj)->info->seestate) | ||
384 | |||
385 | extern int iquehead; | ||
386 | extern int iquetail; | ||
387 | |||
388 | void P_RespawnSpecials(void); | ||
389 | mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); | ||
390 | void P_RemoveMobj(mobj_t *th); | ||
391 | boolean P_SetMobjState(mobj_t *mobj, statenum_t state); | ||
392 | void P_MobjThinker(mobj_t *mobj); | ||
393 | void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z); | ||
394 | void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage); | ||
395 | mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type); | ||
396 | void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type); | ||
397 | boolean P_IsDoomnumAllowed(int doomnum); | ||
398 | void P_SpawnMapThing (const mapthing_t* mthing); | ||
399 | void P_SpawnPlayer(int n, const mapthing_t *mthing); | ||
400 | void P_CheckMissileSpawn(mobj_t*); // killough 8/2/98 | ||
401 | void P_ExplodeMissile(mobj_t*); // killough | ||
402 | #endif | ||
403 | |||