]> icculus.org git repositories - taylor/freespace2.git/blob - include/beam.h
Initial revision
[taylor/freespace2.git] / include / beam.h
1 /*
2  * $Logfile: /Freespace2/code/Weapon/Beam.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * all sorts of cool stuff about ships
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 21    9/08/99 10:29p Dave
15  * Make beam sound pausing and unpausing much safer.
16  * 
17  * 20    6/29/99 7:39p Dave
18  * Lots of small bug fixes.
19  * 
20  * 19    6/21/99 7:25p Dave
21  * netplayer pain packet. Added type E unmoving beams.
22  * 
23  * 18    6/18/99 5:16p Dave
24  * Added real beam weapon lighting. Fixed beam weapon sounds. Added MOTD
25  * dialog to PXO screen.
26  * 
27  * 17    6/04/99 2:16p Dave
28  * Put in shrink effect for beam weapons.
29  * 
30  * 16    5/14/99 11:47a Andsager
31  * Added  beam_get_weapon_info_index(object *bm)
32  * 
33  * 15    5/08/99 8:25p Dave
34  * Upped object pairs. First run of nebula lightning.
35  * 
36  * 14    4/22/99 11:06p Dave
37  * Final pass at beam weapons. Solidified a lot of stuff. All that remains
38  * now is to tweak and fix bugs as they come up. No new beam weapon
39  * features.
40  * 
41  * 13    4/21/99 6:15p Dave
42  * Did some serious housecleaning in the beam code. Made it ready to go
43  * for anti-fighter "pulse" weapons. Fixed collision pair creation. Added
44  * a handy macro for recalculating collision pairs for a given object.
45  * 
46  * 12    4/20/99 6:39p Dave
47  * Almost done with artillery targeting. Added support for downloading
48  * images on the PXO screen.
49  * 
50  * 11    4/19/99 11:01p Dave
51  * More sophisticated targeting laser support. Temporary checkin.
52  * 
53  * 10    4/16/99 5:54p Dave
54  * Support for on/off style "stream" weapons. Real early support for
55  * target-painting lasers.
56  * 
57  * 9     3/08/99 7:03p Dave
58  * First run of new object update system. Looks very promising.
59  * 
60  * 8     3/04/99 6:09p Dave
61  * Added in sexpressions for firing beams and checking for if a ship is
62  * tagged.
63  * 
64  * 7     1/30/99 1:29a Dave
65  * Fixed nebula thumbnail problem. Full support for 1024x768 choose pilot
66  * screen.  Fixed beam weapon death messages.
67  * 
68  * 6     1/24/99 11:37p Dave
69  * First full rev of beam weapons. Very customizable. Removed some bogus
70  * Int3()'s in low level net code.
71  * 
72  * 5     1/21/99 10:45a Dave
73  * More beam weapon stuff. Put in warmdown time.
74  * 
75  * 4     1/14/99 12:48a Dave
76  * Todo list bug fixes. Made a pass at putting briefing icons back into
77  * FRED. Sort of works :(
78  * 
79  * 3     1/12/99 12:53a Dave
80  * More work on beam weapons - made collision detection very efficient -
81  * collide against all object types properly - made 3 movement types
82  * smooth. Put in test code to check for possible non-darkening pixels on
83  * object textures.
84  * 
85  * 2     1/08/99 2:08p Dave
86  * Fixed software rendering for pofview. Super early support for AWACS and
87  * beam weapons.
88  * 
89  * 
90  * $NoKeywords: $
91  */
92
93 #ifndef __FS2_BEAM_WEAPON_HEADER_FILE
94 #define __FS2_BEAM_WEAPON_HEADER_FILE
95
96 #include "model.h"
97
98 // ------------------------------------------------------------------------------------------------
99 // BEAM WEAPON DEFINES/VARS
100 //
101
102 // prototypes
103 struct object;
104 struct ship_subsys;
105 struct obj_pair;
106 struct beam_weapon_info;
107 struct vector;
108
109 // beam types
110 // REMINDER : if you change the behavior of any of these beam types, make sure to update their "cones" of possible
111 // movement inside of the function beam_get_cone_dot(...) in beam.cpp  Otherwise it could cause collisions to not
112 // function properly!!!!!!
113 #define BEAM_TYPE_A                                     0                               // unidirectional beam
114 #define BEAM_TYPE_B                                     1                               // "slash" in one direction
115 #define BEAM_TYPE_C                                     2                               // targeting lasers (only lasts one frame)
116 #define BEAM_TYPE_D                                     3                               // similar to the type A beams, but takes multiple shots and "chases" fighters around
117 #define BEAM_TYPE_E                                     4                               // stupid beam. like type A, only it doesn't aim. it just shoots directly out of the turret
118
119 // max # of "shots" an individual beam will take
120 #define MAX_BEAM_SHOTS                          5
121
122 // uses to define beam behavior ahead of time - needed for multiplayer
123 typedef struct beam_info {
124         vector                  dir_a, dir_b;                                           // direction vectors for beams  
125         float                           delta_ang;                                                      // angle between dir_a and dir_b
126         ubyte                           shot_count;                                                     // # of shots   
127         float                           shot_aim[MAX_BEAM_SHOTS];               // accuracy. this is a constant multiple of radius. anything < 1.0 will guarantee a hit 
128 } beam_info;
129
130 // pass to beam fire 
131 typedef struct beam_fire_info {
132         int                             beam_info_index;                                // weapon info index 
133         object                  *shooter;                                               // whos shooting
134         vector                  targeting_laser_offset;         // offset from the center of the object (for targeting lasers only)
135         ship_subsys             *turret;                                                        // where he's shooting from
136         float                           accuracy;                                               // 0.0 to 1.0 (only really effects targeting on small ships)
137         object                  *target;                                                        // whos getting shot
138         ship_subsys             *target_subsys;                         // (optional), specific subsystem to be targeted on the target 
139         beam_info               *beam_info_override;                    // (optional), pass this in to override all beam movement info (for multiplayer)
140         int                             num_shots;                                              // (optional), only used for type D weapons
141 } beam_fire_info;
142
143 // collision info
144 typedef struct beam_collision {
145         mc_info                 cinfo;                                                  // collision info
146         int                             c_objnum;                                               // objnum of the guy we recently collided with
147         int                             c_sig;                                                  // object sig
148         int                             c_stamp;                                                        // when we should next apply damage     
149 } beam_collision;
150
151 // beam lighting effects
152 extern int Beam_lighting;
153
154 // ------------------------------------------------------------------------------------------------
155 // BEAM WEAPON FUNCTIONS
156 //
157
158 // ---------------
159 // the next functions are probably the only ones anyone should care about calling. the rest require somewhat detailed knowledge of beam weapons
160
161 // fire a beam, returns objnum on success. the innards of the code handle all the rest, foo
162 int beam_fire(beam_fire_info *fire_info);
163
164 // fire a targeting beam, returns objnum on success. a much much simplified version of a beam weapon
165 // targeting lasers last _one_ frame. For a continuous stream - they must be created every frame.
166 // this allows it to work smoothly in multiplayer (detect "trigger down". every frame just create a targeting laser firing straight out of the
167 // object. this way you get all the advantages of nice rendering and collisions).
168 // NOTE : only references beam_info_index and shooter
169 int beam_fire_targeting(beam_fire_info *fire_info);
170
171 // return an object index of the guy who's firing this beam
172 int beam_get_parent(object *bm);
173
174 // return weapon_info_index of beam
175 int beam_get_weapon_info_index(object *bm);
176
177 // render the beam itself
178 void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink = 1.0f);
179
180 // given a beam object, get the # of collisions which happened during the last collision check (typically, last frame)
181 int beam_get_num_collisions(int objnum);
182
183 // stuff collision info, returns 1 on success
184 int beam_get_collision(int objnum, int num, int *collision_objnum, mc_info **cinfo);
185 // ---------------
186
187 // init at game startup
188 void beam_init();
189
190 // initialize beam weapons for this level
191 void beam_level_init();
192
193 // shutdown beam weapons for this level
194 void beam_level_close();
195
196 // collide a beam with a ship, returns 1 if we can ignore all future collisions between the 2 objects
197 int beam_collide_ship(obj_pair *pair);
198
199 // collide a beam with an asteroid, returns 1 if we can ignore all future collisions between the 2 objects
200 int beam_collide_asteroid(obj_pair *pair);
201
202 // collide a beam with a missile, returns 1 if we can ignore all future collisions between the 2 objects
203 int beam_collide_missile(obj_pair *pair);
204
205 // collide a beam with debris, returns 1 if we can ignore all future collisions between the 2 objects
206 int beam_collide_debris(obj_pair *pair);
207
208 // pre-move (before collision checking - but AFTER ALL OTHER OBJECTS HAVE BEEN MOVED)
209 void beam_move_all_pre();
210
211 // post-collision time processing for beams
212 void beam_move_all_post();
213
214 // render all beam weapons
215 void beam_render_all();
216
217 // early-out function for when adding object collision pairs, return 1 if the pair should be ignored
218 int beam_collide_early_out(object *a, object *b);
219
220 // pause all looping beam sounds
221 void beam_pause_sounds();
222
223 // unpause looping beam sounds
224 void beam_unpause_sounds();
225
226 // debug code
227 void beam_test(int whee);
228 void beam_test_new(int whee);
229
230 #endif
231