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