1 /* $Id: aistruct.h,v 1.2 2003-10-04 03:14:47 btb Exp $ */
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.
17 * Structs and constants for AI system.
18 * object.h depends on this.
19 * ai.h depends on object.h.
23 * Revision 1.2 1995/10/10 11:49:04 allender
26 * Revision 1.1 1995/05/16 15:54:08 allender
29 * Revision 2.0 1995/02/27 11:30:19 john
30 * New version 2.0, which has no anonymous unions, builds with
31 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
33 * Revision 1.34 1995/01/25 13:50:46 mike
34 * Robots make angry sounds.
36 * Revision 1.33 1994/12/29 12:44:56 rob
37 * Added new coop robot flag.
39 * Revision 1.32 1994/12/20 20:41:54 rob
40 * Added new ai flag for multiplayer robots.
42 * Revision 1.31 1994/12/19 16:37:39 rob
43 * Added a new flag for remote controlled objects.
45 * Revision 1.30 1994/12/07 00:36:07 mike
46 * fix phys_apply_rot for robots -- ai was bashing effect in next frame.
48 * Revision 1.29 1994/12/02 22:06:28 mike
49 * add fields to allow robots to make awareness sounds every so often, not every damn blasted frame
51 * Revision 1.28 1994/11/04 17:18:35 yuan
52 * Increased MAX_SEG_POINTS to 2500.
54 * Revision 1.27 1994/10/17 21:19:22 mike
57 * Revision 1.26 1994/10/12 21:28:38 mike
58 * Add new ai mode: AIM_OPEN_DOOR.
59 * Add GOALSIDE to aip.
61 * Revision 1.25 1994/09/25 23:41:08 matt
62 * Changed the object load & save code to read/write the structure fields one
63 * at a time (rather than the whole structure at once). This mean that the
64 * object structure can be changed without breaking the load/save functions.
65 * As a result of this change, the local_object data can be and has been
66 * incorporated into the object array. Also, timeleft is now a property
67 * of all objects, and the object structure has been otherwise cleaned up.
69 * Revision 1.24 1994/09/21 12:28:11 mike
70 * Change AI behavior for when player cloaked
72 * Revision 1.23 1994/09/19 21:43:00 mike
73 * Add follow_path_start_seg and follow_path_end_seg to aistruct.h.
75 * Revision 1.22 1994/09/18 18:06:14 mike
76 * Add Last_uncloaked_time and Last_uncloaked_position variables.
78 * Revision 1.21 1994/09/15 16:31:38 mike
80 * Add previous_visibility to ai_local struct.
82 * Revision 1.20 1994/09/12 19:12:45 mike
83 * Change some bytes to ints in ai_local so I could set watchpoints.
85 * Revision 1.19 1994/08/25 21:53:31 mike
86 * Add behavior, taking place of what used to be mode.
88 * Revision 1.18 1994/08/23 16:38:09 mike
89 * rapidfire_count in ai_local.
91 * Revision 1.17 1994/08/19 17:38:23 mike
92 * *** empty log message ***
94 * Revision 1.16 1994/08/17 22:18:58 mike
95 * add time_since_processed to ai_local.
97 * Revision 1.15 1994/08/10 19:52:25 mike
98 * Add Overall_agitation.
100 * Revision 1.14 1994/08/04 16:32:32 mike
101 * Add time_player_seen.
103 * Revision 1.13 1994/07/28 16:58:11 mike
104 * Move constants from ai.c
106 * Revision 1.12 1994/07/19 15:26:24 mike
107 * New ai_static and ai_local structures.
109 * Revision 1.11 1994/07/15 15:17:19 matt
110 * Changes MAX_AI_FLAGS for better alignment
118 //#include "polyobj.h"
122 #define MAX_SEGMENTS_PER_PATH 20
124 #define PA_WEAPON_WALL_COLLISION 2 // Level of robot awareness after player weapon hits nearby wall
125 //#define PA_PLAYER_VISIBLE 2 // Level of robot awareness if robot is looking towards player, and player not hidden
126 #define PA_NEARBY_ROBOT_FIRED 1 // Level of robot awareness after nearby robot fires a weapon
127 #define PA_PLAYER_COLLISION 3 // Level of robot awareness after player bumps into robot
128 #define PA_WEAPON_ROBOT_COLLISION 4 // Level of robot awareness after player weapon hits nearby robot
130 //#define PAE_WEAPON_HIT_WALL 1 // weapon hit wall, create player awareness
131 //#define PAE_WEAPON_HIT_ROBOT 2 // weapon hit wall, create player awareness
133 // Constants indicating currently moving forward or backward through
134 // path. Note that you can add aip->direction to aip_path_index to
135 // get next segment on path.
136 #define AI_DIR_FORWARD 1
137 #define AI_DIR_BACKWARD (-AI_DIR_FORWARD)
140 #define AIB_STILL 0x80
141 #define AIB_NORMAL 0x81
142 #define AIB_BEHIND 0x82
143 #define AIB_RUN_FROM 0x83
144 #define AIB_SNIPE 0x84
145 #define AIB_STATION 0x85
146 #define AIB_FOLLOW 0x86
148 #define MIN_BEHAVIOR 0x80
149 #define MAX_BEHAVIOR 0x86
154 #define AIM_FOLLOW_PATH 2
155 #define AIM_CHASE_OBJECT 3
156 #define AIM_RUN_FROM_OBJECT 4
158 #define AIM_FOLLOW_PATH_2 6
159 #define AIM_OPEN_DOOR 7
160 #define AIM_GOTO_PLAYER 8 // Only for escort behavior
161 #define AIM_GOTO_OBJECT 9 // Only for escort behavior
163 #define AIM_SNIPE_ATTACK 10
164 #define AIM_SNIPE_FIRE 11
165 #define AIM_SNIPE_RETREAT 12
166 #define AIM_SNIPE_RETREAT_BACKWARDS 13
167 #define AIM_SNIPE_WAIT 14
169 #define AIM_THIEF_ATTACK 15
170 #define AIM_THIEF_RETREAT 16
171 #define AIM_THIEF_WAIT 17
173 #define AISM_GOHIDE 0
174 #define AISM_HIDING 1
176 #define AI_MAX_STATE 7
177 #define AI_MAX_EVENT 4
193 //typedef struct opath {
194 // sbyte path_index; // current index of path
195 // sbyte path_direction; // current path direction
196 // sbyte path_length; // length of current path
198 // short path[MAX_SEGMENTS_PER_PATH];
199 // short always_0xabc; // If this is ever not 0xabc, then someone overwrote
202 //typedef struct oai_state {
204 // short counter; // kind of a hack, frame countdown until switch modes
206 // vms_vector movement_vector; // movement vector for one second
209 #define SUB_FLAGS_GUNSEG 0x01
210 #define SUB_FLAGS_SPROX 0x02 // If set, then this bot drops a super prox, not a prox, when it's time to drop something
211 #define SUB_FLAGS_CAMERA_AWAKE 0x04 // If set, a camera (on a missile) woke this robot up, so don't fire at player. Can look real stupid!
213 // Constants defining meaning of flags in ai_state
214 #define MAX_AI_FLAGS 11 // This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
216 #define CURRENT_GUN flags[0] // This is the last gun the object fired from
217 #define CURRENT_STATE flags[1] // current behavioral state
218 #define GOAL_STATE flags[2] // goal state
219 #define PATH_DIR flags[3] // direction traveling path, 1 = forward, -1 = backward, other = error!
220 #define SUB_FLAGS flags[4] // bit 0: Set -> Robot's current gun in different segment than robot's center.
221 #define GOALSIDE flags[5] // for guys who open doors, this is the side they are going after.
222 #define CLOAKED flags[6] // Cloaked now.
223 #define SKIP_AI_COUNT flags[7] // Skip AI this frame, but decrement in do_ai_frame.
224 #define REMOTE_OWNER flags[8] // Who is controlling this remote AI object (multiplayer use only)
225 #define REMOTE_SLOT_NUM flags[9] // What slot # is this robot in for remote control purposes (multiplayer use only)
226 #define MULTI_ANGER flags[10] // How angry is a robot in multiplayer mode
228 // This is the stuff that is permanent for an AI object and is
229 // therefore saved to disk.
230 typedef struct ai_static {
232 sbyte flags[MAX_AI_FLAGS]; // various flags, meaning defined by constants
233 short hide_segment; // Segment to go to for hiding.
234 short hide_index; // Index in Path_seg_points
235 short path_length; // Length of hide path.
236 sbyte cur_path_index; // Current index in path.
237 sbyte dying_sound_playing; // !0 if this robot is playing its dying sound.
239 // -- not needed! -- short follow_path_start_seg; // Start segment for robot which follows path.
240 // -- not needed! -- short follow_path_end_seg; // End segment for robot which follows path.
242 short danger_laser_num;
243 int danger_laser_signature;
244 fix dying_start_time; // Time at which this robot started dying.
246 //sbyte extras[28]; // 32 extra bytes for storing stuff so we don't have to change versions on disk
247 } __pack__ ai_static;
249 // This is the stuff which doesn't need to be saved to disk.
250 typedef struct ai_local {
251 // These used to be bytes, changed to ints so I could set watchpoints on them.
252 // player_awareness_type..rapidfire_count used to be bytes
253 // goal_segment used to be short.
254 int player_awareness_type; // type of awareness of player
255 int retry_count; // number of retries in physics last time this object got moved.
256 int consecutive_retries; // number of retries in consecutive frames (ie, without a retry_count of 0)
257 int mode; // current mode within behavior
258 int previous_visibility; // Visibility of player last time we checked.
259 int rapidfire_count; // number of shots fired rapidly
260 int goal_segment; // goal segment for current path
262 // -- MK, 10/21/95, unused -- fix last_see_time, last_attack_time; // For sound effects, time at which player last seen, attacked
264 fix next_action_time; // time in seconds until something happens, mode dependent
265 fix next_fire; // time in seconds until can fire again
266 fix next_fire2; // time in seconds until can fire again from second weapon
267 fix player_awareness_time; // time in seconds robot will be aware of player, 0 means not aware of player
268 fix time_player_seen; // absolute time in seconds at which player was last seen, might cause to go into follow_path mode
269 fix time_player_sound_attacked; // absolute time in seconds at which player was last seen with visibility of 2.
270 fix next_misc_sound_time; // absolute time in seconds at which this robot last made an angry or lurking sound.
271 fix time_since_processed; // time since this robot last processed in do_ai_frame
272 vms_angvec goal_angles[MAX_SUBMODELS]; // angles for each subobject
273 vms_angvec delta_angles[MAX_SUBMODELS]; // angles for each subobject
274 sbyte goal_state[MAX_SUBMODELS]; // Goal state for this sub-object
275 sbyte achieved_state[MAX_SUBMODELS]; // Last achieved state
287 #define MAX_POINT_SEGS 2500
289 extern point_seg Point_segs[MAX_POINT_SEGS];
290 extern point_seg *Point_segs_free_ptr;
291 extern int Overall_agitation;
293 // These are the information for a robot describing the location of
294 // the player last time he wasn't cloaked, and the time at which he
295 // was uncloaked. We should store this for each robot, but that's
297 //extern fix Last_uncloaked_time;
298 //extern vms_vector Last_uncloaked_position;
300 extern void ai_do_cloak_stuff(void);
302 #endif /* _AISTRUCT_H */