1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
|
ther things,
// but only as the instigator (missiles will run into other
// things, but nothing can run into a missile).
// Each block in the grid is 128*128 units, and knows about
// every line_t that it contains a piece of, and every
// interactable mobj_t that has its origin contained.
//
// A valid mobj_t is a mobj_t that has the proper subsector_t
// filled in for its xy coordinates and is linked into the
// sector from which the subsector was made, or has the
// MF_NOSECTOR flag set (the subsector_t needs to be valid
// even if MF_NOSECTOR is set), and is linked into a blockmap
// block or has the MF_NOBLOCKMAP flag set.
// Links should only be modified by the P_[Un]SetThingPosition()
// functions.
// Do not change the MF_NO? flags while a thing is valid.
//
// Any questions?
//
//
// Misc. mobj flags
//
// Call P_SpecialThing when touched.
#define MF_SPECIAL (uint_64_t)(0x0000000000000001LL)
// Blocks.
#define MF_SOLID (uint_64_t)(0x0000000000000002LL)
// Can be hit.
#define MF_SHOOTABLE (uint_64_t)(0x0000000000000004LL)
// Don't use the sector links (invisible but touchable).
#define MF_NOSECTOR (uint_64_t)(0x0000000000000008LL)
// Don't use the blocklinks (inert but displayable)
#define MF_NOBLOCKMAP (uint_64_t)(0x0000000000000010LL)
// Not to be activated by sound, deaf monster.
#define MF_AMBUSH (uint_64_t)(0x0000000000000020LL)
// Will try to attack right back.
#define MF_JUSTHIT (uint_64_t)(0x0000000000000040LL)
// Will take at least one step before attacking.
#define MF_JUSTATTACKED (uint_64_t)(0x0000000000000080LL)
// On level spawning (initial position),
// hang from ceiling instead of stand on floor.
#define MF_SPAWNCEILING (uint_64_t)(0x0000000000000100LL)
// Don't apply gravity (every tic),
// that is, object will float, keeping current height
// or changing it actively.
#define MF_NOGRAVITY (uint_64_t)(0x0000000000000200LL)
// Movement flags.
// This allows jumps from high places.
#define MF_DROPOFF (uint_64_t)(0x0000000000000400LL)
// For players, will pick up items.
#define MF_PICKUP (uint_64_t)(0x0000000000000800LL)
// Player cheat. ???
#define MF_NOCLIP (uint_64_t)(0x0000000000001000LL)
// Player: keep info about sliding along walls.
#define MF_SLIDE (uint_64_t)(0x0000000000002000LL)
// Allow moves to any height, no gravity.
// For active floaters, e.g. cacodemons, pain elementals.
#define MF_FLOAT (uint_64_t)(0x0000000000004000LL)
// Don't cross lines
// ??? or look at heights on teleport.
#define MF_TELEPORT (uint_64_t)(0x0000000000008000LL)
// Don't hit same species, explode on block.
// Player missiles as well as fireballs of various kinds.
#define MF_MISSILE (uint_64_t)(0x0000000000010000LL)
// Dropped by a demon, not level spawned.
// E.g. ammo clips dropped by dying former humans.
#define MF_DROPPED (uint_64_t)(0x0000000000020000LL)
// Use fuzzy draw (shadow demons or spectres),
// temporary player invisibility powerup.
#define MF_SHADOW (uint_64_t)(0x0000000000040000LL)
// Flag: don't bleed when shot (use puff),
// barrels and shootable furniture shall not bleed.
#define MF_NOBLOOD (uint_64_t)(0x0000000000080000LL)
// Don't stop moving halfway off a step,
// that is, have dead bodies slide down all the way.
#define MF_CORPSE (uint_64_t)(0x0000000000100000LL)
// Floating to a height for a move, ???
// don't auto float to target's height.
#define MF_INFLOAT (uint_64_t)(0x0000000000200000LL)
// On kill, count this enemy object
// towards intermission kill total.
// Happy gathering.
#define MF_COUNTKILL (uint_64_t)(0x0000000000400000LL)
// On picking up, count this item object
// towards intermission item total.
#define MF_COUNTITEM (uint_64_t)(0x0000000000800000LL)
// Special handling: skull in flight.
// Neither a cacodemon nor a missile.
#define MF_SKULLFLY (uint_64_t)(0x0000000001000000LL)
// Don't spawn this object
// in death match mode (e.g. key cards).
#define MF_NOTDMATCH (uint_64_t)(0x0000000002000000LL)
// Player sprites in multiplayer modes are modified
// using an internal color lookup table for re-indexing.
// If 0x4 0x8 or 0xc,
// use a translation table for player colormaps
#define MF_TRANSLATION (uint_64_t)(0x000000000c000000LL)
#define MF_TRANSLATION1 (uint_64_t)(0x0000000004000000LL)
#define MF_TRANSLATION2 (uint_64_t)(0x0000000008000000LL)
// Hmm ???.
#define MF_TRANSSHIFT 26
// proff 11/19/98: Andy Baker's stealth monsters - unused yet
//Stealth Mode - Creatures that dissappear and reappear.
#define MF_STEALTH (uint_64_t)(0x0000000010000000LL)
// proff 11/19/98: 3 (4 counting opaque) levels of translucency
// not very good to set the next one in this enum, should be seperate
#define MF_TRANSLUCBITS (uint_64_t)(0x0000000060000000LL)
#define MF_TRANSLUC25 (uint_64_t)(0x0000000020000000LL)
#define MF_TRANSLUC50 (uint_64_t)(0x0000000040000000LL)
#define MF_TRANSLUC75 (uint_64_t)(0x0000000060000000LL)
// Translucent sprite? // phares
#define MF_TRANSLUCENT (uint_64_t)(0x0000000040000000LL)
// these are greater than an int. That's why the flags below are now uint_64_t
#define MF_TOUCHY (uint_64_t)(0x0000000100000000LL)
#define MF_BOUNCES (uint_64_t)(0x0000000200000000LL)
#define MF_FRIEND (uint_64_t)(0x0000000400000000LL)
// killough 9/15/98: Same, but internal flags, not intended for .deh
// (some degree of opaqueness is good, to avoid compatibility woes)
enum {
MIF_FALLING = 1, // Object is falling
MIF_ARMED = 2, // Object is armed (for MF_TOUCHY objects)
};
// Map Object definition.
//
// killough 2/20/98:
//
// WARNING: Special steps must be taken in p_saveg.c if C pointers are added to
// this mobj_s struct, or else savegames will crash when loaded. See p_saveg.c.
// Do not add "struct mobj_s *fooptr" without adding code to p_saveg.c to
// convert the pointers to ordinals and back for savegames. This was the whole
// reason behind monsters going to sleep when loading savegames (the "target"
// pointer was simply nullified after loading, to prevent Doom from crashing),
// and the whole reason behind loadgames crashing on savegames of AV attacks.
//
// killough 9/8/98: changed some fields to shorts,
// for better memory usage (if only for cache).
typedef struct mobj_s
{
// List: thinker links.
thinker_t thinker;
// Info for drawing: position.
fixed_t x;
fixed_t y;
fixed_t z;
// More list: links in sector (if needed)
struct mobj_s* snext;
struct mobj_s** sprev; // killough 8/10/98: change to ptr-to-ptr
//More drawing info: to determine current sprite.
angle_t angle; // orientation
spritenum_t sprite; // used to find patch_t and flip value
int frame; // might be ORed with FF_FULLBRIGHT
// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
struct mobj_s* bnext;
struct mobj_s** bprev; // killough 8/11/98: change to ptr-to-ptr
struct subsector_s* subsector;
// The closest interval over all contacted Sectors.
fixed_t floorz;
fixed_t ceilingz;
// killough 11/98: the lowest floor over all contacted Sectors.
fixed_t dropoffz;
// For movement checking.
fixed_t radius;
fixed_t height;
// Momentums, used to update position.
fixed_t momx;
fixed_t momy;
fixed_t momz;
// If == validcount, already checked.
int validcount;
mobjtype_t type;
mobjinfo_t* info; // &mobjinfo[mobj->type]
int tics; // state tic counter
state_t* state;
uint_64_t flags;
int intflags; // killough 9/15/98: internal flags
int health;
// Movement direction, movement generation (zig-zagging).
short movedir; // 0-7
short movecount; // when 0, select a new dir
short strafecount; // killough 9/8/98: monster strafing
// Thing being chased/attacked (or NULL),
// also the originator for missiles.
struct mobj_s* target;
// Reaction time: if non 0, don't attack yet.
// Used by player to freeze a bit after teleporting.
short reactiontime;
// If >0, the current target will be chased no
// matter what (even if shot by another object)
short threshold;
// killough 9/9/98: How long a monster pursues a target.
short pursuecount;
short gear; // killough 11/98: used in torque simulation
// Additional info record for player avatars only.
// Only valid if type == MT_PLAYER
struct player_s* player;
// Player number last looked for.
short lastlook;
// For nightmare respawn.
mapthing_t spawnpoint;
// Thing being chased/attacked for tracers.
struct mobj_s* tracer;
//proff 11/22/98: Andy Baker's stealth monsters
boolean invisible;
// new field: last known enemy -- killough 2/15/98
struct mobj_s* lastenemy;
// Are we above a Thing? above_thing points to the Thing // phares
// if so, otherwise it's zero. // |
// V
struct mobj_s* above_thing;
// Are we below a Thing? below_thing points to the Thing
// if so, otherwise it's zero.
// ^
struct mobj_s* below_thing; // |
// phares
// killough 8/2/98: friction properties part of sectors,
// not objects -- removed friction properties from here
// a linked list of sectors where this object appears
struct msecnode_s* touching_sectorlist; // phares 3/14/98
// SEE WARNING ABOVE ABOUT POINTER FIELDS!!!
} mobj_t;
// External declarations (fomerly in p_local.h) -- killough 5/2/98
#define VIEWHEIGHT (41*FRACUNIT)
#define PLAYERRADIUS (16*FRACUNIT)
#define GRAVITY FRACUNIT
#define MAXMOVE (30*FRACUNIT)
#define ONFLOORZ INT_MIN
#define ONCEILINGZ INT_MAX
// Time interval for item respawning.
#define ITEMQUESIZE 128
#define FLOATSPEED (FRACUNIT*4)
#define STOPSPEED (FRACUNIT/16)
// killough 11/98:
// For torque simulation:
#define OVERDRIVE 6
#define MAXGEAR (OVERDRIVE+16)
// killough 11/98:
// Whether an object is "sentient" or not. Used for environmental influences.
#define sentient(mobj) ((mobj)->health > 0 && (mobj)->info->seestate)
extern mapthing_t itemrespawnque[];
extern int itemrespawntime[];
extern int iquehead;
extern int iquetail;
void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
void P_RemoveMobj(mobj_t *th);
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
void P_MobjThinker(mobj_t *mobj);
void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z);
void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage);
mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type);
void P_SpawnMapThing (mapthing_t* mthing);
void P_CheckMissileSpawn(mobj_t*); // killough 8/2/98
void P_ExplodeMissile(mobj_t*); // killough
#endif
|