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
15 * header for sexpression parsing
18 * Revision 1.3 2003/05/25 02:30:42 taylor
21 * Revision 1.2 2002/06/09 04:41:14 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 40 9/07/99 1:05a Andsager
29 * Added team-score sexp for multi team vs team missions
31 * 39 9/02/99 7:06p Dave
32 * Bumped MAX_SEXP_NODES to 2200
34 * 38 8/27/99 4:07p Andsager
35 * Add is-ship-visible sexp. Make ship-vanish sexp SINGLE player only
37 * 37 8/24/99 4:25p Andsager
38 * Add ship-vanish sexp
40 * 36 8/16/99 10:04p Andsager
41 * Add special-warp-dist and special-warpout-name sexp for Knossos device
44 * 35 8/09/99 2:00p Dave
47 * 34 8/02/99 4:26p Dave
48 * Added 2 new sexpressions.
50 * 33 7/28/99 1:36p Andsager
51 * Modify cargo1 to include flag CARGO_NO_DEPLETE. Add sexp
52 * cargo-no-deplete (only for BIG / HUGE). Modify ship struct to pack
55 * 32 7/24/99 4:56p Dave
56 * Added 3 new sexpressions.
58 * 31 7/21/99 8:10p Dave
59 * First run of supernova effect.
61 * 30 7/20/99 9:19p Andsager
62 * Added facing waypoint sexp
64 * 29 7/20/99 9:54a Andsager
65 * Add subsys-set-random sexp
67 * 28 7/15/99 9:20a Andsager
68 * FS2_DEMO initial checkin
70 * 27 7/13/99 3:37p Andsager
71 * Add secondaries-depleted sexp
73 * 26 7/08/99 12:06p Andsager
74 * Add turret-tagged-only and turret-tagged-clear sexp.
76 * 25 6/28/99 4:51p Andsager
77 * Add ship-guardian sexp (does not allow ship to be killed)
79 * 24 6/23/99 5:51p Andsager
80 * Add waypoint-cap-speed. Checkin stealth ai - inactive.
82 * 23 6/16/99 10:21a Dave
83 * Added send-message-list sexpression.
85 * 22 6/01/99 8:35p Dave
86 * Finished lockarm weapons. Added proper supercap weapons/damage. Added
87 * awacs-set-radius sexpression.
89 * 21 5/24/99 11:28a Dave
90 * Sexpression for adding/removing ships from the hud escort list.
92 * 20 4/28/99 9:33a Andsager
93 * Add turret-free and turret-lock (and -all) sexp. Stargger start time
94 * of beam weapons beam-free and beam-free-all.
96 * 19 4/26/99 2:14p Andsager
97 * Add beam-protect-ship and beam-unprotect-ship sexp.
99 * 18 4/23/99 9:45a Andsager
100 * Modify rand_sexp to return the same value each time it is called on a
101 * particular node. This prevents random time delay defaulting to min.
103 * 17 4/02/99 9:55a Dave
104 * Added a few more options in the weapons.tbl for beam weapons. Attempt
105 * at putting "pain" packets into multiplayer.
107 * 16 3/20/99 3:46p Dave
108 * Added support for model-based background nebulae. Added 3 new
111 * 15 3/04/99 6:09p Dave
112 * Added in sexpressions for firing beams and checking for if a ship is
115 * 14 2/26/99 6:01p Andsager
116 * Add sexp has-been-tagged-delay and cap-subsys-cargo-known-delay
118 * 13 2/11/99 5:22p Andsager
119 * Fixed bugs, generalized block Sexp_variables
121 * 12 2/11/99 2:15p Andsager
122 * Add ship explosion modification to FRED
124 * 11 1/25/99 4:29p Andsager
125 * Modify sexp_modify_variable() to handle type string. added quick out
126 * for multiplayer_client
128 * 10 1/25/99 8:15a Andsager
131 * 9 1/25/99 8:14a Andsager
132 * Add sexp_modify_variable(). Changed syntax checking to allow, adding
133 * operator return type ambiguous
135 * 8 1/24/99 11:37p Dave
136 * First full rev of beam weapons. Very customizable. Removed some bogus
137 * Int3()'s in low level net code.
139 * 7 1/20/99 9:37a Andsager
141 * 6 1/19/99 3:57p Andsager
142 * Round 2 of variables
144 * 5 1/07/99 1:52p Andsager
145 * Initial check in of Sexp_variables
147 * 4 12/15/98 3:59p Dan
148 * DA: bumped sexp nodes to 2000 for dan
150 * 3 11/05/98 5:55p Dave
151 * Big pass at reducing #includes
153 * 2 10/07/98 10:53a Dave
156 * 1 10/07/98 10:50a Dave
158 * 168 9/17/98 9:25p Dave
159 * _really_ upped max sexp nodes to 1800.
161 * 167 9/16/98 6:54p Dave
162 * Upped max sexpression nodes to 1800 (from 1600). Changed FRED to sort
163 * the ship list box. Added code so that tracker stats are not stored with
166 * 166 9/16/98 10:42a Hoffoss
167 * Added sexp node counting to fsm files for end user designers.
169 * 165 4/25/98 7:40p Allender
170 * fixd some small hotkey stuff. Worked on turret orientation being
171 * correct for multiplayer. new sexpression called end-campaign will will
172 * end the main campaign
174 * 164 4/24/98 4:20p Hoffoss
175 * Made the Cond operator an unlisted operator, as using this in Fred with
176 * the sexp trees will cause them to be generated wrong, and then
177 * FreeSpace would pay the price.
179 * 163 4/23/98 5:50p Hoffoss
180 * Added tracking of techroom database list info in pilot files, added
181 * sexp to add more to list, made mouse usable on ship listing in tech
184 * 162 4/16/98 4:33p Hoffoss
185 * Added support for detecting instructor terminating training due to
186 * player shooting at him.
188 * 161 4/15/98 12:58p Lawrance
189 * increase MAX_SEXP_NODES for demo build, needed since training mission
192 * 160 4/14/98 5:46p Hoffoss
193 * Added special-check operator.
195 * 159 4/14/98 5:24p Hoffoss
196 * Added a custom operator for training handling for Mike K.
198 * 158 4/14/98 11:55a Allender
199 * add end-of-campaign sexpression to allow for mission replay at the end
202 * 157 4/09/98 4:32p Hoffoss
203 * Fixed several bugs in debriefing.
205 * 156 4/06/98 5:37p Hoffoss
206 * Added sexp tree support to briefings in Fred.
208 * 155 4/03/98 2:47p Allender
209 * made directives act different when multiple waves of a wing take a long
212 * 154 4/03/98 12:18a Allender
213 * new sexpression to detect departed or destroyed. optionally disallow
214 * support ships. Allow docking with escape pods
216 * 153 4/02/98 10:13p Lawrance
217 * increase MAX_SEXP_NODES to 1600
219 * 152 4/02/98 6:32p Lawrance
220 * reduce MAX_SEXP_NODES if DEMO defined
222 * 151 4/02/98 11:40a Lawrance
223 * check for #ifdef DEMO instead of #ifdef DEMO_RELEASE
225 * 150 4/01/98 8:30p Mike
226 * Reduce MAX_SHIP_SUBOBJECTS and MAX_SEXP_NODES
228 * 149 3/17/98 4:29p Allender
229 * allow the warp broken sexpressions
231 * 148 3/15/98 3:41p Allender
232 * new sexpression to gauge whether a ship warped out in proximity of jump
235 * 147 3/09/98 4:31p Allender
236 * multiplayer secondary weapon changes. red-alert and cargo-known-delay
237 * sexpressions. Add time cargo revealed to ship structure
239 * 146 3/02/98 9:17p Allender
240 * four new sexpressions: ships-(in)vulnerable.
241 * percent-ships-(destroyed/departed)
243 * 145 2/26/98 10:07p Hoffoss
244 * Rewrote state saving and restoring to fix bugs and simplify the code.
246 * 144 2/19/98 4:54p Allender
247 * new sexpression to make ships visible/invisible on players sensors
249 * 143 2/10/98 8:58p Allender
250 * added hull damage to set/repair/sabotage subsystem
252 * 142 1/30/98 4:23p Hoffoss
253 * Added operators for debriefing checking.
255 * 141 1/23/98 4:09p Hoffoss
256 * Added a new operator format type to allow ships that aren't player
257 * ships. Made sabotage, repair and set-subsys-strength utilize it.
259 * 140 1/20/98 4:49p Allender
260 * new sexpression to help AI fire huge secondary weapons
262 * 139 1/07/98 2:08p Hoffoss
263 * Moved do-nothing operator so it appears last in the catagory's list.
265 * 138 1/07/98 2:02p Johnson
266 * Added do-nothing to change catagory.
268 * 137 1/07/98 1:48p Hoffoss
269 * Put do-nothing operator into change catagory so designers can make use
272 * 136 1/05/98 4:26p Allender
273 * added sexpression to flash a hud gauge -- a training only operator
275 * 135 1/02/98 4:41p Allender
276 * new sexpressions (not allowed yet) for changing warp status of ships
278 * 134 12/19/97 2:59p Allender
279 * more stuff to get persistent ships/weapons across campaign missions
281 * 133 12/19/97 12:43p Hoffoss
282 * Changed code to allow counts in directives.
284 * 132 12/19/97 12:03p Allender
285 * Added GM_CAMPAIGN_MODE to indicate when player is in a campaign or not.
286 * Started adding FreeSpace support for carrying of ship/weapon types
287 * across missions in a campaign.
297 #define OPERATOR_LENGTH 24 // if this ever exceeds TOKEN_LENGTH, let JasonH know!
298 #define TOKEN_LENGTH 32
300 #if defined(FS2_DEMO) || defined(FS1_DEMO)
301 #define MAX_SEXP_NODES 1600
303 #define MAX_SEXP_NODES 2200 // Reduced from 2000 to 1200 by MK on 4/1/98.
304 // Most used nodes is 698 in sm1-10a. Sandeep thinks that's the most complex mission.
305 // AL 2-4-98: upped to 1600, btm03 ran out of sexps, since campaign took a bunch
306 // DA 12/15 bumped up to 2000 - Dan ran out
309 #define MAX_SEXP_VARIABLES 100
311 #define MAX_SEXP_TEXT 2000
312 #define MAX_OPERATORS 200 // Yes, this is used, but not by the Sexp code.
314 // Operator argument formats (data types of an argument)
315 #define OPF_NONE 1 // argument cannot exist at this position if it's this
316 #define OPF_NULL 2 // no value. Can still be used for type matching, however
321 #define OPF_SUBSYSTEM 7
322 #define OPF_POINT 8 // either a 3d point in space, or a waypoint name
324 #define OPF_AI_GOAL 10 // special to match ai goals
325 #define OPF_DOCKER_POINT 11 // docking point on docker ship
326 #define OPF_DOCKEE_POINT 12 // docking point on dockee ship
327 #define OPF_MESSAGE 13 // the name (id) of a message in Messages[] array
328 #define OPF_WHO_FROM 14 // who sent the message -- doesn't necessarily have to be a ship!!!
329 #define OPF_PRIORITY 15 // priority for messages
330 #define OPF_WAYPOINT_PATH 16 // name of a waypoint
331 #define OPF_POSITIVE 17 // positive number or zero
332 #define OPF_MISSION_NAME 18 // name of a mission for various mission related things
333 #define OPF_SHIP_POINT 19 // a waypoint or a ship
334 #define OPF_GOAL_NAME 20 // name of goal (or maybe event?) from a mission
335 #define OPF_SHIP_WING 21 // either a ship or wing name (they don't conflict)
336 #define OPF_SHIP_WING_POINT 22 // name of a ship, wing, or a point
337 #define OPF_SHIP_TYPE 23 // type of ship (fighter/bomber/etc)
338 #define OPF_KEYPRESS 24 // a default key
339 #define OPF_EVENT_NAME 25 // name of an event
340 #define OPF_AI_ORDER 26 // a squadmsg order player can give to a ship
341 #define OPF_SKILL_LEVEL 27 // current skill level of the game
342 #define OPF_MEDAL_NAME 28 // name of medals
343 #define OPF_WEAPON_NAME 29 // name of a weapon
344 #define OPF_SHIP_CLASS_NAME 30 // name of a ship class
345 #define OPF_HUD_GAUGE_NAME 31 // name of HUD gauge
346 #define OPF_HUGE_WEAPON 32 // name of a secondary bomb type weapon
347 #define OPF_SHIP_NOT_PLAYER 33 // a ship, but not a player ship
348 #define OPF_JUMP_NODE_NAME 34 // name of a jump node
349 #define OPF_VARIABLE_NAME 35 // variable name
350 #define OPF_AMBIGUOUS 36 // type used with variable
351 #define OPF_AWACS_SUBSYSTEM 37 // an awacs subsystem
353 // Operand return types
354 #define OPR_NUMBER 1 // returns number
355 #define OPR_BOOL 2 // returns true/false value
356 #define OPR_NULL 3 // doesn't return a value
357 #define OPR_AI_GOAL 4 // is an ai operator (doesn't really return a value, but used for type matching)
358 #define OPR_POSITIVE 5 // returns a non-negative number
359 #define OPR_STRING 6 // not really a return type, but used for type matching.
360 #define OPR_AMBIGUOUS 7 // not really a return type, but used for type matching.
362 #define OP_INSERT_FLAG 0x8000
363 #define OP_REPLACE_FLAG 0x4000
364 #define OP_NONCAMPAIGN_FLAG 0x2000
365 #define OP_CAMPAIGN_ONLY_FLAG 0x1000
366 #define FIRST_OP 0x0100
367 #define OP_CATAGORY_MASK 0x0f00
369 #define OP_CATAGORY_OBJECTIVE 0x0100
370 #define OP_CATAGORY_TIME 0x0200
371 #define OP_CATAGORY_LOGICAL 0x0300
372 #define OP_CATAGORY_ARITHMETIC 0x0400
373 #define OP_CATAGORY_STATUS 0x0500
374 #define OP_CATAGORY_CHANGE 0x0600
375 #define OP_CATAGORY_CONDITIONAL 0x0700
376 #define OP_CATAGORY_DEBUG 0x0800
377 #define OP_CATAGORY_AI 0x0900 // used for AI goals
378 #define OP_CATAGORY_TRAINING 0x0a00
379 #define OP_CATAGORY_UNLISTED 0x0b00
380 #define OP_CATAGORY_GOAL_EVENT 0x0c00
382 #define OP_PLUS (0x0000 | OP_CATAGORY_ARITHMETIC)
383 #define OP_MINUS (0x0001 | OP_CATAGORY_ARITHMETIC)
384 #define OP_MOD (0x0002 | OP_CATAGORY_ARITHMETIC)
385 #define OP_MUL (0x0003 | OP_CATAGORY_ARITHMETIC)
386 #define OP_DIV (0x0004 | OP_CATAGORY_ARITHMETIC)
387 #define OP_RAND (0x0005 | OP_CATAGORY_ARITHMETIC)
389 #define OP_TRUE (0x0000 | OP_CATAGORY_LOGICAL)
390 #define OP_FALSE (0x0001 | OP_CATAGORY_LOGICAL)
391 #define OP_AND (0x0002 | OP_CATAGORY_LOGICAL)
392 #define OP_AND_IN_SEQUENCE (0x0003 | OP_CATAGORY_LOGICAL)
393 #define OP_OR (0x0004 | OP_CATAGORY_LOGICAL)
394 #define OP_EQUALS (0x0005 | OP_CATAGORY_LOGICAL)
395 #define OP_GREATER_THAN (0x0006 | OP_CATAGORY_LOGICAL)
396 #define OP_LESS_THAN (0x0007 | OP_CATAGORY_LOGICAL)
397 #define OP_IS_IFF (0x0008 | OP_CATAGORY_LOGICAL | OP_NONCAMPAIGN_FLAG)
398 #define OP_HAS_TIME_ELAPSED (0x0009 | OP_CATAGORY_LOGICAL | OP_NONCAMPAIGN_FLAG)
399 #define OP_NOT (0x000a | OP_CATAGORY_LOGICAL)
401 #define OP_GOAL_INCOMPLETE (0x0000 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
402 #define OP_GOAL_TRUE_DELAY (0x0001 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
403 #define OP_GOAL_FALSE_DELAY (0x0002 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
404 #define OP_EVENT_INCOMPLETE (0x0003 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
405 #define OP_EVENT_TRUE_DELAY (0x0004 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
406 #define OP_EVENT_FALSE_DELAY (0x0005 | OP_CATAGORY_GOAL_EVENT | OP_NONCAMPAIGN_FLAG)
407 #define OP_PREVIOUS_EVENT_TRUE (0x0006 | OP_CATAGORY_GOAL_EVENT)
408 #define OP_PREVIOUS_EVENT_FALSE (0x0007 | OP_CATAGORY_GOAL_EVENT)
409 #define OP_PREVIOUS_GOAL_TRUE (0x0009 | OP_CATAGORY_GOAL_EVENT)
410 #define OP_PREVIOUS_GOAL_FALSE (0x000a | OP_CATAGORY_GOAL_EVENT)
412 #define OP_IS_DESTROYED_DELAY (0x0008 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
413 #define OP_IS_SUBSYSTEM_DESTROYED_DELAY (0x0009 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
414 #define OP_IS_DISABLED_DELAY (0x000a | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
415 #define OP_IS_DISARMED_DELAY (0x000b | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
416 #define OP_HAS_DOCKED_DELAY (0x000c | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
417 #define OP_HAS_UNDOCKED_DELAY (0x000d | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
418 #define OP_HAS_ARRIVED_DELAY (0x000e | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
419 #define OP_HAS_DEPARTED_DELAY (0x000f | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
420 #define OP_WAYPOINTS_DONE_DELAY (0x0011 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
421 #define OP_SHIP_TYPE_DESTROYED (0x0012 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
422 #define OP_PERCENT_SHIPS_DEPARTED (0x0013 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
423 #define OP_PERCENT_SHIPS_DESTROYED (0x0014 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
424 #define OP_DEPART_NODE_DELAY (0x0015 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
425 #define OP_DESTROYED_DEPARTED_DELAY (0x0016 | OP_CATAGORY_OBJECTIVE | OP_NONCAMPAIGN_FLAG)
427 #define OP_TIME_SHIP_DESTROYED (0x0000 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
428 #define OP_TIME_SHIP_ARRIVED (0x0001 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
429 #define OP_TIME_SHIP_DEPARTED (0x0002 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
430 #define OP_TIME_WING_DESTROYED (0x0003 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
431 #define OP_TIME_WING_ARRIVED (0x0004 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
432 #define OP_TIME_WING_DEPARTED (0x0005 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
433 #define OP_MISSION_TIME (0x0006 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
434 #define OP_TIME_DOCKED (0x0007 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
435 #define OP_TIME_UNDOCKED (0x0008 | OP_CATAGORY_TIME | OP_NONCAMPAIGN_FLAG)
437 #define OP_SHIELDS_LEFT (0x0000 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
438 #define OP_HITS_LEFT (0x0001 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
439 #define OP_HITS_LEFT_SUBSYSTEM (0x0002 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
440 #define OP_DISTANCE (0x0003 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
441 #define OP_LAST_ORDER_TIME (0x0004 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
442 #define OP_NUM_PLAYERS (0x0005 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
443 #define OP_SKILL_LEVEL_AT_LEAST (0x0006 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
444 #define OP_WAS_PROMOTION_GRANTED (0x0008 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
445 #define OP_WAS_MEDAL_GRANTED (0x0009 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
446 #define OP_CARGO_KNOWN_DELAY (0x000a | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
447 #define OP_CAP_SUBSYS_CARGO_KNOWN_DELAY (0x000b | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
448 #define OP_HAS_BEEN_TAGGED_DELAY (0x000c | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
449 #define OP_IS_TAGGED (0x000d | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
450 #define OP_NUM_KILLS (0x000e | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
451 #define OP_NUM_TYPE_KILLS (0x000f | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
452 #define OP_NUM_CLASS_KILLS (0x0010 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
453 #define OP_SHIELD_RECHARGE_PCT (0x0011 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
454 #define OP_ENGINE_RECHARGE_PCT (0x0012 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
455 #define OP_WEAPON_RECHARGE_PCT (0x0013 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
456 #define OP_SHIELD_QUAD_LOW (0x0014 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
457 #define OP_SECONDARY_AMMO_PCT (0x0015 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
458 #define OP_IS_SECONDARY_SELECTED (0x0016 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
459 #define OP_IS_PRIMARY_SELECTED (0x0017 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
460 #define OP_SPECIAL_WARP_DISTANCE (0X0018 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
461 #define OP_IS_SHIP_VISIBLE (0X0019 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
462 #define OP_TEAM_SCORE (0X0020 | OP_CATAGORY_STATUS | OP_NONCAMPAIGN_FLAG)
466 // conditional sexpressions
467 #define OP_WHEN (0x0000 | OP_CATAGORY_CONDITIONAL)
469 // sexpressions with side-effects
470 #define OP_CHANGE_IFF (0x0000 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
471 #define OP_REPAIR_SUBSYSTEM (0x0001 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
472 #define OP_SABOTAGE_SUBSYSTEM (0x0002 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
473 #define OP_SET_SUBSYSTEM_STRNGTH (0x0003 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
474 #define OP_PROTECT_SHIP (0x0004 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
475 #define OP_SEND_MESSAGE (0x0005 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
476 #define OP_SELF_DESTRUCT (0x0006 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
477 #define OP_CLEAR_GOALS (0x0007 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
478 #define OP_ADD_GOAL (0x0008 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
479 #define OP_INVALIDATE_GOAL (0x0009 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
480 #define OP_VALIDATE_GOAL (0x000a | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
481 #define OP_SEND_RANDOM_MESSAGE (0x000b | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
482 #define OP_TRANSFER_CARGO (0x000c | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
483 #define OP_EXCHANGE_CARGO (0x000d | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
484 #define OP_UNPROTECT_SHIP (0x000e | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
485 #define OP_GOOD_REARM_TIME (0x0010 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
486 #define OP_BAD_REARM_TIME (0x0011 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
487 #define OP_GRANT_PROMOTION (0x0012 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
488 #define OP_GRANT_MEDAL (0x0013 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
489 #define OP_ALLOW_SHIP (0x0014 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
490 #define OP_ALLOW_WEAPON (0x0015 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
491 #define OP_GOOD_SECONDARY_TIME (0x0016 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
492 #define OP_WARP_BROKEN (0x0017 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
493 #define OP_WARP_NOT_BROKEN (0x0018 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
494 #define OP_WARP_NEVER (0x0019 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
495 #define OP_WARP_ALLOWED (0x0020 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
496 #define OP_SHIP_INVISIBLE (0x0021 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
497 #define OP_SHIP_VISIBLE (0x0022 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
498 #define OP_SHIP_INVULNERABLE (0x0023 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
499 #define OP_SHIP_VULNERABLE (0x0024 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
500 #define OP_RED_ALERT (0x0025 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
501 #define OP_TECH_ADD_SHIP (0x0026 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
502 #define OP_TECH_ADD_WEAPON (0x0027 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
503 #define OP_END_CAMPAIGN (0x0028 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
504 #define OP_JETTISON_CARGO (0x0029 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
505 #define OP_MODIFY_VARIABLE (0X0030 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
506 #define OP_NOP (0x0031 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
507 #define OP_BEAM_FIRE (0x0032 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
508 #define OP_BEAM_FREE (0x0033 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
509 #define OP_BEAM_FREE_ALL (0x0034 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
510 #define OP_BEAM_LOCK (0x0035 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
511 #define OP_BEAM_LOCK_ALL (0x0036 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
512 #define OP_BEAM_PROTECT_SHIP (0x0037 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
513 #define OP_BEAM_UNPROTECT_SHIP (0x0038 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
514 #define OP_TURRET_FREE (0x0039 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
515 #define OP_TURRET_FREE_ALL (0x0040 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
516 #define OP_TURRET_LOCK (0x0041 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
517 #define OP_TURRET_LOCK_ALL (0x0042 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
518 #define OP_ADD_REMOVE_ESCORT (0x0043 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
519 #define OP_AWACS_SET_RADIUS (0x0044 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
520 #define OP_SEND_MESSAGE_LIST (0x0045 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
521 #define OP_CAP_WAYPOINT_SPEED (0x0046 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
522 #define OP_SHIP_GUARDIAN (0x0047 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
523 #define OP_SHIP_NO_GUARDIAN (0x0048 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
524 #define OP_TURRET_TAGGED_ONLY_ALL (0x0049 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
525 #define OP_TURRET_TAGGED_CLEAR_ALL (0x0050 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
526 #define OP_SUBSYS_SET_RANDOM (0x0051 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
527 #define OP_SUPERNOVA_START (0x0052 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
528 #define OP_CARGO_NO_DEPLETE (0x0053 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
529 #define OP_SET_SPECIAL_WARPOUT_NAME (0X0054 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
530 #define OP_SHIP_VANISH (0X0055 | OP_CATAGORY_CHANGE | OP_NONCAMPAIGN_FLAG)
533 // debugging sexpressions
534 #define OP_INT3 (0x0000 | OP_CATAGORY_DEBUG)
536 // defined for AI goals
537 #define OP_AI_CHASE (0x0000 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
538 #define OP_AI_DOCK (0x0001 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
539 #define OP_AI_UNDOCK (0x0002 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
540 #define OP_AI_WARP_OUT (0x0003 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
541 #define OP_AI_WAYPOINTS (0x0004 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
542 #define OP_AI_WAYPOINTS_ONCE (0x0005 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
543 #define OP_AI_DESTROY_SUBSYS (0x0006 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
544 #define OP_AI_DISABLE_SHIP (0x0008 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
545 #define OP_AI_DISARM_SHIP (0x0009 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
546 #define OP_AI_GUARD (0x000a | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
547 #define OP_AI_CHASE_ANY (0x000b | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
548 #define OP_AI_EVADE_SHIP (0x000d | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
549 #define OP_AI_STAY_NEAR_SHIP (0x000e | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
550 #define OP_AI_KEEP_SAFE_DISTANCE (0x000f | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
551 #define OP_AI_IGNORE (0x0010 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
552 #define OP_AI_STAY_STILL (0x0011 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
553 #define OP_AI_PLAY_DEAD (0x0012 | OP_CATAGORY_AI | OP_NONCAMPAIGN_FLAG)
555 #define OP_GOALS_ID (0x0001 | OP_CATAGORY_UNLISTED)
556 #define OP_NEXT_MISSION (0x0002 | OP_CATAGORY_UNLISTED) // used in campaign files for branching
557 #define OP_IS_DESTROYED (0x0003 | OP_CATAGORY_UNLISTED)
558 #define OP_IS_SUBSYSTEM_DESTROYED (0x0004 | OP_CATAGORY_UNLISTED)
559 #define OP_IS_DISABLED (0x0005 | OP_CATAGORY_UNLISTED)
560 #define OP_IS_DISARMED (0x0006 | OP_CATAGORY_UNLISTED)
561 #define OP_HAS_DOCKED (0x0007 | OP_CATAGORY_UNLISTED)
562 #define OP_HAS_UNDOCKED (0x0008 | OP_CATAGORY_UNLISTED)
563 #define OP_HAS_ARRIVED (0x0009 | OP_CATAGORY_UNLISTED)
564 #define OP_HAS_DEPARTED (0x000a | OP_CATAGORY_UNLISTED)
565 #define OP_WAYPOINTS_DONE (0x000b | OP_CATAGORY_UNLISTED)
566 #define OP_ADD_SHIP_GOAL (0x000c | OP_CATAGORY_UNLISTED)
567 #define OP_CLEAR_SHIP_GOALS (0x000d | OP_CATAGORY_UNLISTED)
568 #define OP_ADD_WING_GOAL (0x000e | OP_CATAGORY_UNLISTED)
569 #define OP_CLEAR_WING_GOALS (0x000f | OP_CATAGORY_UNLISTED)
570 #define OP_AI_CHASE_WING (0x0010 | OP_CATAGORY_UNLISTED)
571 #define OP_AI_GUARD_WING (0x0011 | OP_CATAGORY_UNLISTED)
572 #define OP_EVENT_TRUE (0x0012 | OP_CATAGORY_UNLISTED)
573 #define OP_EVENT_FALSE (0x0013 | OP_CATAGORY_UNLISTED)
574 #define OP_PREVIOUS_GOAL_INCOMPLETE (0x0014 | OP_CATAGORY_UNLISTED)
575 #define OP_PREVIOUS_EVENT_INCOMPLETE (0x0015 | OP_CATAGORY_UNLISTED)
576 #define OP_AI_WARP (0x0016 | OP_CATAGORY_UNLISTED)
577 #define OP_END_MISSION_DELAY (0x0017 | OP_CATAGORY_UNLISTED)
578 #define OP_IS_CARGO_KNOWN (0x001c | OP_CATAGORY_UNLISTED)
579 #define OP_COND (0x001e | OP_CATAGORY_UNLISTED)
580 #define OP_END_OF_CAMPAIGN (0x001f | OP_CATAGORY_UNLISTED)
582 #define OP_KEY_PRESSED (0x0000 | OP_CATAGORY_TRAINING)
583 #define OP_KEY_RESET (0x0001 | OP_CATAGORY_TRAINING)
584 #define OP_TARGETED (0x0002 | OP_CATAGORY_TRAINING)
585 #define OP_SPEED (0x0003 | OP_CATAGORY_TRAINING)
586 #define OP_FACING (0x0004 | OP_CATAGORY_TRAINING)
587 #define OP_ORDER (0x0005 | OP_CATAGORY_TRAINING)
588 #define OP_WAYPOINT_MISSED (0x0006 | OP_CATAGORY_TRAINING)
589 #define OP_PATH_FLOWN (0x0007 | OP_CATAGORY_TRAINING)
590 #define OP_WAYPOINT_TWICE (0x0008 | OP_CATAGORY_TRAINING)
591 #define OP_TRAINING_MSG (0x0009 | OP_CATAGORY_TRAINING)
592 #define OP_FLASH_HUD_GAUGE (0x000a | OP_CATAGORY_TRAINING)
593 #define OP_SPECIAL_CHECK (0x000b | OP_CATAGORY_TRAINING)
594 #define OP_SECONDARIES_DEPLETED (0x000c | OP_CATAGORY_TRAINING)
595 #define OP_FACING2 (0x000d | OP_CATAGORY_TRAINING)
597 #define OP_SET_TRAINING_CONTEXT_FLY_PATH (0x0080 | OP_CATAGORY_TRAINING)
598 #define OP_SET_TRAINING_CONTEXT_SPEED (0x0081 | OP_CATAGORY_TRAINING)
600 // defines for string constants
601 #define SEXP_HULL_STRING "Hull"
603 // macros for accessing sexpression atoms
604 #define CAR(n) (Sexp_nodes[n].first)
605 #define CDR(n) (Sexp_nodes[n].rest)
606 #define CADR(n) (Sexp_nodes[Sexp_nodes[n].rest].first)
607 // #define CTEXT(n) (Sexp_nodes[n].text)
610 #define REF_TYPE_SHIP 1
611 #define REF_TYPE_WING 2
612 #define REF_TYPE_PLAYER 3
613 #define REF_TYPE_WAYPOINT 4
614 #define REF_TYPE_PATH 5 // waypoint path
616 #define SRC_SHIP_ARRIVAL 0x10000
617 #define SRC_SHIP_DEPARTURE 0x20000
618 #define SRC_WING_ARRIVAL 0x30000
619 #define SRC_WING_DEPARTURE 0x40000
620 #define SRC_EVENT 0x50000
621 #define SRC_MISSION_GOAL 0x60000
622 #define SRC_SHIP_ORDER 0x70000
623 #define SRC_WING_ORDER 0x80000
624 #define SRC_DEBRIEFING 0x90000
625 #define SRC_BRIEFING 0xa0000
626 #define SRC_UNKNOWN 0xffff0000
627 #define SRC_MASK 0xffff0000
628 #define SRC_DATA_MASK 0xffff
630 #define SEXP_MODE_GENERAL 0
631 #define SEXP_MODE_CAMPAIGN 1
633 // defines for type field of sexp nodes. The actual type of the node will be stored in the lower
634 // two bytes of the field. The upper two bytes will be used for flags (bleah...)
635 // Be sure not to conflict with type field of sexp_variable
636 #define SEXP_NOT_USED 0
640 // flags for sexpressions -- masked onto the end of the type field
641 #define SEXP_FLAG_PERSISTENT (1<<31) // should this sexp node be persistant across missions
642 #define SEXP_FLAG_VARIABLE (1<<30)
644 // sexp variable definitions
645 #define SEXP_VARIABLE_CHAR ('@')
646 // defines for type field of sexp_variable. Be sure not to conflict with type field of sexp_node
647 #define SEXP_VARIABLE_NUMBER (0x0010)
648 #define SEXP_VARIABLE_STRING (0x0020)
649 #define SEXP_VARIABLE_UNKNOWN (0x0040)
650 #define SEXP_VARIABLE_NOT_USED (0x0080)
652 #define SEXP_VARIABLE_BLOCK (0X0001)
653 #define SEXP_VARIABLE_BLOCK_EXP (0X0002)
655 #define BLOCK_EXP_SIZE 6
661 #define SHOCK_SPEED 5
664 #define SEXP_VARIABLE_SET (0x0100)
665 #define SEXP_VARIABLE_MODIFIED (0x0200)
667 #define SEXP_TYPE_MASK(t) (t & 0x00ff)
668 #define SEXP_NODE_TYPE(n) (Sexp_nodes[n].type & 0x00ff)
670 // defines for subtypes of atoms
671 #define SEXP_ATOM_LIST 0
672 #define SEXP_ATOM_OPERATOR 1
673 #define SEXP_ATOM_NUMBER 2
674 #define SEXP_ATOM_STRING 3
676 // defines to short circuit evaluation when possible. Also used then goals can't
677 // be satisfied yet because ship (or wing) hasn't been created yet.
681 #define SEXP_KNOWN_FALSE -1
682 #define SEXP_KNOWN_TRUE -2
683 #define SEXP_UNKNOWN -3
684 #define SEXP_NAN -4 // not a number -- used when ships/wing part of boolean and haven't arrived yet
685 #define SEXP_NAN_FOREVER -5 // not a number and will never change -- used to falsify boolean sexpressions
686 #define SEXP_CANT_EVAL -6 // can't evaluate yet for whatever reason (acts like false)
687 #define SEXP_NUM_EVAL -7 // already completed an arithmetic operation and result is stored
689 // defines for check_sexp_syntax
690 #define SEXP_CHECK_NONOP_ARGS -1 // non-operator has arguments
691 #define SEXP_CHECK_OP_EXPTECTED -2 // operator expected, but found data instead
692 #define SEXP_CHECK_UNKNOWN_OP -3 // unrecognized operator
693 #define SEXP_CHECK_TYPE_MISMATCH -4 // return type or data type mismatch
694 #define SEXP_CHECK_BAD_ARG_COUNT -5 // argument count in incorrect
695 #define SEXP_CHECK_UNKNOWN_TYPE -6 // unrecognized return type of data type
697 #define SEXP_CHECK_INVALID_NUM -101 // number is not valid
698 #define SEXP_CHECK_INVALID_SHIP -102 // invalid ship name
699 #define SEXP_CHECK_INVALID_WING -103 // invalid wing name
700 #define SEXP_CHECK_INVALID_SUBSYS -104 // invalid subsystem
701 #define SEXP_CHECK_INVALID_IFF -105 // invalid iff string
702 #define SEXP_CHECK_INVALID_POINT -106 // invalid point
703 #define SEXP_CHECK_NEGATIVE_NUM -107 // negative number wasn't allowed
704 #define SEXP_CHECK_INVALID_SHIP_WING -108 // invalid ship/wing
705 #define SEXP_CHECK_INVALID_SHIP_TYPE -109 // invalid ship type
706 #define SEXP_CHECK_UNKNOWN_MESSAGE -110 // invalid message
707 #define SEXP_CHECK_INVALID_PRIORITY -111 // invalid priority for a message
708 #define SEXP_CHECK_INVALID_MISSION_NAME -112 // invalid mission name
709 #define SEXP_CHECK_INVALID_GOAL_NAME -113 // invalid goal name
710 #define SEXP_CHECK_INVALID_LEVEL -114 // mission level too high in campaign
711 #define SEXP_CHECK_INVALID_MSG_SOURCE -115 // invalid 'who-from' for a message being sent
712 #define SEXP_CHECK_INVALID_DOCKER_POINT -116
713 #define SEXP_CHECK_INVALID_DOCKEE_POINT -117
714 #define SEXP_CHECK_ORDER_NOT_ALLOWED -118 // ship goal (order) isn't allowed for given ship
715 #define SEXP_CHECK_DOCKING_NOT_ALLOWED -119
716 #define SEXP_CHECK_NUM_RANGE_INVALID -120
717 #define SEXP_CHECK_INVALID_EVENT_NAME -121
718 #define SEXP_CHECK_INVALID_SKILL_LEVEL -122
719 #define SEXP_CHECK_INVALID_MEDAL_NAME -123
720 #define SEXP_CHECK_INVALID_WEAPON_NAME -124
721 #define SEXP_CHECK_INVALID_SHIP_CLASS_NAME -125
722 #define SEXP_CHECK_INVALID_GAUGE_NAME -126
723 #define SEXP_CHECK_INVALID_JUMP_NODE -127
724 #define SEXP_CHECK_INVALID_VARIABLE -128
726 #define TRAINING_CONTEXT_SPEED (1<<0)
727 #define TRAINING_CONTEXT_FLY_PATH (1<<1)
729 // numbers used in special_training_check() function
730 #define SPECIAL_CHECK_TRAINING_FAILURE 2000
732 typedef struct sexp_ai_goal_link {
737 typedef struct sexp_oper {
743 typedef struct sexp_node {
744 char text[TOKEN_LENGTH];
745 int type; // atom, list, or not used
746 int subtype; // type of atom or list?
747 int first; // if first parameter is sexp, index into Sexp_nodes
748 int rest; // index into Sexp_nodes of rest of parameters
749 int value; // known to be true, known to be false, or not known
752 typedef struct sexp_variable {
754 char text[TOKEN_LENGTH];
755 char variable_name[TOKEN_LENGTH];
758 // next define used to eventually mark a directive as satisfied even though there may be more
759 // waves for a wing. bascially a hack for the directives display.
760 #define DIRECTIVE_WING_ZERO -999
762 extern sexp_oper Operators[];
763 extern sexp_node Sexp_nodes[MAX_SEXP_NODES];
764 extern sexp_variable Sexp_variables[MAX_SEXP_VARIABLES];
765 extern int Num_operators;
766 extern int Locked_sexp_true, Locked_sexp_false;
767 extern int Directive_count;
768 extern int Sexp_useful_number; // a variable to pass useful info in from external modules
769 extern char *Sexp_string;
770 extern int Training_context;
771 extern int Training_context_speed_min;
772 extern int Training_context_speed_max;
773 extern int Training_context_speed_set;
774 extern int Training_context_speed_timestamp;
775 extern int Training_context_path;
776 extern int Training_context_goal_waypoint;
777 extern int Training_context_at_waypoint;
778 extern float Training_context_distance;
779 extern int Players_target;
780 extern ship_subsys *Players_targeted_subsys;
781 extern int Players_target_timestamp;
782 extern int Sexp_clipboard; // used by Fred
784 extern void init_sexp();
785 extern int alloc_sexp(const char *text, int type, int subtype, int first, int rest);
786 extern int find_free_sexp();
787 extern int free_one_sexp(int num);
788 extern int free_sexp(int num);
789 extern int free_sexp2(int num);
790 extern int dup_sexp_chain(int node);
791 extern int cmp_sexp_chains(int node1, int node2);
792 extern int find_sexp_list(int num);
793 extern int find_parent_operator(int num);
794 extern int is_sexp_top_level( int node );
795 extern int identify_operator(const char *token);
796 extern int find_operator(const char *token);
797 extern int query_sexp_args_count(int index);
798 extern int check_sexp_syntax(int index, int return_type = OPR_BOOL, int recursive = 0, int *bindex = NULL, int mode = 0);
799 extern int get_sexp_main(void); // Returns start node
800 extern int stuff_sexp_variable_list();
801 extern int eval_sexp(int index);
802 extern int query_operator_return_type(int op);
803 extern int query_operator_argument_type(int op, int argnum);
804 extern void update_sexp_references(char *old_name, char *new_name);
805 extern void update_sexp_references(char *old_name, char *new_name, int format);
806 extern int query_referenced_in_sexp(int mode, char *name, int *node);
807 extern int verify_vector(char *text);
808 extern void skip_white(char **str);
809 extern int validate_float(char **str);
810 extern int build_sexp_string(int cur_node, int level, int mode);
811 extern int sexp_query_type_match(int opf, int opr);
812 extern const char *sexp_error_message(int num);
813 extern int count_free_sexp_nodes();
815 // functions to change the attributes of an sexpression tree to persistent or not persistent
816 extern void sexp_unmark_persistent( int n );
817 extern void sexp_mark_persistent( int n );
818 extern int waypoint_lookup(char *name);
819 extern int verify_sexp_tree(int node);
820 extern int query_sexp_ai_goal_valid(int sexp_ai_goal, int ship);
821 int query_node_in_sexp(int node, int sexp);
822 void flush_sexp_tree(int node);
825 void sexp_modify_variable(int);
826 void sexp_modify_variable(char *text, int index);
827 int get_index_sexp_variable_name(const char* temp_name);
828 int sexp_variable_count();
829 void sexp_variable_delete(int index);
830 void sexp_variable_sort();
831 void sexp_fred_modify_variable(const char *text, const char *var_name, int index, int type);
832 int sexp_add_variable(const char *text, const char *var_name, int type, int index=-1);
833 int sexp_variable_allocate_block(const char* block_name, int block_type);
834 void sexp_variable_condense_block();
835 void sexp_variable_block_free(const char *ship_name, int start_index, int block_type);