2 * $Logfile: /Freespace2/code/Asteroid/Asteroid.h $
7 * Header file for asteroids
10 * Revision 1.1 2002/05/03 03:28:12 root
14 * 12 6/09/99 2:55p Andsager
15 * Allow multiple asteroid subtypes (of large, medium, small) and follow
18 * 11 6/07/99 1:18p Andsager
19 * Make asteroids choose consistent texture from large to small. Modify
20 * fireball radius of dying asteroids.
22 * 10 5/03/99 10:50p Andsager
23 * Make Asteroid_obj_list. Change get_nearest_turret_objnum() to use
24 * Asteroid_obj_list, Ship_obj_list and Missile_obj_list vs.
27 * 9 4/16/99 2:34p Andsager
28 * Second pass on debris fields
30 * 8 4/15/99 5:00p Andsager
31 * Frist pass on Debris field
33 * 7 3/31/99 9:51a Andsager
34 * Add for generalization to debris field
36 * 6 2/07/99 8:51p Andsager
37 * Add inner bound to asteroid field. Inner bound tries to stay astroid
38 * free. Wrap when within and don't throw at ships inside.
40 * 5 1/20/99 6:04p Dave
41 * Another bit of stuff for beam weapons. Ships will properly use them
42 * now, although they're really deadly.
44 * 4 11/05/98 5:55p Dave
45 * Big pass at reducing #includes
47 * 3 10/16/98 1:22p Andsager
48 * clean up header files
50 * 2 10/07/98 10:52a Dave
53 * 1 10/07/98 10:48a Dave
55 * 17 3/26/98 9:19a Lawrance
56 * Support multiple asteroid pofs
58 * 16 3/17/98 12:16a Allender
59 * asteroids in multiplayer -- minor problems with position being correct
61 * 15 3/14/98 1:44p Mike
62 * Todolist items 3365..3368. Make child asteroids collide properly.
63 * Make asteroid throwing less bunchy, toss asteroids earlier, make
64 * facing-ness not break mission balance.
66 * 14 3/11/98 12:13a Lawrance
67 * Auto-target asteroids if no hostile ships present
69 * 13 3/08/98 4:16p Hoffoss
71 * 12 3/07/98 3:48p Lawrance
72 * Show offscreen indicators for asteroids
74 * 11 3/04/98 11:59p Lawrance
75 * create an asteroid.tbl, read all asteroid data from there
77 * 10 3/04/98 4:11p Lawrance
78 * Have area effects affect asteroids, have asteroids cast an area effect,
81 * 9 3/03/98 12:48a Lawrance
82 * Ensure collide_objnum is still valid each frame.
84 * 8 3/02/98 11:35p Lawrance
85 * Keep track of asteroids that will impact ships on the escort view.
87 * 7 2/26/98 10:07p Hoffoss
88 * Rewrote state saving and restoring to fix bugs and simplify the code.
90 * 6 2/26/98 4:22p Lawrance
91 * Change wrapping behavior, make vel random
93 * 5 2/20/98 8:31p Lawrance
94 * delay creation of sub-asteroids
96 * 4 2/19/98 4:33p Lawrance
97 * hook in new sounds and custom explosion animation
99 * 3 2/19/98 12:46a Lawrance
100 * Further work on asteroids.
102 * 2 2/10/98 6:43p Lawrance
103 * Moved asteroid code to a separate lib.
105 * 1 2/10/98 6:05p Lawrance
110 #ifndef __ASTEROID_H__
111 #define __ASTEROID_H__
114 #include "parselo.h" // for NAME_LENGTH
118 struct collision_info_struct;
120 #define MAX_ASTEROIDS 256
123 #define MAX_DEBRIS_TYPES 12
124 #define ASTEROID_TYPE_SMALL 0
125 #define ASTEROID_TYPE_MEDIUM 1
126 #define ASTEROID_TYPE_BIG 2
128 #define DEBRIS_TERRAN_SMALL 3
129 #define DEBRIS_TERRAN_MEDIUM 4
130 #define DEBRIS_TERRAN_LARGE 5
132 #define DEBRIS_VASUDAN_SMALL 6
133 #define DEBRIS_VASUDAN_MEDIUM 7
134 #define DEBRIS_VASUDAN_LARGE 8
136 #define DEBRIS_SHIVAN_SMALL 9
137 #define DEBRIS_SHIVAN_MEDIUM 10
138 #define DEBRIS_SHIVAN_LARGE 11
141 typedef struct debris_struct {
146 // Data structure to track the active asteroids
147 typedef struct asteroid_obj {
148 asteroid_obj *next, *prev;
151 extern asteroid_obj Asteroid_obj_list;
154 extern debris_struct Field_debris_info[];
156 #define MAX_ASTEROID_POFS 3 // Max number of POFs per asteroid type
158 #define AF_USED (1<<0) // Set means used.
160 typedef struct asteroid_info {
161 char name[NAME_LENGTH]; // name for the asteroid
162 char pof_files[MAX_ASTEROID_POFS][NAME_LENGTH]; // POF files to load/associate with ship
163 int num_detail_levels; // number of detail levels for this ship
164 int detail_distance[MAX_SHIP_DETAIL_LEVELS]; // distance to change detail levels at
165 float max_speed; // cap on speed for asteroid
166 float inner_rad; // radius within which maximum area effect damage is applied
167 float outer_rad; // radius at which no area effect damage is applied
168 float damage; // maximum damage applied from area effect explosion
169 float blast; // maximum blast impulse from area effect explosion
170 float initial_hull_strength; // starting strength of asteroid
171 polymodel *modelp[MAX_ASTEROID_POFS];
172 int model_num[MAX_ASTEROID_POFS];
175 typedef struct asteroid {
178 int type; // In 0..Num_asteroid_types
179 int asteroid_subtype; // Which index into asteroid_info for modelnum and modelp
180 int check_for_wrap; // timestamp to check for asteroid wrapping around field
181 int check_for_collide; // timestamp to check for asteroid colliding with escort ships
182 int final_death_time; // timestamp to swap in new models after explosion starts
183 int collide_objnum; // set to objnum that asteroid will be impacting soon
184 int collide_objsig; // object signature corresponding to collide_objnum
185 vector death_hit_pos; // hit pos that caused death
186 int target_objnum; // Yes, hah! Asteroids can have targets. See asteroid_aim_at_target().
189 // TYPEDEF FOR SPECIES OF DEBRIS - BITFIELD
190 #define DS_TERRAN 0x01
191 #define DS_VASUDAN 0x02
192 #define DS_SHIVAN 0x04
194 // TYPEDEF FOR DEBRIS TYPE
200 // TYPEDEF FOR FIELD TYPE
206 #define MAX_ACTIVE_DEBRIS_TYPES 3
208 typedef struct asteroid_field {
209 vector min_bound; // Minimum range of field.
210 vector max_bound; // Maximum range of field.
212 vector inner_min_bound;
213 vector inner_max_bound;
214 vector vel; // Average asteroid moves at this velocity.
215 float speed; // Average speed of field
216 int num_initial_asteroids; // Number of asteroids at creation.
217 field_type_t field_type; // active throws and wraps, passive does not
218 debris_genre_t debris_genre; // type of debris (ship or asteroid) [generic type]
219 int field_debris_type[MAX_ACTIVE_DEBRIS_TYPES]; // one of the debris type defines above
222 extern asteroid_info Asteroid_info[MAX_DEBRIS_TYPES];
223 extern asteroid Asteroids[MAX_ASTEROIDS];
224 extern asteroid_field Asteroid_field;
226 extern int Num_asteroid_types;
227 extern int Num_asteroids;
228 extern int Asteroids_enabled;
230 void asteroid_init();
231 void asteroid_level_init();
232 void asteroid_level_close();
233 void asteroid_create_all();
234 void asteroid_render( object *asteroid_objp );
235 void asteroid_delete( object *asteroid_objp );
236 void asteroid_process_pre( object *asteroid_objp, float frame_time);
237 void asteroid_process_post( object *asteroid_objp, float frame_time);
238 int asteroid_check_collision( object *asteroid_objp, object * other_obj, vector * hitpos, collision_info_struct *asteroid_hit_info=NULL );
239 void asteroid_hit( object *asteroid_objp, object *other_objp, vector *hitpos, float damage );
240 int asteroid_count();
241 int asteroid_collide_objnum(object *asteroid_objp);
242 float asteroid_time_to_impact(object *asteroid_objp);
243 void asteroid_show_brackets();
244 void asteroid_target_closest_danger();
245 int asteroid_get_random_in_cone(vector *pos, vector *dir, float ang, int danger = 0);
247 // need to extern for multiplayer
248 void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec);
250 void asteroid_frame();
252 #endif // __ASTEROID_H__