]> icculus.org git repositories - taylor/freespace2.git/blob - include/asteroid.h
re-add PXO sources to project files
[taylor/freespace2.git] / include / asteroid.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/Asteroid/Asteroid.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Header file for asteroids
16  *
17  * $Log$
18  * Revision 1.3  2003/05/25 02:30:42  taylor
19  * Freespace 1 support
20  *
21  * Revision 1.2  2002/06/09 04:41:12  relnev
22  * added copyright header
23  *
24  * Revision 1.1.1.1  2002/05/03 03:28:12  root
25  * Initial import.
26  *
27  * 
28  * 12    6/09/99 2:55p Andsager
29  * Allow multiple asteroid subtypes (of large, medium, small) and follow
30  * family.
31  * 
32  * 11    6/07/99 1:18p Andsager
33  * Make asteroids choose consistent texture from large to small.  Modify
34  * fireball radius of dying asteroids.
35  * 
36  * 10    5/03/99 10:50p Andsager
37  * Make Asteroid_obj_list.  Change get_nearest_turret_objnum() to use
38  * Asteroid_obj_list, Ship_obj_list and Missile_obj_list vs.
39  * obj_used_list.
40  * 
41  * 9     4/16/99 2:34p Andsager
42  * Second pass on debris fields
43  * 
44  * 8     4/15/99 5:00p Andsager
45  * Frist pass on Debris field
46  * 
47  * 7     3/31/99 9:51a Andsager
48  * Add for generalization to debris field
49  * 
50  * 6     2/07/99 8:51p Andsager
51  * Add inner bound to asteroid field.  Inner bound tries to stay astroid
52  * free.  Wrap when within and don't throw at ships inside.
53  * 
54  * 5     1/20/99 6:04p Dave
55  * Another bit of stuff for beam weapons. Ships will properly use them
56  * now, although they're really deadly.
57  * 
58  * 4     11/05/98 5:55p Dave
59  * Big pass at reducing #includes
60  * 
61  * 3     10/16/98 1:22p Andsager
62  * clean up header files
63  * 
64  * 2     10/07/98 10:52a Dave
65  * Initial checkin.
66  * 
67  * 1     10/07/98 10:48a Dave
68  * 
69  * 17    3/26/98 9:19a Lawrance
70  * Support multiple asteroid pofs
71  * 
72  * 16    3/17/98 12:16a Allender
73  * asteroids in multiplayer -- minor problems with position being correct
74  * 
75  * 15    3/14/98 1:44p Mike
76  * Todolist items 3365..3368.  Make child asteroids collide properly.
77  * Make asteroid throwing less bunchy, toss asteroids earlier, make
78  * facing-ness not break mission balance.
79  * 
80  * 14    3/11/98 12:13a Lawrance
81  * Auto-target asteroids if no hostile ships present
82  * 
83  * 13    3/08/98 4:16p Hoffoss
84  * 
85  * 12    3/07/98 3:48p Lawrance
86  * Show offscreen indicators for asteroids
87  * 
88  * 11    3/04/98 11:59p Lawrance
89  * create an asteroid.tbl, read all asteroid data from there
90  * 
91  * 10    3/04/98 4:11p Lawrance
92  * Have area effects affect asteroids, have asteroids cast an area effect,
93  * fix ship shockwaves
94  * 
95  * 9     3/03/98 12:48a Lawrance
96  * Ensure collide_objnum is still valid each frame.
97  * 
98  * 8     3/02/98 11:35p Lawrance
99  * Keep track of asteroids that will impact ships on the escort view.
100  * 
101  * 7     2/26/98 10:07p Hoffoss
102  * Rewrote state saving and restoring to fix bugs and simplify the code.
103  * 
104  * 6     2/26/98 4:22p Lawrance
105  * Change wrapping behavior, make vel random
106  * 
107  * 5     2/20/98 8:31p Lawrance
108  * delay creation of sub-asteroids
109  * 
110  * 4     2/19/98 4:33p Lawrance
111  * hook in new sounds and custom explosion animation
112  * 
113  * 3     2/19/98 12:46a Lawrance
114  * Further work on asteroids.
115  * 
116  * 2     2/10/98 6:43p Lawrance
117  * Moved asteroid code to a separate lib.
118  * 
119  * 1     2/10/98 6:05p Lawrance
120  *
121  * $NoKeywords: $
122  */
123
124 #ifndef __ASTEROID_H__
125 #define __ASTEROID_H__
126
127 #include "ship.h"
128 #include "parselo.h"            // for NAME_LENGTH
129
130 struct object;
131 struct polymodel;
132 struct collision_info_struct;
133
134 #define MAX_ASTEROIDS                   256
135
136 // DEBRIS TYPES
137 #ifdef MAKE_FS1
138 #define MAX_DEBRIS_TYPES                        3
139 #define ASTEROID_TYPE_SMALL                     0
140 #define ASTEROID_TYPE_MEDIUM            1
141 #define ASTEROID_TYPE_BIG                       2
142 #else
143 #define MAX_DEBRIS_TYPES                        12
144 #define ASTEROID_TYPE_SMALL             0
145 #define ASTEROID_TYPE_MEDIUM            1
146 #define ASTEROID_TYPE_BIG                       2
147 //
148 #define DEBRIS_TERRAN_SMALL             3
149 #define DEBRIS_TERRAN_MEDIUM            4
150 #define DEBRIS_TERRAN_LARGE             5
151 //
152 #define DEBRIS_VASUDAN_SMALL            6
153 #define DEBRIS_VASUDAN_MEDIUM   7
154 #define DEBRIS_VASUDAN_LARGE            8
155 //
156 #define DEBRIS_SHIVAN_SMALL             9
157 #define DEBRIS_SHIVAN_MEDIUM            10
158 #define DEBRIS_SHIVAN_LARGE             11
159 #endif
160 // END DEBRIS TYPES
161
162 typedef struct debris_struct {
163         int index;
164         const char *name;
165 } debris_struct;
166
167 // Data structure to track the active asteroids
168 typedef struct asteroid_obj {
169         asteroid_obj *next, *prev;
170         int flags, objnum;
171 } asteroid_obj;
172 extern asteroid_obj Asteroid_obj_list;
173
174
175 extern debris_struct Field_debris_info[];
176
177 #ifdef MAKE_FS1
178 #define MAX_ASTEROID_POFS                       2
179 #else
180 #define MAX_ASTEROID_POFS                       3                               // Max number of POFs per asteroid type
181 #endif
182
183 #define AF_USED                                 (1<<0)                  //      Set means used.
184
185 typedef struct asteroid_info {
186         char                    name[NAME_LENGTH];                                                                      // name for the asteroid
187         char                    pof_files[MAX_ASTEROID_POFS][NAME_LENGTH];      // POF files to load/associate with ship
188         int                     num_detail_levels;                                                                      // number of detail levels for this ship
189         int                     detail_distance[MAX_SHIP_DETAIL_LEVELS];                // distance to change detail levels at
190         float                   max_speed;                                                                                              // cap on speed for asteroid
191         float                   inner_rad;                                                                                              // radius within which maximum area effect damage is applied
192         float                   outer_rad;                                                                                              // radius at which no area effect damage is applied
193         float                   damage;                                                                                                 // maximum damage applied from area effect explosion
194         float                   blast;                                                                                                  // maximum blast impulse from area effect explosion                                                                     
195         float                   initial_hull_strength;                                                          // starting strength of asteroid
196         polymodel       *modelp[MAX_ASTEROID_POFS];
197         int                     model_num[MAX_ASTEROID_POFS];
198 } asteroid_info;
199
200 typedef struct asteroid {
201         int             flags;
202         int             objnum;
203         int             type;                                           //      In 0..Num_asteroid_types
204         int             asteroid_subtype;               // Which index into asteroid_info for modelnum and modelp
205         int             check_for_wrap;         //      timestamp to check for asteroid wrapping around field
206         int             check_for_collide;      // timestamp to check for asteroid colliding with escort ships
207         int             final_death_time;               // timestamp to swap in new models after explosion starts
208         int             collide_objnum;         // set to objnum that asteroid will be impacting soon
209         int             collide_objsig;         // object signature corresponding to collide_objnum
210         vector  death_hit_pos;                  // hit pos that caused death
211         int             target_objnum;                  //      Yes, hah!  Asteroids can have targets.  See asteroid_aim_at_target().
212 } asteroid;
213
214 // TYPEDEF FOR SPECIES OF DEBRIS - BITFIELD
215 #define DS_TERRAN               0x01
216 #define DS_VASUDAN      0x02
217 #define DS_SHIVAN               0x04
218
219 // TYPEDEF FOR DEBRIS TYPE
220 typedef enum {
221         DG_ASTEROID,
222         DG_SHIP
223 } debris_genre_t;
224
225 // TYPEDEF FOR FIELD TYPE
226 typedef enum {
227         FT_ACTIVE,
228         FT_PASSIVE
229 } field_type_t;
230
231 #define MAX_ACTIVE_DEBRIS_TYPES 3
232
233 typedef struct asteroid_field {
234         vector  min_bound;                                              //      Minimum range of field.
235         vector  max_bound;                                              //      Maximum range of field.
236         int             has_inner_bound;
237         vector  inner_min_bound;
238         vector  inner_max_bound;
239         vector  vel;                                                            //      Average asteroid moves at this velocity.
240         float           speed;                                                  // Average speed of field
241         int             num_initial_asteroids;          //      Number of asteroids at creation.
242         field_type_t            field_type;                     // active throws and wraps, passive does not
243         debris_genre_t  debris_genre;           // type of debris (ship or asteroid)  [generic type]
244         int                             field_debris_type[MAX_ACTIVE_DEBRIS_TYPES];     // one of the debris type defines above
245 } asteroid_field;
246
247 extern asteroid_info Asteroid_info[MAX_DEBRIS_TYPES];
248 extern asteroid Asteroids[MAX_ASTEROIDS];
249 extern asteroid_field   Asteroid_field;
250
251 extern int      Num_asteroid_types;
252 extern int      Num_asteroids;
253 extern int      Asteroids_enabled;
254
255 void    asteroid_init();        
256 void    asteroid_level_init();
257 void    asteroid_level_close();
258 void    asteroid_create_all();
259 void    asteroid_render( object *asteroid_objp );
260 void    asteroid_delete( object *asteroid_objp );
261 void    asteroid_process_pre( object *asteroid_objp, float frame_time);
262 void    asteroid_process_post( object *asteroid_objp, float frame_time);
263 int     asteroid_check_collision( object *asteroid_objp, object * other_obj, vector * hitpos, collision_info_struct *asteroid_hit_info=NULL );
264 void    asteroid_hit( object *asteroid_objp, object *other_objp, vector *hitpos, float damage );
265 int     asteroid_count();
266 int     asteroid_collide_objnum(object *asteroid_objp);
267 float asteroid_time_to_impact(object *asteroid_objp);
268 void    asteroid_show_brackets();
269 void    asteroid_target_closest_danger();
270 int     asteroid_get_random_in_cone(vector *pos, vector *dir, float ang, int danger = 0);
271
272 // need to extern for multiplayer
273 void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec);
274
275 void asteroid_frame();
276
277 #endif  // __ASTEROID_H__
278