1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _AIGOALS_H
13 #define _AIGOALS_H
14 
15 #include "globalincs/globals.h"
16 #include "globalincs/pstypes.h"
17 
18 struct wing;
19 struct ai_info;
20 struct ai_goal;
21 
22 // macros for goals which get set via sexpressions in the mission code
23 
24 // IMPORTANT!  If you add a new AI_GOAL_x define, be sure to update the functions
25 // ai_update_goal_references() and query_referenced_in_ai_goals() or else risk breaking
26 // Fred.  If the goal you add doesn't have a target (such as chase_any), then you don't have
27 // to worry about doing this.  Also add it to list in Fred\Management.cpp, and let Hoffoss know!
28 // WMC - Oh and add them to Ai_goal_names plz. TY! :)
29 // Goober5000 - As well as Ai_goal_text and Ai_goal_list, if appropriate
30 #define AI_GOAL_CHASE					(1<<1)	// 0x00000002
31 #define AI_GOAL_DOCK					(1<<2)	// 0x00000004	// used for undocking as well
32 #define AI_GOAL_WAYPOINTS				(1<<3)	// 0x00000008
33 #define AI_GOAL_WAYPOINTS_ONCE			(1<<4)	// 0x00000010
34 #define AI_GOAL_WARP					(1<<5)	// 0x00000020
35 #define AI_GOAL_DESTROY_SUBSYSTEM		(1<<6)	// 0x00000040
36 #define AI_GOAL_FORM_ON_WING			(1<<7)	// 0x00000080
37 #define AI_GOAL_UNDOCK					(1<<8)	// 0x00000100
38 #define AI_GOAL_CHASE_WING				(1<<9)	// 0x00000200
39 #define AI_GOAL_GUARD					(1<<10)	// 0x00000400
40 #define AI_GOAL_DISABLE_SHIP			(1<<11)	// 0x00000800
41 #define AI_GOAL_DISARM_SHIP				(1<<12)	// 0x00001000
42 #define AI_GOAL_CHASE_ANY				(1<<13)	// 0x00002000
43 #define AI_GOAL_IGNORE					(1<<14)	// 0x00004000
44 #define AI_GOAL_GUARD_WING				(1<<15)	// 0x00008000
45 #define AI_GOAL_EVADE_SHIP				(1<<16)	// 0x00010000
46 
47 // the next goals are for support ships only
48 #define AI_GOAL_STAY_NEAR_SHIP			(1<<17)	// 0x00020000
49 #define AI_GOAL_KEEP_SAFE_DISTANCE		(1<<18)	// 0x00040000
50 #define AI_GOAL_REARM_REPAIR			(1<<19)	// 0x00080000
51 
52 // resume regular goals
53 #define AI_GOAL_STAY_STILL				(1<<20)	// 0x00100000
54 #define AI_GOAL_PLAY_DEAD				(1<<21)	// 0x00200000
55 
56 // added by SCP
57 #define AI_GOAL_CHASE_WEAPON			(1<<22)	// 0x00400000
58 #define AI_GOAL_FLY_TO_SHIP				(1<<23) // 0x00800000
59 #define AI_GOAL_IGNORE_NEW				(1<<24)	// 0x01000000
60 #define AI_GOAL_CHASE_SHIP_CLASS		(1<<25)	// 0x02000000
61 #define AI_GOAL_PLAY_DEAD_PERSISTENT	(1<<26)	// 0x03000000
62 
63 // now the masks for ship types
64 
65 // Goober5000: added AI_GOAL_STAY_NEAR_SHIP and AI_GOAL_KEEP_SAFE_DISTANCE as valid for fighters
66 //WMC - Don't need these anymore. Whee!
67 /*
68 #define AI_GOAL_ACCEPT_FIGHTER		( AI_GOAL_FLY_TO_SHIP | 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_IGNORE_NEW | AI_GOAL_GUARD_WING | AI_GOAL_EVADE_SHIP | AI_GOAL_STAY_STILL | AI_GOAL_PLAY_DEAD | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP | AI_GOAL_KEEP_SAFE_DISTANCE )
69 #define AI_GOAL_ACCEPT_BOMBER			( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
70 #define AI_GOAL_ACCEPT_STEALTH		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FIGHTER | AI_GOAL_STAY_NEAR_SHIP )
71 #define AI_GOAL_ACCEPT_TRANSPORT		( AI_GOAL_FLY_TO_SHIP | 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 | AI_GOAL_PLAY_DEAD_PERSISTENT | AI_GOAL_STAY_NEAR_SHIP )
72 #define AI_GOAL_ACCEPT_FREIGHTER		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT | AI_GOAL_STAY_NEAR_SHIP )
73 #define AI_GOAL_ACCEPT_CRUISER		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_FREIGHTER | AI_GOAL_STAY_NEAR_SHIP )
74 #define AI_GOAL_ACCEPT_CORVETTE		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
75 #define AI_GOAL_ACCEPT_GAS_MINER		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
76 #define AI_GOAL_ACCEPT_AWACS			( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER | AI_GOAL_STAY_NEAR_SHIP )
77 #define AI_GOAL_ACCEPT_CAPITAL		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CRUISER & ~(AI_GOAL_DOCK | AI_GOAL_UNDOCK) | AI_GOAL_STAY_NEAR_SHIP )
78 #define AI_GOAL_ACCEPT_SUPERCAP		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_CAPITAL | AI_GOAL_STAY_NEAR_SHIP )
79 #define AI_GOAL_ACCEPT_SUPPORT		( AI_GOAL_FLY_TO_SHIP | 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 | AI_GOAL_PLAY_DEAD_PERSISTENT )
80 #define AI_GOAL_ACCEPT_ESCAPEPOD		( AI_GOAL_FLY_TO_SHIP | AI_GOAL_ACCEPT_TRANSPORT| AI_GOAL_STAY_NEAR_SHIP  )
81 */
82 
83 #define MAX_AI_DOCK_NAMES				25
84 
85 typedef flag_def_list ai_goal_list;
86 
87 extern ai_goal_list Ai_goal_names[];
88 extern int Num_ai_goals;
89 
90 extern int Num_ai_dock_names;
91 extern char Ai_dock_names[MAX_AI_DOCK_NAMES][NAME_LENGTH];
92 
93 extern const char *Ai_goal_text(int goal);
94 
95 // extern function definitions
96 extern void ai_post_process_mission();
97 extern void ai_maybe_add_form_goal( wing *wingp );
98 extern void ai_process_mission_orders( int objnum, ai_info *aip );
99 
100 extern int ai_goal_num(ai_goal *goals);
101 
102 // adds goals to ships/wing through sexpressions
103 extern void ai_add_ship_goal_scripting(int mode, int submode, int priority, char *shipname, ai_info *aip);
104 extern void ai_add_ship_goal_sexp( int sexp, int type, ai_info *aip );
105 extern void ai_add_wing_goal_sexp( int sexp, int type, wing *wingp );
106 extern void ai_add_goal_sub_sexp( int sexp, int type, ai_goal *aigp, char *actor_name );
107 
108 extern int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp );
109 extern void ai_remove_wing_goal_sexp( int sexp, wing *wingp );
110 
111 // adds goals to ships/sings through player orders
112 extern void ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip );
113 extern void ai_add_wing_goal_player( int type, int mode, int submode, char *shipname, int wingnum );
114 
115 extern void ai_remove_ship_goal( ai_info *aip, int index );
116 extern void ai_clear_ship_goals( ai_info *aip );
117 extern void ai_clear_wing_goals( wing *wingp );
118 
119 extern void ai_copy_mission_wing_goal( ai_goal *aigp, ai_info *aip );
120 
121 extern void ai_mission_goal_complete( ai_info *aip );
122 extern void ai_mission_wing_goal_complete( int wingnum, ai_goal *remove_goalp );
123 
124 extern void ai_update_goal_references(ai_goal *goals, int type, const char *old_name, const char *new_name);
125 extern int query_referenced_in_ai_goals(ai_goal *goals, int type, const char *name);
126 extern char *ai_add_dock_name(const char *str);
127 
128 extern int ai_query_goal_valid( int ship, int ai_goal_type );
129 
130 extern void ai_add_goal_ship_internal( ai_info *aip, int goal_type, char *name, int docker_point, int dockee_point, int immediate = 1 );
131 
132 #endif
133