2 * $Logfile: /Freespace2/code/Weapon/Beam.h $
7 * all sorts of cool stuff about ships
10 * Revision 1.1 2002/05/03 03:28:12 root
14 * 21 9/08/99 10:29p Dave
15 * Make beam sound pausing and unpausing much safer.
17 * 20 6/29/99 7:39p Dave
18 * Lots of small bug fixes.
20 * 19 6/21/99 7:25p Dave
21 * netplayer pain packet. Added type E unmoving beams.
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.
27 * 17 6/04/99 2:16p Dave
28 * Put in shrink effect for beam weapons.
30 * 16 5/14/99 11:47a Andsager
31 * Added beam_get_weapon_info_index(object *bm)
33 * 15 5/08/99 8:25p Dave
34 * Upped object pairs. First run of nebula lightning.
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
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.
46 * 12 4/20/99 6:39p Dave
47 * Almost done with artillery targeting. Added support for downloading
48 * images on the PXO screen.
50 * 11 4/19/99 11:01p Dave
51 * More sophisticated targeting laser support. Temporary checkin.
53 * 10 4/16/99 5:54p Dave
54 * Support for on/off style "stream" weapons. Real early support for
55 * target-painting lasers.
57 * 9 3/08/99 7:03p Dave
58 * First run of new object update system. Looks very promising.
60 * 8 3/04/99 6:09p Dave
61 * Added in sexpressions for firing beams and checking for if a ship is
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.
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.
72 * 5 1/21/99 10:45a Dave
73 * More beam weapon stuff. Put in warmdown time.
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 :(
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
85 * 2 1/08/99 2:08p Dave
86 * Fixed software rendering for pofview. Super early support for AWACS and
93 #ifndef __FS2_BEAM_WEAPON_HEADER_FILE
94 #define __FS2_BEAM_WEAPON_HEADER_FILE
98 // ------------------------------------------------------------------------------------------------
99 // BEAM WEAPON DEFINES/VARS
106 struct beam_weapon_info;
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
119 // max # of "shots" an individual beam will take
120 #define MAX_BEAM_SHOTS 5
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
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
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
151 // beam lighting effects
152 extern int Beam_lighting;
154 // ------------------------------------------------------------------------------------------------
155 // BEAM WEAPON FUNCTIONS
159 // the next functions are probably the only ones anyone should care about calling. the rest require somewhat detailed knowledge of beam weapons
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);
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);
171 // return an object index of the guy who's firing this beam
172 int beam_get_parent(object *bm);
174 // return weapon_info_index of beam
175 int beam_get_weapon_info_index(object *bm);
177 // render the beam itself
178 void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink = 1.0f);
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);
183 // stuff collision info, returns 1 on success
184 int beam_get_collision(int objnum, int num, int *collision_objnum, mc_info **cinfo);
187 // init at game startup
190 // initialize beam weapons for this level
191 void beam_level_init();
193 // shutdown beam weapons for this level
194 void beam_level_close();
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);
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);
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);
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);
208 // pre-move (before collision checking - but AFTER ALL OTHER OBJECTS HAVE BEEN MOVED)
209 void beam_move_all_pre();
211 // post-collision time processing for beams
212 void beam_move_all_post();
214 // render all beam weapons
215 void beam_render_all();
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);
220 // pause all looping beam sounds
221 void beam_pause_sounds();
223 // unpause looping beam sounds
224 void beam_unpause_sounds();
227 void beam_test(int whee);
228 void beam_test_new(int whee);