| 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_external_struct.h $ |
| 21 | * $Revision: 19 $ |
| 22 | * $Date: 4/28/99 11:28a $ |
| 23 | * $Author: Jason $ |
| 24 | * |
| 25 | * Contains the structures needed for object definition (can be exported if needed to DLLs) |
| 26 | * |
| 27 | * $Log: /DescentIII/main/object_external_struct.h $ |
| 28 | * |
| 29 | * 19 4/28/99 11:28a Jason |
| 30 | * made real viseffects not cast light |
| 31 | * |
| 32 | * 18 4/22/99 4:13p Matt |
| 33 | * Deleted sounds array from the object struct, since it was never used. |
| 34 | * |
| 35 | * 17 4/21/99 12:41p Jason |
| 36 | * make explosion system framerate independant |
| 37 | * |
| 38 | * 16 4/18/99 8:13p Chris |
| 39 | * Fixed the floating flare problems (where windows where broken out and |
| 40 | * the flare remained) |
| 41 | * |
| 42 | * 15 4/06/99 6:02p Matt |
| 43 | * Added score system |
| 44 | * |
| 45 | * 14 4/05/99 4:39p Jason |
| 46 | * added groovy new smoke trails |
| 47 | * |
| 48 | * 13 4/05/99 10:31a Matt |
| 49 | * Changed soundsource volume from int to float. Duh. |
| 50 | * |
| 51 | * 12 4/03/99 4:24p Jason |
| 52 | * sped up attached vis effects by a large amount |
| 53 | * |
| 54 | * 11 3/28/99 5:56p Matt |
| 55 | * Added sparking effect for objects |
| 56 | * |
| 57 | * 10 2/25/99 11:01a Matt |
| 58 | * Added new explosion system. |
| 59 | * |
| 60 | * 9 2/25/99 10:30a Jason |
| 61 | * added nonvis generic/robot system |
| 62 | * |
| 63 | * 8 2/22/99 2:04p Jason |
| 64 | * added different damages for players and generics |
| 65 | * |
| 66 | * 7 2/21/99 4:20p Matt |
| 67 | * Added SoundSource objects (and reformatted parts of the object header |
| 68 | * files). |
| 69 | * |
| 70 | * 6 2/09/99 9:58a Chris |
| 71 | * Massive BOA update :) Terrain happy now. Vis happy now. Sound happy |
| 72 | * now. |
| 73 | * |
| 74 | * 5 2/03/99 12:43a Chris |
| 75 | * Added Obj_GetGroundPos |
| 76 | * |
| 77 | * 4 2/01/99 4:17p Jason |
| 78 | * more changes for multisafe |
| 79 | * |
| 80 | * 3 1/22/99 8:53p Jeff |
| 81 | * added custom-default script overrides |
| 82 | * |
| 83 | * 2 1/21/99 11:15p Jeff |
| 84 | * pulled out some structs and defines from header files and moved them |
| 85 | * into seperate header files so that multiplayer dlls don't require major |
| 86 | * game headers, just those new headers. Side effect is a shorter build |
| 87 | * time. Also cleaned up some header file #includes that weren't needed. |
| 88 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 89 | * manage.h and multi.h |
| 90 | * |
| 91 | * $NoKeywords: $ |
| 92 | */ |
| 93 | |
| 94 | #include <cstdint> |
| 95 | |
| 96 | #include "vecmat_external.h" |
| 97 | #include "robotfirestruct.h" |
| 98 | |
| 99 | #include "polymodel_external.h" |
| 100 | |
| 101 | #include "aistruct.h" //Not to be included for multiplayer game sdk |
| 102 | |
| 103 | #ifndef OBJECT_EXTERNAL_STRUCT_H |
| 104 | #define OBJECT_EXTERNAL_STRUCT_H |
| 105 | |
| 106 | // IMPORTANT: make sure MAX_OBJECTS meshes with handle bit allocation |
| 107 | #define MAX_OBJECTS 1500 // total number of objects in world |
| 108 | |
| 109 | // Splinter stuff |
| 110 | #define MAX_VERTS_PER_SPLINTER 4 |
| 111 | |
| 112 | /* |
| 113 | * MACROS |
| 114 | */ |
| 115 | |
| 116 | // Flags and masks for cell numbers |
| 117 | #define ROOMNUM_CELLNUM_FLAG 0x80000000 |
| 118 | #define ROOMNUM_CELLNUM_MASK 0x7fffffff |
| 119 | |
| 120 | // Get a cell number from a room number |
| 121 | #define CELLNUM(roomnum) ((roomnum) & ROOMNUM_CELLNUM_MASK) |
| 122 | |
| 123 | // Make a room number from a cell number |
| 124 | #define MAKE_ROOMNUM(cellnum) ((cellnum) | ROOMNUM_CELLNUM_FLAG) |
| 125 | |
| 126 | // Determine if a roomnum is really a cell number |
| 127 | #define ROOMNUM_OUTSIDE(roomnum) (((roomnum) & ROOMNUM_CELLNUM_FLAG) != 0) |
| 128 | |
| 129 | // Determine if an object is outside |
| 130 | #define OBJECT_OUTSIDE(objp) ROOMNUM_OUTSIDE((objp)->roomnum) |
| 131 | |
| 132 | /* |
| 133 | * STRUCTURES |
| 134 | */ |
| 135 | |
| 136 | // lighting info |
| 137 | struct light_info { |
| 138 | int32_t flags; // see above |
| 139 | float light_distance; |
| 140 | float red_light1, green_light1, blue_light1; |
| 141 | float red_light2, green_light2, blue_light2; |
| 142 | float time_interval; |
| 143 | float flicker_distance; |
| 144 | float directional_dot; |
| 145 | int32_t timebits; |
| 146 | uint8_t angle; |
| 147 | uint8_t lighting_render_type; |
| 148 | }; |
| 149 | |
| 150 | struct effect_info_s { |
| 151 | int32_t type_flags; // see EF_FLAGS above |
| 152 | |
| 153 | float alpha; // alpha value |
| 154 | float deform_range; // how many units to deform when drawing |
| 155 | float cloak_time; // how much time left cloaked |
| 156 | float deform_time; // how much time left deforming |
| 157 | float color_time; // how much time left colored |
| 158 | float r, g, b; |
| 159 | |
| 160 | // For fading in/out |
| 161 | float fade_time; |
| 162 | float fade_max_time; |
| 163 | |
| 164 | float damage_time; |
| 165 | float damage_per_second; // how much damage this object takes per second |
| 166 | float last_damage_time; // last time this object took damage |
| 167 | int32_t damage_handle; // the object handle of the owner of the damage |
| 168 | |
| 169 | float volume_change_time; |
| 170 | vector volume_old_pos; |
| 171 | int32_t volume_old_room; |
| 172 | |
| 173 | // For powerups only |
| 174 | float last_object_hit_time; |
| 175 | int32_t last_object_hit; |
| 176 | |
| 177 | // For specular lighting |
| 178 | vector spec_pos; |
| 179 | float spec_mag; |
| 180 | float spec_r, spec_g, spec_b; |
| 181 | |
| 182 | // For dynamic volume lighting |
| 183 | uint8_t dynamic_this_frame; |
| 184 | float dynamic_red, dynamic_green, dynamic_blue; |
| 185 | |
| 186 | // For liquid object |
| 187 | float liquid_time_left; |
| 188 | uint8_t liquid_mag; |
| 189 | |
| 190 | // For freeze objects |
| 191 | float freeze_scalar; |
| 192 | |
| 193 | // For attach objects |
| 194 | int32_t attach_line_handle; // handle to the object that this object is tethered to |
| 195 | |
| 196 | // Sound for special effects |
| 197 | int32_t sound_handle; |
| 198 | |
| 199 | // For spark effect |
| 200 | float spark_delay; // delay between sparks |
| 201 | float spark_timer; // how long until next spark |
| 202 | float spark_time_left; // how long until sparking stops |
| 203 | |
| 204 | }; |
| 205 | |
| 206 | // Describes the next animation state for a robot |
| 207 | struct custom_anim { |
| 208 | float server_time; |
| 209 | uint16_t server_anim_frame; |
| 210 | |
| 211 | uint16_t anim_start_frame; |
| 212 | uint16_t anim_end_frame; |
| 213 | float anim_time; |
| 214 | float max_speed; |
| 215 | |
| 216 | int16_t anim_sound_index; |
| 217 | uint8_t flags; |
| 218 | int8_t next_anim_type; |
| 219 | }; |
| 220 | |
| 221 | struct multi_turret { |
| 222 | float time; |
| 223 | float last_time; |
| 224 | uint8_t num_turrets; |
| 225 | float *last_keyframes; |
| 226 | float *keyframes; |
| 227 | uint8_t flags; |
| 228 | }; |
| 229 | |
| 230 | // Information specific to objects that render as a polygon model |
| 231 | struct polyobj_info { |
| 232 | int16_t model_num; // Which polygon model this object is |
| 233 | int16_t dying_model_num; // The dying model for this object |
| 234 | |
| 235 | float anim_start_frame; |
| 236 | float anim_frame; // The model's current animation frame |
| 237 | float anim_end_frame; |
| 238 | float anim_time; |
| 239 | uint32_t anim_flags; // Looping/notify at finish/pending |
| 240 | float max_speed; |
| 241 | |
| 242 | union { |
| 243 | custom_anim multi_anim_info; // Multiplayer client info |
| 244 | custom_anim custom_anim_info; // Single-player/Server custom anim AIA_CUSTOM info |
| 245 | }; |
| 246 | multi_turret multi_turret_info; |
| 247 | |
| 248 | uint32_t subobj_flags; // Mask of which subobjects to draw |
| 249 | int32_t tmap_override; // If this is not -1, map all faces to this |
| 250 | }; |
| 251 | |
| 252 | // A shard of, presumably, glass |
| 253 | struct shard_info_s { |
| 254 | vector points[3]; |
| 255 | float u[3], v[3]; |
| 256 | vector normal; |
| 257 | int16_t tmap; |
| 258 | }; |
| 259 | |
| 260 | struct line_info_s { |
| 261 | vector end_pos; // start pos is the object's .pos field |
| 262 | }; |
| 263 | |
| 264 | struct blast_info_s { |
| 265 | float max_size; |
| 266 | int32_t bm_handle; |
| 267 | }; |
| 268 | |
| 269 | struct dying_info_s { |
| 270 | int32_t death_flags; // Info about the death |
| 271 | float delay_time; // How long until object dies |
| 272 | int32_t killer_playernum; // The player who wille this object, or -1 if not a player |
| 273 | float last_spark_time; |
| 274 | float last_fireball_time; |
| 275 | float last_smoke_time; |
| 276 | }; |
| 277 | |
| 278 | struct debris_info_s { |
| 279 | int32_t death_flags; // a copy of the parent's death flags |
| 280 | float last_smoke_time; |
| 281 | }; |
| 282 | |
| 283 | struct laser_info_s { |
| 284 | int16_t parent_type; // The type of the parent of this object |
| 285 | int16_t src_gun_num; // The src gunpoint that this object fired from |
| 286 | |
| 287 | int32_t last_hit_handle; // For persistent weapons (survive object collision), object it most recently hit. |
| 288 | int32_t track_handle; // Object this object is tracking. |
| 289 | float last_track_time; // Last track time (see if an object is visible) |
| 290 | |
| 291 | int32_t hit_status; // Zero not used |
| 292 | vector hit_pnt; |
| 293 | vector hit_wall_pnt; |
| 294 | vector hit_wall_normal; |
| 295 | int32_t hit_room; |
| 296 | int32_t hit_pnt_room; |
| 297 | int16_t hit_face; |
| 298 | |
| 299 | float multiplier; // Power if this is a fusion bolt (or other super weapon to be added). |
| 300 | float thrust_left; // How many seconds of thrust are left before the weapon stops thrusting |
| 301 | |
| 302 | float last_drop_time; // Last time a particle was dropped from this weapon |
| 303 | vector last_smoke_pos; // Last place smoke was dropped from this weapon |
| 304 | bool casts_light; // Whether or not this weapon casts light |
| 305 | }; |
| 306 | |
| 307 | struct powerup_info_s { |
| 308 | int32_t count; // how many/much we pick up (vulcan cannon only?) |
| 309 | }; |
| 310 | |
| 311 | struct splinter_info_s { |
| 312 | uint8_t subobj_num; |
| 313 | int16_t facenum; |
| 314 | vector verts[MAX_VERTS_PER_SPLINTER]; |
| 315 | vector center; |
| 316 | }; |
| 317 | |
| 318 | // Data for sourcesource objects |
| 319 | struct soundsource_info_s { |
| 320 | int32_t sound_index; |
| 321 | float volume; |
| 322 | }; |
| 323 | |
| 324 | // information for physics sim for an object |
| 325 | // Some of this stuff is not object instance dependant -- so, it could be moved into |
| 326 | // a different struct to save space. (But, then we cannot change it -- i.e we might want a powerup |
| 327 | // to change the mass of an object...) Wait to move until we are optimizing -- see Chris if you move any fields |
| 328 | // out of the physics_info struct. Thanx! |
| 329 | struct physics_info { |
| 330 | vector velocity; // Velocity vector of this object |
| 331 | vector thrust; // Constant force applied to this object |
| 332 | union { |
| 333 | vector rotvel; // Rotational velecity (angles) |
| 334 | float turn_rate; |
| 335 | }; |
| 336 | union { |
| 337 | vector rotthrust; // Rotational acceleration |
| 338 | }; |
| 339 | angle turnroll; // Rotation caused by turn banking |
| 340 | float last_still_time; // The current delta position a wiggle has caused. |
| 341 | int32_t num_bounces; // Number of bounces before exploding (PHYSICS_UNLIMITED_BOUNCE is for unlimited bouncing) |
| 342 | |
| 343 | float coeff_restitution; // What percent of velocity is kept after a bounce |
| 344 | float mass; // The mass of this object -- what about moving into type info |
| 345 | float drag; // How fast this slows down -- what about moving into type info |
| 346 | float rotdrag; // How much resistance to a change in spin rate -- what about moving into type info |
| 347 | union { |
| 348 | float full_thrust; // Maximum thrust magnitude -- what about moving into type info |
| 349 | float max_velocity; |
| 350 | }; |
| 351 | union { |
| 352 | float full_rotthrust; // Maximum rotation thrust magnitude -- what about moving into type info |
| 353 | float max_turn_rate; |
| 354 | }; |
| 355 | float max_turnroll_rate; // How fast is the maximum turnroll rate -- what about moving into type info |
| 356 | float turnroll_ratio; // How much roll for a given turning rate -- what about moving into type info |
| 357 | float wiggle_amplitude; // The amplitude of an object's wiggle -- what about moving into type info |
| 358 | float wiggles_per_sec; // How fast something wiggles -- what about moving into type info |
| 359 | |
| 360 | vector dest_pos; // destination position for interpolating velocity (for multiplayer only) |
| 361 | |
| 362 | union { |
| 363 | float hit_die_dot; |
| 364 | int32_t stuck_room; |
| 365 | }; |
| 366 | |
| 367 | union { |
| 368 | float max_speed_time; |
| 369 | int32_t stuck_portal; |
| 370 | }; |
| 371 | |
| 372 | uint32_t flags; // Misc physics flags |
| 373 | }; |
| 374 | |
| 375 | struct shockwave_info { |
| 376 | uint32_t damaged_list[(MAX_OBJECTS / 32) + 1]; |
| 377 | }; |
| 378 | |
| 379 | struct object_link_info { |
| 380 | int32_t parent_handle; |
| 381 | int32_t sobj_index; |
| 382 | vector fvec; |
| 383 | vector uvec; |
| 384 | vector pos; |
| 385 | }; |
| 386 | |
| 387 | struct tOSIRISScriptNode { |
| 388 | uint16_t DLLID; |
| 389 | uint16_t script_id; |
| 390 | void *script_instance; |
| 391 | }; |
| 392 | |
| 393 | struct tOSIRISScript { |
| 394 | tOSIRISScriptNode custom_script; |
| 395 | tOSIRISScriptNode mission_script; |
| 396 | tOSIRISScriptNode level_script; |
| 397 | tOSIRISScriptNode default_script; |
| 398 | }; |
| 399 | |
| 400 | // The data for an object |
| 401 | struct object { |
| 402 | uint8_t type; // what type of object this is... robot, weapon, hostage, powerup, fireball |
| 403 | uint8_t dummy_type; // stored type of an OBJ_DUMMY |
| 404 | uint16_t id; // which form of object...which powerup, robot, etc. |
| 405 | uint32_t flags; |
| 406 | |
| 407 | char *name; // the name of this object, or NULL |
| 408 | |
| 409 | int32_t handle; // unique handle for this object. See defines above |
| 410 | int16_t next, prev; // id of next and previous connected object in Objects, -1 = no connection |
| 411 | |
| 412 | uint8_t control_type; // how this object is controlled |
| 413 | uint8_t movement_type; // how this object moves |
| 414 | uint8_t render_type; // how this object renders |
| 415 | uint8_t lighting_render_type; // how this object is lit. See flags above |
| 416 | |
| 417 | int32_t roomnum; // room number or terrain cell containing object |
| 418 | |
| 419 | vector pos; // absolute x,y,z coordinate of center of object |
| 420 | matrix orient; // orientation of object in world |
| 421 | vector last_pos; // where object was last frame |
| 422 | |
| 423 | uint16_t renderframe; // framenum this object was last rendered |
| 424 | |
| 425 | vector wall_sphere_offset; |
| 426 | vector anim_sphere_offset; |
| 427 | |
| 428 | float size; // 3d size of object - for collision detection |
| 429 | float shields; // Starts at maximum, when <0, object dies.. |
| 430 | |
| 431 | int8_t contains_type; // Type of object this object contains (eg, spider contains powerup) |
| 432 | int8_t contains_id; // ID of object this object contains (eg, id = blue type = key) |
| 433 | int8_t contains_count; // number of objects of type:id this object contains |
| 434 | int8_t pad3; // keep alignment |
| 435 | |
| 436 | float creation_time; // absolute time when this object was created |
| 437 | float lifeleft; // how long until goes away, if OF_USES_LIFELEFT flag is set |
| 438 | float lifetime; // How long this object stays alive (in seconds) |
| 439 | |
| 440 | int32_t parent_handle; // The handle of this object's parent |
| 441 | |
| 442 | int32_t attach_ultimate_handle; |
| 443 | int32_t attach_parent_handle; |
| 444 | int32_t *attach_children; // List of object handles for connected children |
| 445 | |
| 446 | uint8_t weapon_fire_flags; // Used to indicate special weapon effects. See flags above. |
| 447 | |
| 448 | int8_t attach_type; |
| 449 | int16_t lowest_attached_vis; |
| 450 | union { |
| 451 | float attach_dist; |
| 452 | int16_t attach_index; |
| 453 | }; |
| 454 | |
| 455 | // Movement info, determined by MOVEMENT_TYPE |
| 456 | union { |
| 457 | physics_info phys_info; // a physics object |
| 458 | shockwave_info shock_info; |
| 459 | object_link_info obj_link_info; |
| 460 | } mtype; |
| 461 | |
| 462 | // Collition detection stuff |
| 463 | vector min_xyz, max_xyz; // the current min & max extents of this object's sphere |
| 464 | |
| 465 | // Current weapon battery info for this object |
| 466 | dynamic_wb_info *dynamic_wb; |
| 467 | |
| 468 | // Explosion information |
| 469 | float impact_size; |
| 470 | float impact_time; |
| 471 | float impact_player_damage; |
| 472 | float impact_generic_damage; |
| 473 | float impact_force; |
| 474 | |
| 475 | // Object change information |
| 476 | int32_t change_flags; |
| 477 | |
| 478 | // object generic vis flags |
| 479 | int32_t generic_nonvis_flags; |
| 480 | int32_t generic_sent_nonvis; |
| 481 | |
| 482 | lightmap_object lm_object; // The lightmap object for this object |
| 483 | |
| 484 | // Control info, determined by CONTROL_TYPE |
| 485 | union { |
| 486 | laser_info_s laser_info; |
| 487 | powerup_info_s powerup_info; |
| 488 | splinter_info_s splinter_info; |
| 489 | blast_info_s blast_info; |
| 490 | dying_info_s dying_info; |
| 491 | debris_info_s debris_info; |
| 492 | soundsource_info_s soundsource_info; |
| 493 | } ctype; |
| 494 | |
| 495 | ai_frame *ai_info; // AI information pointer |
| 496 | |
| 497 | // Render info, determined by RENDER_TYPE |
| 498 | union { |
| 499 | polyobj_info pobj_info; // polygon model |
| 500 | shard_info_s shard_info; // shard |
| 501 | #ifdef _DEBUG |
| 502 | line_info_s line_info; // line info |
| 503 | #endif |
| 504 | ddgr_color sphere_color; // for RT_EDITOR_SPHERE |
| 505 | } rtype; |
| 506 | |
| 507 | effect_info_s *effect_info; |
| 508 | light_info *lighting_info; // Pointer to lighting info, or NULL if inherits from type |
| 509 | |
| 510 | // Something to do with multiplayer, possibly, but it's hard to know for sure |
| 511 | // because some people are incapable of commented their code. |
| 512 | uint16_t position_counter; |
| 513 | |
| 514 | // OSIRIS Script Info (new OSIRIS) |
| 515 | tOSIRISScript *osiris_script; |
| 516 | |
| 517 | char *custom_default_script_name; |
| 518 | char *custom_default_module_name; |
| 519 | }; |
| 520 | |
| 521 | #endif |