FS#12756 by Marek Salaba - update Czech translation
[maemo-rb.git] / apps / plugins / doom / p_mobj.h
blobbdd863afd93dab93be157482e08ed93aa9e63f5c
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
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
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * Map Objects, MObj, definition and handling.
30 *-----------------------------------------------------------------------------*/
32 #ifndef __P_MOBJ__
33 #define __P_MOBJ__
35 // Basics.
36 #include "tables.h"
37 #include "m_fixed.h"
39 // We need the thinker_t stuff.
40 #include "d_think.h"
42 // We need the WAD data structure for Map things,
43 // from the THINGS lump.
44 #include "doomdata.h"
46 // States are tied to finite states are
47 // tied to animation frames.
48 // Needs precompiled tables/data structures.
49 #include "info.h"
52 // NOTES: mobj_t
54 // mobj_ts are used to tell the refresh where to draw an image,
55 // tell the world simulation when objects are contacted,
56 // and tell the sound driver how to position a sound.
58 // The refresh uses the next and prev links to follow
59 // lists of things in sectors as they are being drawn.
60 // The sprite, frame, and angle elements determine which patch_t
61 // is used to draw the sprite if it is visible.
62 // The sprite and frame values are allmost allways set
63 // from state_t structures.
64 // The statescr.exe utility generates the states.h and states.c
65 // files that contain the sprite/frame numbers from the
66 // statescr.txt source file.
67 // The xyz origin point represents a point at the bottom middle
68 // of the sprite (between the feet of a biped).
69 // This is the default origin position for patch_ts grabbed
70 // with lumpy.exe.
71 // A walking creature will have its z equal to the floor
72 // it is standing on.
74 // The sound code uses the x,y, and subsector fields
75 // to do stereo positioning of any sound effited by the mobj_t.
77 // The play simulation uses the blocklinks, x,y,z, radius, height
78 // to determine when mobj_ts are touching each other,
79 // touching lines in the map, or hit by trace lines (gunshots,
80 // lines of sight, etc).
81 // The mobj_t->flags element has various bit flags
82 // used by the simulation.
84 // Every mobj_t is linked into a single sector
85 // based on its origin coordinates.
86 // The subsector_t is found with R_PointInSubsector(x,y),
87 // and the sector_t can be found with subsector->sector.
88 // The sector links are only used by the rendering code,
89 // the play simulation does not care about them at all.
91 // Any mobj_t that needs to be acted upon by something else
92 // in the play world (block movement, be shot, etc) will also
93 // need to be linked into the blockmap.
94 // If the thing has the MF_NOBLOCK flag set, it will not use
95 // the block links. It can still interact with other things,
96 // but only as the instigator (missiles will run into other
97 // things, but nothing can run into a missile).
98 // Each block in the grid is 128*128 units, and knows about
99 // every line_t that it contains a piece of, and every
100 // interactable mobj_t that has its origin contained.
102 // A valid mobj_t is a mobj_t that has the proper subsector_t
103 // filled in for its xy coordinates and is linked into the
104 // sector from which the subsector was made, or has the
105 // MF_NOSECTOR flag set (the subsector_t needs to be valid
106 // even if MF_NOSECTOR is set), and is linked into a blockmap
107 // block or has the MF_NOBLOCKMAP flag set.
108 // Links should only be modified by the P_[Un]SetThingPosition()
109 // functions.
110 // Do not change the MF_NO? flags while a thing is valid.
112 // Any questions?
116 // Misc. mobj flags
119 // Call P_SpecialThing when touched.
120 #define MF_SPECIAL (uint_64_t)(0x0000000000000001LL)
121 // Blocks.
122 #define MF_SOLID (uint_64_t)(0x0000000000000002LL)
123 // Can be hit.
124 #define MF_SHOOTABLE (uint_64_t)(0x0000000000000004LL)
125 // Don't use the sector links (invisible but touchable).
126 #define MF_NOSECTOR (uint_64_t)(0x0000000000000008LL)
127 // Don't use the blocklinks (inert but displayable)
128 #define MF_NOBLOCKMAP (uint_64_t)(0x0000000000000010LL)
130 // Not to be activated by sound, deaf monster.
131 #define MF_AMBUSH (uint_64_t)(0x0000000000000020LL)
132 // Will try to attack right back.
133 #define MF_JUSTHIT (uint_64_t)(0x0000000000000040LL)
134 // Will take at least one step before attacking.
135 #define MF_JUSTATTACKED (uint_64_t)(0x0000000000000080LL)
136 // On level spawning (initial position),
137 // hang from ceiling instead of stand on floor.
138 #define MF_SPAWNCEILING (uint_64_t)(0x0000000000000100LL)
139 // Don't apply gravity (every tic),
140 // that is, object will float, keeping current height
141 // or changing it actively.
142 #define MF_NOGRAVITY (uint_64_t)(0x0000000000000200LL)
144 // Movement flags.
145 // This allows jumps from high places.
146 #define MF_DROPOFF (uint_64_t)(0x0000000000000400LL)
147 // For players, will pick up items.
148 #define MF_PICKUP (uint_64_t)(0x0000000000000800LL)
149 // Player cheat. ???
150 #define MF_NOCLIP (uint_64_t)(0x0000000000001000LL)
151 // Player: keep info about sliding along walls.
152 #define MF_SLIDE (uint_64_t)(0x0000000000002000LL)
153 // Allow moves to any height, no gravity.
154 // For active floaters, e.g. cacodemons, pain elementals.
155 #define MF_FLOAT (uint_64_t)(0x0000000000004000LL)
156 // Don't cross lines
157 // ??? or look at heights on teleport.
158 #define MF_TELEPORT (uint_64_t)(0x0000000000008000LL)
159 // Don't hit same species, explode on block.
160 // Player missiles as well as fireballs of various kinds.
161 #define MF_MISSILE (uint_64_t)(0x0000000000010000LL)
162 // Dropped by a demon, not level spawned.
163 // E.g. ammo clips dropped by dying former humans.
164 #define MF_DROPPED (uint_64_t)(0x0000000000020000LL)
165 // Use fuzzy draw (shadow demons or spectres),
166 // temporary player invisibility powerup.
167 #define MF_SHADOW (uint_64_t)(0x0000000000040000LL)
168 // Flag: don't bleed when shot (use puff),
169 // barrels and shootable furniture shall not bleed.
170 #define MF_NOBLOOD (uint_64_t)(0x0000000000080000LL)
171 // Don't stop moving halfway off a step,
172 // that is, have dead bodies slide down all the way.
173 #define MF_CORPSE (uint_64_t)(0x0000000000100000LL)
174 // Floating to a height for a move, ???
175 // don't auto float to target's height.
176 #define MF_INFLOAT (uint_64_t)(0x0000000000200000LL)
178 // On kill, count this enemy object
179 // towards intermission kill total.
180 // Happy gathering.
181 #define MF_COUNTKILL (uint_64_t)(0x0000000000400000LL)
183 // On picking up, count this item object
184 // towards intermission item total.
185 #define MF_COUNTITEM (uint_64_t)(0x0000000000800000LL)
187 // Special handling: skull in flight.
188 // Neither a cacodemon nor a missile.
189 #define MF_SKULLFLY (uint_64_t)(0x0000000001000000LL)
191 // Don't spawn this object
192 // in death match mode (e.g. key cards).
193 #define MF_NOTDMATCH (uint_64_t)(0x0000000002000000LL)
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 #define MF_TRANSLATION (uint_64_t)(0x000000000c000000LL)
200 #define MF_TRANSLATION1 (uint_64_t)(0x0000000004000000LL)
201 #define MF_TRANSLATION2 (uint_64_t)(0x0000000008000000LL)
202 // Hmm ???.
203 #define MF_TRANSSHIFT 26
205 // proff 11/19/98: Andy Baker's stealth monsters - unused yet
206 //Stealth Mode - Creatures that dissappear and reappear.
208 #define MF_STEALTH (uint_64_t)(0x0000000010000000LL)
210 // proff 11/19/98: 3 (4 counting opaque) levels of translucency
211 // not very good to set the next one in this enum, should be seperate
212 #define MF_TRANSLUCBITS (uint_64_t)(0x0000000060000000LL)
213 #define MF_TRANSLUC25 (uint_64_t)(0x0000000020000000LL)
214 #define MF_TRANSLUC50 (uint_64_t)(0x0000000040000000LL)
215 #define MF_TRANSLUC75 (uint_64_t)(0x0000000060000000LL)
217 // Translucent sprite? // phares
218 #define MF_TRANSLUCENT (uint_64_t)(0x0000000040000000LL)
220 // these are greater than an int. That's why the flags below are now uint_64_t
221 #define MF_TOUCHY (uint_64_t)(0x0000000100000000LL)
222 #define MF_BOUNCES (uint_64_t)(0x0000000200000000LL)
223 #define MF_FRIEND (uint_64_t)(0x0000000400000000LL)
225 // killough 9/15/98: Same, but internal flags, not intended for .deh
226 // (some degree of opaqueness is good, to avoid compatibility woes)
228 enum {
229 MIF_FALLING = 1, // Object is falling
230 MIF_ARMED = 2, // Object is armed (for MF_TOUCHY objects)
233 // Map Object definition.
235 // killough 2/20/98:
237 // WARNING: Special steps must be taken in p_saveg.c if C pointers are added to
238 // this mobj_s struct, or else savegames will crash when loaded. See p_saveg.c.
239 // Do not add "struct mobj_s *fooptr" without adding code to p_saveg.c to
240 // convert the pointers to ordinals and back for savegames. This was the whole
241 // reason behind monsters going to sleep when loading savegames (the "target"
242 // pointer was simply nullified after loading, to prevent Doom from crashing),
243 // and the whole reason behind loadgames crashing on savegames of AV attacks.
246 // killough 9/8/98: changed some fields to shorts,
247 // for better memory usage (if only for cache).
249 typedef struct mobj_s
251 // List: thinker links.
252 thinker_t thinker;
254 // Info for drawing: position.
255 fixed_t x;
256 fixed_t y;
257 fixed_t z;
259 // More list: links in sector (if needed)
260 struct mobj_s* snext;
261 struct mobj_s** sprev; // killough 8/10/98: change to ptr-to-ptr
263 //More drawing info: to determine current sprite.
264 angle_t angle; // orientation
265 spritenum_t sprite; // used to find patch_t and flip value
266 int frame; // might be ORed with FF_FULLBRIGHT
268 // Interaction info, by BLOCKMAP.
269 // Links in blocks (if needed).
270 struct mobj_s* bnext;
271 struct mobj_s** bprev; // killough 8/11/98: change to ptr-to-ptr
273 struct subsector_s* subsector;
275 // The closest interval over all contacted Sectors.
276 fixed_t floorz;
277 fixed_t ceilingz;
279 // killough 11/98: the lowest floor over all contacted Sectors.
280 fixed_t dropoffz;
282 // For movement checking.
283 fixed_t radius;
284 fixed_t height;
286 // Momentums, used to update position.
287 fixed_t momx;
288 fixed_t momy;
289 fixed_t momz;
291 // If == validcount, already checked.
292 int validcount;
294 mobjtype_t type;
295 mobjinfo_t* info; // &mobjinfo[mobj->type]
297 int tics; // state tic counter
298 state_t* state;
299 uint_64_t flags;
300 int intflags; // killough 9/15/98: internal flags
301 int health;
303 // Movement direction, movement generation (zig-zagging).
304 short movedir; // 0-7
305 short movecount; // when 0, select a new dir
306 short strafecount; // killough 9/8/98: monster strafing
308 // Thing being chased/attacked (or NULL),
309 // also the originator for missiles.
310 struct mobj_s* target;
312 // Reaction time: if non 0, don't attack yet.
313 // Used by player to freeze a bit after teleporting.
314 short reactiontime;
316 // If >0, the current target will be chased no
317 // matter what (even if shot by another object)
318 short threshold;
320 // killough 9/9/98: How long a monster pursues a target.
321 short pursuecount;
323 short gear; // killough 11/98: used in torque simulation
325 // Additional info record for player avatars only.
326 // Only valid if type == MT_PLAYER
327 struct player_s* player;
329 // Player number last looked for.
330 short lastlook;
332 // For nightmare respawn.
333 mapthing_t spawnpoint;
335 // Thing being chased/attacked for tracers.
336 struct mobj_s* tracer;
338 //proff 11/22/98: Andy Baker's stealth monsters
339 boolean invisible;
341 // new field: last known enemy -- killough 2/15/98
342 struct mobj_s* lastenemy;
344 // Are we above a Thing? above_thing points to the Thing // phares
345 // if so, otherwise it's zero. // |
346 // V
347 struct mobj_s* above_thing;
349 // Are we below a Thing? below_thing points to the Thing
350 // if so, otherwise it's zero.
351 // ^
352 struct mobj_s* below_thing; // |
353 // phares
355 // killough 8/2/98: friction properties part of sectors,
356 // not objects -- removed friction properties from here
358 // a linked list of sectors where this object appears
359 struct msecnode_s* touching_sectorlist; // phares 3/14/98
361 // SEE WARNING ABOVE ABOUT POINTER FIELDS!!!
362 } mobj_t;
364 // External declarations (fomerly in p_local.h) -- killough 5/2/98
366 #define VIEWHEIGHT (41*FRACUNIT)
367 #define PLAYERRADIUS (16*FRACUNIT)
369 #define GRAVITY FRACUNIT
370 #define MAXMOVE (30*FRACUNIT)
372 #define ONFLOORZ INT_MIN
373 #define ONCEILINGZ INT_MAX
375 // Time interval for item respawning.
376 #define ITEMQUESIZE 128
378 #define FLOATSPEED (FRACUNIT*4)
379 #define STOPSPEED (FRACUNIT/16)
381 // killough 11/98:
382 // For torque simulation:
384 #define OVERDRIVE 6
385 #define MAXGEAR (OVERDRIVE+16)
387 // killough 11/98:
388 // Whether an object is "sentient" or not. Used for environmental influences.
389 #define sentient(mobj) ((mobj)->health > 0 && (mobj)->info->seestate)
391 extern mapthing_t itemrespawnque[];
392 extern int itemrespawntime[];
393 extern int iquehead;
394 extern int iquetail;
396 void P_RespawnSpecials(void);
397 mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
398 void P_RemoveMobj(mobj_t *th);
399 boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
400 void P_MobjThinker(mobj_t *mobj);
401 void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z);
402 void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage);
403 mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
404 void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type);
405 void P_SpawnMapThing (mapthing_t* mthing);
406 void P_CheckMissileSpawn(mobj_t*); // killough 8/2/98
407 void P_ExplodeMissile(mobj_t*); // killough
408 #endif