This commit was generated by cvs2svn to compensate for changes in r2,
[btb/d2x.git] / main / weapon.h
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifndef _WEAPON_H
15 #define _WEAPON_H
16
17 #include "inferno.h"
18 #include "gr.h"
19 #include "game.h"
20 #include "piggy.h"
21
22 //weapon info flags
23 #define WIF_PLACABLE            1               //can be placed by level designer
24
25 typedef struct weapon_info {
26         byte    render_type;                            // How to draw 0=laser, 1=blob, 2=object
27         byte    persistent;                                     //      0 = dies when it hits something, 1 = continues (eg, fusion cannon)
28         short   model_num;                                      // Model num if rendertype==2.
29         short   model_num_inner;                        // Model num of inner part if rendertype==2.
30
31         byte    flash_vclip;                            // What vclip to use for muzzle flash
32         byte    robot_hit_vclip;                        // What vclip for impact with robot
33         short   flash_sound;                            // What sound to play when fired
34
35         byte    wall_hit_vclip;                 // What vclip for impact with wall
36         byte    fire_count;                                     //      Number of bursts fired from EACH GUN per firing.  For weapons which fire from both sides, 3*fire_count shots will be fired.
37         short   robot_hit_sound;                        // What sound for impact with robot
38
39         byte    ammo_usage;                                     //      How many units of ammunition it uses.
40         byte    weapon_vclip;                           //      Vclip to render for the weapon, itself.
41         short   wall_hit_sound;                 // What sound for impact with wall
42
43         byte    destroyable;                            //      If !0, this weapon can be destroyed by another weapon.
44         byte    matter;                                         //      Flag: set if this object is matter (as opposed to energy)
45         byte    bounce;                                         //      1==always bounces, 2=bounces twice 
46         byte    homing_flag;                            //      Set if this weapon can home in on a target.
47
48         ubyte   speedvar;                                       //      allowed variance in speed below average, /128: 64 = 50% meaning if speed = 100, can be 50..100
49
50         ubyte   flags;                                          // see values above
51
52         byte    flash;                                          //      Flash effect
53         byte    afterburner_size;                       //      Size of blobs in F1_0/16 units, specify in bitmaps.tbl as floating point.  Player afterburner size = 2.5.
54
55         byte    children;                                       //      ID of weapon to drop if this contains children.  -1 means no children.
56
57         fix     energy_usage;                           //      How much fuel is consumed to fire this weapon.
58         fix     fire_wait;                                      //      Time until this weapon can be fired again.
59
60         fix     multi_damage_scale;             //      Scale damage by this amount when applying to player in multiplayer.  F1_0 means no change.
61
62         bitmap_index bitmap;                            // Pointer to bitmap if rendertype==0 or 1.
63
64         fix     blob_size;                                      // Size of blob if blob type
65         fix     flash_size;                                     // How big to draw the flash
66         fix     impact_size;                            // How big of an impact
67         fix     strength[NDL];                          // How much damage it can inflict
68         fix     speed[NDL];                                     // How fast it can move, difficulty level based.
69         fix     mass;                                                   // How much mass it has
70         fix     drag;                                                   // How much drag it has
71         fix     thrust;                                         //      How much thrust it has
72         fix     po_len_to_width_ratio;  // For polyobjects, the ratio of len/width. (10 maybe?)
73         fix     light;                                          //      Amount of light this weapon casts.
74         fix     lifetime;                                       //      Lifetime in seconds of this weapon.
75         fix     damage_radius;                          //      Radius of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit
76 //-- unused--   fix     damage_force;                           //      Force of damage caused by weapon, used for missiles (not lasers) to apply to damage to things it did not hit
77 // damage_force was a real mess.  Wasn't Difficulty_level based, and was being applied instead of weapon's actual strength.  Now use 2*strength instead. --MK, 01/19/95
78         bitmap_index    picture;                                // a picture of the weapon for the cockpit
79         bitmap_index    hires_picture;          // a hires picture of the above
80 } __pack__ weapon_info;
81
82 #define REARM_TIME                                      (F1_0)
83
84 #define WEAPON_DEFAULT_LIFETIME (F1_0*12)       //      Lifetime of an object if a bozo forgets to define it.
85
86 #define WEAPON_TYPE_WEAK_LASER  0
87 #define WEAPON_TYPE_STRONG_LASER        1
88 #define WEAPON_TYPE_CANNON_BALL 2
89 #define WEAPON_TYPE_MISSILE             3
90
91 #define MAX_WEAPON_TYPES                        70
92
93 #define WEAPON_RENDER_NONE                      -1
94 #define WEAPON_RENDER_LASER             0
95 #define WEAPON_RENDER_BLOB                      1
96 #define WEAPON_RENDER_POLYMODEL 2
97 #define WEAPON_RENDER_VCLIP             3
98
99 #define MAX_PRIMARY_WEAPONS             10
100 #define MAX_SECONDARY_WEAPONS   10
101
102 //given a weapon index, return the flag value
103 #define  HAS_FLAG(index)  (1<<(index))
104
105 //      Weapon flags, if player->weapon_flags & WEAPON_FLAG is set, then the player has this weapon
106 #define HAS_LASER_FLAG                          HAS_FLAG(LASER_INDEX)
107 #define HAS_VULCAN_FLAG                 HAS_FLAG(VULCAN_INDEX)
108 #define HAS_SPREADFIRE_FLAG             HAS_FLAG(SPREADFIRE_INDEX)
109 #define HAS_PLASMA_FLAG                 HAS_FLAG(PLASMA_INDEX)
110 #define HAS_FUSION_FLAG                 HAS_FLAG(FUSION_INDEX)
111
112 #define HAS_CONCUSSION_FLAG             HAS_FLAG(CONCUSSION_INDEX)
113 #define HAS_HOMING_FLAG                 HAS_FLAG(HOMING_INDEX)
114 #define HAS_PROXIMITY_FLAG              HAS_FLAG(PROXIMITY_INDEX)
115 #define HAS_SMART_FLAG                          HAS_FLAG(SMART_INDEX)
116 #define HAS_MEGA_FLAG                           HAS_FLAG(MEGA_INDEX)
117
118 #define CLASS_PRIMARY                           0
119 #define CLASS_SECONDARY                 1
120
121 #define LASER_INDEX                                     0
122 #define VULCAN_INDEX                            1
123 #define SPREADFIRE_INDEX                        2
124 #define PLASMA_INDEX                            3
125 #define FUSION_INDEX                            4
126 #define SUPER_LASER_INDEX                       5
127 #define GAUSS_INDEX                                     6
128 #define HELIX_INDEX                                     7
129 #define PHOENIX_INDEX                           8
130 #define OMEGA_INDEX                                     9
131
132 #define CONCUSSION_INDEX                        0
133 #define HOMING_INDEX                            1
134 #define PROXIMITY_INDEX                 2
135 #define SMART_INDEX                                     3
136 #define MEGA_INDEX                                      4
137 #define SMISSILE1_INDEX                 5
138 #define GUIDED_INDEX                            6
139 #define SMART_MINE_INDEX                        7
140 #define SMISSILE4_INDEX                 8
141 #define SMISSILE5_INDEX                 9
142
143 #define SUPER_WEAPON                            5
144
145 #define VULCAN_AMMO_SCALE               0xcc163 //(0x198300/2)          //multiply ammo by this before displaying
146
147 #define NUM_SMART_CHILDREN      6               //      Number of smart children created by default.
148
149 extern weapon_info Weapon_info[];
150 extern int N_weapon_types;
151 extern void do_weapon_select(int weapon_num, int secondary_flag);
152 extern void show_weapon_status(void);
153
154 extern byte     Primary_weapon, Secondary_weapon;
155
156 extern ubyte Primary_weapon_to_weapon_info[MAX_PRIMARY_WEAPONS];
157 extern ubyte Secondary_weapon_to_weapon_info[MAX_SECONDARY_WEAPONS];
158
159 //for each Secondary weapon, which gun it fires out of
160 extern ubyte Secondary_weapon_to_gun_num[MAX_SECONDARY_WEAPONS];
161
162 //for each primary weapon, what kind of powerup gives weapon
163 extern ubyte Primary_weapon_to_powerup[MAX_SECONDARY_WEAPONS];
164
165 //for each Secondary weapon, what kind of powerup gives weapon
166 extern ubyte Secondary_weapon_to_powerup[MAX_SECONDARY_WEAPONS];
167
168 //flags whether the last time we use this weapon, it was the 'super' version
169 extern ubyte Primary_last_was_super[MAX_PRIMARY_WEAPONS];
170 extern ubyte Secondary_last_was_super[MAX_SECONDARY_WEAPONS];
171
172 extern void auto_select_weapon(int weapon_type);                //parm is primary or secondary
173 extern void select_weapon(int weapon_num, int secondary_flag, int print_message,int wait_for_rearm);
174
175 extern char     *Primary_weapon_names_short[];
176 extern char     *Secondary_weapon_names_short[];
177 extern char     *Primary_weapon_names[];
178 extern char     *Secondary_weapon_names[];
179 extern int      Primary_ammo_max[MAX_PRIMARY_WEAPONS];
180 extern ubyte    Secondary_ammo_max[MAX_SECONDARY_WEAPONS];
181 extern byte     Weapon_is_energy[MAX_WEAPON_TYPES];
182
183 #define HAS_WEAPON_FLAG 1
184 #define HAS_ENERGY_FLAG 2
185 #define HAS_AMMO_FLAG           4
186 #define  HAS_ALL (HAS_WEAPON_FLAG|HAS_ENERGY_FLAG|HAS_AMMO_FLAG)
187
188 //      ------------------------------------------------------------------------------------
189 //      Return:
190 // Bits set:
191 //              HAS_WEAPON_FLAG
192 //              HAS_ENERGY_FLAG
193 //              HAS_AMMO_FLAG   
194 //              HAS_SUPER_FLAG
195 extern int player_has_weapon(int weapon_num, int secondary_flag);
196
197 //called when one of these weapons is picked up
198 //when you pick up a secondary, you always get the weapon & ammo for it
199 int pick_up_secondary(int weapon_index,int count);
200
201 //called when a primary weapon is picked up
202 //returns true if actually picked up
203 int pick_up_primary(int weapon_index);
204
205 //called when ammo (for the vulcan cannon) is picked up
206 int pick_up_ammo(int class_flag,int weapon_index,int ammo_count);
207
208 extern int attempt_to_steal_item(object *objp, int player_num);
209
210 //this function is for when the player intentionally drops a powerup
211 extern int spit_powerup(object *spitter, int id, int seed);
212
213 #define SMEGA_ID        40
214
215 extern void rock_the_mine_frame(void);
216 extern void smega_rock_stuff(void);
217 extern void init_smega_detonates(void);
218 extern void tactile_set_button_jolt (void);
219
220 #endif