]> icculus.org git repositories - btb/d2x.git/blob - main/robot.h
load d1 levels
[btb/d2x.git] / main / robot.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
15
16 #ifndef _ROBOT_H
17 #define _ROBOT_H
18
19 #include "vecmat.h"
20 #include "object.h"
21 #include "game.h"
22 #include "cfile.h"
23
24 #define MAX_GUNS 8              //should be multiple of 4 for ubyte array
25
26 //Animation states
27 #define AS_REST         0
28 #define AS_ALERT        1
29 #define AS_FIRE         2
30 #define AS_RECOIL       3
31 #define AS_FLINCH       4
32 #define N_ANIM_STATES   5
33
34 #define RI_CLOAKED_NEVER            0
35 #define RI_CLOAKED_ALWAYS           1
36 #define RI_CLOAKED_EXCEPT_FIRING    2
37
38 //describes the position of a certain joint
39 typedef struct jointpos {
40         short jointnum;
41         vms_angvec angles;
42 } jointpos;
43
44 //describes a list of joint positions
45 typedef struct jointlist {
46         short n_joints;
47         short offset;
48 } jointlist;
49
50 //robot info flags
51 #define RIF_BIG_RADIUS  1       //pad the radius to fix robots firing through walls
52 #define RIF_THIEF                       2       //this guy steals!
53
54 //      Robot information
55 typedef struct robot_info {
56         int                     model_num;                                                      // which polygon model?
57         vms_vector      gun_points[MAX_GUNS];                   // where each gun model is
58         ubyte                   gun_submodels[MAX_GUNS];                // which submodel is each gun in?
59
60         short           exp1_vclip_num;
61         short                   exp1_sound_num;
62
63         short           exp2_vclip_num;
64         short                   exp2_sound_num;
65
66         byte                    weapon_type;
67         byte                    weapon_type2;                                           //      Secondary weapon number, -1 means none, otherwise gun #0 fires this weapon.
68         byte                    n_guns;                                                         // how many different gun positions
69         byte                    contains_id;                                            //      ID of powerup this robot can contain.
70
71         byte                    contains_count;                                 //      Max number of things this instance can contain.
72         byte                    contains_prob;                                          //      Probability that this instance will contain something in N/16
73         byte                    contains_type;                                          //      Type of thing contained, robot or powerup, in bitmaps.tbl, !0=robot, 0=powerup
74         byte                    kamikaze;                                                       //      !0 means commits suicide when hits you, strength thereof. 0 means no.
75
76         short                   score_value;                                            //      Score from this robot.
77         byte                    badass;                                                         //      Dies with badass explosion, and strength thereof, 0 means NO.
78         byte                    energy_drain;                                           //      Points of energy drained at each collision.
79
80         fix                     lighting;                                                       // should this be here or with polygon model?
81         fix                     strength;                                                       // Initial shields of robot
82
83         fix             mass;                                                                           // how heavy is this thing?
84         fix             drag;                                                                           // how much drag does it have?
85
86         fix             field_of_view[NDL];                                     // compare this value with forward_vector.dot.vector_to_player, if field_of_view <, then robot can see player
87         fix             firing_wait[NDL];                                               //      time in seconds between shots
88         fix             firing_wait2[NDL];                                      //      time in seconds between shots
89         fix             turn_time[NDL];                                         // time in seconds to rotate 360 degrees in a dimension
90 // -- unused, mk, 05/25/95      fix             fire_power[NDL];                                                //      damage done by a hit from this robot
91 // -- unused, mk, 05/25/95      fix             shield[NDL];                                                    //      shield strength of this robot
92         fix             max_speed[NDL];                                         //      maximum speed attainable by this robot
93         fix             circle_distance[NDL];                           //      distance at which robot circles player
94
95         byte            rapidfire_count[NDL];                           //      number of shots fired rapidly
96         byte            evade_speed[NDL];                                               //      rate at which robot can evade shots, 0=none, 4=very fast
97         byte            cloak_type;                                                             //      0=never, 1=always, 2=except-when-firing
98         byte            attack_type;                                                    //      0=firing, 1=charge (like green guy)
99
100         ubyte           see_sound;                                                              //      sound robot makes when it first sees the player
101         ubyte           attack_sound;                                                   //      sound robot makes when it attacks the player
102         ubyte           claw_sound;                                                             //      sound robot makes as it claws you (attack_type should be 1)
103         ubyte           taunt_sound;                                                    //      sound robot makes after you die
104
105         byte            boss_flag;                                                              //      0 = not boss, 1 = boss.  Is that surprising?
106         byte            companion;                                                              //      Companion robot, leads you to things.
107         byte            smart_blobs;                                                    //      how many smart blobs are emitted when this guy dies!
108         byte            energy_blobs;                                                   //      how many smart blobs are emitted when this guy gets hit by energy weapon!
109
110         byte            thief;                                                                  //      !0 means this guy can steal when he collides with you!
111         byte            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
112         byte            lightcast;                                                              //      Amount of light cast. 1 is default.  10 is very large.
113         byte            death_roll;                                                             //      0 = dies without death roll. !0 means does death roll, larger = faster and louder
114
115         //boss_flag, companion, thief, & pursuit probably should also be bits in the flags byte.
116         ubyte           flags;                                                                  // misc properties
117         ubyte           pad[3];                                                                 // alignment
118
119         ubyte           deathroll_sound;                                                // if has deathroll, what sound?
120         ubyte           glow;                                                                           // apply this light to robot itself. stored as 4:4 fixed-point
121         ubyte           behavior;                                                               //      Default behavior.
122         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
123
124         //animation info
125         jointlist anim_states[MAX_GUNS+1][N_ANIM_STATES];
126
127         int             always_0xabcd;                                                  // debugging
128
129 } robot_info;
130
131
132 #define MAX_ROBOT_TYPES 85                      // maximum number of robot types
133
134 #define ROBOT_NAME_LENGTH       16
135 extern char     Robot_names[MAX_ROBOT_TYPES][ROBOT_NAME_LENGTH];
136
137 //the array of robots types
138 extern robot_info Robot_info[];                 // Robot info for AI system, loaded from bitmaps.tbl.
139
140 //how many kinds of robots
141 extern  int     N_robot_types;          // Number of robot types.  We used to assume this was the same as N_polygon_models.
142
143 //test data for one robot
144 #define MAX_ROBOT_JOINTS 1600
145 extern jointpos Robot_joints[MAX_ROBOT_JOINTS];
146 extern int      N_robot_joints;
147
148 //given an object and a gun number, return position in 3-space of gun
149 //fills in gun_point
150 void calc_gun_point(vms_vector *gun_point,object *obj,int gun_num);
151 //void calc_gun_point(vms_vector *gun_point,int objnum,int gun_num);
152
153 //      Tells joint positions for a gun to be in a specified state.
154 //      A gun can have associated with it any number of joints.  In order to tell whether a gun is a certain
155 //      state (such as FIRE or ALERT), you should call this function and check the returned joint positions
156 //      against the robot's gun's joint positions.  This function should also be called to determine how to
157 //      move a gun into a desired position.
158 //      For now (May 30, 1994), it is assumed that guns will linearly interpolate from one joint position to another.
159 //      There is no ordering of joint movement, so it's impossible to guarantee that a strange starting position won't
160 //      cause a gun to move through a robot's body, for example.
161
162 //      Given:
163 //              jp_list_ptr             pointer to list of joint angles, on exit, this is pointing at a static array
164 //              robot_type              type of robot for which to get joint information.  A particular type, not an instance of a robot.
165 //              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.
166 //              state                           state about which to get information.  Legal states in range 0..N_ANIM_STATES-1, defined in robot.h, are:
167 //                                                              AS_REST, AS_ALERT, AS_FIRE, AS_RECOIL, AS_FLINCH
168
169 //      On exit:
170 //              Returns number of joints in list.
171 //              jp_list_ptr is stuffed with a pointer to a static array of joint positions.  This pointer is valid forever.
172 extern int robot_get_anim_state(jointpos **jp_list_ptr,int robot_type,int gun_num,int state);
173
174 /*
175  * reads a robot_info structure from a CFILE
176  */
177 extern void robot_info_read(robot_info *ri, CFILE *fp);
178
179 /*
180  * reads a jointpos structure from a CFILE
181  */
182 extern void jointpos_read(jointpos *jp, CFILE *fp);
183
184 #endif