]> icculus.org git repositories - btb/d2x.git/blob - main/laser.h
added option to disable kalinix under unix
[btb/d2x.git] / main / laser.h
1 /* $Id: laser.h,v 1.3 2003-10-10 00:30:28 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Definitions for the laser code.
18  *
19  * Old Log:
20  * Revision 1.1  1995/05/16  15:58:43  allender
21  * Initial revision
22  *
23  * Revision 2.0  1995/02/27  11:32:27  john
24  * New version 2.0, which has no anonymous unions, builds with
25  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
26  *
27  * Revision 1.50  1995/02/01  21:03:44  john
28  * Lintified.
29  *
30  * Revision 1.49  1995/02/01  16:34:11  john
31  * Linted.
32  *
33  * Revision 1.48  1995/01/31  16:16:16  mike
34  * Separate smart blobs for robot and player.
35  *
36  * Revision 1.47  1995/01/27  17:02:55  mike
37  * Add LASER_ID -- why wasn't this added in June?
38  *
39  * Revision 1.46  1995/01/25  10:53:27  mike
40  * make badass damage go through grates.
41  *
42  * Revision 1.45  1994/12/12  17:17:32  mike
43  * make boss cloak/teleport when get hit, make quad laser 3/4 as powerful.
44  *
45  * Revision 1.44  1994/12/04  16:17:23  mike
46  * spruce up homing missile behavior.
47  *
48  * Revision 1.43  1994/12/03  12:48:30  mike
49  * make homing missile tracking not frame rate dependent (more-or-less)
50  *
51  * Revision 1.42  1994/10/12  08:04:54  mike
52  * Clean up proximity/homing mess.
53  *
54  * Revision 1.41  1994/10/09  20:07:04  rob
55  * Change prototype for do_laser_firing
56  *
57  * Revision 1.40  1994/10/09  00:15:48  mike
58  * Add constants for super mech missile, regular mech missile, silent spreadfire.
59  *
60  * Revision 1.39  1994/10/08  19:52:09  rob
61  * Added new weapon fire flags.
62  *
63  * Revision 1.38  1994/10/07  15:31:12  mike
64  * Prototypes for new laser functions which don't necessarily make sound.
65  *
66  * Revision 1.37  1994/10/05  17:08:29  matt
67  * Fixed a couple of small bugs, and made homing missiles alternate sides
68  *
69  * Revision 1.36  1994/09/28  14:28:55  rob
70  * Added firing of missiles on networks/serial.
71  *
72  * Revision 1.35  1994/09/24  14:17:02  mike
73  * Prototype do_laser_firing.
74  *
75  * Revision 1.34  1994/09/23  11:36:49  mike
76  * Prototype Laser_create_new_easy.
77  *
78  * Revision 1.33  1994/09/20  11:55:01  mike
79  * Fix bug.
80  *
81  * Revision 1.32  1994/09/20  11:48:34  mike
82  * Change spreadfire laser to use new bitmap. (Define SPREADFIRE_ID)
83  *
84  * Revision 1.31  1994/09/15  16:31:28  mike
85  * Prototype object_to_object_visibility.
86  *
87  * Revision 1.30  1994/09/10  17:31:40  mike
88  * Add thrust to weapons.
89  *
90  * Revision 1.29  1994/09/08  14:49:44  mike
91  * Bunch of IDs for new weapon types.
92  *
93  * Revision 1.28  1994/09/07  19:16:40  mike
94  * Homing missile.
95  *
96  * Revision 1.27  1994/09/07  15:59:47  mike
97  * Kill FLARE_MAX_TIME (now defined in bitmaps.tbl), add PROXIMITY_ID (shame!), prototype do_laser_firing, do_missile_firing.
98  *
99  * Revision 1.26  1994/09/03  15:22:41  mike
100  * Kill Projectile_player_fire prototype.
101  *
102  * Revision 1.25  1994/09/02  16:39:00  mike
103  * IDs for primary weapons.
104  *
105  * Revision 1.24  1994/09/02  11:55:54  mike
106  * Define some illegal constants.
107  *
108  * Revision 1.23  1994/08/25  18:12:06  matt
109  * Made player's weapons and flares fire from the positions on the 3d model.
110  * Also added support for quad lasers.
111  *
112  * Revision 1.22  1994/08/19  15:22:28  mike
113  * Define constant for MAX_LASER_LEVEL.
114  *
115  * Revision 1.21  1994/08/13  12:20:47  john
116  * Made the networking uise the Players array.
117  *
118  * Revision 1.20  1994/08/10  10:44:05  john
119  * Made net players fire..
120  *
121  * Revision 1.19  1994/06/27  18:30:57  mike
122  * Add flares.
123  *
124  * Revision 1.18  1994/06/09  15:32:37  mike
125  * Muzzle flash
126  *
127  * Revision 1.17  1994/05/19  09:09:00  mike
128  * Move a bunch of laser variables to bm.h, I think.
129  * Also, added Robot_laser_speed, instead of hard-coding Laser_speed/4.
130  *
131  * Revision 1.16  1994/05/14  17:16:20  matt
132  * Got rid of externs in source (non-header) files
133  *
134  * Revision 1.15  1994/05/13  20:27:39  john
135  * Version II of John's new object code.
136  *
137  * Revision 1.14  1994/04/20  15:06:47  john
138  * Neatend laser code and fixed some laser bugs.
139  *
140  * Revision 1.13  1994/04/01  13:35:15  matt
141  * Cleaned up laser code a bit; moved some code here object.c to laser.c
142  *
143  * Revision 1.12  1994/04/01  11:14:24  yuan
144  * Added multiple bitmap functionality to all objects...
145  * (hostages, powerups, lasers, etc.)
146  * Hostages and powerups are implemented in the object system,
147  * just need to finish function call to "affect" player.
148  *
149  * Revision 1.11  1994/03/31  09:10:09  matt
150  * Added #define to turn crosshair off
151  *
152  * Revision 1.10  1994/02/17  11:33:15  matt
153  * Changes in object system
154  *
155  * Revision 1.9  1994/01/06  11:56:01  john
156  * Made lasers be lines, not purple blobs
157  *
158  * Revision 1.8  1994/01/05  10:53:35  john
159  * New object code by John.
160  *
161  * Revision 1.7  1993/12/08  14:21:36  john
162  * Added ExplodeObject
163  *
164  * Revision 1.6  1993/12/08  11:28:54  john
165  * Made lasers look like bolts.
166  *
167  * Revision 1.5  1993/12/01  13:12:40  john
168  * made lasers frame-rate independant
169  *
170  * Revision 1.4  1993/11/30  19:00:42  john
171  * lasers working kinda
172  *
173  * Revision 1.3  1993/11/29  19:44:53  john
174  * *** empty log message ***
175  *
176  * Revision 1.2  1993/11/29  17:44:55  john
177  * *** empty log message ***
178  *
179  * Revision 1.1  1993/11/29  17:19:19  john
180  * Initial revision
181  *
182  *
183  */
184
185 #ifndef _LASER_H
186 #define _LASER_H
187
188 #define LASER_ID        0   //0..3 are lasers
189 #define CONCUSSION_ID   8
190 #define FLARE_ID        9   //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
191 #define VULCAN_ID       11  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
192 #define SPREADFIRE_ID   12  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
193 #define PLASMA_ID       13  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
194 #define FUSION_ID       14  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
195 #define HOMING_ID       15
196 #define PROXIMITY_ID    16
197 #define SMART_ID        17
198 #define MEGA_ID         18
199
200 #define PLAYER_SMART_HOMING_ID  19
201 #define SUPER_MECH_MISS         21
202 #define REGULAR_MECH_MISS       22
203 #define SILENT_SPREADFIRE_ID    23
204 #define ROBOT_SMART_HOMING_ID   29
205 #define EARTHSHAKER_MEGA_ID     54
206
207 #define SUPER_LASER_ID          30  // 30,31 are super lasers (level 5,6)
208
209 #define GAUSS_ID                32  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
210 #define HELIX_ID                33  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
211 #define PHOENIX_ID              34  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
212 #define OMEGA_ID                35  //  NOTE: This MUST correspond to the ID generated at bitmaps.tbl read time.
213
214 #define FLASH_ID                36
215 #define GUIDEDMISS_ID           37
216 #define SUPERPROX_ID            38
217 #define MERCURY_ID              39
218 #define EARTHSHAKER_ID          40
219
220 #define SMART_MINE_HOMING_ID        47
221 #define ROBOT_SMART_MINE_HOMING_ID  49
222 #define ROBOT_SUPERPROX_ID          53
223 #define ROBOT_EARTHSHAKER_ID        58
224
225 #define PMINE_ID                    51  //the mine that the designers can place
226
227 #define OMEGA_MULTI_LIFELEFT    (F1_0/6)
228
229 // These are new defines for the value of 'flags' passed to do_laser_firing.
230 // The purpose is to collect other flags like QUAD_LASER and Spreadfire_toggle
231 // into a single 8-bit quantity so it can be easily used in network mode.
232
233 #define LASER_QUAD                  1
234 #define LASER_SPREADFIRE_TOGGLED    2
235 #define LASER_HELIX_FLAG0           4   // helix uses 3 bits for angle
236 #define LASER_HELIX_FLAG1           8   // helix uses 3 bits for angle
237 #define LASER_HELIX_FLAG2           16  // helix uses 3 bits for angle
238
239 #define LASER_HELIX_SHIFT       2   // how far to shift count to put in flags
240 #define LASER_HELIX_MASK        7   // must match number of bits in flags
241
242 #define MAX_LASER_LEVEL         3   // Note, laser levels are numbered from 0.
243 #define MAX_SUPER_LASER_LEVEL   5   // Note, laser levels are numbered from 0.
244
245 #define MAX_LASER_BITMAPS   6
246
247 // For muzzle firing casting light.
248 #define MUZZLE_QUEUE_MAX    8
249
250 // Constants governing homing missile behavior.
251 // MIN_TRACKABLE_DOT gets inversely scaled by FrameTime and stuffed in
252 // Min_trackable_dot
253 #define MIN_TRACKABLE_DOT               (7*F1_0/8)
254 #define MAX_TRACKABLE_DIST              (F1_0*250)
255 #define HOMING_MISSILE_STRAIGHT_TIME    (F1_0/8)    //  Changed as per request of John, Adam, Yuan, but mostly John
256
257 extern fix Min_trackable_dot;   //  MIN_TRACKABLE_DOT inversely scaled by FrameTime
258
259 extern object *Guided_missile[];
260 extern int Guided_missile_sig[];
261
262 void Laser_render(object *obj);
263 void Laser_player_fire(object * obj, int type, int gun_num, int make_sound, int harmless_flag);
264 void Laser_player_fire_spread(object *obj, int laser_type, int gun_num, fix spreadr, fix spreadu, int make_sound, int harmless);
265 void Laser_do_weapon_sequence(object *obj);
266 void Flare_create(object *obj);
267 int laser_are_related(int o1, int o2);
268
269 extern int do_laser_firing_player(void);
270 extern void do_missile_firing(int do_autoselect);
271 extern void net_missile_firing(int player, int weapon, int flags);
272
273 int Laser_create_new(vms_vector * direction, vms_vector * position, int segnum, int parent, int type, int make_sound);
274
275 // Fires a laser-type weapon (a Primary weapon)
276 // Fires from object objnum, weapon type weapon_id.
277 // Assumes that it is firing from a player object, so it knows which
278 // gun to fire from.
279 // Returns the number of shots actually fired, which will typically be
280 // 1, but could be higher for low frame rates when rapidfire weapons,
281 // such as vulcan or plasma are fired.
282 extern int do_laser_firing(int objnum, int weapon_id, int level, int flags, int nfires);
283
284 // Easier to call than Laser_create_new because it determines the
285 // segment containing the firing point and deals with it being stuck
286 // in an object or through a wall.
287 // Fires a laser of type "weapon_type" from an object (parent) in the
288 // direction "direction" from the position "position"
289 // Returns object number of laser fired or -1 if not possible to fire
290 // laser.
291 int Laser_create_new_easy(vms_vector * direction, vms_vector * position, int parent, int weapon_type, int make_sound);
292
293 // creates a weapon object
294 int create_weapon_object(int weapon_type,int segnum,vms_vector *position);
295
296 // give up control of the guided missile
297 void release_guided_missile(int player_num);
298
299 extern void create_smart_children(object *objp, int count);
300 extern int object_to_object_visibility(object *obj1, object *obj2, int trans_type);
301
302 extern int Muzzle_queue_index;
303
304 typedef struct muzzle_info {
305         fix         create_time;
306         short       segnum;
307         vms_vector  pos;
308 } muzzle_info;
309
310 extern muzzle_info Muzzle_data[MUZZLE_QUEUE_MAX];
311
312 // Omega cannon stuff.
313 #define MAX_OMEGA_CHARGE    (F1_0)  //  Maximum charge level for omega cannonw
314 extern fix Omega_charge;
315 // NOTE: OMEGA_CHARGE_SCALE moved to laser.c to avoid long rebuilds if changed
316
317 #endif /* _LASER_H */