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