]> icculus.org git repositories - btb/d2x.git/blob - main/robot.h
Visual C, PocketPC fixes
[btb/d2x.git] / main / robot.h
1 /* $Id: robot.h,v 1.4 2003-10-04 03:14:47 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  * Header for robot.c
18  *
19  * Old Log:
20  * Revision 1.1  1995/05/16  16:01:59  allender
21  * Initial revision
22  *
23  * Revision 2.1  1995/03/07  16:52:00  john
24  * Fixed robots not moving without edtiro bug.
25  *
26  * Revision 2.0  1995/02/27  11:30:59  john
27  * New version 2.0, which has no anonymous unions, builds with
28  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
29  *
30  * Revision 1.25  1994/11/30  14:02:44  mike
31  * fields for see/attack/claw sounds.
32  *
33  * Revision 1.24  1994/10/27  15:55:41  adam
34  * *** empty log message ***
35  *
36  * Revision 1.23  1994/10/20  15:17:03  mike
37  * Add boss flag.
38  *
39  * Revision 1.22  1994/10/20  09:51:00  adam
40  * *** empty log message ***
41  *
42  * Revision 1.21  1994/10/18  10:52:54  mike
43  * Support robots lunging as an attack_type.
44  *
45  * Revision 1.20  1994/10/17  21:19:02  mike
46  * robot cloaking.
47  *
48  * Revision 1.19  1994/09/27  00:03:39  mike
49  * Add score_value to robot_info struct.
50  *
51  * Revision 1.18  1994/09/22  19:01:12  mike
52  * Move NDL from here to game.h
53  *
54  * Revision 1.17  1994/09/22  15:46:55  mike
55  * Add default contained objects for robots.
56  *
57  * Revision 1.16  1994/09/22  10:46:57  mike
58  * Add difficulty levels.
59  *
60  * Revision 1.15  1994/09/15  16:34:16  mike
61  * Change rapidfire_count to a byte, add evade_speed, dum1, dum2.
62  *
63  * Revision 1.14  1994/09/09  14:21:58  matt
64  * Increased maximum number of games
65  *
66  * Revision 1.13  1994/08/25  18:12:13  matt
67  * Made player's weapons and flares fire from the positions on the 3d model.
68  * Also added support for quad lasers.
69  *
70  * Revision 1.12  1994/08/23  16:37:24  mike
71  * Add rapidfire_count to robot_info.
72  *
73  * Revision 1.11  1994/07/27  19:45:01  mike
74  * Objects containing objects.
75  *
76  * Revision 1.10  1994/07/12  12:40:01  matt
77  * Revamped physics system
78  *
79  * Revision 1.9  1994/06/21  12:17:12  mike
80  * Add circle_distance to robot_info.
81  *
82  * Revision 1.8  1994/06/09  16:22:28  matt
83  * Moved header for calc_gun_point() here, where it belongs
84  *
85  * Revision 1.7  1994/06/08  18:16:23  john
86  * Bunch of new stuff that basically takes constants out of the code
87  * and puts them into bitmaps.tbl.
88  *
89  * Revision 1.6  1994/06/03  11:38:09  john
90  * Made robots get their strength for RobotInfo->strength, which
91  * is read in from bitmaps.tbl
92  *
93  * Revision 1.5  1994/05/30  19:43:31  mike
94  * Add voluminous comment for robot_get_anim_state.
95  *
96  * Revision 1.4  1994/05/30  00:03:18  matt
97  * Got rid of robot render type, and generally cleaned up polygon model
98  * render objects.
99  *
100  * Revision 1.3  1994/05/29  18:46:37  matt
101  * Added stuff for getting robot animation info for different states
102  *
103  * Revision 1.2  1994/05/26  21:09:18  matt
104  * Moved robot stuff out of polygon model and into robot_info struct
105  * Made new file, robot.c, to deal with robots
106  *
107  * Revision 1.1  1994/05/26  18:02:12  matt
108  * Initial revision
109  *
110  *
111  */
112
113 #ifndef _ROBOT_H
114 #define _ROBOT_H
115
116 #include "vecmat.h"
117 #include "object.h"
118 #include "game.h"
119 #include "cfile.h"
120
121 #define MAX_GUNS 8      //should be multiple of 4 for ubyte array
122
123 //Animation states
124 #define AS_REST         0
125 #define AS_ALERT        1
126 #define AS_FIRE         2
127 #define AS_RECOIL       3
128 #define AS_FLINCH       4
129 #define N_ANIM_STATES   5
130
131 #define RI_CLOAKED_NEVER            0
132 #define RI_CLOAKED_ALWAYS           1
133 #define RI_CLOAKED_EXCEPT_FIRING    2
134
135 //describes the position of a certain joint
136 typedef struct jointpos {
137         short jointnum;
138         vms_angvec angles;
139 } __pack__ jointpos;
140
141 //describes a list of joint positions
142 typedef struct jointlist {
143         short n_joints;
144         short offset;
145 } jointlist;
146
147 //robot info flags
148 #define RIF_BIG_RADIUS  1   //pad the radius to fix robots firing through walls
149 #define RIF_THIEF       2   //this guy steals!
150
151 //  Robot information
152 typedef struct robot_info {
153         int     model_num;                  // which polygon model?
154         vms_vector  gun_points[MAX_GUNS];   // where each gun model is
155         ubyte   gun_submodels[MAX_GUNS];    // which submodel is each gun in?
156
157         short   exp1_vclip_num;
158         short   exp1_sound_num;
159
160         short   exp2_vclip_num;
161         short   exp2_sound_num;
162
163         sbyte   weapon_type;
164         sbyte   weapon_type2;   //  Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon.
165         sbyte   n_guns;         // how many different gun positions
166         sbyte   contains_id;    //  ID of powerup this robot can contain.
167
168         sbyte   contains_count; //  Max number of things this instance can contain.
169         sbyte   contains_prob;  //  Probability that this instance will contain something in N/16
170         sbyte   contains_type;  //  Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup
171         sbyte   kamikaze;       //  !0 means commits suicide when hits you, strength thereof. 0 means no.
172
173         short   score_value;    //  Score from this robot.
174         sbyte   badass;         //  Dies with badass explosion, and strength thereof, 0 means NO.
175         sbyte   energy_drain;   //  Points of energy drained at each collision.
176
177         fix     lighting;       // should this be here or with polygon model?
178         fix     strength;       // Initial shields of robot
179
180         fix     mass;           // how heavy is this thing?
181         fix     drag;           // how much drag does it have?
182
183         fix     field_of_view[NDL]; // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player
184         fix     firing_wait[NDL];   //  time in seconds between shots
185         fix     firing_wait2[NDL];  //  time in seconds between shots
186         fix     turn_time[NDL];     // time in seconds to rotate 360 degrees in a dimension
187 // -- unused, mk, 05/25/95  fix fire_power[NDL];    //  damage done by a hit from this robot
188 // -- unused, mk, 05/25/95  fix shield[NDL];        //  shield strength of this robot
189         fix     max_speed[NDL];         //  maximum speed attainable by this robot
190         fix     circle_distance[NDL];   //  distance at which robot circles player
191
192         sbyte   rapidfire_count[NDL];   //  number of shots fired rapidly
193         sbyte   evade_speed[NDL];       //  rate at which robot can evade shots, 0=none, 4=very fast
194         sbyte   cloak_type;     //  0=never, 1=always, 2=except-when-firing
195         sbyte   attack_type;    //  0=firing, 1=charge (like green guy)
196
197         ubyte   see_sound;      //  sound robot makes when it first sees the player
198         ubyte   attack_sound;   //  sound robot makes when it attacks the player
199         ubyte   claw_sound;     //  sound robot makes as it claws you (attack_type should be 1)
200         ubyte   taunt_sound;    //  sound robot makes after you die
201
202         sbyte   boss_flag;      //  0 = not boss, 1 = boss.  Is that surprising?
203         sbyte   companion;      //  Companion robot, leads you to things.
204         sbyte   smart_blobs;    //  how many smart blobs are emitted when this guy dies!
205         sbyte   energy_blobs;   //  how many smart blobs are emitted when this guy gets hit by energy weapon!
206
207         sbyte   thief;          //  !0 means this guy can steal when he collides with you!
208         sbyte   pursuit;        //  !0 means pursues player after he goes around a corner.  4 = 4/2 pursue up to 4/2 seconds after becoming invisible if up to 4 segments away
209         sbyte   lightcast;      //  Amount of light cast. 1 is default.  10 is very large.
210         sbyte   death_roll;     //  0 = dies without death roll. !0 means does death roll, larger = faster and louder
211
212         //boss_flag, companion, thief, & pursuit probably should also be bits in the flags byte.
213         ubyte   flags;          // misc properties
214         ubyte   pad[3];         // alignment
215
216         ubyte   deathroll_sound;    // if has deathroll, what sound?
217         ubyte   glow;               // apply this light to robot itself. stored as 4:4 fixed-point
218         ubyte   behavior;           //  Default behavior.
219         ubyte   aim;                //  255 = perfect, less = more likely to miss.  0 != random, would look stupid.  0=45 degree spread.  Specify in bitmaps.tbl in range 0.0..1.0
220
221         //animation info
222         jointlist anim_states[MAX_GUNS+1][N_ANIM_STATES];
223
224         int     always_0xabcd;      // debugging
225
226 } __pack__ robot_info;
227
228
229 #define MAX_ROBOT_TYPES 85      // maximum number of robot types
230
231 #define ROBOT_NAME_LENGTH   16
232 extern char Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH];
233
234 //the array of robots types
235 extern robot_info Robot_info[];     // Robot info for AI system, loaded from bitmaps.tbl.
236
237 //how many kinds of robots
238 extern  int N_robot_types;      // Number of robot types.  We used to assume this was the same as N_polygon_models.
239
240 //test data for one robot
241 #define MAX_ROBOT_JOINTS 1600
242 extern jointpos Robot_joints[MAX_ROBOT_JOINTS];
243 extern int  N_robot_joints;
244
245 //given an object and a gun number, return position in 3-space of gun
246 //fills in gun_point
247 void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num);
248 //void calc_gun_point(vms_vector *gun_point,int objnum,int gun_num);
249
250 //  Tells joint positions for a gun to be in a specified state.
251 //  A gun can have associated with it any number of joints.  In order to tell whether a gun is a certain
252 //  state (such as FIRE or ALERT), you should call this function and check the returned joint positions
253 //  against the robot's gun's joint positions.  This function should also be called to determine how to
254 //  move a gun into a desired position.
255 //  For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another.
256 //  There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't
257 //  cause a gun to move through a robot's body, for example.
258
259 //  Given:
260 //      jp_list_ptr     pointer to list of joint angles, on exit, this is pointing at a static array
261 //      robot_type      type of robot for which to get joint information.  A particular type, not an instance of a robot.
262 //      gun_num         gun number.  If in 0..Robot_info[robot_type].n_guns-1, then it is a gun, else it refers to non-animating parts of robot.
263 //      state           state about which to get information.  Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are:
264 //                          AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH
265
266 //  On exit:
267 //      Returns number of joints in list.
268 //      jp_list_ptr is stuffed with a pointer to a static array of joint positions.  This pointer is valid forever.
269 extern int robot_get_anim_state(jointpos **jp_list_ptr,int robot_type,int gun_num,int state);
270
271 #ifdef FAST_FILE_IO
272 #define robot_info_read_n(ri, n, fp) cfread(ri, sizeof(robot_info), n, fp)
273 #define jointpos_read_n(jp, n, fp) cfread(jp, sizeof(jointpos), n, fp)
274 #else
275 /*
276  * reads n robot_info structs from a CFILE
277  */
278 extern int robot_info_read_n(robot_info *ri, int n, CFILE *fp);
279
280 /*
281  * reads n jointpos structs from a CFILE
282  */
283 extern int jointpos_read_n(jointpos *jp, int n, CFILE *fp);
284 #endif
285
286 #endif