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