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