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