Debian Codegraph @

Descent3/objinfo.h

raw symbols SCIP
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/objinfo.h $
21 * $Revision: 83 $
22 * $Date: 9/13/01 2:31p $
23 * $Author: Matt $
24 *
25 * Structure information about different kinds of objects
26 *
27 * $Log: /DescentIII/Main/objinfo.h $
28 *
29 * 83 9/13/01 2:31p Matt
30 * Increased MAX_OBJECT_IDS from 810 to 910, and made the value the same
31 * for the PC and Mac.
32 *
33 * 82 3/20/00 12:18p Matt
34 * Merge of Duane's post-1.3 changes.
35 * Lower MAX_OBJECT_IDS for Mac (Mac only)
36 *
37 * 81 10/28/99 12:44p 3dsmax
38 * Increased the number of Object IDs
39 *
40 * 80 10/26/99 10:32a Jeff
41 * no red guidebot in non-Windows versions
42 *
43 * 79 10/22/99 11:30a Matt
44 * Mac merge
45 *
46 * 78 10/20/99 5:40p Chris
47 * Added the Red Guidebot
48 *
49 * 77 10/08/99 4:29p Chris
50 *
51 * 76 10/08/99 4:24p 3dsmax
52 * upped number of objids (don't know who did this)
53 *
54 * 75 5/17/99 10:15p Matt
55 * Added system for having ambient objects that get deleted at low detail
56 * levels.
57 *
58 * 74 5/09/99 1:13p Matt
59 * Made ChaffChunk a static object.
60 *
61 * 73 5/09/99 2:01a Matt
62 * Increased max object IDs from 600 to 650.
63 *
64 * 72 5/06/99 1:04a Gwar
65 * adding object support to new editor -- place objects with right-click
66 * in orthogonal views (still needs many bug fixes :)
67 *
68 * 71 5/01/99 3:49a Chris
69 * Added the "No scale movement properties by diff level" checkbox
70 *
71 * 70 4/30/99 11:54p Jeff
72 * put max_object_ids back up to 600 for now
73 *
74 * 69 4/30/99 12:56p Kevin
75 * Lowered values for MAX_SOUNDS, MAX_ROOMS, MAX_TEXTURES and MAX_OBJIDS.
76 * Talk to me before changing any of these again.
77 *
78 * 68 4/28/99 5:06a Chris
79 * Added the no-scale damage by diff checkbox
80 *
81 * 67 4/22/99 7:08p Matt
82 * Reduced the number of object sounds from 3 to 2, since we were only
83 * using two.
84 *
85 * 66 4/22/99 4:13p Matt
86 * Deleted sounds array from the object struct, since it was never used.
87 *
88 * 65 4/22/99 11:33a Chris
89 * Added the ability of some generic objects to be able to go through
90 * forcefields and glass
91 *
92 * 64 4/21/99 2:50p Matt
93 * Killed function LoadObjectImage(), since it was only used in one file
94 * and only did a call to LoadPolygonModel()
95 *
96 * 63 4/21/99 1:23p Chris
97 * Added the check ceiling checkbox for generic objects
98 *
99 * 62 4/18/99 4:50p Matt
100 * Took out code that hacked in ammo amounts for weapon powerups, and
101 * added code to set the counts on the page and read and write to the
102 * table file.
103 *
104 * 61 4/15/99 1:41a Jeff
105 * changes for linux compile
106 *
107 * 60 4/14/99 10:31p Jeff
108 * fixed name of ai_info struct to t_ai_info
109 *
110 * 59 4/10/99 6:39p Matt
111 * Only save the designer-editable AI data in the Object_info array,
112 * instead of the whole ai_frame structure. This saves 3200 bytes per
113 * Object_info entry, which is about 2 MB overall.
114 *
115 * 58 4/02/99 11:23a Matt
116 * Made KillObject not take a death_info struct, but rather the death info
117 * as individual parameters. Moved death_info into objinfo.h, since it's
118 * only used for generic objects. Took out fade-away death hack, now that
119 * fade-away deaths can be explicitely set.
120 *
121 * 57 3/31/99 3:59p Chris
122 * made the MC_ stuff externalized to OSIRIS.
123 *
124 * 56 3/10/99 7:14p Jason
125 * upped max object id limit to 600
126 *
127 * 55 2/28/99 6:20p Matt
128 * Added the ability to set death types for generic objects.
129 *
130 * 54 2/23/99 12:39p Jason
131 * added more options for generic objects
132 *
133 * 53 2/22/99 11:24p Matt
134 * Deleted static debris objects, since they were never used
135 *
136 * 52 2/02/99 8:43a Chris
137 * I made buildings with AI work correctly (ie really big robots should be
138 * buildings)
139 * anim to and from states are now shorts instead of bytes
140 *
141 * 51 1/21/99 11:15p Jeff
142 * pulled out some structs and defines from header files and moved them
143 * into seperate header files so that multiplayer dlls don't require major
144 * game headers, just those new headers. Side effect is a shorter build
145 * time. Also cleaned up some header file #includes that weren't needed.
146 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
147 * manage.h and multi.h
148 *
149 * 50 1/19/99 4:22p Matt
150 * Added the ability for objects to have their own lighting info,
151 * different from the default lighting for that type of object.
152 *
153 * 49 1/13/99 2:29a Chris
154 * Massive AI, OSIRIS update
155 *
156 * 48 1/06/99 5:06p Chris
157 * Improving OSIRIS/game intergration - improved support for custom
158 * animations
159 *
160 * 47 12/30/98 5:17p Jeff
161 * changes made to handle script name override, to override the name of
162 * the script to use in a module.
163 *
164 * 46 12/18/98 6:00p Jeff
165 * added support for door scripts in new osiris
166 *
167 * 45 12/16/98 11:27a Jeff
168 * added new osiris fields
169 *
170 * 44 9/28/98 6:23p Chris
171 * Changed multi_anim to custom_anim
172 *
173 * 43 9/22/98 2:29p Kevin
174 * moved ships allowed code out of dll and into main app. Also added
175 * powerup exclusions
176 *
177 * 42 8/31/98 1:35p Keneta
178 * Made some use count unsigned shorts
179 *
180 * 41 8/31/98 10:41a Keneta
181 * increase max_object_ids
182 *
183 * 40 8/26/98 8:07p Jason
184 * added directional lights to objects
185 *
186 * 39 8/16/98 6:17p Chris
187 * Added generic object spewing code
188 *
189 * 38 8/13/98 11:55a Jeff
190 * added 2 flags for inventory information
191 *
192 * 37 7/10/98 2:12p Jeff
193 * added a flag for inventory information in objinfo
194 *
195 * 36 5/03/98 5:38p Chris
196 * Added sounds to anim page
197 *
198 * 35 4/30/98 12:22p Jason
199 * did some lo-res model optimizations
200 *
201 * 34 4/24/98 7:09p Jeff
202 * Added a flag for a non-useable inventory item
203 *
204 * 33 4/16/98 2:56p Chris
205 * Updated buddy support and intergrated scripting and AI
206 *
207 * 32 4/13/98 2:21p Chris
208 * Fixed some collision problems dealing with AABBs and Polymodel paging
209 * in.
210 *
211 * 31 4/06/98 4:53p Jason
212 * got pageable polymodels working correctly with editor
213 *
214 * 30 3/25/98 11:02a Chris
215 * version 1.0 of the new AI ranged firing code.
216 *
217 * 29 3/12/98 6:22p Jeff
218 * added an atexit call to free up any memory allocated in objinfos
219 *
220 * 28 2/20/98 5:50p Jeff
221 * Changed it so that whether an inventory item was selected was placed in
222 * the objinfo flags
223 *
224 * 27 2/20/98 4:55p Jeff
225 * Added inven_selectable field to determine if an object can be selected
226 * in the inventory
227 *
228 * 26 2/16/98 2:47a Chris
229 * Massive improvements to the animation system and the AI
230 *
231 * 25 2/06/98 6:18p Jason
232 * fixed model mixup bug
233 *
234 * 24 2/03/98 6:15p Jeff
235 * Added fields for inventory description and icon name
236 *
237 * 23 1/29/98 3:29p Chris
238 * Major update to the AI system.
239 *
240 * 22 1/05/98 3:54p Chris
241 * Added ambient and explosion sounds
242 *
243 * 21 12/01/97 9:54a Chris
244 * Added support for concussive forces, generalized robot collisions to
245 * generic collisions
246 *
247 * 20 11/25/97 12:28p Chris
248 * Starting to add support for concussive blast damage
249 *
250 * 19 11/25/97 12:29p Jason
251 * added LOD levels for certain objects
252 *
253 * 18 11/06/97 6:18p Jason
254 * added support for lights that flicker a little bit
255 *
256 * 17 10/29/97 12:36p Jason
257 * added some features to object lighting
258 *
259 * 16 10/28/97 12:22p Chris
260 * now use the ai_frame struct to store ai information in the generic
261 * objects
262 *
263 * 15 9/24/97 6:18p Samir
264 * Use script names instead of script id values to identify scripts.
265 *
266 * 14 9/10/97 5:17p Jason
267 * more lighting improvements
268 *
269 * 13 9/08/97 11:51a Chris
270 * Added support for entering seconds-per-cycle animation information
271 *
272 * 12 9/05/97 1:29p Jason
273 * revamped generic object lighting
274 *
275 * 11 9/04/97 3:21p Jason
276 * added pulse timing for lit objects
277 *
278 * 10 9/04/97 12:11p Jason
279 * added flickering generic objects
280 *
281 * 9 9/03/97 6:17p Jason
282 * added code to support powerups/robots/etc that cast light
283 *
284 * 8 9/03/97 2:12p Chris
285 * Added new weapon battery system and made the animation system usable.
286 *
287 * 7 8/22/97 3:03a Chris
288 *
289 * 6 8/13/97 4:54p Matt
290 * Added destroyable flag & hitpoints
291 *
292 * 5 8/11/97 6:48p Matt
293 * Rewrote static object remap system
294 *
295 * 4 8/11/97 1:53p Matt
296 * Ripped out robot & powerup pages, and added generic page
297 *
298 * 3 8/08/97 11:54a Matt
299 * Added constants from robot.h, and prototypes for the generic object
300 * functions.
301 *
302 * 2 8/06/97 2:21p Matt
303 *
304 * 1 8/06/97 2:20p Matt
305 * Generic object info for robots, powerups, etc.
306 *
307 * $NoKeywords: $
308 */
309
310 #ifndef _OBJINFO_H
311 #define _OBJINFO_H
312
313 #include "object.h"
314 #include "manage.h"
315 #include "DeathInfo.h"
316
317 #ifdef NEWEDITOR
318 #include "..\neweditor\ned_Object.h"
319 #include "..\neweditor\ned_Tablefile.h"
320 #endif
321
322 // max sizes for inventory information in the objinfo
323 #define MAX_INVEN_DESC_SIZE 180
324 #define MAX_INVEN_ICON_SIZE 30
325
326 // How many object ids in the array
327 #define MAX_OBJECT_IDS 910
328
329 // How many different sounds each object can make
330 #define MAX_OBJ_SOUNDS 2
331
332 // Object info flags
333 #define OIF_CONTROL_AI 0x01 // this object uses AI
334 #define OIF_USES_PHYSICS 0x02 // this object uses physics
335 #define OIF_DESTROYABLE 0x04 // this object can be destroyed
336 #define OIF_INVEN_SELECTABLE 0x08 // this object can be selected in the inventory
337 #define OIF_INVEN_NONUSEABLE 0x10 // this object can not be used by pressing ENTER during the game
338 #define OIF_INVEN_TYPE_MISSION 0x20 // this object is for Mission objectives
339 #define OIF_INVEN_NOREMOVE 0x40 // this object should NOT be removed from the inventory when used
340 #define OIF_INVEN_VISWHENUSED 0x80 // this object will not have it contol type, movement type and render types
341 #define OIF_AI_SCRIPTED_DEATH 0x100
342 #define OIF_DO_CEILING_CHECK 0x200
343 #define OIF_IGNORE_FORCEFIELDS_AND_GLASS 0x400
344 #define OIF_NO_DIFF_SCALE_DAMAGE 0x800
345 #define OIF_NO_DIFF_SCALE_MOVE 0x1000
346 #define OIF_AMBIENT_OBJECT (1 << 13) // this object is just for show, & can be removed to improve performance
347
348 // This next numbers define the distance at which LOD popping occurs in models
349 #define DEFAULT_MED_LOD_DISTANCE 75.0f
350 #define DEFAULT_LO_LOD_DISTANCE 120.0f
351
352 // The number of ids of each type in the list
353 extern int Num_object_ids[];
354
355 extern const char * const Movement_class_names[];
356 extern const char * const Anim_state_names[];
357
358 // These defines must correspond to the Static_object_names array
359 #define GENOBJ_GUIDEBOT 0 // NOTE: This must match ROBOT_GUIDEBOT
360 #define GENOBJ_CHAFFCHUNK 1
361 #define GENOBJ_GUIDEBOTRED 2 // NOTE: This must match ROBOT_GUIDEBOTRED
362
363 #define IS_GUIDEBOT(x) \
364 (((object *)x)->type == OBJ_ROBOT && \
365 ((((object *)x)->id == ROBOT_GUIDEBOTRED) || (((object *)x)->id == ROBOT_GUIDEBOT)))
366
367 // Animation constants
368 #define NUM_MOVEMENT_CLASSES 5
369 #define NUM_ANIMS_PER_CLASS 24
370
371 // Info for an animation state
372 struct anim_entry {
373 int16_t from, to;
374 float spc;
375 int anim_sound_index;
376 uint8_t used;
377 };
378
379 struct anim_elem {
380 anim_entry elem[NUM_ANIMS_PER_CLASS];
381 };
382
383 #define MAX_DSPEW_TYPES 2
384 #define DSF_ONLY_IF_PLAYER_HAS_OBJ_1 1
385 #define DSF_ONLY_IF_NO_1 2
386
387 // How many different deaths each object can have
388 #define MAX_DEATH_TYPES 4
389
390 // Death info for an object type
391 struct death_info {
392 uint32_t flags; // death flags
393 float delay_min; // if delay, min amount
394 float delay_max; // if delay, max amount
395 };
396
397 // AI info for this object
398 // This is the subset of ai_frame data that the user can edit for an object type
399 struct t_ai_info {
400 char ai_class;
401 char ai_type;
402
403 float max_velocity;
404 float max_delta_velocity;
405 float max_turn_rate;
406 float max_delta_turn_rate;
407
408 float attack_vel_percent;
409 float flee_vel_percent;
410 float dodge_vel_percent;
411
412 float circle_distance;
413 float dodge_percent;
414
415 float melee_damage[2];
416 float melee_latency[2];
417
418 int sound[MAX_AI_SOUNDS];
419
420 char movement_type;
421 char movement_subtype;
422
423 int flags;
424 int notify_flags;
425
426 float fov;
427
428 float avoid_friends_distance;
429
430 float frustration;
431 float curiousity;
432 float life_preservation;
433 float agression;
434
435 float fire_spread;
436 float night_vision;
437 float fog_vision;
438 float lead_accuracy;
439 float lead_varience;
440 float fight_team;
441 float fight_same;
442 float hearing;
443 float roaming;
444
445 float biased_flight_importance;
446 float biased_flight_min;
447 float biased_flight_max;
448 };
449
450 #ifndef NEWEDITOR
451
452 // Info for robots, powerups, debris, etc.
453 struct object_info {
454 char name[PAGENAME_LEN]; // the name on the page
455
456 int type; // what type of object this is
457 float size; // size
458 int flags; // misc flags. See above.
459
460 // int render_type; //set RT_ defines in object.h
461 int render_handle; // handle for bitmap/polygon model(hi-res)
462 int med_render_handle; // handle for med res version of this object
463 int lo_render_handle; // handle for lo res version of this object
464
465 float med_lod_distance; // The distance at which the med-res model takes over
466 float lo_lod_distance; // The distance at which the lo-res model takes over
467
468 int score; // how many points you get for killing/picking up
469
470 int hit_points; // if destroyable, the hit points
471 float damage;
472 float impact_size;
473 float impact_time;
474
475 int ammo_count; // if a powerup, how much ammo it has
476
477 char *description; // used for inventory
478 char icon_name[MAX_INVEN_ICON_SIZE]; // used for inventory
479
480 int16_t sounds[MAX_OBJ_SOUNDS]; // list of sound handles
481 int16_t dspew[MAX_DSPEW_TYPES];
482 float dspew_percent[MAX_DSPEW_TYPES];
483 int16_t dspew_number[MAX_DSPEW_TYPES];
484 uint8_t f_dspew;
485
486 // Valid for physics objects only
487 physics_info phys_info; // the physics data for this obj type
488
489 // Valid for lighting of objects
490 light_info lighting_info;
491
492 // for multiplayer respawning
493 float respawn_scalar;
494
495 bool multi_allowed;
496
497 // OSIRIS information
498 char module_name[MAX_MODULENAME_LEN];
499 char script_name_override[PAGENAME_LEN];
500
501 // Death information
502 death_info death_types[MAX_DEATH_TYPES]; // the ways this object can die
503 uint8_t death_probabilities[MAX_DEATH_TYPES]; // how likely each death is, from 0-100 (percent)
504
505 // Valid for AI objects only
506 t_ai_info *ai_info; // the AI info for this obj type
507
508 // Valid for polygon models with weapons
509 otype_wb_info *static_wb;
510 // otype_wb_info static_wb[MAX_WBS_PER_OBJ];
511
512 // Valid for polygon model objects only
513 anim_elem *anim; // which anim states are active
514 // anim_elem anim[NUM_MOVEMENT_CLASSES]; // which anim states are active
515
516 };
517
518 // The big array of object info
519 extern object_info Object_info[];
520
521 #endif
522
523 // Sets all objects to unused
524 void InitObjectInfo();
525
526 // Frees up all objects (any memory allocated, and resets them) automatic atexit
527 void FreeObjectInfo(void);
528
529 // Allocs a object for use, returns -1 if error, else index on success
530 // int AllocObjectID(int type, int flags);
531 int AllocObjectID(int type, bool f_anim, bool f_weapons, bool f_ai);
532
533 // Frees object index n
534 void FreeObjectID(int n);
535
536 // Find an object with the given type. Returns -1 if none found.
537 int GetObjectID(int type);
538
539 // Gets next object from n of the same type as n
540 int GetNextObjectID(int n);
541
542 // Gets previous object from n that has the same type
543 int GetPrevObjectID(int n);
544
545 // Searches thru all object ids for a specific name
546 // Returns the found id, or -1 if not found
547 int FindObjectIDName(const char *name);
548
549 // Given an object handle, returns an index to that object's model
550 int GetObjectImage(int handle);
551
552 // Given an object, renders the representation of this object
553 void DrawObject(object *obj);
554
555 // Moves an object from a given index into a new one (above MAX_STATIC_IDS)
556 // returns new index
557 int MoveObjectFromIndex(int index);
558
559 // Remap all the static object ids (objects that must have a specific index) into their assigned slots.
560 void RemapStaticIDs();
561
562 void ChangeOldModelsForObjects(int old_handle, int new_handle);
563
564 #endif