1 /* 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. 12 */ 13 14 15 #ifndef _AISTRUCT_H 16 #define _AISTRUCT_H 17 18 #include "inferno.h" 19 //#include "polyobj.h" 20 21 #define GREEN_GUY 1 22 23 #define MAX_SEGMENTS_PER_PATH 20 24 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 30 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 33 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) 38 39 // Behaviors 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 47 48 #define MIN_BEHAVIOR 0x80 49 #define MAX_BEHAVIOR 0x86 50 51 // Modes 52 #define AIM_STILL 0 53 #define AIM_WANDER 1 54 #define AIM_FOLLOW_PATH 2 55 #define AIM_CHASE_OBJECT 3 56 #define AIM_RUN_FROM_OBJECT 4 57 #define AIM_BEHIND 5 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 62 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 68 69 #define AIM_THIEF_ATTACK 15 70 #define AIM_THIEF_RETREAT 16 71 #define AIM_THIEF_WAIT 17 72 73 #define AISM_GOHIDE 0 74 #define AISM_HIDING 1 75 76 #define AI_MAX_STATE 7 77 #define AI_MAX_EVENT 4 78 79 #define AIS_NONE 0 80 #define AIS_REST 1 81 #define AIS_SRCH 2 82 #define AIS_LOCK 3 83 #define AIS_FLIN 4 84 #define AIS_FIRE 5 85 #define AIS_RECO 6 86 #define AIS_ERR_ 7 87 88 #define AIE_FIRE 0 89 #define AIE_HITT 1 90 #define AIE_COLL 2 91 #define AIE_HURT 3 92 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 97 // byte nothing; 98 // short path[MAX_SEGMENTS_PER_PATH]; 99 // short always_0xabc; // If this is ever not 0xabc, then someone overwrote 100 //} opath; 101 // 102 //typedef struct oai_state { 103 // short mode; // 104 // short counter; // kind of a hack, frame countdown until switch modes 105 // opath paths[2]; 106 // vms_vector movement_vector; // movement vector for one second 107 //} oai_state; 108 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! 112 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 115 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 127 128 // This is the stuff that is permanent for an AI object and is therefore saved to disk. 129 typedef struct ai_static { 130 ubyte behavior; // 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. 137 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. 140 141 short danger_laser_num; 142 int danger_laser_signature; 143 fix dying_start_time; // Time at which this robot started dying. 144 145 // byte extras[28]; // 32 extra bytes for storing stuff so we don't have to change versions on disk 146 } __pack__ ai_static; 147 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 160 161 // -- MK, 10/21/95, unused -- fix last_see_time, last_attack_time; // For sound effects, time at which player last seen, attacked 162 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 175 } ai_local; 176 177 typedef struct { 178 int segnum; 179 vms_vector point; 180 } point_seg; 181 182 typedef struct { 183 short start, end; 184 } seg_seg; 185 186 #define MAX_POINT_SEGS 2500 187 188 extern point_seg Point_segs[MAX_POINT_SEGS]; 189 extern point_seg *Point_segs_free_ptr; 190 extern int Overall_agitation; 191 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; 196 197 extern void ai_do_cloak_stuff(void); 198 199 #endif 200