]> icculus.org git repositories - taylor/freespace2.git/blob - include/debris.h
added copyright header
[taylor/freespace2.git] / include / debris.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Debris/Debris.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Code for the pieces of exploding object debris.
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:12  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:11  root
22  * Initial import.
23  *
24  * 
25  * 6     7/15/99 9:20a Andsager
26  * FS2_DEMO initial checkin
27  * 
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.
31  * 
32  * 4     11/05/98 5:55p Dave
33  * Big pass at reducing #includes
34  * 
35  * 3     10/16/98 1:22p Andsager
36  * clean up header files
37  * 
38  * 2     10/07/98 10:52a Dave
39  * Initial checkin.
40  * 
41  * 1     10/07/98 10:48a Dave
42  * 
43  * 29    4/02/98 6:30p Lawrance
44  * reduce max debris piece if DEMO defined
45  * 
46  * 28    4/02/98 11:40a Lawrance
47  * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
48  * 
49  * 27    2/26/98 10:07p Hoffoss
50  * Rewrote state saving and restoring to fix bugs and simplify the code.
51  * 
52  * 26    2/19/98 12:46a Lawrance
53  * Further work on asteroids.
54  * 
55  * 25    2/10/98 6:43p Lawrance
56  * Moved asteroid code to a separate lib.
57  * 
58  * 24    2/06/98 3:08p Mike
59  * More asteroid stuff, including resolving conflicts between the two
60  * asteroid_field structs!
61  * 
62  * 23    2/05/98 12:51a Mike
63  * Early asteroid stuff.
64  * 
65  * 22    1/29/98 5:50p John
66  * Made electrical arcing on debris pieces be persistent from frame to
67  * frame
68  * 
69  * 21    1/21/98 7:18p Lawrance
70  * Fix bug with creating debris before the mission starts.
71  * 
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
75  * 
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.
79  * 
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.
83  * 
84  * 17    9/20/97 9:25a John
85  * fixed bug with species specific debris shards.
86  * 
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
92  * 
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
96  * 
97  * 14    7/13/97 5:53p Lawrance
98  * save model name in debris
99  * 
100  * 13    7/02/97 11:48a Lawrance
101  * update debris to delay persistant sound
102  * 
103  * 12    6/06/97 4:13p Lawrance
104  * leave debris chunks from very large ships persistant, scale fireball
105  * lifetime by ship radius
106  * 
107  * 11    6/06/97 12:12p Lawrance
108  * limit hull debris pieces, destroying oldest debris to make way for new
109  * debris.  
110  * 
111  * 10    5/14/97 4:08p Lawrance
112  * removing my_index from game arrays
113  * 
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.
117  * 
118  * 8     3/31/97 11:11a John
119  * added ship species specific debris.
120  * 
121  * 7     3/25/97 3:55p Lawrance
122  * allowing debris to be targeted and shown on radar
123  * 
124  * 6     2/27/97 12:07p John
125  * Added code to suppord debris chunks after a ship is exploded..
126  * 
127  * 5     2/26/97 2:18p Lawrance
128  * adding Debris[] to save/restore
129  * 
130  * 4     2/10/97 12:38p John
131  * made all ships blow up into debris pieces when exploded.
132  * 
133  * 3     2/07/97 10:45a John
134  * Initial bare bones implementation of blowing off turrets.
135  * 
136  * 2     2/07/97 9:30a John
137  * 
138  * 1     2/06/97 4:13p John
139  *
140  * $NoKeywords: $
141  */
142
143 #ifndef _DEBRIS_H
144 #define _DEBRIS_H
145
146 struct object;
147 struct CFILE;
148
149 #define MAX_DEBRIS_ARCS 8               // Must be less than MAX_ARC_EFFECTS in model.h
150
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.
169
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
173         
174 } debris;
175
176
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)
180
181
182 #ifdef FS2_DEMO
183         #define MAX_DEBRIS_PIECES       48
184 #else
185         #define MAX_DEBRIS_PIECES       64
186 #endif
187
188 extern  debris Debris[MAX_DEBRIS_PIECES];
189
190 extern int Num_debris_pieces;
191
192 struct collision_info_struct;
193
194 void debris_init();
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);
204
205 #endif // _DEBRIS_H
206