]> icculus.org git repositories - btb/d2x.git/blob - main/aistruct.h
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / main / aistruct.h
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  *
16  * Structs and constants for AI system.
17  * object.h depends on this.
18  * ai.h depends on object.h.
19  * Get it?
20  *
21  */
22
23 #ifndef _AISTRUCT_H
24 #define _AISTRUCT_H
25
26 #include "inferno.h"
27 //#include "polyobj.h"
28
29 #define GREEN_GUY   1
30
31 #define MAX_SEGMENTS_PER_PATH       20
32
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
38
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
41
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)
47
48 // Behaviors
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
56
57 #define MIN_BEHAVIOR    0x80
58 #define MAX_BEHAVIOR    0x86
59
60 //  Modes
61 #define AIM_STILL                   0
62 #define AIM_WANDER                  1
63 #define AIM_FOLLOW_PATH             2
64 #define AIM_CHASE_OBJECT            3
65 #define AIM_RUN_FROM_OBJECT         4
66 #define AIM_BEHIND                  5
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
71
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
77
78 #define AIM_THIEF_ATTACK            15
79 #define AIM_THIEF_RETREAT           16
80 #define AIM_THIEF_WAIT              17
81
82 #define AISM_GOHIDE                 0
83 #define AISM_HIDING                 1
84
85 #define AI_MAX_STATE    7
86 #define AI_MAX_EVENT    4
87
88 #define AIS_NONE        0
89 #define AIS_REST        1
90 #define AIS_SRCH        2
91 #define AIS_LOCK        3
92 #define AIS_FLIN        4
93 #define AIS_FIRE        5
94 #define AIS_RECO        6
95 #define AIS_ERR_        7
96
97 #define AIE_FIRE        0
98 #define AIE_HITT        1
99 #define AIE_COLL        2
100 #define AIE_HURT        3
101
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
106 //      sbyte   nothing;
107 //      short   path[MAX_SEGMENTS_PER_PATH];
108 //      short   always_0xabc;   // If this is ever not 0xabc, then someone overwrote
109 //} opath;
110 //
111 //typedef struct oai_state {
112 //      short   mode;               //
113 //      short   counter;            // kind of a hack, frame countdown until switch modes
114 //      opath   paths[2];
115 //      vms_vector movement_vector; // movement vector for one second
116 //} oai_state;
117
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!
121
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
124
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
136
137 // This is the stuff that is permanent for an AI object and is
138 // therefore saved to disk.
139 typedef struct ai_static {
140         ubyte   behavior;               //
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.
147
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.
150
151         short   danger_laser_num;
152         int     danger_laser_signature;
153         fix     dying_start_time;       // Time at which this robot started dying.
154
155         //sbyte   extras[28];             // 32 extra bytes for storing stuff so we don't have to change versions on disk
156 } __pack__ ai_static;
157
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
170
171         // -- MK, 10/21/95, unused -- fix     last_see_time, last_attack_time; // For sound effects, time at which player last seen, attacked
172
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
185 } ai_local;
186
187 typedef struct {
188         int         segnum;
189         vms_vector  point;
190 } point_seg;
191
192 typedef struct {
193         short       start, end;
194 } seg_seg;
195
196 #define MAX_POINT_SEGS  2500
197
198 extern point_seg    Point_segs[MAX_POINT_SEGS];
199 extern point_seg    *Point_segs_free_ptr;
200 extern int          Overall_agitation;
201
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
205 // memory expensive.
206 //extern fix        Last_uncloaked_time;
207 //extern vms_vector Last_uncloaked_position;
208
209 extern void ai_do_cloak_stuff(void);
210
211 #endif /* _AISTRUCT_H */