1 /* $Id: aistruct.h,v 1.3 2004-08-28 23:17:45 schaffner 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.
28 //#include "polyobj.h"
32 #define MAX_SEGMENTS_PER_PATH 20
34 #define PA_WEAPON_WALL_COLLISION 2 // Level of robot awareness after player weapon hits nearby wall
35 //#define PA_PLAYER_VISIBLE 2 // Level of robot awareness if robot is looking towards player, and player not hidden
36 #define PA_NEARBY_ROBOT_FIRED 1 // Level of robot awareness after nearby robot fires a weapon
37 #define PA_PLAYER_COLLISION 3 // Level of robot awareness after player bumps into robot
38 #define PA_WEAPON_ROBOT_COLLISION 4 // Level of robot awareness after player weapon hits nearby robot
40 //#define PAE_WEAPON_HIT_WALL 1 // weapon hit wall, create player awareness
41 //#define PAE_WEAPON_HIT_ROBOT 2 // weapon hit wall, create player awareness
43 // Constants indicating currently moving forward or backward through
44 // path. Note that you can add aip->direction to aip_path_index to
45 // get next segment on path.
46 #define AI_DIR_FORWARD 1
47 #define AI_DIR_BACKWARD (-AI_DIR_FORWARD)
50 #define AIB_STILL 0x80
51 #define AIB_NORMAL 0x81
52 #define AIB_BEHIND 0x82
53 #define AIB_RUN_FROM 0x83
54 #define AIB_SNIPE 0x84
55 #define AIB_STATION 0x85
56 #define AIB_FOLLOW 0x86
58 #define MIN_BEHAVIOR 0x80
59 #define MAX_BEHAVIOR 0x86
64 #define AIM_FOLLOW_PATH 2
65 #define AIM_CHASE_OBJECT 3
66 #define AIM_RUN_FROM_OBJECT 4
68 #define AIM_FOLLOW_PATH_2 6
69 #define AIM_OPEN_DOOR 7
70 #define AIM_GOTO_PLAYER 8 // Only for escort behavior
71 #define AIM_GOTO_OBJECT 9 // Only for escort behavior
73 #define AIM_SNIPE_ATTACK 10
74 #define AIM_SNIPE_FIRE 11
75 #define AIM_SNIPE_RETREAT 12
76 #define AIM_SNIPE_RETREAT_BACKWARDS 13
77 #define AIM_SNIPE_WAIT 14
79 #define AIM_THIEF_ATTACK 15
80 #define AIM_THIEF_RETREAT 16
81 #define AIM_THIEF_WAIT 17
86 #define AI_MAX_STATE 7
87 #define AI_MAX_EVENT 4
103 //typedef struct opath {
104 // sbyte path_index; // current index of path
105 // sbyte path_direction; // current path direction
106 // sbyte path_length; // length of current path
108 // short path[MAX_SEGMENTS_PER_PATH];
109 // short always_0xabc; // If this is ever not 0xabc, then someone overwrote
112 //typedef struct oai_state {
114 // short counter; // kind of a hack, frame countdown until switch modes
116 // vms_vector movement_vector; // movement vector for one second
119 #define SUB_FLAGS_GUNSEG 0x01
120 #define SUB_FLAGS_SPROX 0x02 // If set, then this bot drops a super prox, not a prox, when it's time to drop something
121 #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!
123 // Constants defining meaning of flags in ai_state
124 #define MAX_AI_FLAGS 11 // This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
126 #define CURRENT_GUN flags[0] // This is the last gun the object fired from
127 #define CURRENT_STATE flags[1] // current behavioral state
128 #define GOAL_STATE flags[2] // goal state
129 #define PATH_DIR flags[3] // direction traveling path, 1 = forward, -1 = backward, other = error!
130 #define SUB_FLAGS flags[4] // bit 0: Set -> Robot's current gun in different segment than robot's center.
131 #define GOALSIDE flags[5] // for guys who open doors, this is the side they are going after.
132 #define CLOAKED flags[6] // Cloaked now.
133 #define SKIP_AI_COUNT flags[7] // Skip AI this frame, but decrement in do_ai_frame.
134 #define REMOTE_OWNER flags[8] // Who is controlling this remote AI object (multiplayer use only)
135 #define REMOTE_SLOT_NUM flags[9] // What slot # is this robot in for remote control purposes (multiplayer use only)
136 #define MULTI_ANGER flags[10] // How angry is a robot in multiplayer mode
138 // This is the stuff that is permanent for an AI object and is
139 // therefore saved to disk.
140 typedef struct ai_static {
142 sbyte flags[MAX_AI_FLAGS]; // various flags, meaning defined by constants
143 short hide_segment; // Segment to go to for hiding.
144 short hide_index; // Index in Path_seg_points
145 short path_length; // Length of hide path.
146 sbyte cur_path_index; // Current index in path.
147 sbyte dying_sound_playing; // !0 if this robot is playing its dying sound.
149 // -- not needed! -- short follow_path_start_seg; // Start segment for robot which follows path.
150 // -- not needed! -- short follow_path_end_seg; // End segment for robot which follows path.
152 short danger_laser_num;
153 int danger_laser_signature;
154 fix dying_start_time; // Time at which this robot started dying.
156 //sbyte extras[28]; // 32 extra bytes for storing stuff so we don't have to change versions on disk
157 } __pack__ ai_static;
159 // This is the stuff which doesn't need to be saved to disk.
160 typedef struct ai_local {
161 // These used to be bytes, changed to ints so I could set watchpoints on them.
162 // player_awareness_type..rapidfire_count used to be bytes
163 // goal_segment used to be short.
164 int player_awareness_type; // type of awareness of player
165 int retry_count; // number of retries in physics last time this object got moved.
166 int consecutive_retries; // number of retries in consecutive frames (ie, without a retry_count of 0)
167 int mode; // current mode within behavior
168 int previous_visibility; // Visibility of player last time we checked.
169 int rapidfire_count; // number of shots fired rapidly
170 int goal_segment; // goal segment for current path
172 // -- MK, 10/21/95, unused -- fix last_see_time, last_attack_time; // For sound effects, time at which player last seen, attacked
174 fix next_action_time; // time in seconds until something happens, mode dependent
175 fix next_fire; // time in seconds until can fire again
176 fix next_fire2; // time in seconds until can fire again from second weapon
177 fix player_awareness_time; // time in seconds robot will be aware of player, 0 means not aware of player
178 fix time_player_seen; // absolute time in seconds at which player was last seen, might cause to go into follow_path mode
179 fix time_player_sound_attacked; // absolute time in seconds at which player was last seen with visibility of 2.
180 fix next_misc_sound_time; // absolute time in seconds at which this robot last made an angry or lurking sound.
181 fix time_since_processed; // time since this robot last processed in do_ai_frame
182 vms_angvec goal_angles[MAX_SUBMODELS]; // angles for each subobject
183 vms_angvec delta_angles[MAX_SUBMODELS]; // angles for each subobject
184 sbyte goal_state[MAX_SUBMODELS]; // Goal state for this sub-object
185 sbyte achieved_state[MAX_SUBMODELS]; // Last achieved state
197 #define MAX_POINT_SEGS 2500
199 extern point_seg Point_segs[MAX_POINT_SEGS];
200 extern point_seg *Point_segs_free_ptr;
201 extern int Overall_agitation;
203 // These are the information for a robot describing the location of
204 // the player last time he wasn't cloaked, and the time at which he
205 // was uncloaked. We should store this for each robot, but that's
207 //extern fix Last_uncloaked_time;
208 //extern vms_vector Last_uncloaked_position;
210 extern void ai_do_cloak_stuff(void);
212 #endif /* _AISTRUCT_H */