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