]> icculus.org git repositories - taylor/freespace2.git/blob - include/weapon.h
Initial revision
[taylor/freespace2.git] / include / weapon.h
1 /*
2  * $Logfile: /Freespace2/code/Weapon/Weapon.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * <insert description of file here>
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 34    9/06/99 12:46a Andsager
15  * Add weapon_explosion_ani LOD
16  * 
17  * 33    8/27/99 1:34a Andsager
18  * Modify damage by shockwaves for BIG|HUGE ships.  Modify shockwave damge
19  * when weapon blows up.
20  * 
21  * 32    8/24/99 10:47a Jefff
22  * tech room weapon anims.  added tech anim field to weapons.tbl
23  * 
24  * 31    8/10/99 5:30p Jefff
25  * Added tech_title string to weapon_info.  Changed parser accordingly.
26  * 
27  * 30    8/02/99 5:16p Dave
28  * Bumped up weapon title string length from 32 to 48
29  * 
30  * 29    7/15/99 9:20a Andsager
31  * FS2_DEMO initial checkin
32  * 
33  * 28    6/30/99 5:53p Dave
34  * Put in new anti-camper code.
35  * 
36  * 27    6/21/99 7:25p Dave
37  * netplayer pain packet. Added type E unmoving beams.
38  * 
39  * 26    6/14/99 10:45a Dave
40  * Made beam weapons specify accuracy by skill level in the weapons.tbl
41  * 
42  * 25    6/04/99 2:16p Dave
43  * Put in shrink effect for beam weapons.
44  * 
45  * 24    6/01/99 8:35p Dave
46  * Finished lockarm weapons. Added proper supercap weapons/damage. Added
47  * awacs-set-radius sexpression.
48  * 
49  * 23    5/27/99 6:17p Dave
50  * Added in laser glows.
51  * 
52  * 22    5/20/99 7:00p Dave
53  * Added alternate type names for ships. Changed swarm missile table
54  * entries.
55  * 
56  * 21    4/28/99 11:13p Dave
57  * Temporary checkin of artillery code.
58  * 
59  * 20    4/28/99 3:11p Andsager
60  * Stagger turret weapon fire times.  Make turrets smarter when target is
61  * protected or beam protected.  Add weaopn range to weapon info struct.
62  * 
63  * 19    4/22/99 11:06p Dave
64  * Final pass at beam weapons. Solidified a lot of stuff. All that remains
65  * now is to tweak and fix bugs as they come up. No new beam weapon
66  * features.
67  * 
68  * 18    4/19/99 11:01p Dave
69  * More sophisticated targeting laser support. Temporary checkin.
70  * 
71  * 17    4/16/99 5:54p Dave
72  * Support for on/off style "stream" weapons. Real early support for
73  * target-painting lasers.
74  * 
75  * 16    4/02/99 9:55a Dave
76  * Added a few more options in the weapons.tbl for beam weapons. Attempt
77  * at putting "pain" packets into multiplayer.
78  * 
79  * 15    3/31/99 8:24p Dave
80  * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
81  * and background nebulae. Added per-ship non-dimming pixel colors.
82  * 
83  * 14    3/23/99 11:03a Dave
84  * Added a few new fields and fixed parsing code for new weapon stuff.
85  * 
86  * 13    3/19/99 9:52a Dave
87  * Checkin to repair massive source safe crash. Also added support for
88  * pof-style nebulae, and some new weapons code.
89  * 
90  * 12    1/29/99 12:47a Dave
91  * Put in sounds for beam weapon. A bunch of interface screens (tech
92  * database stuff).
93  * 
94  * 11    1/27/99 9:56a Dave
95  * Temporary checkin of beam weapons for Dan to make cool sounds.
96  * 
97  * 10    1/25/99 5:03a Dave
98  * First run of stealth, AWACS and TAG missile support. New mission type
99  * :)
100  * 
101  * 9     1/24/99 11:37p Dave
102  * First full rev of beam weapons. Very customizable. Removed some bogus
103  * Int3()'s in low level net code.
104  * 
105  * 8     1/21/99 10:45a Dave
106  * More beam weapon stuff. Put in warmdown time.
107  * 
108  * 7     1/08/99 2:08p Dave
109  * Fixed software rendering for pofview. Super early support for AWACS and
110  * beam weapons.
111  * 
112  * 6     11/14/98 5:33p Dave
113  * Lots of nebula work. Put in ship contrails.
114  * 
115  * 5     10/26/98 9:42a Dave
116  * Early flak gun support.
117  * 
118  * 4     10/16/98 3:42p Andsager
119  * increase MAX_WEAPONS and MAX_SHIPS and som header files
120  * 
121  * 3     10/07/98 6:27p Dave
122  * Globalized mission and campaign file extensions. Removed Silent Threat
123  * special code. Moved \cache \players and \multidata into the \data
124  * directory.
125  * 
126  * 2     10/07/98 10:54a Dave
127  * Initial checkin.
128  * 
129  * 1     10/07/98 10:51a Dave
130  * 
131  * 100   9/04/98 3:52p Dave
132  * Put in validated mission updating and application during stats
133  * updating.
134  * 
135  * 99    9/01/98 4:25p Dave
136  * Put in total (I think) backwards compatibility between mission disk
137  * freespace and non mission disk freespace, including pilot files and
138  * campaign savefiles.
139  * 
140  * 98    8/28/98 3:29p Dave
141  * EMP effect done. AI effects may need some tweaking as required.
142  * 
143  * 97    8/25/98 1:49p Dave
144  * First rev of EMP effect. Player side stuff basically done. Next comes
145  * AI code.
146  * 
147  * 96    8/18/98 10:15a Dave
148  * Touchups on the corkscrew missiles. Added particle spewing weapons.
149  * 
150  * 95    8/17/98 5:07p Dave
151  * First rev of corkscrewing missiles.
152  * 
153  * 94    5/18/98 1:58a Mike
154  * Make Phoenix not be fired at fighters (but yes bombers).
155  * Improve positioning of ships in guard mode.
156  * Make turrets on player ship not fire near end of support ship docking.
157  * 
158  * 93    5/15/98 5:37p Hoffoss
159  * Added new 'tech description' fields to ship and weapon tables, and
160  * added usage of it in tech room.
161  * 
162  * 92    5/06/98 8:06p Dave
163  * Made standalone reset properly under weird conditions. Tweak
164  * optionsmulti screen. Upped MAX_WEAPONS to 350. Put in new launch
165  * countdown anim. Minro ui fixes/tweaks.
166  * 
167  * 91    5/05/98 11:15p Lawrance
168  * Optimize weapon flyby sound determination
169  * 
170  * 90    5/05/98 4:08p Hoffoss
171  * Added WIF_PLAYER_ALLOWED to check what is valid for the weaponry pool
172  * in Fred.
173  * 
174  * 89    4/23/98 5:50p Hoffoss
175  * Added tracking of techroom database list info in pilot files, added
176  * sexp to add more to list, made mouse usable on ship listing in tech
177  * room.
178  * 
179  * 88    4/19/98 9:21p Sandeep
180  * 
181  * 87    4/13/98 5:11p Mike
182  * More improvement to countermeasure code.
183  * 
184  * 86    4/10/98 11:02p Mike
185  * Make countermeasures less effective against aspect seekers than against
186  * heat seekers.
187  * Make AI ships match bank with each other when attacking a faraway
188  * target.
189  * Make ships not do silly loop-de-loop sometimes when attacking a faraway
190  * target.
191  * 
192  * 85    4/10/98 4:52p Hoffoss
193  * Made several changes related to tooltips.
194  * 
195  * 84    4/02/98 11:40a Lawrance
196  * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
197  * 
198  * 83    4/01/98 5:35p John
199  * Made only the used POFs page in for a level.   Reduced some interp
200  * arrays.    Made custom detail level work differently.
201  * 
202  * 82    3/21/98 3:37p Mike
203  * Fix/optimize attacking of big ships.
204  * 
205  * 81    3/15/98 9:44p Lawrance
206  * Get secondary weapons for turrets working
207  * 
208  * 79    3/12/98 1:24p Mike
209  * When weapons linked, increase firing delay.
210  * Free up weapon slots for AI ships, if necessary.
211  * Backside render shield effect.
212  * Remove shield hit triangle if offscreen.
213  * 
214  * 78    3/11/98 4:34p John
215  * Made weapons have glow & thrusters.
216  * 
217  * 77    3/04/98 8:51a Mike
218  * Working on making ships better about firing Synaptic.
219  * 
220  * 76    3/03/98 5:12p Dave
221  * 50% done with team vs. team interface issues. Added statskeeping to
222  * secondary weapon blasts. Numerous multiplayer ui bug fixes.
223  * 
224  * 75    3/02/98 10:00a Sandeep
225  * 
226  * 74    2/15/98 11:28p Allender
227  * allow increase in MAX_WEAPON_TYPES by chaning all bitfield references
228  * 
229  * 73    2/11/98 1:52p Sandeep
230  * 
231  * 72    2/02/98 8:47a Andsager
232  * Ship death area damage applied as instantaneous damage for small ships
233  * and shockwaves for large (>50 radius) ships.
234  * 
235  * 71    1/29/98 11:48a John
236  * Added new counter measure rendering as model code.   Made weapons be
237  * able to have impact explosion.
238  * 
239  * 70    1/23/98 5:08p John
240  * Took L out of vertex structure used B (blue) instead.   Took all small
241  * fireballs out of fireball types and used particles instead.  Fixed some
242  * debris explosion things.  Restructured fireball code.   Restructured
243  * some lighting code.   Made dynamic lighting on by default. Made groups
244  * of lasers only cast one light.  Made fireballs not cast light.
245  * 
246  * 69    1/21/98 7:20p Lawrance
247  * removed unused mount_size member
248  * 
249  * 68    1/19/98 10:01p Lawrance
250  * Implement "Electronics" missiles
251  * 
252  * 67    1/17/98 10:04p Lawrance
253  * Implementing "must lock to fire" missiles.  Fix couple bugs with rearm
254  * time display.
255  * 
256  * 66    1/17/98 4:45p Mike
257  * Better support for AI selection of secondary weapons.
258  * 
259  * 65    1/16/98 11:43a Mike
260  * Fix countermeasures.
261  * 
262  * 64    1/15/98 11:13a John
263  * Added code for specifying weapon trail bitmaps in weapons.tbl
264  * 
265  * 63    1/06/98 6:58p Lawrance
266  * Add wp->turret_subsys, which gets set when a turret fires a weapon.
267  * 
268  * $NoKeywords: $
269  */
270
271 #ifndef _WEAPON_H
272 #define _WEAPON_H
273
274 // define moved to before includes so that we can have it available when ship.h is included below
275 #define MAX_WEAPON_TYPES                                200
276
277 // define to compile corkscrew missiles in
278
279 #include "object.h"
280 #include "parselo.h"
281 #include "ship.h"               /* needed for ship_subsys* */
282 #include "2d.h"         // needed for color
283 #include "shockwave.h"
284 #include "trails.h"
285 #include "ai.h"
286
287 #define WP_UNUSED       -1
288 #define WP_LASER                0
289 #define WP_MISSILE      1
290 #define WP_BEAM         2
291
292 #define WRT_LASER       1
293 #define WRT_POF         2
294
295 //      Bitflags controlling weapon behavior
296 #define MAX_WEAPON_FLAGS        18                                              //      Maximum number of different bit flags legal to specify in a single weapons.tbl Flags line
297
298 #define WIF_HOMING_HEAT (1 << 0)                                //      if set, this weapon homes via seeking heat
299 #define WIF_HOMING_ASPECT       (1 << 1)                                //      if set, this weapon homes via chasing aspect
300 #define WIF_ELECTRONICS (1 << 2)                                //      Takes out electronics systems.
301 #define WIF_SPAWN                       (1 << 3)                                //      Spawns projectiles on detonation.
302 #define WIF_REMOTE                      (1 << 4)                                //      Can be remotely detonated by parent.
303 #define WIF_PUNCTURE            (1 << 5)                                //      Punctures armor, damaging subsystems.
304 #define WIF_SUPERCAP            (1 << 6)                                //      This is a weapon which does supercap class damage (meaning, it applies real damage to supercap ships)
305 #define WIF_AREA_EFFECT (1 << 7)                                //      Explosion has an area effect
306 #define WIF_SHOCKWAVE           (1 << 8)                                //      Explosion has a shockwave
307 #define  WIF_TURNS                      (1 << 9)                                // Set this if the weapon ever changes heading.  If you
308                                                                                                                         // don't set this and the weapon turns, collision detection
309                                                                                                                         // won't work, I promise!
310 #define WIF_SWARM                       (1 << 10)                       // Missile "swarms".. ie changes heading and twists on way to target
311 #define WIF_TRAIL                       (1 << 11)                       //      Has a trail
312 #define WIF_BIG_ONLY            (1 << 12)                       //      Only big ships (cruiser, capital, etc.) can arm this weapon
313 #define WIF_CHILD                       (1 << 13)                       //      No ship can have this weapon.  It gets created by weapon detonations.
314 #define WIF_BOMB                                (1 << 14)                       // Bomb-type missile, can be targeted
315 #define WIF_HUGE                                (1 << 15)                       //      Huge damage (generally 500+), probably only fired at huge ships.
316 #define WIF_NO_DUMBFIRE (1      <<      16)                     // Missile cannot be fired dumbfire (ie requires aspect lock)
317 #define  WIF_THRUSTER           (1 << 17)                       // Has thruster cone and/or glow
318 #define WIF_IN_TECH_DATABASE            (1 << 18)
319 #define WIF_PLAYER_ALLOWED              (1 << 19)   // allowed to be on starting wing ships/in weaponry pool
320 #define WIF_BOMBER_PLUS (1 << 20)                       //      Fire this missile only at a bomber or big ship.  But not a fighter.
321
322 #define WIF_CORKSCREW           (1 << 21)                       // corkscrew style missile
323 #define WIF_PARTICLE_SPEW       (1 << 22)                       // spews particles as it travels
324 #define WIF_EMP                         (1 << 23)                       // weapon explodes with a serious EMP effect
325 #define  WIF_ENERGY_SUCK        (1 << 24)                       // energy suck primary (impact effect)
326 #define WIF_FLAK                                (1 << 25)                       // use for big-ship turrets - flak gun
327 #define WIF_BEAM                                (1 << 26)                       // if this is a beam weapon : NOTE - VERY SPECIAL CASE
328 #define WIF_TAG                         (1 << 27)                       // this weapon has a tag effect when it hits
329 #define WIF_SHUDDER                     (1 << 28)                       // causes the weapon to shudder. shudder is proportional to the mass and damage of the weapon
330 #define WIF_MFLASH                      (1 << 29)                       // has muzzle flash
331 #define WIF_LOCKARM                     (1 << 30)                       // if the missile was fired without a lock, it does significanlty less damage on impact
332 #define  WIF_STREAM                     (1 << 31)                       // handled by "trigger down/trigger up" instead of "fire - wait - fire - wait"
333
334 #define WIF_HOMING                                      (WIF_HOMING_HEAT | WIF_HOMING_ASPECT)
335 #define  WIF_HURTS_BIG_SHIPS            (WIF_BOMB | WIF_BEAM | WIF_HUGE | WIF_BIG_ONLY)
336
337 #define WEAPON_EXHAUST_DELTA_TIME       75              //      Delay in milliseconds between exhaust blobs
338
339 #define WF_LOCK_WARNING_PLAYED          (1<<0)          // set when a lock warning sound is played for the player
340                                                                                                                                 //      (needed since we don't want to play multiple lock sounds)
341 #define WF_ALREADY_APPLIED_STATS                (1<<1)          // for use in ship_apply_local and ship_apply_global damage functions
342                                                                                                                                 // so that we don't record multiple hits (stats) for one impact
343 #define WF_PLAYED_FLYBY_SOUND                   (1<<2)          // flyby sound has been played for this weapon
344 #define WF_CONSIDER_FOR_FLYBY_SOUND     (1<<3)          // consider for flyby
345 #define WF_DEAD_IN_WATER                                (1<<4)          // a missiles engines have died
346 #define WF_LOCKED_WHEN_FIRED                    (1<<5)          // fired with a lock
347 #define WF_DESTROYED_BY_WEAPON          (1<<6)          // destroyed by damage from other weapon
348
349 typedef struct weapon {
350         int             weapon_info_index;                      // index into weapon_info array
351         int             objnum;                                                 // object number for this weapon
352         int             team;                                                           // The team of the ship that fired this
353         int             species;                                                        // The species of the ship that fired this
354         float           lifeleft;                                               // life left on this weapon     
355         int             target_num;                                             //      Object index of target
356         int             target_sig;                                             //      So we know if the target is the same one we've been tracking
357         float           nearest_dist;                                   //      nearest distance yet attained to target
358         fix             creation_time;                                  //      time at which created, stuffed Missiontime
359         int             weapon_flags;                                   //      bit flags defining behavior, see WF_xxxx
360         object* homing_object;                                  //      object this weapon is homing on.
361         ship_subsys*    homing_subsys;                  // subsystem this weapon is homing on
362         vector  homing_pos;                                             // world position missile is homing on
363         short           swarm_index;                                    // index into swarm missile info, -1 if not WIF_SWARM
364         int             missile_list_index;                     // index for missiles into Missile_obj_list, -1 weapon not missile
365         int             trail_num;                                              // -1 if no trail, else index into Trails array
366         ship_subsys *turret_subsys;                     // points to turret that fired weapon, otherwise NULL
367         int             group_id;                                               // Which group this is in.
368
369         // Stuff for thruster glows
370         int             thruster_bitmap;                                        // What frame the current thruster bitmap is at for this weapon
371         float           thruster_frame;                                 // Used to keep track of which frame the animation should be on.
372         int             thruster_glow_bitmap;                   // What frame the current thruster engine glow bitmap is at for this weapon
373         float           thruster_glow_frame;                            // Used to keep track of which frame the engine glow animation should be on.
374         float           thruster_glow_noise;                            // Noise for current frame
375
376         int             pick_big_attack_point_timestamp;        //      Timestamp at which to pick a new point to attack.
377         vector  big_attack_point;                               //      Target-relative location of attack point.
378
379         int             cmeasure_ignore_objnum;         //      Ignoring this countermeasure.  It's failed to attract this weapon.
380         int             cmeasure_chase_objnum;          //      Chasing this countermeasure.  Don't maybe ignore in future.
381
382         // corkscrew info (taken out for now)
383         short   cscrew_index;                                           // corkscrew info index
384
385         // particle spew info
386         int             particle_spew_time;                     // time to spew next bunch of particles 
387
388         // flak info
389         short flak_index;                                                       // flak info index
390 } weapon;
391
392
393 #ifdef FS2_DEMO
394         #define MAX_WEAPONS     100
395 #else
396         // upped 5/6/98 from 200 - DB
397         #define MAX_WEAPONS     350
398 #endif
399
400 // info specific to beam weapons
401 #define MAX_BEAM_SECTIONS                               5
402 typedef struct beam_weapon_section_info {
403         float width;                                                    // width of the section
404         int texture;                                                    // texture bitmap
405         ubyte rgba_inner[4];                                    // for non-textured beams
406         ubyte rgba_outer[4];                                    // for non-textured beams
407         float flicker;                                                  // how much it flickers (0.0 to 1.0)
408         float z_add;                                                    // is this necessary?
409 } beam_weapon_section_info;
410
411 typedef struct beam_weapon_info {
412         int     beam_type;                                              // beam type
413         float   beam_life;                                              // how long it lasts
414         int     beam_warmup;                                    // how long it takes to warmup (in ms)
415         int     beam_warmdown;                                  // how long it takes to warmdown (in ms)
416         float   beam_muzzle_radius;                     // muzzle glow radius
417         int     beam_particle_count;                    // beam spew particle count
418         float   beam_particle_radius;           // radius of beam particles
419         float   beam_particle_angle;                    // angle of beam particle spew cone
420         int     beam_particle_ani;                      // particle ani
421         float   beam_miss_factor[NUM_SKILL_LEVELS];                             // magic # which makes beams miss more. by skill level
422         int     beam_loop_sound;                                // looping beam sound
423         int     beam_warmup_sound;                      // warmup sound
424         int     beam_warmdown_sound;                    // warmdown sound
425         int     beam_num_sections;                      // the # of visible "sections" on the beam
426         int     beam_glow_bitmap;                               // muzzle glow bitmap
427         int     beam_shots;                                             // # of shots the beam takes
428         float   beam_shrink_factor;                     // what percentage of total beam lifetime when the beam starts shrinking
429         float beam_shrink_pct;                          // what percent/second the beam shrinks at
430         beam_weapon_section_info sections[MAX_BEAM_SECTIONS];                   // info on the visible sections of the beam     
431 } beam_weapon_info;
432
433 extern weapon Weapons[MAX_WEAPONS];
434
435 #define WEAPON_TITLE_LEN                        48
436
437 typedef struct weapon_info {
438         char    name[NAME_LENGTH];                              // name of this weapon
439         char    title[WEAPON_TITLE_LEN];                // official title of weapon (used by tooltips)
440         char    *desc;                                                          // weapon's description (used by tooltips)
441         int     subtype;                                                                // one of the WP_* macros above
442         int     render_type;                                            //      rendering method, laser, pof, avi
443         char    pofbitmap_name[NAME_LENGTH];    // Name of the pof representing this if POF, or bitmap filename if bitmap
444         int     model_num;                                                      // modelnum of weapon -- -1 if no model
445
446         char    *tech_desc;                                                             // weapon's description (in tech database)
447         char    tech_anim_filename[NAME_LENGTH];        // weapon's tech room animation
448         char    tech_title[NAME_LENGTH];                        // weapon's name (in tech database)
449
450         int     laser_bitmap;                                           // Which bitmap renders for laser, -1 if none
451         int     laser_glow_bitmap;                              // optional bitmap for laser glow
452         float laser_length;
453         color   laser_color_1;                                          // for cycling between glow colors
454         color   laser_color_2;                                          // for cycling between glow colors
455         float   laser_head_radius, laser_tail_radius;
456
457         float   max_speed;                                                      // initial speed of the weapon
458         float mass;                                                                     // mass of the weapon
459         float fire_wait;                                                        // fire rate -- amount of time before you can refire the weapon
460         float   blast_force;                                            // force this weapon exhibits when hitting an object
461         float   damage;                                                         //      damage of weapon (for missile, damage within inner radius)
462         float   inner_radius, outer_radius;     // damage radii for missiles (0 means impact only)
463         float   shockwave_speed;                                        // speed of shockwave ( 0 means none )
464         float   armor_factor, shield_factor, subsystem_factor;  //      in 0.0..2.0, scale of damage done to type of thing
465         float   lifetime;                                                       //      How long this thing lives.
466         float energy_consumed;                                  // Energy used up when weapon is fired
467         int     wi_flags;                                                       //      bit flags defining behavior, see WIF_xxxx
468         float turn_time;
469         float   cargo_size;                                                     // cargo space taken up by individual weapon (missiles only)
470         float rearm_rate;                                                       // rate per second at which secondary weapons are loaded during rearming
471         float   weapon_range;                                           // max range weapon can be effectively fired.  (May be less than life * speed)
472
473         // spawn weapons
474         short   spawn_type;                                                     //      Type of weapon to spawn when detonated.
475         short   spawn_count;                                            //      Number of weapons of spawn_type to spawn.
476
477         // swarm count
478         short swarm_count;                                              // how many swarm missiles are fired for this weapon
479
480         //      Specific to ASPECT homing missiles.
481         float   min_lock_time;                                          // minimum time (in seconds) to achieve lock
482         int     lock_pixels_per_sec;                            // pixels/sec moved while locking
483         int     catchup_pixels_per_sec;                 // pixels/sec moved while catching-up for a lock                                
484         int     catchup_pixel_penalty;                  // number of extra pixels to move while locking as a penalty for catching up for a lock                 
485
486         //      Specific to HEAT homing missiles.
487         float   fov;
488
489         int     launch_snd;
490         int     impact_snd;
491         int     flyby_snd;                                                      //      whizz-by sound, transmitted through weapon's portable atmosphere.
492         
493         // Specific to weapons with TRAILS:
494         trail_info tr_info;                     
495
496         char    icon_filename[NAME_LENGTH];     // filename for icon that is displayed in weapon selection
497         char    anim_filename[NAME_LENGTH];     // filename for animation that plays in weapon selection
498
499         int     impact_weapon_expl_index;               // Index into Weapon_expl_info of which ANI should play when this thing impacts something
500         float   impact_explosion_radius;                // How big the explosion should be
501
502         // EMP effect
503         float emp_intensity;                                    // intensity of the EMP effect
504         float emp_time;                                         // time of the EMP effect
505
506         // Energy suck effect
507         float weapon_reduce;                                    // how much energy removed from weapons systems
508         float afterburner_reduce;                       // how much energy removed from weapons systems
509
510         // Beam weapon effect   
511         beam_weapon_info        b_info;                 // this must be valid if the weapon is a beam weapon WIF_BEAM or WIF_BEAM_SMALL
512
513         // tag stuff
514         float   tag_time;                                               // how long the tag lasts               
515         int tag_level;                                                  // tag level (1 - 3)
516
517         // muzzle flash
518         int muzzle_flash;                                               // muzzle flash stuff
519 } weapon_info;
520
521 // Data structure to track the active missiles
522 typedef struct missile_obj {
523         missile_obj *next, *prev;
524         int                     flags, objnum;
525 } missile_obj;
526 extern missile_obj Missile_obj_list;
527
528 extern weapon_info Weapon_info[MAX_WEAPON_TYPES];
529
530 extern int Num_weapon_types;                    // number of weapons in the game
531 extern int First_secondary_index;
532 extern int Num_weapons;
533
534 extern int Num_player_weapon_precedence;                                // Number of weapon types in Player_weapon_precedence
535 extern int Player_weapon_precedence[MAX_WEAPON_TYPES];  // Array of weapon types, precedence list for player weapon selection
536 extern char     *Weapon_names[MAX_WEAPON_TYPES];
537
538 #define WEAPON_INDEX(wp)                                (wp-Weapons)
539 #define WEAPON_INFO_INDEX(wip)          (wip-Weapon_info)
540
541
542 int weapon_info_lookup(char *name);
543 void weapon_init();                                     // called at game startup
544 void weapon_level_init();                       // called before the start of each level
545 void weapon_render(object * obj);
546 void weapon_delete( object * obj );
547 void weapon_process_pre( object *obj, float frame_time);
548 void weapon_process_post( object *obj, float frame_time);
549
550 // Group_id:  If you should quad lasers, they should all have the same group id.  
551 // This will be used to optimize lighting, since each group only needs to cast one light.
552 // Call this to get a new group id, then pass it to each weapon_create call for all the
553 // weapons in the group.   Number will be between 0 and WEAPON_MAX_GROUP_IDS and will
554 // get reused.
555 int weapon_create_group_id();
556
557 // How many unique groups of weapons there can be at one time. 
558 #define WEAPON_MAX_GROUP_IDS 256
559
560 // Passing a group_id of -1 means it isn't in a group.  See weapon_create_group_id for more 
561 // help on weapon groups.
562 int weapon_create( vector * pos, matrix * orient, int weapon_type, int parent_obj, int secondary_flag, int group_id=-1, int is_locked = 0);
563 void weapon_set_tracking_info(int weapon_objnum, int parent_objnum, int target_objnum, int target_is_locked = 0, ship_subsys *target_subsys = NULL);
564
565 // for weapons flagged as particle spewers, spew particles. wheee
566 void weapon_maybe_spew_particle(object *obj);
567
568
569 void weapon_hit( object * weapon_obj, object * other_obj, vector * hitpos );
570 int weapon_name_lookup(char *name);
571 void spawn_child_weapons( object *objp );
572
573 // call to detonate a weapon. essentially calls weapon_hit() with other_obj as NULL, and sends a packet in multiplayer
574 void weapon_detonate(object *objp);
575
576 void    weapon_area_apply_blast(vector *force_apply_pos, object *ship_objp, vector *blast_pos, float blast, int make_shockwave);
577 int     weapon_area_calc_damage(object *objp, vector *pos, float inner_rad, float outer_rad, float max_blast, float max_damage,
578                                                                                 float *blast, float *damage, float limit);
579
580 void    missile_obj_list_rebuild();     // called by save/restore code only
581 missile_obj *missile_obj_return_address(int index);
582 void find_homing_object_cmeasures();
583
584 // THE FOLLOWING FUNCTION IS IN SHIP.CPP!!!!
585 // JAS - figure out which thruster bitmap will get rendered next
586 // time around.  ship_render needs to have shipp->thruster_bitmap set to
587 // a valid bitmap number, or -1 if we shouldn't render thrusters.
588 // This does basically the same thing as ship_do_thruster_frame, except it
589 // operates on a weapon.   This is in the ship code because it needs
590 // the same thruster animation info as the ship stuff, and I would
591 // rather extern this one function than all the thruster animation stuff.
592 void ship_do_weapon_thruster_frame( weapon *weaponp, object *objp, float frametime );
593
594 // call to get the "color" of the laser at the given moment (since glowing lasers can cycle colors)
595 void weapon_get_laser_color(color *c, object *objp);
596
597 void weapon_hit_do_sound(object *hit_obj, weapon_info *wip, vector *hitpos);
598
599 // return a scale factor for damage which should be applied for 2 collisions
600 float weapon_get_damage_scale(weapon_info *wip, object *wep, object *target);
601
602 // return handle to explosion ani
603 int weapon_get_expl_handle(int weapon_expl_index, vector *pos, float size);
604
605 #endif
606