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