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