| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/object.h $ |
| 21 | * $Revision: 174 $ |
| 22 | * $Date: 10/22/99 2:06p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Header for object.c |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/object.h $ |
| 28 | * |
| 29 | * 174 10/22/99 2:06p Matt |
| 30 | * Mac merge |
| 31 | * |
| 32 | * 173 9/18/99 9:24p Jeff |
| 33 | * object position history code (needed for motion blur effect) |
| 34 | * |
| 35 | * 172 5/22/99 1:54a Matt |
| 36 | * Got rid of debug code mistakenly checked in. |
| 37 | * |
| 38 | * 171 5/21/99 3:43a Matt |
| 39 | * |
| 40 | * 170 2/23/99 12:39p Jason |
| 41 | * added more options for generic objects |
| 42 | * |
| 43 | * 169 2/21/99 4:20p Matt |
| 44 | * Added SoundSource objects (and reformatted parts of the object header |
| 45 | * files). |
| 46 | * |
| 47 | * 168 2/10/99 1:47p Matt |
| 48 | * Changed object handle symbolic constants |
| 49 | * |
| 50 | * 167 2/08/99 5:26p Jeff |
| 51 | * removed all calls to MultiSendRemoveObject, incorportated into |
| 52 | * SetObjectDeadFlag. Fixes sequencing issues in multiplayer |
| 53 | * |
| 54 | * 166 2/05/99 3:00p Jason |
| 55 | * fixed some framerate problems |
| 56 | * |
| 57 | * 165 1/21/99 11:15p Jeff |
| 58 | * pulled out some structs and defines from header files and moved them |
| 59 | * into seperate header files so that multiplayer dlls don't require major |
| 60 | * game headers, just those new headers. Side effect is a shorter build |
| 61 | * time. Also cleaned up some header file #includes that weren't needed. |
| 62 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 63 | * manage.h and multi.h |
| 64 | * |
| 65 | * 164 1/21/99 3:34p Jason |
| 66 | * added liquid code |
| 67 | * |
| 68 | * 163 1/19/99 4:22p Matt |
| 69 | * Added the ability for objects to have their own lighting info, |
| 70 | * different from the default lighting for that type of object. |
| 71 | * |
| 72 | * 162 1/18/99 2:46p Matt |
| 73 | * Combined flags & flags2 fields in object struct |
| 74 | * |
| 75 | * 161 1/15/99 7:52p Chris |
| 76 | * Updated ObjSetPos() to include a f_update_attach_children flag |
| 77 | * |
| 78 | * 160 1/13/99 6:38a Jeff |
| 79 | * fixed object.h. There were numerous struct declarations that were the |
| 80 | * same name as the instance of the struct (gcc doesn't like this). |
| 81 | * Changed the struct name. Also added some #ifdef's for linux build, |
| 82 | * along with fixing case-sensitive includes |
| 83 | * |
| 84 | * 159 1/13/99 3:25a Chris |
| 85 | * Added Obj_Burning and Obj_IsEffect to OSIRIS |
| 86 | * |
| 87 | * 158 1/13/99 12:12a Jeff |
| 88 | * changed the name of the obj_link_info struct to object_link_info |
| 89 | * (because the instance is named the same). Allows it to compile under |
| 90 | * GCC |
| 91 | * |
| 92 | * 157 1/08/99 2:56p Samir |
| 93 | * Ripped out OSIRIS1. |
| 94 | * |
| 95 | * 156 1/08/99 12:02p Chris |
| 96 | * |
| 97 | * 155 1/06/99 5:06p Chris |
| 98 | * Improving OSIRIS/game intergration - improved support for custom |
| 99 | * animations |
| 100 | * |
| 101 | * 154 1/04/99 12:42p Chris |
| 102 | * Updated OSIRIS with "xxxx_external.h" files and Obj_Value, and |
| 103 | * Matcen_XXX functions |
| 104 | * |
| 105 | * 153 12/21/98 11:30p Matt |
| 106 | * Added names for objects |
| 107 | * |
| 108 | * 152 12/21/98 6:01p Matt |
| 109 | * Changed the object handle bit allocation to handle object numbers up to |
| 110 | * 2047. |
| 111 | * Increased MAX_OBJECTS to 1500. |
| 112 | * |
| 113 | * 151 12/18/98 6:00p Jeff |
| 114 | * added support for door scripts in new osiris |
| 115 | * |
| 116 | * 150 12/16/98 11:27a Jeff |
| 117 | * added new osiris fields |
| 118 | * |
| 119 | * 149 12/10/98 7:09p Jason |
| 120 | * added cloak fade |
| 121 | * |
| 122 | * 148 12/10/98 12:27p Jason |
| 123 | * added cooler specular mapping for objects |
| 124 | * |
| 125 | * 147 11/03/98 6:16p Chris |
| 126 | * Starting to make on/off and spray weapons accessable to robots |
| 127 | * |
| 128 | * 146 10/20/98 10:27p Chris |
| 129 | * |
| 130 | * 145 10/19/98 11:46p Jason |
| 131 | * changes for multiplayer debug layer |
| 132 | * |
| 133 | * 144 10/19/98 7:18p Matt |
| 134 | * Added system to support different types of damage to the player and |
| 135 | * have these different types make different sounds. |
| 136 | * |
| 137 | * 143 10/19/98 3:14p Chris |
| 138 | * Version .05 of locked axes |
| 139 | * |
| 140 | * 142 10/17/98 12:26p Chris |
| 141 | * Fixed attached flares |
| 142 | * |
| 143 | * 141 10/16/98 5:25p Chris |
| 144 | * Fixed sticky code |
| 145 | * |
| 146 | * 140 10/16/98 4:18p Chris |
| 147 | * Fixed the 'flare thing' |
| 148 | * |
| 149 | * 139 10/16/98 3:39p Chris |
| 150 | * Improved the object linking system and AI and physics |
| 151 | * |
| 152 | * 138 10/15/98 6:46p Chris |
| 153 | * Added custom size for weapons |
| 154 | * |
| 155 | * 137 10/15/98 10:46a Chris |
| 156 | * Made powerups fall to below the ceiling height |
| 157 | * |
| 158 | * 136 10/13/98 11:30a Matt |
| 159 | * Added parens around a macro value |
| 160 | * |
| 161 | * 135 10/12/98 7:09p Matt |
| 162 | * Removed some obsolete stuff |
| 163 | * |
| 164 | * 134 10/06/98 11:27a Jason |
| 165 | * added new death type for robots |
| 166 | * |
| 167 | * 133 9/28/98 6:23p Chris |
| 168 | * Changed multi_anim to custom_anim |
| 169 | * |
| 170 | * 132 9/22/98 12:40p Matt |
| 171 | * Cleaned up the object per-frame processing code. |
| 172 | * |
| 173 | * 131 8/18/98 12:57a Samir |
| 174 | * added ObjUnlink call. |
| 175 | * |
| 176 | * 130 8/12/98 6:37p Jeff |
| 177 | * added functions to ghost an object (make it's type to OBJ_DUMMY) and |
| 178 | * unghost |
| 179 | * |
| 180 | * 129 8/12/98 12:04p Chris |
| 181 | * Attach system version .5 (still needs more work to be multiplayer |
| 182 | * friendly) |
| 183 | * |
| 184 | * 128 8/07/98 8:25p Chris |
| 185 | * Improved the attach system |
| 186 | * |
| 187 | * 127 8/03/98 3:59p Chris |
| 188 | * Added support for FQ_IGNORE_WEAPONS, added .000001 attach code, fix a |
| 189 | * bug in polymodel collision detection |
| 190 | * |
| 191 | * 126 7/31/98 11:52a Chris |
| 192 | * Weapons can be persistent. Added ability for objects to be manually |
| 193 | * set for no object collisions. |
| 194 | * |
| 195 | * 125 7/30/98 11:09a Jason |
| 196 | * added weapons that freeze and deform terrain |
| 197 | * |
| 198 | * 124 7/22/98 3:16p Jason |
| 199 | * added observer mode |
| 200 | * |
| 201 | * 123 7/20/98 2:48p Chris |
| 202 | * Removed hit_time (not neccessary) |
| 203 | * |
| 204 | * 122 7/20/98 2:06p Chris |
| 205 | * Added the precomputation of some weapons (fixed speed weapons). This |
| 206 | * algorithm can be expanded to include some missiles with some minor |
| 207 | * work. |
| 208 | * |
| 209 | * 121 7/19/98 9:44p Chris |
| 210 | * Greatly improved homing performance |
| 211 | * |
| 212 | * 120 7/09/98 7:50p Jeff |
| 213 | * added ObjGetUltimateParent to find out the original parent of an |
| 214 | * object, traces the family tree |
| 215 | * |
| 216 | * 119 7/09/98 11:34a Chris |
| 217 | * Turrets are interpolated. |
| 218 | * |
| 219 | * 118 7/08/98 11:38a Chris |
| 220 | * Improved the turret info passing in multiplayer |
| 221 | * |
| 222 | * 117 7/07/98 7:34p Jeff |
| 223 | * created object type, OBJ_DUMMY |
| 224 | * |
| 225 | * 116 7/07/98 3:26p Chris |
| 226 | * Added changes for turret updates |
| 227 | * |
| 228 | * 115 7/06/98 5:36p Kevin |
| 229 | * Variable parameter passing |
| 230 | * |
| 231 | * 114 7/02/98 2:47p Chris |
| 232 | * Dynamic weapon info is now dynamically allocated |
| 233 | * |
| 234 | * 113 7/01/98 6:36p Chris |
| 235 | * Added more multiplayer support |
| 236 | * |
| 237 | * 112 7/01/98 4:35p Chris |
| 238 | * More multiplayer sync issues |
| 239 | * |
| 240 | * 111 7/01/98 2:02p Chris |
| 241 | * Added the sound for animations |
| 242 | * |
| 243 | * 110 6/30/98 4:28p Chris |
| 244 | * Checked in some missing commas |
| 245 | * |
| 246 | * 109 6/26/98 2:04p Jason |
| 247 | * fixed some graphical problems with the omega |
| 248 | * |
| 249 | * 108 6/12/98 4:07p Jason |
| 250 | * added dynamic volume lighting to objects |
| 251 | * |
| 252 | * 107 6/11/98 12:48p Jason |
| 253 | * added better spewing weapons |
| 254 | * |
| 255 | * 106 5/19/98 4:42a Chris |
| 256 | * Added shockwave's -- enjoy. :) |
| 257 | * |
| 258 | * 105 5/15/98 5:41p Jason |
| 259 | * implemented volume lighting system |
| 260 | * |
| 261 | * 104 5/14/98 12:56p Jason |
| 262 | * changes to help lower memory usage |
| 263 | * |
| 264 | * 103 5/11/98 4:40p Chris |
| 265 | * AI info is now a malloc'ed pointer |
| 266 | * |
| 267 | * 102 5/08/98 1:16p Jason |
| 268 | * added PF_DESTINATION_POS flag for interpolating multiplayer positions |
| 269 | * |
| 270 | * 101 5/07/98 1:41p Chris |
| 271 | * Added hit_death_dot |
| 272 | * |
| 273 | * 100 5/04/98 12:30p Matt |
| 274 | * ObjCreate() now takes object id as a uint16_t |
| 275 | * |
| 276 | * 99 5/04/98 12:28p Matt |
| 277 | * Added shard objects |
| 278 | * |
| 279 | * 98 5/01/98 3:41p Chris |
| 280 | * |
| 281 | * 97 5/31/98 3:08p Chris |
| 282 | * Allowed for death animations |
| 283 | * |
| 284 | * 96 5/30/98 10:16p Chris |
| 285 | * Fixed some bad spelling |
| 286 | * |
| 287 | * 95 4/19/98 5:00p Jason |
| 288 | * added cool napalm effect, plus made object effects dynamically |
| 289 | * allocated |
| 290 | * |
| 291 | * 94 4/17/98 1:59p Jason |
| 292 | * added cool object effects |
| 293 | * |
| 294 | * 93 4/15/98 12:56p Chris |
| 295 | * Updated parent_handle support and added buddy bot support |
| 296 | * |
| 297 | * 92 4/13/98 4:19p Chris |
| 298 | * Added PF_IGNORE_CONCUSSIVE_FORCES |
| 299 | * |
| 300 | * 91 4/10/98 12:41p Jason |
| 301 | * sped up lighting a little |
| 302 | * |
| 303 | * 90 4/09/98 2:23p Jason |
| 304 | * added guided/afterburner stuff |
| 305 | * |
| 306 | * 89 4/09/98 12:05p Chris |
| 307 | * Added parenting for all object types. :) |
| 308 | * |
| 309 | * 88 4/08/98 6:02p Luke |
| 310 | * |
| 311 | * 87 4/08/98 3:47p Chris |
| 312 | * Moved stuff around so that the object flags can stay 16 bits |
| 313 | * |
| 314 | * 86 4/08/98 2:53p Chris |
| 315 | * Added flags for move this frame and stop this frame |
| 316 | * |
| 317 | * 85 3/31/98 4:23p Chris |
| 318 | * Added a new AIpath system |
| 319 | * |
| 320 | * 84 3/20/98 9:34p Jason |
| 321 | * added SetObjectDeadFlag inlined function |
| 322 | * |
| 323 | * 83 3/16/98 3:47p Jason |
| 324 | * got rid of circular dependencies for objects and polymodels |
| 325 | * |
| 326 | * 82 3/13/98 5:55p Chris |
| 327 | * Added the new collision spheres |
| 328 | * |
| 329 | * 81 3/12/98 7:30p Chris |
| 330 | * Added ObjSetOrient |
| 331 | * |
| 332 | * 80 3/09/98 4:54p Jason |
| 333 | * don't render objects that can't been seen through a portal |
| 334 | * |
| 335 | * 79 3/09/98 8:12a Chris |
| 336 | * Added the start of the homing code |
| 337 | * |
| 338 | * 78 3/06/98 2:15p Chris |
| 339 | * Changed target_object to target_handle |
| 340 | * |
| 341 | * 77 2/20/98 1:46p Chris |
| 342 | * JASON: Made dynamic lighting only occur if the object is rendered |
| 343 | * |
| 344 | * 76 2/19/98 11:21a Chris |
| 345 | * Made ROOMNUM_OUTSIDE return a bool |
| 346 | * |
| 347 | * 75 2/18/98 1:39p Jason |
| 348 | * more changes for lighting |
| 349 | * |
| 350 | * 74 2/17/98 5:54p Luke |
| 351 | * |
| 352 | * 73 2/16/98 2:49p Chris |
| 353 | * Made the MAX_SUBOBJECTS determine the number of normalized_time values |
| 354 | * to be processed. No longer a 'literal' problem. |
| 355 | * |
| 356 | * 72 2/16/98 2:47a Chris |
| 357 | * Massive improvements to the animation system and the AI |
| 358 | * |
| 359 | * 71 2/11/98 6:58p Matt |
| 360 | * Changed the way cameras are rendered, so they show up on the terrain as |
| 361 | * well. |
| 362 | * |
| 363 | * 70 2/11/98 7:01p Chris |
| 364 | * Started to add the new anim stuff |
| 365 | * |
| 366 | * 69 2/09/98 7:28p Matt |
| 367 | * Added a rendering type for external room so we could check against |
| 368 | * render type == RT_NONE |
| 369 | * |
| 370 | * 68 2/06/98 2:57a Chris |
| 371 | * Added point_collide_with_walls and ignore_robot_collisions |
| 372 | * |
| 373 | * 67 2/05/98 3:00p Matt |
| 374 | * Made ObjSetPos() take optional orienation. Got rid of unlink & relink |
| 375 | * funcs from header. |
| 376 | * |
| 377 | * 66 2/04/98 6:09p Matt |
| 378 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 379 | * rid of the object flag which used to indicate terrain. |
| 380 | * |
| 381 | * 65 2/03/98 11:17a Samir |
| 382 | * Added macro to get handle from an object. |
| 383 | * |
| 384 | * 64 1/29/98 5:49p Matt |
| 385 | * Changed old camera object type to be viewer object (for editor), and |
| 386 | * now camera objects will just be for game cameras. |
| 387 | * |
| 388 | * 63 1/29/98 10:07a Matt |
| 389 | * Added a constant that defines an invalid object handle |
| 390 | * |
| 391 | * 62 1/27/98 12:24p Samir |
| 392 | * Added GetObjectPointInWorld. |
| 393 | * |
| 394 | * 61 1/21/98 1:11p Jason |
| 395 | * incremental checkin for multiplayer |
| 396 | * |
| 397 | * 60 1/20/98 4:12p Samir |
| 398 | * New script housekeeping system. |
| 399 | * |
| 400 | * 59 1/19/98 2:44p Samir |
| 401 | * Use one script per object and started parameter passing support. |
| 402 | * |
| 403 | * 58 1/19/98 10:04a Matt |
| 404 | * Added new object handle system |
| 405 | * |
| 406 | * 57 1/07/98 3:32p Chris |
| 407 | * Ship's wiggle falloff is computed via last thrust time. |
| 408 | * |
| 409 | * 56 1/05/98 3:54p Chris |
| 410 | * Added ambient and explosion sounds |
| 411 | * |
| 412 | * 55 12/08/97 5:22p Jason |
| 413 | * added code for destroyable buildings that leave their base object |
| 414 | * around |
| 415 | * |
| 416 | * 54 12/03/97 5:53p Jason |
| 417 | * worked on cooler explosion effects |
| 418 | * |
| 419 | * 53 12/03/97 4:31p Chris |
| 420 | * Added the initial shockwave structure |
| 421 | * |
| 422 | * 52 12/01/97 9:54a Chris |
| 423 | * Added support for concussive forces, generalized robot collisions to |
| 424 | * generic collisions |
| 425 | * |
| 426 | * 51 11/12/97 5:47p Chris |
| 427 | * re-ordered the object structure so that Soar people can get to known |
| 428 | * data elements without having to worry about other stuff. |
| 429 | * |
| 430 | * 50 10/29/97 10:35a Chris |
| 431 | * Added the no collide/relink flag to physics -- Dangerous ask Chris how |
| 432 | * to use correctly |
| 433 | * |
| 434 | * 49 10/24/97 2:30p Jason |
| 435 | * more changes for explosions |
| 436 | * |
| 437 | * 48 10/23/97 6:14p Jason |
| 438 | * tweaks for splinter objects |
| 439 | * |
| 440 | * 47 10/23/97 5:36p Jason |
| 441 | * added splinter objects (probably temporary) |
| 442 | * |
| 443 | * 46 10/23/97 2:06p Chris |
| 444 | * Added physics structural support for walkers/flyers with reduced |
| 445 | * physics |
| 446 | * |
| 447 | * 45 10/22/97 4:19p Jason |
| 448 | * added lifetime field to object structure |
| 449 | * |
| 450 | * 44 10/20/97 5:54p Jason |
| 451 | * added polygon_object flag |
| 452 | * |
| 453 | * 43 10/20/97 4:46p Jason |
| 454 | * changes for explosions |
| 455 | * |
| 456 | * 42 10/15/97 5:07p Chris |
| 457 | * Added a gravity mask define |
| 458 | * |
| 459 | * 41 10/14/97 6:53p Chris |
| 460 | * Added the initial SOAR support |
| 461 | * |
| 462 | * 40 10/03/97 5:11p Chris |
| 463 | * Wrong MAX_OBJECT_TYPES fixed |
| 464 | * |
| 465 | * 39 10/03/97 4:43p Chris |
| 466 | * added debug fvi call and object type line |
| 467 | * |
| 468 | * 38 10/02/97 1:04p Jason |
| 469 | * implemented FreeAllObjects |
| 470 | * |
| 471 | * 37 10/01/97 7:00p Jason |
| 472 | * did more work on object lightmaps |
| 473 | * |
| 474 | * 36 10/01/97 6:15p Matt |
| 475 | * Added object type for rooms, and changed object id to a short |
| 476 | * |
| 477 | * 35 10/01/97 10:59a Chris |
| 478 | * |
| 479 | * 34 9/30/97 6:40p Jason |
| 480 | * got lightmap stuff sort of working with objects |
| 481 | * |
| 482 | * 33 9/24/97 6:18p Samir |
| 483 | * Use script names instead of script id values to identify scripts. |
| 484 | * |
| 485 | * 32 9/22/97 6:20p Matt |
| 486 | * Removed some obsolete render type constants |
| 487 | * |
| 488 | * 31 9/19/97 6:58p Chris |
| 489 | * Fixed some bugs with the big object system and removed some annoying |
| 490 | * mprintf's |
| 491 | * |
| 492 | * 30 9/19/97 1:01p Chris |
| 493 | * Better big object support |
| 494 | * |
| 495 | * 29 9/18/97 1:27p Matt |
| 496 | * Cleaned up object struct |
| 497 | * |
| 498 | * 28 9/17/97 12:02p Jason |
| 499 | * put back segnum field in object struct (for the terrain) |
| 500 | * |
| 501 | * 27 9/17/97 11:16a Matt |
| 502 | * Ripped out segment code |
| 503 | * |
| 504 | * 26 9/15/97 5:21a Chris |
| 505 | * Added sphere2poly support |
| 506 | * |
| 507 | * 25 9/12/97 6:36p Chris |
| 508 | * Added collision terrain segment support |
| 509 | * Added some LARGE OBJECT collision support |
| 510 | * |
| 511 | * 24 9/11/97 5:38p Jason |
| 512 | * initial door coding for room engine |
| 513 | * |
| 514 | * 23 9/10/97 5:17p Jason |
| 515 | * more lighting improvements |
| 516 | * |
| 517 | * 22 9/05/97 1:29p Jason |
| 518 | * revamped generic object lighting |
| 519 | * |
| 520 | * 21 9/04/97 3:21p Jason |
| 521 | * added pulse timing for lit objects |
| 522 | * |
| 523 | * 20 9/03/97 6:17p Jason |
| 524 | * added code to support powerups/robots/etc that cast light |
| 525 | * |
| 526 | * 19 9/03/97 3:54p Jason |
| 527 | * got objects to cast light |
| 528 | * |
| 529 | * 18 9/03/97 2:12p Chris |
| 530 | * Added new weapon battery system and made the animation system usable. |
| 531 | * |
| 532 | * 17 8/13/97 4:53p Matt |
| 533 | * Added OF_DESTROYABLE flag |
| 534 | * |
| 535 | * 16 8/12/97 3:56p Matt |
| 536 | * Added new object type: OBJ_BUILDING |
| 537 | * |
| 538 | * 15 8/12/97 1:13p Chris |
| 539 | * Added AABBs. |
| 540 | * |
| 541 | * 14 8/11/97 9:57p Samir |
| 542 | * Added scripts to objects. |
| 543 | * |
| 544 | * 13 8/07/97 4:44p Chris |
| 545 | * Massively expanded the weapon system. Not done yet. |
| 546 | * |
| 547 | * 12 8/06/97 4:32p Chris |
| 548 | * Expanded the weapons page |
| 549 | * |
| 550 | * 11 8/04/97 4:09p Matt |
| 551 | * Added ObjSetPos() that takes the new room number |
| 552 | * |
| 553 | * 10 7/29/97 10:27a Jason |
| 554 | * added RenderOBject abstraction layer |
| 555 | * |
| 556 | * 9 7/28/97 1:14p Chris |
| 557 | * Added support for sub-object visability. Plus, debris. |
| 558 | * |
| 559 | * 8 7/15/97 5:32p Jason |
| 560 | * got simple static lighting working with objects |
| 561 | * |
| 562 | * 7 7/15/97 4:59p Chris |
| 563 | * |
| 564 | * 6 7/15/97 4:59p Chris |
| 565 | * added support for AI and animations |
| 566 | * |
| 567 | * 23 6/30/97 5:03p Chris |
| 568 | * Added new AI stuff. |
| 569 | * |
| 570 | * 22 6/27/97 7:18p Matt |
| 571 | * Added OBJNUM() macro |
| 572 | * |
| 573 | * 21 5/22/97 5:15p Chris |
| 574 | * |
| 575 | * 20 5/16/97 2:17p Samir |
| 576 | * ResetPlayerObject added. |
| 577 | * |
| 578 | * 19 5/14/97 3:41p Chris |
| 579 | * |
| 580 | * 18 5/09/97 5:34p Samir |
| 581 | * Added object scripting to object structure. |
| 582 | * |
| 583 | * 17 4/24/97 5:42p Jason |
| 584 | * got fireball vclips working |
| 585 | * |
| 586 | * 16 4/14/97 3:48p Jason |
| 587 | * changed RT_LASER to RT_WEAPON |
| 588 | * |
| 589 | * 15 4/09/97 9:57p Chris |
| 590 | * Added more ability to customize ships/objects. |
| 591 | * |
| 592 | * 14 4/07/97 3:13p Chris |
| 593 | * |
| 594 | * 13 4/04/97 2:57p Matt |
| 595 | * Added code to initialize all the type-specific data for an object from |
| 596 | * the page for that object type. This means that we need to pass less |
| 597 | * info to ObjCreate(), and that we save less info in the level save file. |
| 598 | * It also makes it easy to reset all the objects when an object page has |
| 599 | * changed. |
| 600 | * |
| 601 | * 12 3/27/97 10:45a Chris |
| 602 | * Set player mass and drag info |
| 603 | * |
| 604 | * 11 3/21/97 5:02p Jason |
| 605 | * change short to int in segnum field of object struct |
| 606 | * |
| 607 | * 10 3/20/97 5:45p Jason |
| 608 | * made object work with and render on terrain |
| 609 | * |
| 610 | * 9 3/20/97 12:17p Jason |
| 611 | * added terrain flag to object flags |
| 612 | * |
| 613 | * 8 3/14/97 12:18p Chris |
| 614 | * Tweak physics and remove braking for now. |
| 615 | * |
| 616 | * 7 2/13/97 12:16p Jason |
| 617 | * changes for powerup remapping |
| 618 | * |
| 619 | * 6 2/11/97 6:51p Matt |
| 620 | * Ripped out some old stuff & renamed a function |
| 621 | * |
| 622 | * 5 2/07/97 5:48p Matt |
| 623 | * Renamed vector.h to vecmat.h to fix DevStudio problem |
| 624 | * |
| 625 | * $NoKeywords: $ |
| 626 | */ |
| 627 | |
| 628 | #ifndef _OBJECT_H |
| 629 | #define _OBJECT_H |
| 630 | |
| 631 | #include "pstypes.h" |
| 632 | #include "pserror.h" |
| 633 | #include "object_external_struct.h" |
| 634 | #include "object_external.h" |
| 635 | |
| 636 | /* |
| 637 | * CONSTANTS |
| 638 | */ |
| 639 | |
| 640 | // Object handle stuff. |
| 641 | // The handle is comprised of the object number in the low 10 bits, and a count in the high 22 bits. |
| 642 | #define HANDLE_OBJNUM_MASK 0x7ff // to mask off the object number part of the handle |
| 643 | #define HANDLE_COUNT_MASK 0xfffff800 // to maks off the count part of the handle |
| 644 | #define HANDLE_COUNT_INCREMENT 0x800 // what gets added to the handle to increment it |
| 645 | |
| 646 | // See object external for OBJ_ types |
| 647 | |
| 648 | // Lighting render types |
| 649 | #define LRT_STATIC 0 |
| 650 | #define LRT_GOURAUD 1 |
| 651 | #define LRT_LIGHTMAPS 2 |
| 652 | |
| 653 | extern char *Object_type_names[MAX_OBJECT_TYPES]; |
| 654 | |
| 655 | // stuctures for different kinds of weapon simulation (for precompution) |
| 656 | |
| 657 | #define WPC_NOT_USED 0 |
| 658 | #define WPC_NO_COLLISIONS 1 |
| 659 | #define WPC_HIT_WALL 2 |
| 660 | |
| 661 | #define FMA_VALID 1 |
| 662 | #define FMA_CURRENT 2 |
| 663 | #define FMA_LOOPING 4 |
| 664 | #define FMA_USE_SPEED 8 |
| 665 | #define FMA_HAS_AI 16 |
| 666 | |
| 667 | #define FMT_NEW_DATA 1 |
| 668 | #define FMT_UPDATING 2 |
| 669 | |
| 670 | // object light info flags |
| 671 | #define OLF_FLICKERING 1 |
| 672 | #define OLF_TIMEBITS 2 |
| 673 | #define OLF_PULSE 4 |
| 674 | #define OLF_PULSE_TO_SECOND 8 |
| 675 | #define OLF_FLICKER_SLIGHTLY 16 |
| 676 | #define OLF_DIRECTIONAL 32 // Directional light - casts light in a cone |
| 677 | #define OLF_NO_SPECULARITY 64 // Object does not have specular light cast on it |
| 678 | |
| 679 | // OSIRIS defines |
| 680 | #define MAX_MODULENAME_LEN 32 |
| 681 | |
| 682 | // How long an object name can be |
| 683 | #define OBJ_NAME_LEN 19 // max length for object name |
| 684 | |
| 685 | /* |
| 686 | * VARIABLES |
| 687 | */ |
| 688 | |
| 689 | extern object Objects[]; |
| 690 | extern int Highest_object_index; // highest objnum |
| 691 | |
| 692 | extern object *Player_object; // the object that is the player |
| 693 | extern object *Viewer_object; // which object we are seeing from |
| 694 | |
| 695 | #define MAX_BIG_OBJECTS 350 |
| 696 | extern int Num_big_objects; |
| 697 | extern int16_t BigObjectList[MAX_BIG_OBJECTS]; // DAJ_MR utb int |
| 698 | |
| 699 | // Compute the object number from an object pointer |
| 700 | #define OBJNUM(objp) (objp - Objects) |
| 701 | #define OBJHANDLE(objp) ((objp) ? (objp)->handle : 0) |
| 702 | |
| 703 | /* |
| 704 | * FUNCTIONS |
| 705 | */ |
| 706 | |
| 707 | // Set the dead flag for an object |
| 708 | static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove = false, bool play_sound_on_clients = false); |
| 709 | static inline void SetObjectDeadFlag(object *obj, bool tell_clients_to_remove, bool play_sound_on_clients) { |
| 710 | int objnum = OBJNUM(obj); |
| 711 | ASSERT(objnum != -1); |
| 712 | ASSERT(objnum != 0); |
| 713 | ASSERT(obj->type != OBJ_NONE); |
| 714 | ASSERT(obj != Player_object); |
| 715 | |
| 716 | obj->flags |= OF_DEAD; |
| 717 | |
| 718 | if (tell_clients_to_remove) { |
| 719 | if (play_sound_on_clients) { |
| 720 | obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATHWS; |
| 721 | } else { |
| 722 | obj->flags |= OF_SEND_MULTI_REMOVE_ON_DEATH; |
| 723 | } |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | void SetObjectControlType(object *obj, int control_type); |
| 728 | |
| 729 | // do whatever setup needs to be done |
| 730 | void InitObjects(void); |
| 731 | |
| 732 | // links an object into a room's list of objects. |
| 733 | // takes object number and room number |
| 734 | void ObjLink(int objnum, int roomnum); |
| 735 | |
| 736 | // reverses ObjLink. |
| 737 | void ObjUnlink(int objnum); |
| 738 | |
| 739 | // Sets the AABB for the object |
| 740 | void ObjSetAABB(object *obj); |
| 741 | |
| 742 | // initialize a new object. adds to the list for the given room |
| 743 | // returns the object number |
| 744 | int ObjCreate(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient, |
| 745 | int parent_handle = OBJECT_HANDLE_NONE); |
| 746 | |
| 747 | // remove object from the world |
| 748 | void ObjDelete(int objnum); |
| 749 | |
| 750 | // Resets the handles for all the objects. Called by the editor to init a new level. |
| 751 | void ResetObjectList(); |
| 752 | |
| 753 | // Builds the free object list by scanning the list of free objects & adding unused ones to the list |
| 754 | // Also sets Highest_object_index |
| 755 | void ResetFreeObjects(); |
| 756 | |
| 757 | // Frees all the objects that are currently in use |
| 758 | void FreeAllObjects(); |
| 759 | |
| 760 | // Deletes all objects that have been marked for death. |
| 761 | void ObjDeleteDead(); |
| 762 | |
| 763 | // Process all objects for the current frame |
| 764 | void ObjDoFrameAll(); |
| 765 | |
| 766 | // set viewer object to next object in array |
| 767 | void ObjGotoNextViewer(); |
| 768 | |
| 769 | // move an object for the current frame |
| 770 | void ObjMoveOne(object *obj); |
| 771 | |
| 772 | // Sets the position of an object. This should be called whenever an object moves. |
| 773 | // Parameters: obj - the object being moved |
| 774 | // pos - the new position |
| 775 | // roomnum - the correct roomnum for pos. No error checking is done. |
| 776 | // orient - if this is not null, the object's orientation is set to this. |
| 777 | void ObjSetPos(object *obj, vector *pos, int roomnum, matrix *orient, bool f_update_attached_children); |
| 778 | void ObjSetOrient(object *obj, const matrix *orient); |
| 779 | |
| 780 | // delete objects, such as weapons & explosions, that shouldn't stay between levels |
| 781 | // if clear_all is set, clear even proximity bombs |
| 782 | void ClearTransientObjects(int clear_all); |
| 783 | |
| 784 | // Remaps all static powerups,sounds,etc to their appropriate indices |
| 785 | void RemapEverything(); |
| 786 | |
| 787 | void BigObjAdd(int objnum); |
| 788 | void InitBigObjects(void); |
| 789 | |
| 790 | // Creates the player object in the center of the given room |
| 791 | void CreatePlayerObject(int roomnum); |
| 792 | |
| 793 | // Retruns a pointer to an object given its handle. Returns NULL if object no longer exists. |
| 794 | object *ObjGet(int handle); |
| 795 | |
| 796 | // returns a vertex of an object in WORLD coordinates. |
| 797 | void GetObjectPointInWorld(vector *dest, object *obj, int subnum, int vertnum); |
| 798 | |
| 799 | // These functions are for setting and getting an objects animation information |
| 800 | // (used in multiplayer games and the like) |
| 801 | bool ObjGetAnimUpdate(uint16_t objnum, custom_anim *multi_anim_info); |
| 802 | void ObjSetAnimUpdate(uint16_t objnum, custom_anim *multi_anim_info); |
| 803 | |
| 804 | void ObjGetTurretUpdate(uint16_t objnum, multi_turret *multi_turret_info); |
| 805 | void ObjSetTurretUpdate(uint16_t objnum, multi_turret *multi_turret_info); |
| 806 | |
| 807 | // Returns the original parent for the given object. Returns self if it has no parent |
| 808 | object *ObjGetUltimateParent(object *child); |
| 809 | |
| 810 | // Sets an object to a type OBJ_DUMMY (saves its old type) so it won't be renderered, etc, but still alive |
| 811 | void ObjGhostObject(int objnum); |
| 812 | |
| 813 | // Restores a ghosted object back to it's old type |
| 814 | void ObjUnGhostObject(int objnum); |
| 815 | |
| 816 | ///////////////////////////////// |
| 817 | // Position history information |
| 818 | // ---Not to be externalized--- |
| 819 | // Used for motion blur |
| 820 | ///////////////////////////////// |
| 821 | #define MAX_OBJECT_POS_HISTORY (MAX_OBJECTS / 2) |
| 822 | #define MAX_POSITION_HISTORY 3 |
| 823 | struct tPosHistory { |
| 824 | vector pos[MAX_POSITION_HISTORY]; |
| 825 | }; |
| 826 | extern tPosHistory Object_position_samples[MAX_OBJECT_POS_HISTORY]; |
| 827 | extern uint8_t Object_position_head; |
| 828 | extern int16_t Object_map_position_history[MAX_OBJECTS]; |
| 829 | extern float Last_position_history_update[MAX_POSITION_HISTORY]; // last gametime the positions were updated |
| 830 | void ObjInitPositionHistory(object *obj); |
| 831 | void ObjFreePositionHistory(object *obj); |
| 832 | void ObjResetPositionHistory(void); |
| 833 | void ObjReInitPositionHistory(void); |
| 834 | #endif |