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/Weapon/Beam.h $
15 * all sorts of cool stuff about ships
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 * 21 9/08/99 10:29p Dave
26 * Make beam sound pausing and unpausing much safer.
28 * 20 6/29/99 7:39p Dave
29 * Lots of small bug fixes.
31 * 19 6/21/99 7:25p Dave
32 * netplayer pain packet. Added type E unmoving beams.
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.
38 * 17 6/04/99 2:16p Dave
39 * Put in shrink effect for beam weapons.
41 * 16 5/14/99 11:47a Andsager
42 * Added beam_get_weapon_info_index(object *bm)
44 * 15 5/08/99 8:25p Dave
45 * Upped object pairs. First run of nebula lightning.
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
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.
57 * 12 4/20/99 6:39p Dave
58 * Almost done with artillery targeting. Added support for downloading
59 * images on the PXO screen.
61 * 11 4/19/99 11:01p Dave
62 * More sophisticated targeting laser support. Temporary checkin.
64 * 10 4/16/99 5:54p Dave
65 * Support for on/off style "stream" weapons. Real early support for
66 * target-painting lasers.
68 * 9 3/08/99 7:03p Dave
69 * First run of new object update system. Looks very promising.
71 * 8 3/04/99 6:09p Dave
72 * Added in sexpressions for firing beams and checking for if a ship is
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.
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.
83 * 5 1/21/99 10:45a Dave
84 * More beam weapon stuff. Put in warmdown time.
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 :(
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
96 * 2 1/08/99 2:08p Dave
97 * Fixed software rendering for pofview. Super early support for AWACS and
104 #ifndef __FS2_BEAM_WEAPON_HEADER_FILE
105 #define __FS2_BEAM_WEAPON_HEADER_FILE
109 // ------------------------------------------------------------------------------------------------
110 // BEAM WEAPON DEFINES/VARS
117 struct beam_weapon_info;
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
130 // max # of "shots" an individual beam will take
131 #define MAX_BEAM_SHOTS 5
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
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
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
162 // beam lighting effects
163 extern int Beam_lighting;
165 // ------------------------------------------------------------------------------------------------
166 // BEAM WEAPON FUNCTIONS
170 // the next functions are probably the only ones anyone should care about calling. the rest require somewhat detailed knowledge of beam weapons
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);
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);
182 // return an object index of the guy who's firing this beam
183 int beam_get_parent(object *bm);
185 // return weapon_info_index of beam
186 int beam_get_weapon_info_index(object *bm);
188 // render the beam itself
189 void beam_render(beam_weapon_info *bwi, vector *start, vector *shot, float shrink = 1.0f);
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);
194 // stuff collision info, returns 1 on success
195 int beam_get_collision(int objnum, int num, int *collision_objnum, mc_info **cinfo);
198 // init at game startup
201 // initialize beam weapons for this level
202 void beam_level_init();
204 // shutdown beam weapons for this level
205 void beam_level_close();
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);
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);
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);
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);
219 // pre-move (before collision checking - but AFTER ALL OTHER OBJECTS HAVE BEEN MOVED)
220 void beam_move_all_pre();
222 // post-collision time processing for beams
223 void beam_move_all_post();
225 // render all beam weapons
226 void beam_render_all();
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);
231 // pause all looping beam sounds
232 void beam_pause_sounds();
234 // unpause looping beam sounds
235 void beam_unpause_sounds();
238 void beam_test(int whee);
239 void beam_test_new(int whee);