2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Debris/Debris.h $
15 * Code for the pieces of exploding object debris.
18 * Revision 1.2 2002/06/09 04:41:12 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:11 root
25 * 6 7/15/99 9:20a Andsager
26 * FS2_DEMO initial checkin
28 * 5 7/01/99 11:44a Dave
29 * Updated object sound system to allow multiple obj sounds per ship.
30 * Added hit-by-beam sound. Added killed by beam sound.
32 * 4 11/05/98 5:55p Dave
33 * Big pass at reducing #includes
35 * 3 10/16/98 1:22p Andsager
36 * clean up header files
38 * 2 10/07/98 10:52a Dave
41 * 1 10/07/98 10:48a Dave
43 * 29 4/02/98 6:30p Lawrance
44 * reduce max debris piece if DEMO defined
46 * 28 4/02/98 11:40a Lawrance
47 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
49 * 27 2/26/98 10:07p Hoffoss
50 * Rewrote state saving and restoring to fix bugs and simplify the code.
52 * 26 2/19/98 12:46a Lawrance
53 * Further work on asteroids.
55 * 25 2/10/98 6:43p Lawrance
56 * Moved asteroid code to a separate lib.
58 * 24 2/06/98 3:08p Mike
59 * More asteroid stuff, including resolving conflicts between the two
60 * asteroid_field structs!
62 * 23 2/05/98 12:51a Mike
63 * Early asteroid stuff.
65 * 22 1/29/98 5:50p John
66 * Made electrical arcing on debris pieces be persistent from frame to
69 * 21 1/21/98 7:18p Lawrance
70 * Fix bug with creating debris before the mission starts.
72 * 20 12/22/97 9:56p Andsager
73 * Implement ship:debris collisions. Generalize and move
74 * ship_ship_or_debris_hit struct from CollideShipShip to ObjCollide.h
76 * 19 11/19/97 5:57p Mike
77 * Make debris go away if more than N units away from the nearest player.
78 * Make speed of a docked object not read zero if it's moving.
80 * 18 10/01/97 10:52a Mike
81 * Change debris prototype to take an additional parameter to give debris
82 * more thrust when it is created.
84 * 17 9/20/97 9:25a John
85 * fixed bug with species specific debris shards.
87 * 16 8/13/97 9:50p Allender
88 * split *_move into *_process_pre and *_process_post functions.
89 * process_pre functions called before object is moved. _process_post
90 * functions called after object is moved. Reordered code in ship_post
91 * and weapon_post for multiplayer
93 * 15 7/24/97 8:35a Allender
94 * allow ships to blow up before missions starts. Made some debris system
95 * items available in other modules
97 * 14 7/13/97 5:53p Lawrance
98 * save model name in debris
100 * 13 7/02/97 11:48a Lawrance
101 * update debris to delay persistant sound
103 * 12 6/06/97 4:13p Lawrance
104 * leave debris chunks from very large ships persistant, scale fireball
105 * lifetime by ship radius
107 * 11 6/06/97 12:12p Lawrance
108 * limit hull debris pieces, destroying oldest debris to make way for new
111 * 10 5/14/97 4:08p Lawrance
112 * removing my_index from game arrays
114 * 9 4/03/97 12:23a Mike
115 * Make debris collidable-with. Can hit it, too.
116 * Make AI ships stop firing when target enters death roll.
118 * 8 3/31/97 11:11a John
119 * added ship species specific debris.
121 * 7 3/25/97 3:55p Lawrance
122 * allowing debris to be targeted and shown on radar
124 * 6 2/27/97 12:07p John
125 * Added code to suppord debris chunks after a ship is exploded..
127 * 5 2/26/97 2:18p Lawrance
128 * adding Debris[] to save/restore
130 * 4 2/10/97 12:38p John
131 * made all ships blow up into debris pieces when exploded.
133 * 3 2/07/97 10:45a John
134 * Initial bare bones implementation of blowing off turrets.
136 * 2 2/07/97 9:30a John
138 * 1 2/06/97 4:13p John
149 #define MAX_DEBRIS_ARCS 8 // Must be less than MAX_ARC_EFFECTS in model.h
151 typedef struct debris {
152 debris *next, *prev; // used for a linked list of the hull debris chunks
153 int flags; // See DEBRIS_??? defines
154 int source_objnum; // What object this came from
155 int source_sig; // Signature of the source object
156 int ship_info_index; // Ship info index of the ship type debris came from
157 int team; // Team of the ship where the debris came from
158 int objnum; // What object this is linked to
159 float lifeleft; // When 0 or less object dies
160 int model_num; // What model this uses
161 int submodel_num; // What submodel this uses
162 int next_fireball; // When to start a fireball
163 int is_hull; // indicates a large hull chunk of debris
164 int species; // What species this is from. -1 if don't care.
165 int fire_timeout; // timestamp that holds time for fireballs to stop appearing
166 int sound_delay; // timestamp to signal when sound should start
167 fix time_started; // time when debris was created
168 int next_distance_check; // timestamp to determine whether to delete this piece of debris.
170 vector arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
171 int arc_timestamp[MAX_DEBRIS_ARCS]; // When this times out, the spark goes away. -1 is not used
172 int arc_frequency; // Starts at 0, gets bigger
177 // flags for debris pieces
178 #define DEBRIS_USED (1<<0)
179 #define DEBRIS_EXPIRE (1<<1) // debris can expire (ie hull chunks from small ships)
183 #define MAX_DEBRIS_PIECES 48
185 #define MAX_DEBRIS_PIECES 64
188 extern debris Debris[MAX_DEBRIS_PIECES];
190 extern int Num_debris_pieces;
192 struct collision_info_struct;
195 void debris_render( object * obj );
196 void debris_delete( object * obj );
197 void debris_process_pre( object * obj, float frame_time);
198 void debris_process_post( object * obj, float frame_time);
199 object *debris_create( object * source_obj, int model_num, int submodel_num, vector *pos, vector *exp_center, int hull_flag, float exp_force );
200 int debris_check_collision( object * obj, object * other_obj, vector * hitpos, collision_info_struct *debris_hit_info=NULL );
201 void debris_hit( object * debris_obj, object * other_obj, vector * hitpos, float damage );
202 int debris_get_team(object *objp);
203 void debris_clear_expired_flag(debris *db);