2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Ship/AiGoals.h $
15 * <insert description of file here>
18 * Revision 1.2 2002/06/09 04:41:12 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 5 7/09/99 5:54p Dave
26 * Seperated cruiser types into individual types. Added tons of new
27 * briefing icons. Campaign screen.
29 * 4 3/26/99 4:49p Dave
30 * Made cruisers able to dock with stuff. Made docking points and paths
33 * 3 11/05/98 5:55p Dave
34 * Big pass at reducing #includes
36 * 2 10/07/98 10:53a Dave
39 * 1 10/07/98 10:51a Dave
41 * 46 2/26/98 10:08p Hoffoss
42 * Rewrote state saving and restoring to fix bugs and simplify the code.
44 * 45 2/22/98 4:17p John
45 * More string externalization classification... 190 left to go!
47 * 44 2/16/98 10:13p Allender
48 * initial work on being able to target weapons (bombs specifically).
49 * Work on getting rearm/repair working under multiplayer
51 * 43 2/13/98 3:21p Lawrance
52 * Set up allowed goals for escape pods.
54 * 42 1/30/98 10:01a Allender
55 * made large ships able to attack other ships. Made goal code recognize
56 * when ships removed from wings during ship select
58 * 41 12/15/97 5:25p Allender
59 * fix problem with docked ships receiving another dock goal. They now
62 * 40 11/17/97 6:39p Lawrance
63 * add AI_goal_text[] array, used by HUD code to show text description of
66 * 39 10/29/97 10:02p Allender
67 * be sure that player starting wings that arrive late also form on the
68 * players wing if there are no goals
70 * 38 10/23/97 4:41p Allender
71 * lots of new rearm/repair code. Rearm requests now queue as goals for
72 * support ship. Warp in of new support ships functional. Support for
73 * stay-still and play-dead.
75 * 37 10/22/97 1:44p Allender
76 * more work on stay-still and play-dead
78 * 36 10/22/97 11:07a Allender
79 * Hooked in form on my wing into Mikes AI code
81 * 35 10/22/97 10:33a Hoffoss
82 * Added AI_GOAL_PLAY_DEAD as a valid goal for all ships.
84 * 34 10/22/97 9:54a Allender
85 * added ai_goal_play_dead
87 * 33 10/10/97 5:03p Allender
88 * started work on ai-stay-still
90 * 32 9/23/97 4:35p Allender
91 * added two function to add "internal" goals to ships and wings. Used by
92 * AI when it needs to do something special
94 * 31 8/15/97 11:07a Hoffoss
95 * Added warning to help eliminate problems later on down the road.
97 * 30 8/15/97 9:59a Hoffoss
98 * Changed ai_query_goal_valid() again. I can't think of any time you
99 * wouldn't find it easier just to pass in a ship instead of a ship_info
100 * flag structure filtered of all flags that aren't ship type bits. Since
101 * I'll call this quite a few times, it will make my life easier.
103 * 29 8/14/97 10:00p Allender
104 * made ai goals bitfields so that we can have set of orders that certain
105 * ship types are allowed to receive. Added function for Hoffoss to check
106 * goal vs. ship type validity
108 * 28 8/12/97 1:55a Hoffoss
109 * Made extensive changes to object reference checking and handling for
110 * object deletion call.
112 * 27 8/08/97 1:30p Allender
113 * added commands (and ai goals) for support ships. stay near ship (which
114 * could be player or current target), and keep safe distance
116 * 26 8/06/97 9:41a Allender
117 * renamed from ai_goal function. made a function to remove a goal from a
118 * wing (used strictly for waypoints now). ai-chase-wing and
119 * ai-guard-wing now appear to user as ai-chase and ai-guard. Tidied up
120 * function which deals with sexpression goals
122 * 25 8/06/97 8:06a Lawrance
123 * add more stuff to save/restore
125 * 24 7/24/97 4:55p Allender
126 * added ai-evade-ship to fred and to Freespace
128 * 23 7/17/97 4:23p Allender
129 * ai-guard-wing now in both Fred and Freespace
131 * 22 7/15/97 11:57a Hoffoss
132 * Added a general ai goal reference update mode.
134 * 21 6/18/97 11:46a Hoffoss
135 * Fixed initial order object reference updating and added briefing dialog
136 * window tracking data.
147 // macros for goals which get set via sexpressions in the mission code
149 // IMPORTANT! If you add a new AI_GOAL_x define, be sure to update the functions
150 // ai_update_goal_references() and query_referenced_in_ai_goals() or else risk breaking
151 // Fred. If the goal you add doesn't have a target (such as chase_any), then you don't have
152 // to worry about doing this. Also add it to list in Fred\Management.cpp, and let Hoffoss know!
153 #define AI_GOAL_CHASE (1<<1)
154 #define AI_GOAL_DOCK (1<<2) // used for undocking as well
155 #define AI_GOAL_WAYPOINTS (1<<3)
156 #define AI_GOAL_WAYPOINTS_ONCE (1<<4)
157 #define AI_GOAL_WARP (1<<5)
158 #define AI_GOAL_DESTROY_SUBSYSTEM (1<<6)
159 #define AI_GOAL_FORM_ON_WING (1<<7)
160 #define AI_GOAL_UNDOCK (1<<8)
161 #define AI_GOAL_CHASE_WING (1<<9)
162 #define AI_GOAL_GUARD (1<<10)
163 #define AI_GOAL_DISABLE_SHIP (1<<11)
164 #define AI_GOAL_DISARM_SHIP (1<<12)
165 #define AI_GOAL_CHASE_ANY (1<<13)
166 #define AI_GOAL_IGNORE (1<<14)
167 #define AI_GOAL_GUARD_WING (1<<15)
168 #define AI_GOAL_EVADE_SHIP (1<<16)
170 // the next goals are for support ships only
171 #define AI_GOAL_STAY_NEAR_SHIP (1<<17)
172 #define AI_GOAL_KEEP_SAFE_DISTANCE (1<<18)
173 #define AI_GOAL_REARM_REPAIR (1<<19)
175 #define AI_GOAL_STAY_STILL (1<<20)
176 #define AI_GOAL_PLAY_DEAD (1<<21)
177 #define AI_GOAL_CHASE_WEAPON (1<<22)
179 // now the masks for ship types
181 #define AI_GOAL_ACCEPT_FIGHTER ( AI_GOAL_CHASE | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_DESTROY_SUBSYSTEM | AI_GOAL_CHASE_WING | AI_GOAL_GUARD | AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP | AI_GOAL_CHASE_ANY | AI_GOAL_IGNORE | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD)
182 #define AI_GOAL_ACCEPT_BOMBER ( AI_GOAL_ACCEPT_FIGHTER )
183 #define AI_GOAL_ACCEPT_STEALTH ( AI_GOAL_ACCEPT_FIGHTER )
184 #define AI_GOAL_ACCEPT_TRANSPORT ( AI_GOAL_CHASE | AI_GOAL_CHASE_WING | AI_GOAL_DOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_WARP | AI_GOAL_UNDOCK | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD)
185 #define AI_GOAL_ACCEPT_FREIGHTER ( AI_GOAL_ACCEPT_TRANSPORT )
186 #define AI_GOAL_ACCEPT_CRUISER ( AI_GOAL_ACCEPT_FREIGHTER )
187 #define AI_GOAL_ACCEPT_CORVETTE ( AI_GOAL_ACCEPT_CRUISER )
188 #define AI_GOAL_ACCEPT_GAS_MINER ( AI_GOAL_ACCEPT_CRUISER )
189 #define AI_GOAL_ACCEPT_AWACS ( AI_GOAL_ACCEPT_CRUISER )
190 #define AI_GOAL_ACCEPT_CAPITAL ( AI_GOAL_ACCEPT_CRUISER & ~(AI_GOAL_DOCK | AI_GOAL_UNDOCK) )
191 #define AI_GOAL_ACCEPT_SUPERCAP ( AI_GOAL_ACCEPT_CAPITAL )
192 #define AI_GOAL_ACCEPT_SUPPORT ( AI_GOAL_DOCK | AI_GOAL_UNDOCK | AI_GOAL_WAYPOINTS | AI_GOAL_WAYPOINTS_ONCE | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD)
193 #define AI_GOAL_ACCEPT_ESCAPEPOD ( AI_GOAL_ACCEPT_TRANSPORT )
195 #define MAX_AI_DOCK_NAMES 25
197 extern int Num_ai_dock_names;
198 extern char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
200 extern char *Ai_goal_text(int goal);
202 // extern function definitions
203 extern void ai_post_process_mission();
204 extern void ai_maybe_add_form_goal( wing *wingp );
205 extern void ai_process_mission_orders( int objnum, ai_info *aip );
207 // adds goals to ships/wing through sexpressions
208 extern void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip );
209 extern void ai_add_wing_goal_sexp( int sexp, int type, int wingnum );
210 extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp );
212 // adds goals to ships/sings through player orders
213 extern void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip );
214 extern void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum );
216 extern void ai_remove_ship_goal( ai_info *aip, int index );
217 extern void ai_clear_ship_goals( ai_info *aip );
218 extern void ai_clear_wing_goals( int wingnum );
220 extern void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip );
222 extern void ai_mission_goal_complete( ai_info *aip );
223 extern void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp );
225 extern int ai_get_subsystem_type( char *subsystem );
226 extern char *ai_get_subsystem_type_name(int type);
227 extern void ai_update_goal_references(ai_goal *goals, int type, char *old_name, char *new_name);
228 extern int query_referenced_in_ai_goals(ai_goal *goals, int type, char *name);
229 extern char *ai_add_dock_name(char *str);
231 extern int ai_query_goal_valid( int ship, int ai_goal );
233 extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate = 1 );
234 extern void ai_add_goal_wing_internal( wing *wingp, int goal_type, char *name, int immediate = 1 );