home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / lib / aistruct.h < prev    next >
C/C++ Source or Header  |  1998-06-08  |  11KB  |  273 lines

  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-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/main/rcs/aistruct.h $
  15.  * $Revision: 2.0 $
  16.  * $Author: john $
  17.  * $Date: 1995/02/27 11:30:19 $
  18.  * 
  19.  * Structs and constants for AI system.
  20.  * object.h depends on this.
  21.  * ai.h depends on object.h.
  22.  * Get it?
  23.  * 
  24.  * $Log: aistruct.h $
  25.  * Revision 2.0  1995/02/27  11:30:19  john
  26.  * New version 2.0, which has no anonymous unions, builds with
  27.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  28.  * 
  29.  * Revision 1.34  1995/01/25  13:50:46  mike
  30.  * Robots make angry sounds.
  31.  * 
  32.  * Revision 1.33  1994/12/29  12:44:56  rob
  33.  * Added new coop robot flag.
  34.  * 
  35.  * Revision 1.32  1994/12/20  20:41:54  rob
  36.  * Added new ai flag for multiplayer robots.
  37.  * 
  38.  * Revision 1.31  1994/12/19  16:37:39  rob
  39.  * Added a new flag for remote controlled objects.
  40.  * 
  41.  * Revision 1.30  1994/12/07  00:36:07  mike
  42.  * fix phys_apply_rot for robots -- ai was bashing effect in next frame.
  43.  * 
  44.  * Revision 1.29  1994/12/02  22:06:28  mike
  45.  * add fields to allow robots to make awareness sounds every so often, not every damn blasted frame
  46.  * 
  47.  * Revision 1.28  1994/11/04  17:18:35  yuan
  48.  * Increased MAX_SEG_POINTS to 2500.
  49.  * 
  50.  * Revision 1.27  1994/10/17  21:19:22  mike
  51.  * robot cloaking.
  52.  * 
  53.  * Revision 1.26  1994/10/12  21:28:38  mike
  54.  * Add new ai mode: AIM_OPEN_DOOR.
  55.  * Add GOALSIDE to aip.
  56.  * 
  57.  * Revision 1.25  1994/09/25  23:41:08  matt
  58.  * Changed the object load & save code to read/write the structure fields one
  59.  * at a time (rather than the whole structure at once).  This mean that the
  60.  * object structure can be changed without breaking the load/save functions.
  61.  * As a result of this change, the local_object data can be and has been 
  62.  * incorporated into the object array.  Also, timeleft is now a property 
  63.  * of all objects, and the object structure has been otherwise cleaned up.
  64.  * 
  65.  * Revision 1.24  1994/09/21  12:28:11  mike
  66.  * Change AI behavior for when player cloaked
  67.  * 
  68.  * Revision 1.23  1994/09/19  21:43:00  mike
  69.  * Add follow_path_start_seg and follow_path_end_seg to aistruct.h.
  70.  * 
  71.  * Revision 1.22  1994/09/18  18:06:14  mike
  72.  * Add Last_uncloaked_time and Last_uncloaked_position variables.
  73.  * 
  74.  * Revision 1.21  1994/09/15  16:31:38  mike
  75.  * Define GREEN_GUY
  76.  * Add previous_visibility to ai_local struct.
  77.  * 
  78.  * Revision 1.20  1994/09/12  19:12:45  mike
  79.  * Change some bytes to ints in ai_local so I could set watchpoints.
  80.  * 
  81.  * Revision 1.19  1994/08/25  21:53:31  mike
  82.  * Add behavior, taking place of what used to be mode.
  83.  * 
  84.  * Revision 1.18  1994/08/23  16:38:09  mike
  85.  * rapidfire_count in ai_local.
  86.  * 
  87.  * Revision 1.17  1994/08/19  17:38:23  mike
  88.  * *** empty log message ***
  89.  * 
  90.  * Revision 1.16  1994/08/17  22:18:58  mike
  91.  * add time_since_processed to ai_local.
  92.  * 
  93.  * Revision 1.15  1994/08/10  19:52:25  mike
  94.  * Add Overall_agitation.
  95.  * 
  96.  * Revision 1.14  1994/08/04  16:32:32  mike
  97.  * Add time_player_seen.
  98.  * 
  99.  * Revision 1.13  1994/07/28  16:58:11  mike
  100.  * Move constants from ai.c
  101.  * 
  102.  * Revision 1.12  1994/07/19  15:26:24  mike
  103.  * New ai_static and ai_local structures.
  104.  * 
  105.  * Revision 1.11  1994/07/15  15:17:19  matt
  106.  * Changes MAX_AI_FLAGS for better alignment
  107.  * 
  108.  */
  109.  
  110.  
  111. #ifndef _AISTRUCT_H
  112. #define _AISTRUCT_H
  113.  
  114. #include "inferno.h"
  115. //#include "polyobj.h"
  116.  
  117. #define    GREEN_GUY    1
  118.  
  119. #define MAX_SEGMENTS_PER_PATH        20
  120.  
  121. #define    PA_WEAPON_WALL_COLLISION    2        // Level of robot awareness after player weapon hits nearby wall
  122. //#define    PA_PLAYER_VISIBLE                2        //    Level of robot awareness if robot is looking towards player, and player not hidden
  123. #define    PA_NEARBY_ROBOT_FIRED        1        // Level of robot awareness after nearby robot fires a weapon
  124. #define    PA_PLAYER_COLLISION            3        // Level of robot awareness after player bumps into robot
  125. #define    PA_WEAPON_ROBOT_COLLISION    4        // Level of robot awareness after player weapon hits nearby robot
  126.  
  127. // #define    PAE_WEAPON_HIT_WALL        1                    // weapon hit wall, create player awareness
  128. // #define    PAE_WEAPON_HIT_ROBOT        2                    // weapon hit wall, create player awareness
  129.  
  130. //    Constants indicating currently moving forward or backward through path.
  131. //    Note that you can add aip->direction to aip_path_index to get next segment on path.
  132. #define    AI_DIR_FORWARD        1
  133. #define    AI_DIR_BACKWARD    (-AI_DIR_FORWARD)
  134.  
  135. //    Behaviors
  136. #define    AIB_STILL                        0x80
  137. #define    AIB_NORMAL                        0x81
  138. #define    AIB_HIDE                            0x82
  139. #define    AIB_RUN_FROM                    0x83
  140. #define    AIB_FOLLOW_PATH                0x84
  141. #define    AIB_STATION                        0x85
  142.  
  143. #define    MIN_BEHAVIOR    0x80
  144. #define    MAX_BEHAVIOR    0x85
  145.  
  146. //    Modes
  147. #define    AIM_STILL                        0
  148. #define    AIM_WANDER                        1
  149. #define    AIM_FOLLOW_PATH                2
  150. #define    AIM_CHASE_OBJECT                3
  151. #define    AIM_RUN_FROM_OBJECT            4
  152. #define    AIM_HIDE                            5
  153. #define    AIM_FOLLOW_PATH_2                6
  154. #define    AIM_OPEN_DOOR                    7
  155.  
  156. #define    AISM_GOHIDE                        0
  157. #define    AISM_HIDING                        1
  158.  
  159. #define    AI_MAX_STATE    7
  160. #define    AI_MAX_EVENT    4
  161.  
  162. #define    AIS_NONE        0
  163. #define    AIS_REST        1
  164. #define    AIS_SRCH        2
  165. #define    AIS_LOCK        3
  166. #define    AIS_FLIN        4
  167. #define    AIS_FIRE        5
  168. #define    AIS_RECO        6
  169. #define    AIS_ERR_        7
  170.  
  171. #define    AIE_FIRE        0
  172. #define    AIE_HITT        1
  173. #define    AIE_COLL        2
  174. #define    AIE_HURT        3
  175.  
  176. //typedef struct opath {
  177. //    byte            path_index;                    // current index of path
  178. //    byte            path_direction;            // current path direction
  179. //    byte            path_length;                //    length of current path
  180. //    byte            nothing;
  181. //    short            path[MAX_SEGMENTS_PER_PATH];
  182. //    short            always_0xabc;                //    If this is ever not 0xabc, then someone overwrote
  183. //} opath;
  184. //
  185. //typedef struct oai_state {
  186. //    short            mode;                            // 
  187. //    short            counter;                        // kind of a hack, frame countdown until switch modes
  188. //    opath            paths[2];
  189. //    vms_vector    movement_vector;            // movement vector for one second
  190. //} oai_state;
  191.  
  192. //    Constants defining meaning of flags in ai_state
  193. #define    MAX_AI_FLAGS    11                    //    This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
  194.  
  195. #define    CURRENT_GUN        flags[0]            //    This is the last gun the object fired from
  196. #define    CURRENT_STATE    flags[1]            //    current behavioral state
  197. #define    GOAL_STATE        flags[2]            //    goal state
  198. #define    PATH_DIR            flags[3]            //    direction traveling path, 1 = forward, -1 = backward, other = error!
  199. #define    SUBMODE            flags[4]            //    submode, eg AISM_HIDING if mode == AIM_HIDE
  200. #define    GOALSIDE            flags[5]            //    for guys who open doors, this is the side they are going after.
  201. #define    CLOAKED            flags[6]            //    Cloaked now.
  202. #define    SKIP_AI_COUNT    flags[7]            //    Skip AI this frame, but decrement in do_ai_frame.
  203. #define  REMOTE_OWNER    flags[8]            // Who is controlling this remote AI object (multiplayer use only)
  204. #define  REMOTE_SLOT_NUM flags[9]            // What slot # is this robot in for remote control purposes (multiplayer use only)
  205. #define  MULTI_ANGER        flags[10]        // How angry is a robot in multiplayer mode
  206.  
  207. //    This is the stuff that is permanent for an AI object and is therefore saved to disk.
  208. typedef struct ai_static {
  209.     ubyte            behavior;                    // 
  210.     byte            flags[MAX_AI_FLAGS];        // various flags, meaning defined by constants
  211.     short            hide_segment;                //    Segment to go to for hiding.
  212.     short            hide_index;                    //    Index in Path_seg_points
  213.     short            path_length;                //    Length of hide path.
  214.     short            cur_path_index;            //    Current index in path.
  215.  
  216.     short            follow_path_start_seg;    //    Start segment for robot which follows path.
  217.     short            follow_path_end_seg;        //    End segment for robot which follows path.
  218.  
  219.     int            danger_laser_signature;
  220.     short            danger_laser_num;
  221.  
  222. //    byte            extras[28];                    //    32 extra bytes for storing stuff so we don't have to change versions on disk
  223. } ai_static;
  224.  
  225. //    This is the stuff which doesn't need to be saved to disk.
  226. typedef struct ai_local {
  227. //    These used to be bytes, changed to ints so I could set watchpoints on them.
  228.     byte            player_awareness_type;    //    type of awareness of player
  229.     byte            retry_count;                //    number of retries in physics last time this object got moved.
  230.     byte            consecutive_retries;        //    number of retries in consecutive frames (ie, without a retry_count of 0)
  231.     byte            mode;                            //    current mode within behavior
  232.     byte            previous_visibility;        //    Visibility of player last time we checked.
  233.     byte            rapidfire_count;            //    number of shots fired rapidly
  234.     short            goal_segment;                //    goal segment for current path
  235.     fix            last_see_time, last_attack_time;    //    For sound effects, time at which player last seen, attacked
  236.  
  237.     fix            wait_time;                    // time in seconds until something happens, mode dependent
  238.     fix            next_fire;                    // time in seconds until can fire again
  239.     fix            player_awareness_time;    //    time in seconds robot will be aware of player, 0 means not aware of player
  240.     fix            time_player_seen;            //    absolute time in seconds at which player was last seen, might cause to go into follow_path mode
  241.     fix            time_player_sound_attacked;            //    absolute time in seconds at which player was last seen with visibility of 2.
  242.     fix            next_misc_sound_time;            //    absolute time in seconds at which this robot last made an angry or lurking sound.
  243.     fix            time_since_processed;    //    time since this robot last processed in do_ai_frame
  244.     vms_angvec    goal_angles[MAX_SUBMODELS];    //angles for each subobject
  245.     vms_angvec    delta_angles[MAX_SUBMODELS];    //angles for each subobject
  246.     byte            goal_state[MAX_SUBMODELS];    // Goal state for this sub-object
  247.     byte            achieved_state[MAX_SUBMODELS];    // Last achieved state
  248. } ai_local;
  249.  
  250. typedef struct {
  251.     int            segnum;
  252.     vms_vector    point;
  253. } point_seg;
  254.  
  255. typedef struct {
  256.     short        start, end;
  257. } seg_seg;
  258.  
  259. #define    MAX_POINT_SEGS    2500
  260.  
  261. extern    point_seg    Point_segs[MAX_POINT_SEGS];
  262. extern    point_seg    *Point_segs_free_ptr;
  263. extern    int            Overall_agitation;
  264.  
  265. //    These are the information for a robot describing the location of the player last time he wasn't cloaked,
  266. //    and the time at which he was uncloaked.  We should store this for each robot, but that's memory expensive.
  267. //extern    fix            Last_uncloaked_time;
  268. //extern    vms_vector    Last_uncloaked_position;
  269.  
  270. extern    void    ai_do_cloak_stuff(void);
  271.  
  272. #endif
  273.