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