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