| 1 //----------------------------------------------------------------------------- |
1 // Macros and enums from zandronum bots.h |
| 2 // |
|
| 3 // Skulltag Source |
|
| 4 // Copyright (C) 2002 Brad Carney |
|
| 5 // Copyright (C) 2007-2012 Skulltag Development Team |
|
| 6 // All rights reserved. |
|
| 7 // |
|
| 8 // Redistribution and use in source and binary forms, with or without |
|
| 9 // modification, are permitted provided that the following conditions are met: |
|
| 10 // |
|
| 11 // 1. Redistributions of source code must retain the above copyright notice, |
|
| 12 // this list of conditions and the following disclaimer. |
|
| 13 // 2. Redistributions in binary form must reproduce the above copyright notice, |
|
| 14 // this list of conditions and the following disclaimer in the documentation |
|
| 15 // and/or other materials provided with the distribution. |
|
| 16 // 3. Neither the name of the Skulltag Development Team nor the names of its |
|
| 17 // contributors may be used to endorse or promote products derived from this |
|
| 18 // software without specific prior written permission. |
|
| 19 // 4. Redistributions in any form must be accompanied by information on how to |
|
| 20 // obtain complete source code for the software and any accompanying |
|
| 21 // software that uses the software. The source code must either be included |
|
| 22 // in the distribution or be available for no more than the cost of |
|
| 23 // distribution plus a nominal fee, and must be freely redistributable |
|
| 24 // under reasonable conditions. For an executable file, complete source |
|
| 25 // code means the source code for all modules it contains. It does not |
|
| 26 // include source code for modules or files that typically accompany the |
|
| 27 // major components of the operating system on which the executable file |
|
| 28 // runs. |
|
| 29 // |
|
| 30 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
| 31 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
| 32 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
| 33 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
| 34 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
| 35 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
| 36 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
| 37 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
| 38 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
| 39 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 40 // POSSIBILITY OF SUCH DAMAGE. |
|
| 41 // |
|
| 42 // |
|
| 43 // |
|
| 44 // Filename: bots.h |
|
| 45 // |
|
| 46 // Description: Contains bot structures and prototypes |
|
| 47 // [Dusk] Cropped out the stuff botc doesn't need. |
|
| 48 // |
|
| 49 //----------------------------------------------------------------------------- |
|
| 50 |
2 |
| 51 #ifndef BOTC_BOTS_H |
3 #ifndef BOTC_BOTS_H |
| 52 #define BOTC_BOTS_H |
4 #define BOTC_BOTS_H |
| 53 |
5 |
| 54 //***************************************************************************** |
6 static const int g_max_states = 256; |
| 55 // DEFINES |
7 static const int g_max_events = 32; |
| |
8 static const int g_max_global_events = 32; |
| |
9 static const int g_max_global_vars = 128; |
| |
10 static const int g_max_global_arrays = 16; |
| |
11 static const int g_max_array_size = 65536; |
| |
12 static const int g_max_state_vars = 16; |
| |
13 static const int g_max_stringlist_size = 128; |
| |
14 static const int g_max_string_length = 256; |
| |
15 static const int g_max_reaction_time = 52; |
| |
16 static const int g_max_stored_events = 64; |
| 56 |
17 |
| 57 // Maximum number of variables on the bot evaluation stack. |
18 enum e_data_header |
| 58 #define BOTSCRIPT_STACK_SIZE 8 |
|
| 59 |
|
| 60 // Maximum number of botinto structures that can be defines. |
|
| 61 #define MAX_BOTINFO 128 |
|
| 62 |
|
| 63 // Maximum number of states that can appear in a script. |
|
| 64 #define MAX_NUM_STATES 256 |
|
| 65 |
|
| 66 // Maximum number of bot events that can be defined. |
|
| 67 #define MAX_NUM_EVENTS 32 |
|
| 68 |
|
| 69 // Maximum number of global bot events that can be defined. |
|
| 70 #define MAX_NUM_GLOBAL_EVENTS 32 |
|
| 71 |
|
| 72 // Maximum number of global variables that can be defined in a script. |
|
| 73 #define MAX_SCRIPT_VARIABLES 128 |
|
| 74 |
|
| 75 // Maximum number of global arrays that can be defined in a script. |
|
| 76 #define MAX_SCRIPT_ARRAYS 16 |
|
| 77 |
|
| 78 // Maximum number of global arrays that can be defined in a script. |
|
| 79 #define MAX_SCRIPTARRAY_SIZE 65536 |
|
| 80 |
|
| 81 // Maxmimum number of state (local) variables that can appear in a script. |
|
| 82 #define MAX_STATE_VARIABLES 16 |
|
| 83 |
|
| 84 // Maximum number of strings that can appear in a script stringlist. |
|
| 85 #define MAX_LIST_STRINGS 128 |
|
| 86 |
|
| 87 // Maximum length of those strings in the stringlist. |
|
| 88 #define MAX_STRING_LENGTH 256 |
|
| 89 |
|
| 90 // Maximum reaction time for a bot. |
|
| 91 #define MAX_REACTION_TIME 52 |
|
| 92 |
|
| 93 // Maximum number of events the bots can store up that it's waiting to react to. |
|
| 94 #define MAX_STORED_EVENTS 64 |
|
| 95 |
|
| 96 //***************************************************************************** |
|
| 97 typedef enum |
|
| 98 { |
19 { |
| 99 // Bot skill ratings. |
20 dh_command, |
| 100 BOTSKILL_VERYPOOR, |
21 dh_state_index, |
| 101 BOTSKILL_POOR, |
22 dh_state_name, |
| 102 BOTSKILL_LOW, |
23 dh_on_enter, |
| 103 BOTSKILL_MEDIUM, |
24 dh_main_loop, |
| 104 BOTSKILL_HIGH, |
25 dh_on_exit, |
| 105 BOTSKILL_EXCELLENT, |
26 dh_event, |
| 106 BOTSKILL_SUPREME, |
27 dh_end_on_enter, |
| 107 BOTSKILL_GODLIKE, |
28 dh_end_main_loop, |
| 108 BOTSKILL_PERFECT, |
29 dh_end_on_exit, |
| 109 |
30 dh_end_event, |
| 110 NUM_BOT_SKILLS |
31 dh_if_goto, |
| 111 |
32 dh_if_not_goto, |
| 112 } BOTSKILL_e; |
33 dh_goto, |
| 113 |
34 dh_or_logical, |
| 114 //***************************************************************************** |
35 dh_and_logical, |
| 115 // STRUCTURES |
36 dh_or_bitwise, |
| 116 // |
37 dh_eor_bitwise, |
| 117 |
38 dh_and_bitwise, |
| 118 //***************************************************************************** |
39 dh_equals, |
| 119 // These are the botscript data headers that it writes out. |
40 dh_not_equals, |
| 120 typedef enum |
41 dh_less_than, |
| 121 { |
42 dh_at_most, |
| 122 DH_COMMAND, |
43 dh_greater_than, |
| 123 DH_STATEIDX, |
44 dh_at_least, |
| 124 DH_STATENAME, |
45 dh_negate_logical, |
| 125 DH_ONENTER, |
46 dh_left_shift, |
| 126 DH_MAINLOOP, |
47 dh_right_shift, |
| 127 DH_ONEXIT, |
48 dh_add, |
| 128 DH_EVENT, |
49 dh_subtract, |
| 129 DH_ENDONENTER, |
50 dh_unary_minus, |
| 130 DH_ENDMAINLOOP, |
51 dh_multiply, |
| 131 DH_ENDONEXIT, |
52 dh_divide, |
| 132 DH_ENDEVENT, |
53 dh_modulus, |
| 133 DH_IFGOTO, |
54 dh_push_number, |
| 134 DH_IFNOTGOTO, |
55 dh_push_string_index, |
| 135 DH_GOTO, |
56 dh_push_global_var, |
| 136 DH_ORLOGICAL, |
57 dh_push_local_var, |
| 137 DH_ANDLOGICAL, |
58 dh_drop_stack_position, |
| 138 DH_ORBITWISE, |
59 dh_script_var_list, |
| 139 DH_EORBITWISE, |
60 dh_string_list, |
| 140 DH_ANDBITWISE, |
61 dh_increase_global_var, |
| 141 DH_EQUALS, |
62 dh_decrease_global_var, |
| 142 DH_NOTEQUALS, |
63 dh_assign_global_var, |
| 143 DH_LESSTHAN, |
64 dh_add_global_var, |
| 144 DH_LESSTHANEQUALS, |
65 dh_subtract_global_var, |
| 145 DH_GREATERTHAN, |
66 dh_multiply_global_var, |
| 146 DH_GREATERTHANEQUALS, |
67 dh_divide_global_var, |
| 147 DH_NEGATELOGICAL, |
68 dh_mod_global_var, |
| 148 DH_LSHIFT, |
69 dh_increase_local_var, |
| 149 DH_RSHIFT, |
70 dh_decrease_local_var, |
| 150 DH_ADD, |
71 dh_assign_local_var, |
| 151 DH_SUBTRACT, |
72 dh_add_local_var, |
| 152 DH_UNARYMINUS, |
73 dh_subtract_local_var, |
| 153 DH_MULTIPLY, |
74 dh_multiply_local_var, |
| 154 DH_DIVIDE, |
75 dh_divide_local_var, |
| 155 DH_MODULUS, |
76 dh_mod_local_var, |
| 156 DH_PUSHNUMBER, |
77 dh_CASEGOTO, |
| 157 DH_PUSHSTRINGINDEX, |
78 dh_DROP, |
| 158 DH_PUSHGLOBALVAR, |
79 dh_increase_global_array, |
| 159 DH_PUSHLOCALVAR, |
80 dh_decrease_global_array, |
| 160 DH_DROPSTACKPOSITION, |
81 dh_assign_global_array, |
| 161 DH_SCRIPTVARLIST, |
82 dh_add_global_array, |
| 162 DH_STRINGLIST, |
83 dh_subtract_global_array, |
| 163 DH_INCGLOBALVAR, |
84 dh_multiply_global_array, |
| 164 DH_DECGLOBALVAR, |
85 dh_divide_global_array, |
| 165 DH_ASSIGNGLOBALVAR, |
86 dh_mod_global_array, |
| 166 DH_ADDGLOBALVAR, |
87 dh_push_global_array, |
| 167 DH_SUBGLOBALVAR, |
88 dh_swap, |
| 168 DH_MULGLOBALVAR, |
89 dh_dup, |
| 169 DH_DIVGLOBALVAR, |
90 dh_array_set, |
| 170 DH_MODGLOBALVAR, |
91 num_data_headers |
| 171 DH_INCLOCALVAR, |
92 }; |
| 172 DH_DECLOCALVAR, |
|
| 173 DH_ASSIGNLOCALVAR, |
|
| 174 DH_ADDLOCALVAR, |
|
| 175 DH_SUBLOCALVAR, |
|
| 176 DH_MULLOCALVAR, |
|
| 177 DH_DIVLOCALVAR, |
|
| 178 DH_MODLOCALVAR, |
|
| 179 DH_CASEGOTO, |
|
| 180 DH_DROP, |
|
| 181 DH_INCGLOBALARRAY, |
|
| 182 DH_DECGLOBALARRAY, |
|
| 183 DH_ASSIGNGLOBALARRAY, |
|
| 184 DH_ADDGLOBALARRAY, |
|
| 185 DH_SUBGLOBALARRAY, |
|
| 186 DH_MULGLOBALARRAY, |
|
| 187 DH_DIVGLOBALARRAY, |
|
| 188 DH_MODGLOBALARRAY, |
|
| 189 DH_PUSHGLOBALARRAY, |
|
| 190 DH_SWAP, |
|
| 191 DH_DUP, |
|
| 192 DH_ARRAYSET, |
|
| 193 |
|
| 194 NUM_DATAHEADERS |
|
| 195 |
|
| 196 } DATAHEADERS_e; |
|
| 197 |
93 |
| 198 //***************************************************************************** |
94 //***************************************************************************** |
| 199 // These are the different bot events that can be posted to a bot's state. |
95 // These are the different bot events that can be posted to a bot's state. |
| 200 typedef enum |
96 enum e_event |
| 201 { |
97 { |
| 202 BOTEVENT_KILLED_BYENEMY, |
98 ev_killed_by_enemy, |
| 203 BOTEVENT_KILLED_BYPLAYER, |
99 ev_killed_by_player, |
| 204 BOTEVENT_KILLED_BYSELF, |
100 ev_killed_by_self, |
| 205 BOTEVENT_KILLED_BYENVIORNMENT, |
101 ev_killed_by_environment, |
| 206 BOTEVENT_REACHED_GOAL, |
102 ev_reached_goal, |
| 207 BOTEVENT_GOAL_REMOVED, |
103 ev_goal_removed, |
| 208 BOTEVENT_DAMAGEDBY_PLAYER, |
104 ev_damaged_by_player, |
| 209 BOTEVENT_PLAYER_SAY, |
105 ev_player_say, |
| 210 BOTEVENT_ENEMY_KILLED, |
106 ev_enemy_killed, |
| 211 BOTEVENT_RESPAWNED, |
107 ev_respawned, |
| 212 BOTEVENT_INTERMISSION, |
108 ev_intermission, |
| 213 BOTEVENT_NEWMAP, |
109 ev_new_maps, |
| 214 BOTEVENT_ENEMY_USEDFIST, |
110 ev_enemy_used_fist, |
| 215 BOTEVENT_ENEMY_USEDCHAINSAW, |
111 ev_enemy_used_chainsaw, |
| 216 BOTEVENT_ENEMY_FIREDPISTOL, |
112 ev_enemy_fired_pistol, |
| 217 BOTEVENT_ENEMY_FIREDSHOTGUN, |
113 ev_enemy_fired_shotgun, |
| 218 BOTEVENT_ENEMY_FIREDSSG, |
114 ev_enemy_fired_ssg, |
| 219 BOTEVENT_ENEMY_FIREDCHAINGUN, |
115 ev_enemy_fired_chaingun, |
| 220 BOTEVENT_ENEMY_FIREDMINIGUN, |
116 ev_enemy_fired_minigun, |
| 221 BOTEVENT_ENEMY_FIREDROCKET, |
117 ev_enemy_fired_rocket, |
| 222 BOTEVENT_ENEMY_FIREDGRENADE, |
118 ev_enemy_fired_grenade, |
| 223 BOTEVENT_ENEMY_FIREDRAILGUN, |
119 ev_enemy_fired_railgun, |
| 224 BOTEVENT_ENEMY_FIREDPLASMA, |
120 ev_enemy_fired_plasma, |
| 225 BOTEVENT_ENEMY_FIREDBFG, |
121 ev_enemy_fired_bfg, |
| 226 BOTEVENT_ENEMY_FIREDBFG10K, |
122 ev_enemy_fired_bfg10k, |
| 227 BOTEVENT_PLAYER_USEDFIST, |
123 ev_player_used_fist, |
| 228 BOTEVENT_PLAYER_USEDCHAINSAW, |
124 ev_player_used_chainsaw, |
| 229 BOTEVENT_PLAYER_FIREDPISTOL, |
125 ev_player_fired_pistol, |
| 230 BOTEVENT_PLAYER_FIREDSHOTGUN, |
126 ev_player_fired_shotgun, |
| 231 BOTEVENT_PLAYER_FIREDSSG, |
127 ev_player_fired_ssg, |
| 232 BOTEVENT_PLAYER_FIREDCHAINGUN, |
128 ev_player_fired_chaingun, |
| 233 BOTEVENT_PLAYER_FIREDMINIGUN, |
129 ev_player_fired_minigun, |
| 234 BOTEVENT_PLAYER_FIREDROCKET, |
130 ev_player_fired_rocket, |
| 235 BOTEVENT_PLAYER_FIREDGRENADE, |
131 ev_player_fired_grenade, |
| 236 BOTEVENT_PLAYER_FIREDRAILGUN, |
132 ev_player_fired_railgun, |
| 237 BOTEVENT_PLAYER_FIREDPLASMA, |
133 ev_player_fired_plasma, |
| 238 BOTEVENT_PLAYER_FIREDBFG, |
134 ev_player_fired_bfg, |
| 239 BOTEVENT_PLAYER_FIREDBFG10K, |
135 ev_player_fired_bfg10k, |
| 240 BOTEVENT_USEDFIST, |
136 ev_used_fist, |
| 241 BOTEVENT_USEDCHAINSAW, |
137 ev_used_chainsaw, |
| 242 BOTEVENT_FIREDPISTOL, |
138 ev_fired_pistol, |
| 243 BOTEVENT_FIREDSHOTGUN, |
139 ev_fired_shotgun, |
| 244 BOTEVENT_FIREDSSG, |
140 ev_fired_ssg, |
| 245 BOTEVENT_FIREDCHAINGUN, |
141 ev_fired_chaingun, |
| 246 BOTEVENT_FIREDMINIGUN, |
142 ev_fired_minigun, |
| 247 BOTEVENT_FIREDROCKET, |
143 ev_fired_rocket, |
| 248 BOTEVENT_FIREDGRENADE, |
144 ev_fired_grenade, |
| 249 BOTEVENT_FIREDRAILGUN, |
145 ev_fired_railgun, |
| 250 BOTEVENT_FIREDPLASMA, |
146 ev_fired_plasma, |
| 251 BOTEVENT_FIREDBFG, |
147 ev_fired_bfg, |
| 252 BOTEVENT_FIREDBFG10K, |
148 ev_fired_bfg10k, |
| 253 BOTEVENT_PLAYER_JOINEDGAME, |
149 ev_player_joined_game, |
| 254 BOTEVENT_JOINEDGAME, |
150 ev_joined_game, |
| 255 BOTEVENT_DUEL_STARTINGCOUNTDOWN, |
151 ev_duel_starting_countdown, |
| 256 BOTEVENT_DUEL_FIGHT, |
152 ev_duel_fight, |
| 257 BOTEVENT_DUEL_WINSEQUENCE, |
153 ev_duel_win_sequence, |
| 258 BOTEVENT_SPECTATING, |
154 ev_spectating, |
| 259 BOTEVENT_LMS_STARTINGCOUNTDOWN, |
155 ev_lms_starting_countdown, |
| 260 BOTEVENT_LMS_FIGHT, |
156 ev_lms_fight, |
| 261 BOTEVENT_LMS_WINSEQUENCE, |
157 ev_lms_win_sequence, |
| 262 BOTEVENT_WEAPONCHANGE, |
158 ev_weapon_change, |
| 263 BOTEVENT_ENEMY_BFGEXPLODE, |
159 ev_enemy_bfg_explode, |
| 264 BOTEVENT_PLAYER_BFGEXPLODE, |
160 ev_player_bfg_explode, |
| 265 BOTEVENT_BFGEXPLODE, |
161 ev_bfg_explode, |
| 266 BOTEVENT_RECEIVEDMEDAL, |
162 ev_recieved_medal, |
| 267 |
163 |
| 268 NUM_BOTEVENTS |
164 num_bot_events |
| 269 |
165 }; |
| 270 } BOTEVENT_e; |
|
| 271 |
166 |
| 272 #endif // BOTC_BOTS_H |
167 #endif // BOTC_BOTS_H |