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