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