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/Asteroid/Asteroid.h $
15 * Header file for asteroids
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:12 root
28 * 12 6/09/99 2:55p Andsager
29 * Allow multiple asteroid subtypes (of large, medium, small) and follow
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.
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.
41 * 9 4/16/99 2:34p Andsager
42 * Second pass on debris fields
44 * 8 4/15/99 5:00p Andsager
45 * Frist pass on Debris field
47 * 7 3/31/99 9:51a Andsager
48 * Add for generalization to debris field
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.
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.
58 * 4 11/05/98 5:55p Dave
59 * Big pass at reducing #includes
61 * 3 10/16/98 1:22p Andsager
62 * clean up header files
64 * 2 10/07/98 10:52a Dave
67 * 1 10/07/98 10:48a Dave
69 * 17 3/26/98 9:19a Lawrance
70 * Support multiple asteroid pofs
72 * 16 3/17/98 12:16a Allender
73 * asteroids in multiplayer -- minor problems with position being correct
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.
80 * 14 3/11/98 12:13a Lawrance
81 * Auto-target asteroids if no hostile ships present
83 * 13 3/08/98 4:16p Hoffoss
85 * 12 3/07/98 3:48p Lawrance
86 * Show offscreen indicators for asteroids
88 * 11 3/04/98 11:59p Lawrance
89 * create an asteroid.tbl, read all asteroid data from there
91 * 10 3/04/98 4:11p Lawrance
92 * Have area effects affect asteroids, have asteroids cast an area effect,
95 * 9 3/03/98 12:48a Lawrance
96 * Ensure collide_objnum is still valid each frame.
98 * 8 3/02/98 11:35p Lawrance
99 * Keep track of asteroids that will impact ships on the escort view.
101 * 7 2/26/98 10:07p Hoffoss
102 * Rewrote state saving and restoring to fix bugs and simplify the code.
104 * 6 2/26/98 4:22p Lawrance
105 * Change wrapping behavior, make vel random
107 * 5 2/20/98 8:31p Lawrance
108 * delay creation of sub-asteroids
110 * 4 2/19/98 4:33p Lawrance
111 * hook in new sounds and custom explosion animation
113 * 3 2/19/98 12:46a Lawrance
114 * Further work on asteroids.
116 * 2 2/10/98 6:43p Lawrance
117 * Moved asteroid code to a separate lib.
119 * 1 2/10/98 6:05p Lawrance
124 #ifndef __ASTEROID_H__
125 #define __ASTEROID_H__
128 #include "parselo.h" // for NAME_LENGTH
132 struct collision_info_struct;
134 #define MAX_ASTEROIDS 256
138 #define MAX_DEBRIS_TYPES 3
139 #define ASTEROID_TYPE_SMALL 0
140 #define ASTEROID_TYPE_MEDIUM 1
141 #define ASTEROID_TYPE_BIG 2
143 #define MAX_DEBRIS_TYPES 12
144 #define ASTEROID_TYPE_SMALL 0
145 #define ASTEROID_TYPE_MEDIUM 1
146 #define ASTEROID_TYPE_BIG 2
148 #define DEBRIS_TERRAN_SMALL 3
149 #define DEBRIS_TERRAN_MEDIUM 4
150 #define DEBRIS_TERRAN_LARGE 5
152 #define DEBRIS_VASUDAN_SMALL 6
153 #define DEBRIS_VASUDAN_MEDIUM 7
154 #define DEBRIS_VASUDAN_LARGE 8
156 #define DEBRIS_SHIVAN_SMALL 9
157 #define DEBRIS_SHIVAN_MEDIUM 10
158 #define DEBRIS_SHIVAN_LARGE 11
162 typedef struct debris_struct {
167 // Data structure to track the active asteroids
168 typedef struct asteroid_obj {
169 asteroid_obj *next, *prev;
172 extern asteroid_obj Asteroid_obj_list;
175 extern debris_struct Field_debris_info[];
178 #define MAX_ASTEROID_POFS 2
180 #define MAX_ASTEROID_POFS 3 // Max number of POFs per asteroid type
183 #define AF_USED (1<<0) // Set means used.
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];
200 typedef struct asteroid {
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().
214 // TYPEDEF FOR SPECIES OF DEBRIS - BITFIELD
215 #define DS_TERRAN 0x01
216 #define DS_VASUDAN 0x02
217 #define DS_SHIVAN 0x04
219 // TYPEDEF FOR DEBRIS TYPE
225 // TYPEDEF FOR FIELD TYPE
231 #define MAX_ACTIVE_DEBRIS_TYPES 3
233 typedef struct asteroid_field {
234 vector min_bound; // Minimum range of field.
235 vector max_bound; // Maximum range of field.
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
247 extern asteroid_info Asteroid_info[MAX_DEBRIS_TYPES];
248 extern asteroid Asteroids[MAX_ASTEROIDS];
249 extern asteroid_field Asteroid_field;
251 extern int Num_asteroid_types;
252 extern int Num_asteroids;
253 extern int Asteroids_enabled;
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);
272 // need to extern for multiplayer
273 void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec);
275 void asteroid_frame();
277 #endif // __ASTEROID_H__