Scripts.h 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // Scripts.h
  24. // Script data structures.
  25. // Author: John Ahlquist, November 2001
  26. #pragma once
  27. #ifndef SCRIPTS_H
  28. #define SCRIPTS_H
  29. #include "Common/Snapshot.h"
  30. #include "GameNetwork/NetworkDefs.h"
  31. #define THIS_TEAM "<This Team>"
  32. #define ANY_TEAM "<Any Team>"
  33. #define THIS_OBJECT "<This Object>"
  34. #define ANY_OBJECT "<Any Object>"
  35. #define THIS_PLAYER "<This Player>"
  36. #define LOCAL_PLAYER "<Local Player>"
  37. #define THIS_PLAYER_ENEMY "<This Player's Enemy>"
  38. #define WATER_GRID "Water Grid"
  39. // Skirmish waypoint names
  40. #define SKIRMISH_CENTER "Center"
  41. #define SKIRMISH_FLANK "Flank"
  42. #define SKIRMISH_BACKDOOR "Backdoor"
  43. #define SKIRMISH_SPECIAL "Special"
  44. #if 0
  45. // Skirmish Player names
  46. #define SKIRMISH_PLAYER_AI "AI"
  47. #define SKIRMISH_PLAYER_HUMAN "Human"
  48. #define SKIRMISH_PLAYER_AI_ALLIES "AI Allies"
  49. #define SKIRMISH_PLAYER_AI_ENEMIES "AI Enemies"
  50. #define SKIRMISH_PLAYER_HUMAN_ALLIES "Human Allies"
  51. #define SKIRMISH_PLAYER_HUMAN_ENEMIES "Human Enemies"
  52. #endif
  53. // Skirmish Player Areas
  54. #define SKIRMISH_AREA_HOME_BASE "Home Base"
  55. #define SKIRMISH_AREA_ANY_SUPPLYDEPOT "Any Supply Depot"
  56. // Skirmish trigger names.
  57. #define MY_INNER_PERIMETER "[Skirmish]MyInnerPerimeter"
  58. #define MY_OUTER_PERIMETER "[Skirmish]MyOuterPerimeter"
  59. #define ENEMY_OUTER_PERIMETER "[Skirmish]EnemyOuterPerimeter"
  60. #define ENEMY_INNER_PERIMETER "[Skirmish]EnemyInnerPerimeter"
  61. #define INNER_PERIMETER "InnerPerimeter"
  62. #define OUTER_PERIMETER "OuterPerimeter"
  63. class Parameter;
  64. class Script;
  65. class OrCondition;
  66. class Condition;
  67. class DataChunkInput;
  68. struct DataChunkInfo;
  69. class DataChunkOutput;
  70. #define NO_MORE_COMPLEX_SKIRMISH_SCRIPTS
  71. #ifndef NO_MORE_COMPLEX_SKIRMISH_SCRIPTS
  72. // For now, we only actually allow the simple stuff to be chosen. However, as soon as I can get more
  73. // time on the schedule, we need to extend these scripts to be more useful. To that end, I've
  74. // created the parameters and such necessary for more complex behavior, but for now only the
  75. // rudimentary support is enabled. jkmcd
  76. #define MORE_COMPLEX_SKIRMISH_SCRIPTS
  77. #endif
  78. // There is undoubtedly a more sophisticated way to do this, but for some reason my brain hurts.
  79. // The corresponding UnsignedInt values that we pass around are:
  80. // 1 means ground
  81. // 2 means air
  82. // 3 means air or ground
  83. extern const char *Surfaces[];
  84. // Shake intensities. Must be kept in sync with View::CameraShakeType
  85. extern const char *ShakeIntensities[];
  86. //-------------------------------------------------------------------------------------------------
  87. // ******************************** class ScriptGroup ***********************************************
  88. //-------------------------------------------------------------------------------------------------
  89. class ScriptGroup : public MemoryPoolObject, public Snapshot
  90. // This is a list of scripts that are grouped and named, with some
  91. // additional properties.
  92. {
  93. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ScriptGroup, "ScriptGroup")
  94. protected:
  95. // snapshot methods
  96. virtual void crc( Xfer *xfer );
  97. virtual void xfer( Xfer *xfer );
  98. virtual void loadPostProcess( void );
  99. protected:
  100. Script *m_firstScript;
  101. AsciiString m_groupName;
  102. Bool m_isGroupActive;
  103. Bool m_isGroupSubroutine;
  104. ScriptGroup *m_nextGroup;
  105. Bool m_hasWarnings; ///< Runtime flag used by the editor only.
  106. public:
  107. ScriptGroup();
  108. //~ScriptGroup();
  109. public:
  110. ScriptGroup *duplicate(void) const; // note, duplicates just this node, not the full list.
  111. ScriptGroup *duplicateAndQualify(const AsciiString& qualifier,
  112. const AsciiString& playerTemplateName, const AsciiString& newPlayerName) const; // note, duplicates just this node, not the full list.
  113. void setName(AsciiString name) { m_groupName = name;}
  114. void setActive(Bool active) { m_isGroupActive = active;}
  115. void setSubroutine(Bool subr) { m_isGroupSubroutine = subr;}
  116. void setWarnings(Bool warnings) { m_hasWarnings = warnings;}
  117. void setNextGroup(ScriptGroup *pGr) {m_nextGroup = pGr;}
  118. AsciiString getName(void) const { return m_groupName;}
  119. Bool isActive(void) const { return m_isGroupActive;}
  120. Bool isSubroutine(void) const { return m_isGroupSubroutine;}
  121. Bool hasWarnings(void) const { return m_hasWarnings;}
  122. ScriptGroup *getNext(void) const {return m_nextGroup;};
  123. Script *getScript(void) {return m_firstScript;};
  124. void addScript(Script *pScr, Int ndx);
  125. void deleteScript(Script *pScr);
  126. static void WriteGroupDataChunk(DataChunkOutput &chunkWriter, ScriptGroup *pGroup);
  127. static Bool ParseGroupDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  128. };
  129. //-------------------------------------------------------------------------------------------------
  130. // ******************************** class OrCondition ***********************************************
  131. //-------------------------------------------------------------------------------------------------
  132. /// This is a linked list of or clauses, each containing a list of and clauses.
  133. class OrCondition : public MemoryPoolObject
  134. {
  135. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(OrCondition, "OrCondition")
  136. protected:
  137. OrCondition *m_nextOr; // Next or clause.
  138. Condition *m_firstAnd; // These are Anded.
  139. public:
  140. OrCondition():m_nextOr(NULL),m_firstAnd(NULL){};
  141. //~OrCondition();
  142. /// Duplicate creates a "deep" copy. If it is head of a linked list, duplicates the entire list.
  143. OrCondition *duplicate(void) const;
  144. OrCondition *duplicateAndQualify(const AsciiString& qualifier,
  145. const AsciiString& playerTemplateName, const AsciiString& newPlayerName) const;
  146. public:
  147. void setNextOrCondition(OrCondition *pOr) {m_nextOr = pOr;}
  148. void setFirstAndCondition(Condition *pAnd) {m_firstAnd = pAnd;}
  149. OrCondition *getNextOrCondition(void) {return m_nextOr;}
  150. Condition *getFirstAndCondition(void) {return m_firstAnd;}
  151. Condition *removeCondition(Condition *pCond);
  152. void deleteCondition(Condition *pCond);
  153. static void WriteOrConditionDataChunk(DataChunkOutput &chunkWriter, OrCondition *pCondition);
  154. static Bool ParseOrConditionDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  155. // Utility for moving scripts upwards
  156. Condition *findPreviousCondition( Condition *curCond );
  157. };
  158. //-------------------------------------------------------------------------------------------------
  159. // ******************************** class ScriptAction ***********************************************
  160. //-------------------------------------------------------------------------------------------------
  161. /** This is an action that can be executed by a script. The Action Types
  162. are defined by ActionTemplates created in the ScriptEngine::init method. */
  163. enum {MAX_PARMS=12};
  164. class ScriptAction : public MemoryPoolObject // This is the action class.
  165. {
  166. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ScriptAction, "ScriptAction")
  167. // friend bad for MPOs. (srj)
  168. //friend class EditAction;
  169. public:
  170. /// @todo Use a "symbol table" so we can re-order this enum without breaking old maps (MSB)
  171. enum ScriptActionType
  172. {
  173. DEBUG_MESSAGE_BOX=0, ///< Show a message box.
  174. SET_FLAG, ///< Set a flag true of false.
  175. SET_COUNTER, ///< Set a counter to an integer.
  176. VICTORY, ///< Announce victory.
  177. DEFEAT, ///< Announce defeat.
  178. NO_OP, ///< No op.
  179. SET_TIMER, ///< Start a frame timer.
  180. PLAY_SOUND_EFFECT, ///< Play sound.
  181. ENABLE_SCRIPT, ///< Enable script.
  182. DISABLE_SCRIPT, ///< Disable script.
  183. CALL_SUBROUTINE, ///< Call a subroutine.
  184. PLAY_SOUND_EFFECT_AT, ///< Play sound at location.
  185. DAMAGE_MEMBERS_OF_TEAM, ///< Damage team members (boom.)
  186. MOVE_TEAM_TO, ///< Move to.
  187. MOVE_CAMERA_TO, ///< Move camera to.
  188. INCREMENT_COUNTER, ///< Add to a counter.
  189. DECREMENT_COUNTER, ///< subtract from a counter.
  190. MOVE_CAMERA_ALONG_WAYPOINT_PATH, ///< Move camera along path.
  191. ROTATE_CAMERA, ///< Rotate camera.
  192. RESET_CAMERA, ///< Reset camera.
  193. SET_MILLISECOND_TIMER, ///< Start a time based timer.
  194. CAMERA_MOD_FREEZE_TIME, ///< Freeze time during a camera movement.
  195. SET_VISUAL_SPEED_MULTIPLIER, ///< Drop frames so that time "goes" faster..
  196. CREATE_OBJECT, ///< Create an object
  197. SUSPEND_BACKGROUND_SOUNDS, ///< Stop backgropund music & sounds.
  198. RESUME_BACKGROUND_SOUNDS, ///< Resume backgropund music & sounds.
  199. CAMERA_MOD_SET_FINAL_ZOOM, ///< Sets the final zoom for a camera movement
  200. CAMERA_MOD_SET_FINAL_PITCH, ///< Sets the final pitch for a camera movement
  201. CAMERA_MOD_FREEZE_ANGLE, ///< Freeze camera angle during a camera movement.
  202. CAMERA_MOD_SET_FINAL_SPEED_MULTIPLIER,///< Sets the final time multiplier for a camera movement.
  203. CAMERA_MOD_SET_ROLLING_AVERAGE, ///< Sets the number of frames to average changes (angle, positoin) to smooth out a camera movement.
  204. CAMERA_MOD_FINAL_LOOK_TOWARD, ///< Sets the look toward point for the end of a camera movement.
  205. CAMERA_MOD_LOOK_TOWARD, ///< Sets the look toward point during a camera movement.
  206. TEAM_ATTACK_TEAM, ///< Tell team to attack other team
  207. CREATE_REINFORCEMENT_TEAM, ///< Create a team of reinforcements.
  208. MOVE_CAMERA_TO_SELECTION, ///< Move the target to the selected item.
  209. TEAM_FOLLOW_WAYPOINTS, ///< Tell the team to begin following a path, starting at given waypoint
  210. TEAM_SET_STATE, ///< Set a team to a particular state.
  211. MOVE_NAMED_UNIT_TO, ///< Move a named unit to a position
  212. NAMED_ATTACK_NAMED, ///< Make a named unit attack another named unit
  213. CREATE_NAMED_ON_TEAM_AT_WAYPOINT, ///< Create a named unit on a team at a waypoint
  214. CREATE_UNNAMED_ON_TEAM_AT_WAYPOINT, ///< Create a unnamed unit on a team at a waypoint
  215. NAMED_APPLY_ATTACK_PRIORITY_SET, ///< Applies an attack priority set to a named unit
  216. TEAM_APPLY_ATTACK_PRIORITY_SET, ///< Applies an attack priority set to a team
  217. SET_BASE_CONSTRUCTION_SPEED, ///< Impl JKMCD
  218. NAMED_SET_ATTITUDE, ///< Impl JKMCD
  219. TEAM_SET_ATTITUDE, ///< Impl JKMCD
  220. NAMED_ATTACK_AREA, ///< Set a unit to attack an area
  221. NAMED_ATTACK_TEAM, ///< Impl JKMCD
  222. TEAM_ATTACK_AREA, ///< Set a team to attack an area
  223. TEAM_ATTACK_NAMED, ///< Set a team to attack a unit
  224. TEAM_LOAD_TRANSPORTS, ///< Set a team to auto-load transports
  225. NAMED_ENTER_NAMED, ///< Set a unit to enter a transport
  226. TEAM_ENTER_NAMED, ///< Set a team to enter a transport
  227. NAMED_EXIT_ALL, ///< Set a unit to exit its transport
  228. TEAM_EXIT_ALL, ///< Set a team to exit all transports
  229. NAMED_FOLLOW_WAYPOINTS, ///< Set a unit to follow a waypoint path
  230. NAMED_GUARD, ///< Set a unit to guard it's current location.
  231. TEAM_GUARD, ///< Set a team to guard it's current location.
  232. NAMED_HUNT, ///< Set a unit to hunt
  233. TEAM_HUNT, ///< Set a team to hunt
  234. PLAYER_SELL_EVERYTHING, ///< Set a player to sell everything
  235. PLAYER_DISABLE_BASE_CONSTRUCTION, ///< Disallow a player from building anymore base buildings
  236. PLAYER_DISABLE_FACTORIES, ///< Disallow a player from building from factories
  237. PLAYER_DISABLE_UNIT_CONSTRUCTION, ///< Disallow a player from building units
  238. PLAYER_ENABLE_BASE_CONSTRUCTION, ///< Allow a player to build bases
  239. PLAYER_ENABLE_FACTORIES, ///< Allow a player to build from his factories
  240. PLAYER_ENABLE_UNIT_CONSTRUCTION, ///< Allow a player to build units
  241. CAMERA_MOVE_HOME, ///< Impl JKMCD
  242. BUILD_TEAM, ///< Build a team from a teamtemplate
  243. NAMED_DAMAGE, ///< Damage a unit
  244. NAMED_DELETE, ///< Delete a unit
  245. TEAM_DELETE, ///< Delete a team
  246. NAMED_KILL, ///< Kill a unit
  247. TEAM_KILL, ///< Kill a team
  248. PLAYER_KILL, ///< Kill a player
  249. DISPLAY_TEXT, ///< Display a localized string
  250. CAMEO_FLASH, ///< Flashes a command button
  251. NAMED_FLASH, ///< Flashes a specific unit
  252. TEAM_FLASH, ///< Flashes a specific team
  253. MOVIE_PLAY_FULLSCREEN, ///< Play a movie in fullscreen
  254. MOVIE_PLAY_RADAR, ///< Play a movie in the radar
  255. SOUND_PLAY_NAMED, ///< Play a sound as though it comes from a unit
  256. SPEECH_PLAY, ///< Play a speech
  257. PLAYER_TRANSFER_OWNERSHIP_PLAYER, ///< Transfer ownership of all units to another player
  258. NAMED_TRANSFER_OWNERSHIP_PLAYER, ///< Transfer ownership of a single unit to another player
  259. PLAYER_RELATES_PLAYER, ///< Update player-player relations
  260. RADAR_CREATE_EVENT, ///< Impl JKMCD
  261. RADAR_DISABLE, ///< Disable the radar
  262. RADAR_ENABLE, ///< Enable the radar
  263. MAP_REVEAL_AT_WAYPOINT, ///< Reveal the map within a radius of waypoint.
  264. TEAM_AVAILABLE_FOR_RECRUITMENT, ///< Impl JKMCD
  265. TEAM_COLLECT_NEARBY_FOR_TEAM, ///< Impl JKMCD
  266. TEAM_MERGE_INTO_TEAM, ///< Merge a team into another team
  267. DISABLE_INPUT, ///< Disable user input
  268. ENABLE_INPUT, ///< Re-enable user input
  269. PLAYER_HUNT, ///< Set an entire player's team to hunt
  270. SOUND_AMBIENT_PAUSE, ///< Pause all ambient sounds
  271. SOUND_AMBIENT_RESUME, ///< Resume all ambient sounds
  272. MUSIC_SET_TRACK, ///< Set the current music track, allowing for fade-in and fade-out
  273. SET_TREE_SWAY, ///< Set the trees' sway
  274. DEBUG_STRING, ///< Output a debug string without stopping.
  275. MAP_REVEAL_ALL, ///< Reveal the entire map
  276. TEAM_GARRISON_SPECIFIC_BUILDING, ///< Garrison a specific building
  277. EXIT_SPECIFIC_BUILDING, ///< Empty a specific building
  278. TEAM_GARRISON_NEAREST_BUILDING, ///< Garrison a nearby building
  279. TEAM_EXIT_ALL_BUILDINGS, ///< Empty all buildings of units
  280. NAMED_GARRISON_SPECIFIC_BUILDING, ///< Send a unit to garrison a specific building
  281. NAMED_GARRISON_NEAREST_BUILDING, ///< Send a unit to garrison the nearest building
  282. NAMED_EXIT_BUILDING, ///< Tell a unit to exit the building its currently in
  283. PLAYER_GARRISON_ALL_BUILDINGS, ///< Garrison as many buildings as possible (filling each one up)
  284. PLAYER_EXIT_ALL_BUILDINGS, ///< Tell all buildings to empty themselves for this player.
  285. TEAM_WANDER, ///< Tell a team to wander.
  286. TEAM_PANIC, ///< Tell a team to panic.
  287. SETUP_CAMERA, ///< Set up an initial camera position.
  288. CAMERA_LETTERBOX_BEGIN, ///< Set the camera into letterbox mode
  289. CAMERA_LETTERBOX_END, ///< End the Letterbox mode.
  290. ZOOM_CAMERA, ///< Set camera zoom.
  291. PITCH_CAMERA, ///< Set camera pitch.
  292. CAMERA_FOLLOW_NAMED, ///< Camera follow named.
  293. OVERSIZE_TERRAIN, // Oversize the drawn terrain for effect.
  294. CAMERA_FADE_ADD, ///< Fade using an add blend
  295. CAMERA_FADE_SUBTRACT, ///< Fade using a subtract blend
  296. CAMERA_FADE_SATURATE, ///< Fade using a saturate blend
  297. CAMERA_FADE_MULTIPLY, ///< Fade using a multiply blend
  298. CAMERA_BW_MODE_BEGIN, ///< switch camera to black & white mode.
  299. CAMERA_BW_MODE_END, ///< switch camera back to color mode.
  300. DRAW_SKYBOX_BEGIN, ///< draw skybox
  301. DRAW_SKYBOX_END, ///< stop skybox
  302. SET_ATTACK_PRIORITY_THING, ///< Sets the attack priority for a single thing in a set.
  303. SET_ATTACK_PRIORITY_KIND_OF, ///< Sets the attack priority for all of a kind in a set.
  304. SET_DEFAULT_ATTACK_PRIORITY, ///< Sets the default attack priority for a set.
  305. CAMERA_STOP_FOLLOW, ///< Ends a camera follow named.
  306. CAMERA_MOTION_BLUR, ///< Starts a camera motion blur zoom
  307. CAMERA_MOTION_BLUR_JUMP, ///< Starts a camera motion blur in & out with jump.
  308. CAMERA_MOTION_BLUR_FOLLOW, ///< Starts a motion blur follow scrolling effect.
  309. CAMERA_MOTION_BLUR_END_FOLLOW, ///< Ends a motion blur follow scrolling effect.
  310. FREEZE_TIME, ///< Freeze time.
  311. UNFREEZE_TIME, ///< Unfreeze time.
  312. SHOW_MILITARY_CAPTION, ///< Display military-style briefing text
  313. CAMERA_SET_AUDIBLE_DISTANCE, ///< Sets the range for the audible distance
  314. SET_STOPPING_DISTANCE, ///< Sets the stopping distance for a team
  315. NAMED_SET_STOPPING_DISTANCE, ///< Sets the stopping distance for a named object
  316. SET_FPS_LIMIT, ///< Sets the max frames-per-second
  317. MUSIC_SET_VOLUME, ///< Adjust the track volume
  318. MAP_SHROUD_AT_WAYPOINT, ///< Shroud the map at this waypoint
  319. MAP_SHROUD_ALL, ///< Shroud the entire map
  320. SET_RANDOM_TIMER, ///< Start a random frame based timer.
  321. SET_RANDOM_MSEC_TIMER, ///< Start a random time based timer.
  322. STOP_TIMER, ///< Stop a timer. Remembers time stopped.
  323. RESTART_TIMER, ///< Restarts a stopped timer. Remembers time stopped.
  324. ADD_TO_MSEC_TIMER, ///< Adds time to a timer.
  325. SUB_FROM_MSEC_TIMER, ///< Subtracts time from a timer.
  326. TEAM_TRANSFER_TO_PLAYER, ///< Transfers a team to a player, maintaining team-ness
  327. PLAYER_SET_MONEY, ///< Set a player's cash reserves to a specific value.
  328. PLAYER_GIVE_MONEY, ///< // Add/subtract cash from a player's reserves.
  329. DISABLE_SPECIAL_POWER_DISPLAY, ///< hides the special power countdown display
  330. ENABLE_SPECIAL_POWER_DISPLAY, ///< shows the special power countdown display
  331. NAMED_HIDE_SPECIAL_POWER_DISPLAY, ///< hides the special power countdown display for an object
  332. NAMED_SHOW_SPECIAL_POWER_DISPLAY, ///< shows the special power countdown display for an object
  333. DISPLAY_COUNTDOWN_TIMER, ///< shows a countdown timer
  334. HIDE_COUNTDOWN_TIMER, ///< hides a countdown timer
  335. ENABLE_COUNTDOWN_TIMER_DISPLAY, ///< enables countdown timer display
  336. DISABLE_COUNTDOWN_TIMER_DISPLAY, ///< disables countdown timer display
  337. NAMED_STOP_SPECIAL_POWER_COUNTDOWN, ///< pauses the countdown for a special power
  338. NAMED_START_SPECIAL_POWER_COUNTDOWN,///< resumes the countdown for a special power
  339. NAMED_SET_SPECIAL_POWER_COUNTDOWN, ///< set special power countdown for an object
  340. NAMED_ADD_SPECIAL_POWER_COUNTDOWN, ///< add/subtract time from a special power countdown
  341. NAMED_FIRE_SPECIAL_POWER_AT_WAYPOINT, ///< fire a special power
  342. NAMED_FIRE_SPECIAL_POWER_AT_NAMED, ///< fire a special power
  343. REFRESH_RADAR, ///< Force the radar to recalculate the terrain
  344. CAMERA_TETHER_NAMED, ///< Tether the camera location to a named unit
  345. CAMERA_STOP_TETHER_NAMED, ///< Break tether
  346. CAMERA_SET_DEFAULT, ///< Set default angle, pitch, zoom, etc for camera
  347. NAMED_STOP, ///< Make a named unit stop (go idle)
  348. TEAM_STOP, ///< Make a team stop (go idle)
  349. TEAM_STOP_AND_DISBAND, ///< Make a team stop and be merged into the default player team. Also, mark the whole team recruitable
  350. RECRUIT_TEAM, ///< Recruit a team?
  351. TEAM_SET_OVERRIDE_RELATION_TO_TEAM, ///< override a team's relation to another team
  352. TEAM_REMOVE_OVERRIDE_RELATION_TO_TEAM, ///< remove that override
  353. TEAM_REMOVE_ALL_OVERRIDE_RELATIONS,///< remove all overrides
  354. CAMERA_LOOK_TOWARD_OBJECT, ///< Rotate the camera to be pointing toward a unit
  355. NAMED_FIRE_WEAPON_FOLLOWING_WAYPOINT_PATH, ///< Fires a specific weapon that follows waypoint path and detonates at the final waypoint.
  356. TEAM_SET_OVERRIDE_RELATION_TO_PLAYER, ///< override a team's relation to another player
  357. TEAM_REMOVE_OVERRIDE_RELATION_TO_PLAYER, ///< remove that override
  358. PLAYER_SET_OVERRIDE_RELATION_TO_TEAM, ///< override a Player's relation to another team
  359. PLAYER_REMOVE_OVERRIDE_RELATION_TO_TEAM, ///< remove that override
  360. UNIT_EXECUTE_SEQUENTIAL_SCRIPT, ///< Make a unit execute a script sequentially
  361. UNIT_EXECUTE_SEQUENTIAL_SCRIPT_LOOPING, ///< Make a unit execute a script sequentially (forever)
  362. UNIT_STOP_SEQUENTIAL_SCRIPT, ///< Make a unit stop executing its sequential scripts
  363. TEAM_EXECUTE_SEQUENTIAL_SCRIPT, ///< Make a team execute a script sequentially
  364. TEAM_EXECUTE_SEQUENTIAL_SCRIPT_LOOPING, ///< Make a team execute a script sequentially (forever)
  365. TEAM_STOP_SEQUENTIAL_SCRIPT, ///< Make a team stop executing its sequential scripts
  366. UNIT_GUARD_FOR_FRAMECOUNT, ///< Make a specific unit guard for a framecount
  367. UNIT_IDLE_FOR_FRAMECOUNT, ///< Make a specific unit stop idle for a framecount
  368. TEAM_GUARD_FOR_FRAMECOUNT, ///< Make a team guard for a framecount
  369. TEAM_IDLE_FOR_FRAMECOUNT, ///< Make a team stop idle for a framecount
  370. WATER_CHANGE_HEIGHT, ///< Adjust the water level
  371. NAMED_USE_COMMANDBUTTON_ABILITY_ON_NAMED, ///< Make a unit use an ability on another unit.
  372. NAMED_USE_COMMANDBUTTON_ABILITY_AT_WAYPOINT, ///< Make a unit use an ability on a waypoint.
  373. WATER_CHANGE_HEIGHT_OVER_TIME, ///< Adjust the water level over a period of time.
  374. MAP_SWITCH_BORDER, ///< Switch to border color <Blah>
  375. TEAM_GUARD_POSITION,
  376. TEAM_GUARD_OBJECT,
  377. TEAM_GUARD_AREA,
  378. OBJECT_FORCE_SELECT, ///< Force selection of the first object type on the player's team
  379. CAMERA_LOOK_TOWARD_WAYPOINT, ///< Rotate the camera to be pointing toward a waypoint
  380. UNIT_DESTROY_ALL_CONTAINED, ///< Destroy all units contained by the named unit
  381. RADAR_FORCE_ENABLE, ///< Force the radar to be on regardless of player status
  382. RADAR_REVERT_TO_NORMAL, ///< Undo forcing the radar to be on
  383. SCREEN_SHAKE, ///< Shake the entire screen
  384. TECHTREE_MODIFY_BUILDABILITY_OBJECT, ///< Modify how "buildable" something is.
  385. WAREHOUSE_SET_VALUE, ///< Set a Warehouse to have this much money.
  386. OBJECT_CREATE_RADAR_EVENT, ///< Create a radar event at this object
  387. TEAM_CREATE_RADAR_EVENT, ///< Create a radar event at this team
  388. DISPLAY_CINEMATIC_TEXT, ///< Displays a string in the bottom letterbox
  389. DEBUG_CRASH_BOX, ///< Debug/Internal builds only: do a crash box
  390. SOUND_DISABLE_TYPE,
  391. SOUND_ENABLE_TYPE,
  392. SOUND_ENABLE_ALL,
  393. AUDIO_OVERRIDE_VOLUME_TYPE,
  394. AUDIO_RESTORE_VOLUME_TYPE,
  395. AUDIO_RESTORE_VOLUME_ALL_TYPE,
  396. INGAME_POPUP_MESSAGE, ///< Popup an ingame popup message box
  397. SET_CAVE_INDEX, ///< Set the index of which set of caves a cave is connected to.
  398. NAMED_SET_HELD, ///< Sets a named object to be "held" in place or not
  399. NAMED_SET_TOPPLE_DIRECTION, ///< Set the topple direction of the specified direction
  400. UNIT_MOVE_TOWARDS_NEAREST_OBJECT_TYPE, ///< Move a named unit towards the nearest object of type type
  401. TEAM_MOVE_TOWARDS_NEAREST_OBJECT_TYPE, ///< For each member of the team, move towards the nearest object of type
  402. MAP_REVEAL_ALL_PERM,
  403. MAP_REVEAL_ALL_UNDO_PERM,
  404. NAMED_SET_REPULSOR, ///< Set a unit as a repulsor (scares) civilians.
  405. TEAM_SET_REPULSOR, ///< Set a team as a repulsor (scares) civilians.
  406. TEAM_WANDER_IN_PLACE, ///< Set a team to wander around their current position.
  407. TEAM_INCREASE_PRIORITY, ///< Increment a team's ai priority by it's success amount.
  408. TEAM_DECREASE_PRIORITY, ///< Decrease a team's ai prioiryt by it's failure amount.
  409. DISPLAY_COUNTER, ///< shows a counter
  410. HIDE_COUNTER, ///< hides a counter
  411. TEAM_USE_COMMANDBUTTON_ABILITY_ON_NAMED, ///< Make a team use an ability on another unit.
  412. TEAM_USE_COMMANDBUTTON_ABILITY_AT_WAYPOINT, ///< Make a team use an ability on a waypoint.
  413. NAMED_USE_COMMANDBUTTON_ABILITY, ///< Make a unit use an ability.
  414. TEAM_USE_COMMANDBUTTON_ABILITY, ///< Make a team use an ability.
  415. NAMED_FLASH_WHITE, ///< Flashes a specific unit
  416. TEAM_FLASH_WHITE, ///< Flashes a specific team
  417. SKIRMISH_BUILD_BUILDING, ///< Start building a building.
  418. SKIRMISH_FOLLOW_APPROACH_PATH, ///< Follow a particular route to the enemy.
  419. IDLE_ALL_UNITS, ///< cancel any current actions for one player (or all players)
  420. RESUME_SUPPLY_TRUCKING, ///< Re-enable supply trucking for *idle* trucks for one player (or all players)
  421. NAMED_CUSTOM_COLOR, ///< set a specific unit to use a special indicator color (not his controlling player's)
  422. SKIRMISH_MOVE_TO_APPROACH_PATH, ///< Follow a particular route to the enemy.
  423. SKIRMISH_BUILD_BASE_DEFENSE_FRONT, ///< Build some base defense on the front.
  424. SKIRMISH_FIRE_SPECIAL_POWER_AT_MOST_COST, ///< Fire a power or superweapon at the enemy's most costly concentration of structures & units..
  425. NAMED_RECEIVE_UPGRADE, ///< Unit receives an upgrade
  426. PLAYER_REPAIR_NAMED_STRUCTURE, ///< Send a dozer to repair a structure.
  427. SKIRMISH_BUILD_BASE_DEFENSE_FLANK, ///< Build some base defense on the flank.
  428. SKIRMISH_BUILD_STRUCTURE_FRONT, ///< Build some structure on the front.
  429. SKIRMISH_BUILD_STRUCTURE_FLANK, ///< Build some structure on the flank.
  430. SKIRMISH_ATTACK_NEAREST_GROUP_WITH_VALUE, ///< Send a team to attack the nearest group with value comparison
  431. SKIRMISH_PERFORM_COMMANDBUTTON_ON_MOST_VALUABLE_OBJECT, ///< Send a single unit/ all available to perform a command button action on the most valuable target
  432. SKIRMISH_WAIT_FOR_COMMANDBUTTON_AVAILABLE_ALL, ///< In a sequential script, stay on this step until the specified command button is ready for all units.
  433. SKIRMISH_WAIT_FOR_COMMANDBUTTON_AVAILABLE_PARTIAL,///< In a sequential script, stay on this step until the specified command button is ready for one unit on the team.
  434. TEAM_SPIN_FOR_FRAMECOUNT, ///< Tell the team to continue its current task without advancing for this number of frames
  435. TEAM_ALL_USE_COMMANDBUTTON_ON_NAMED, ///< Tell the team to use the commandbutton on a named enemy
  436. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_UNIT, ///< Tell the team to use the commandbutton on the nearest enemy unit
  437. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_GARRISONED_BUILDING, ///< Tell the team to use the commandbutton on the nearest enemy garrisoned building
  438. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_KINDOF, ///< Tell the team to use the commandbutton on the nearest enemy that has kindof set
  439. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_BUILDING, ///< Tell the team to use the commandbutton on the nearest enemy building
  440. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_ENEMY_BUILDING_CLASS, ///< Tell the team to use the commandbutton on the nearest enemy building class
  441. TEAM_ALL_USE_COMMANDBUTTON_ON_NEAREST_OBJECTTYPE, ///< Tell the team to use the commandbutton on the nearest enemy object of type
  442. TEAM_PARTIAL_USE_COMMANDBUTTON, ///< Tell some percentage of the team to use the commandbutton on
  443. TEAM_CAPTURE_NEAREST_UNOWNED_FACTION_UNIT,///< Tell the team to capture the nearest unowned faction unit (unit whose pilot has been killed by Jarmen Kell)
  444. PLAYER_CREATE_TEAM_FROM_CAPTURED_UNITS, ///< Tell the player to create a new named team from all the units who have been captured.
  445. PLAYER_ADD_SKILLPOINTS, ///< add/subtract skill points to the player.
  446. PLAYER_ADD_RANKLEVEL, ///< add/subtract ranklevel for the player.
  447. PLAYER_SET_RANKLEVEL, ///< set the player's ranklevel to an explicit level.
  448. PLAYER_SET_RANKLEVELLIMIT, ///< set the RankLevelLimit for the current map.
  449. PLAYER_GRANT_SCIENCE, ///< grant a Science to the player, regardless of prereqs, etc
  450. PLAYER_PURCHASE_SCIENCE, ///< the Player purchases the specified Science (if he has enough points, prereqs, etc)
  451. TEAM_HUNT_WITH_COMMAND_BUTTON, ///< Hunt using a command button ability.
  452. TEAM_WAIT_FOR_NOT_CONTAINED_ALL, ///< In a sequential script, stay on this step until the entire team is no longer contained
  453. TEAM_WAIT_FOR_NOT_CONTAINED_PARTIAL, ///< In a sequential script, stay on this step until at least one member of the team is no longer contained
  454. TEAM_FOLLOW_WAYPOINTS_EXACT, ///< Follows waypoints exactly.
  455. NAMED_FOLLOW_WAYPOINTS_EXACT, ///< Follows waypoints exactly.
  456. TEAM_SET_EMOTICON, ///< Adds specified emoticon to each unit in team (-1 permanent, 0 get rid of, 1+ duration in ms)
  457. NAMED_SET_EMOTICON, ///< Adds specified emoticon to named unit (-1 permanent, 0 get rid of, 1+ duration in ms)
  458. AI_PLAYER_BUILD_SUPPLY_CENTER, ///< Tell the ai player to build a supply center.
  459. AI_PLAYER_BUILD_UPGRADE, ///< Tell the ai player to build an upgrade.
  460. OBJECTLIST_ADDOBJECTTYPE, ///< Add the associated object to the named list
  461. OBJECTLIST_REMOVEOBJECTTYPE, ///< Remove the associated object to the named list
  462. MAP_REVEAL_PERMANENTLY_AT_WAYPOINT, ///< Reveal an area at a waypoint
  463. MAP_UNDO_REVEAL_PERMANENTLY_AT_WAYPOINT, ///< Undo a previous permanent reveal
  464. NAMED_SET_STEALTH_ENABLED, ///< Enables/disables stealth capability for a specific unit.
  465. TEAM_SET_STEALTH_ENABLED, ///< Enables/disables stealth capability for a team.
  466. EVA_SET_ENABLED_DISABLED, ///< Sets EVA to continue to evaluate messages or not.
  467. OPTIONS_SET_OCCLUSION_MODE, ///< Enables behind building functionality.
  468. LOCALDEFEAT, ///< Announce local player's defeat.
  469. OPTIONS_SET_DRAWICON_UI_MODE, ///< Enables/disables all emoticons.
  470. OPTIONS_SET_PARTICLE_CAP_MODE, ///< Enables/disables particle cap.
  471. PLAYER_SCIENCE_AVAILABILITY, ///< Determines the availability of a specific science.
  472. UNIT_AFFECT_OBJECT_PANEL_FLAGS, ///< Affects the various flags on the object panel for an individual unit
  473. TEAM_AFFECT_OBJECT_PANEL_FLAGS, ///< Affects the various flags on the object panel for all units on a team
  474. PLAYER_SELECT_SKILLSET, ///< Select the skillset for an AI player.
  475. SCRIPTING_OVERRIDE_HULK_LIFETIME, ///< Overrides the lifetime of hulks (for cinematic purposes).
  476. NAMED_FACE_NAMED, ///< Orders unit to face the position of the other named object.
  477. NAMED_FACE_WAYPOINT, ///< Orders unit to face a waypoint.
  478. TEAM_FACE_NAMED, ///< Orders all members of a team to face a specific unit.
  479. TEAM_FACE_WAYPOINT, ///< Orders all members of a team to face a waypoint.
  480. COMMANDBAR_REMOVE_BUTTON_OBJECTTYPE, ///< Remove a button from a command bar for an objecttype
  481. COMMANDBAR_ADD_BUTTON_OBJECTTYPE_SLOT, ///< Add a button to the command bar for an objecttype, in a specific slot
  482. UNIT_SPAWN_NAMED_LOCATION_ORIENTATION, ///< Create a named unit at the specified location, altitude, and orientation
  483. PLAYER_AFFECT_RECEIVING_EXPERIENCE, ///< Adjust whether or not a player is receieving experience for kills
  484. PLAYER_EXCLUDE_FROM_SCORE_SCREEN, ///< This player should be listed in the score screen. Should only be used in campaign games.
  485. TEAM_GUARD_SUPPLY_CENTER, ///< Have an ai team guard the nearest available supply center..
  486. ENABLE_SCORING, ///< Turn on scoring of kills, units destroyed, etc.
  487. DISABLE_SCORING, ///< Turn off scoring of kills, units destroyed, etc.
  488. SOUND_SET_VOLUME, ///< Adjust the volume of the sounds
  489. SPEECH_SET_VOLUME, ///< Adjust the volume of the speech
  490. DISABLE_BORDER_SHROUD, ///< Clear the shroud that draws off the map border
  491. ENABLE_BORDER_SHROUD, ///< Restore the shroud that draws off the map border (normally on)
  492. OBJECT_ALLOW_BONUSES, ///< Change whether or not the bonuses are applied to objects.
  493. SOUND_REMOVE_ALL_DISABLED, ///< Remove any and all disabled sounds from the sound channels.
  494. SOUND_REMOVE_TYPE, ///< Remove sound of type.
  495. TEAM_GUARD_IN_TUNNEL_NETWORK, ///< Team enters nearest tunnel network & guards.
  496. QUICKVICTORY, ///< End map in victory immediately.
  497. SET_INFANTRY_LIGHTING_OVERRIDE, ///< Overrides the natural lighting on infantry for closeups
  498. RESET_INFANTRY_LIGHTING_OVERRIDE, ///< And then goes back to the GlobalData defaults
  499. TEAM_DELETE_LIVING, ///< Delete only the living members of this team
  500. RESIZE_VIEW_GUARDBAND, ///< Allow bigger objects to be perceived as onscreen near the edge
  501. DELETE_ALL_UNMANNED, ///< Delete all unmanned (sniped) vehicles
  502. CHOOSE_VICTIM_ALWAYS_USES_NORMAL, ///< choose victim always uses normal AI behavior, ignoring game difficulty
  503. // add new items here, please
  504. NUM_ITEMS
  505. };
  506. ScriptAction(ScriptActionType type);
  507. //~ScriptAction();
  508. ScriptAction *duplicate(void) const;
  509. ScriptAction *duplicateAndQualify(const AsciiString& qualifier,
  510. const AsciiString& playerTemplateName, const AsciiString& newPlayerName) const;
  511. protected:
  512. ScriptAction(); ///< Protected constructor for read.
  513. protected:
  514. ScriptActionType m_actionType;
  515. Int m_numParms;
  516. Parameter * m_parms[MAX_PARMS];
  517. ScriptAction * m_nextAction;
  518. Bool m_hasWarnings; ///< Runtime flag used by the editor only.
  519. public:
  520. void setActionType(ScriptActionType type);
  521. public:
  522. void setNextAction(ScriptAction *pAct) {m_nextAction = pAct;}
  523. void setWarnings(Bool warnings) { m_hasWarnings = warnings;}
  524. ScriptActionType getActionType(void) {return m_actionType;}
  525. ScriptAction * getNext(void) {return m_nextAction;}
  526. AsciiString getUiText(void);
  527. Parameter *getParameter(Int ndx)
  528. {
  529. if (ndx>=0 && ndx<m_numParms)
  530. return m_parms[ndx];
  531. return NULL;
  532. }
  533. Bool hasWarnings(void) const { return m_hasWarnings;}
  534. Int getNumParameters(void) {return m_numParms;}
  535. Int getUiStrings(AsciiString strings[MAX_PARMS]);
  536. static void WriteActionDataChunk(DataChunkOutput &chunkWriter, ScriptAction *pAct);
  537. static Bool ParseActionDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  538. static void WriteActionFalseDataChunk(DataChunkOutput &chunkWriter, ScriptAction *pAct);
  539. static Bool ParseActionFalseDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  540. };
  541. //-------------------------------------------------------------------------------------------------
  542. // ******************************** class Script ***********************************************
  543. //-------------------------------------------------------------------------------------------------
  544. /** This is a script, in a linked list of scripts. The m_condition list is evaluated, and if one of the
  545. or clauses is true, the m_action list is executed. . */
  546. class Script : public MemoryPoolObject, public Snapshot
  547. {
  548. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Script, "Script")
  549. protected: // Note - If you add any member vars, you must take them into account in duplicate() and updateFrom(), as well as file read/write.
  550. // snapshot methods
  551. virtual void crc( Xfer *xfer );
  552. virtual void xfer( Xfer *xfer );
  553. virtual void loadPostProcess( void );
  554. AsciiString m_scriptName; ///<Short name.
  555. AsciiString m_comment; ///< Long comment.
  556. AsciiString m_conditionComment; ///< Long comment about conditions.
  557. AsciiString m_actionComment; ///< Long comment about actions.
  558. Int m_delayEvaluationSeconds; ///< Number of seconds to delay evaluation.
  559. Bool m_isActive; ///< If true, script is enabled. If false, disabled.
  560. Bool m_isOneShot; ///< If true, script is made not active after executing the m_action actions.
  561. Bool m_isSubroutine; ///< If true, script is a subroutine.
  562. Bool m_easy; ///< Applies to easy campaign.
  563. Bool m_normal; ///< Applies to normal campaign.
  564. Bool m_hard; ///< Applies to Hard campaign.
  565. OrCondition *m_condition; ///< First in a list of ORed clauses.
  566. ScriptAction *m_action; ///< First in a list of actions executed if the conditions are true.
  567. ScriptAction *m_actionFalse;///< First in a list of actions executed if the conditions are false.
  568. Script *m_nextScript; ///< Next in the list of scripts.
  569. // Runtime fields - not saved or read.
  570. UnsignedInt m_frameToEvaluateAt; ///< When to evaluate the conditions next, if m_delayEvaluationSeconds>0.
  571. Bool m_hasWarnings; ///< Runtime flag used by the editor only.
  572. AsciiString m_conditionTeamName; ///< Runtime name used by ScriptEngine only.
  573. Real m_conditionTime; ///< Amount of time (cum) to evaluate conditions.
  574. Real m_curTime; ///< Amount of time (cum) to evaluate conditions.
  575. Int m_conditionExecutedCount; ///< Number of times conditions evaluated.
  576. public:
  577. Script();
  578. //~Script();
  579. Script *duplicate(void) const; // note, duplicates just this node, not the full list.
  580. Script *duplicateAndQualify(const AsciiString& qualifier,
  581. const AsciiString& playerTemplateName, const AsciiString& newPlayerName) const;
  582. public:
  583. void setName(AsciiString name) { m_scriptName = name;}
  584. void setWarnings(Bool warnings) { m_hasWarnings = warnings;}
  585. void setComment(AsciiString comment) { m_comment = comment;}
  586. void setActionComment(AsciiString comment) { m_actionComment = comment;}
  587. void setConditionComment(AsciiString comment) { m_conditionComment = comment;}
  588. void setActive(Bool active) { m_isActive = active;}
  589. void setOneShot(Bool one) { m_isOneShot = one;}
  590. void setEasy(Bool easy) { m_easy = easy;}
  591. void setNormal(Bool normal) { m_normal = normal;}
  592. void setHard(Bool hard) { m_hard = hard;}
  593. void setSubroutine(Bool subr) { m_isSubroutine = subr;}
  594. void setNextScript(Script *pScr) {m_nextScript = pScr;}
  595. void setOrCondition(OrCondition *pCond) {m_condition = pCond;}
  596. void setAction(ScriptAction *pAction) {m_action = pAction;}
  597. void setFalseAction(ScriptAction *pAction) {m_actionFalse = pAction;}
  598. void updateFrom(Script *pSrc); ///< Updates this from pSrc. pSrc IS MODIFIED - it's guts are removed. jba.
  599. void setFrameToEvaluate(UnsignedInt frame) {m_frameToEvaluateAt=frame;}
  600. void incrementConditionCount(void) {m_conditionExecutedCount++;}
  601. void addToConditionTime(Real time) {m_conditionTime += time;}
  602. void setCurTime(Real time) {m_curTime = time;}
  603. void setDelayEvalSeconds(Int delay) {m_delayEvaluationSeconds = delay;}
  604. UnsignedInt getFrameToEvaluate(void) {return m_frameToEvaluateAt;}
  605. Int getConditionCount(void) {return m_conditionExecutedCount;}
  606. Real getConditionTime(void) {return m_conditionTime;}
  607. Real getCurTime(void) {return m_curTime;}
  608. Int getDelayEvalSeconds(void) {return m_delayEvaluationSeconds;}
  609. AsciiString getName(void) const { return m_scriptName;}
  610. AsciiString getComment(void) const {return m_comment;}
  611. AsciiString getActionComment(void) const {return m_actionComment;}
  612. AsciiString getConditionComment(void) const {return m_conditionComment;}
  613. Bool hasWarnings(void) const { return m_hasWarnings;}
  614. Bool isActive(void) const { return m_isActive;}
  615. Bool isOneShot(void) const { return m_isOneShot;}
  616. Bool isEasy(void) const { return m_easy;}
  617. Bool isNormal(void) const { return m_normal;}
  618. Bool isHard(void) const { return m_hard;}
  619. Bool isSubroutine(void) const { return m_isSubroutine;}
  620. Script *getNext(void) const {return m_nextScript;}
  621. OrCondition *getOrCondition(void) const {return m_condition;}
  622. ScriptAction *getAction(void) const {return m_action;}
  623. ScriptAction *getFalseAction(void) const {return m_actionFalse;}
  624. AsciiString getUiText(void);
  625. void deleteOrCondition(OrCondition *pCond);
  626. void deleteAction(ScriptAction *pAct);
  627. void deleteFalseAction(ScriptAction *pAct);
  628. static void WriteScriptDataChunk(DataChunkOutput &chunkWriter, Script *pScript);
  629. static Script *ParseScript(DataChunkInput &file, unsigned short version);
  630. static Bool ParseScriptFromListDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  631. static Bool ParseScriptFromGroupDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  632. // Support routines for moving conditions around
  633. OrCondition *findPreviousOrCondition( OrCondition *curOr );
  634. // Support routines for ScriptEngine -
  635. AsciiString getConditionTeamName(void) {return m_conditionTeamName;}
  636. void setConditionTeamName(AsciiString teamName) {m_conditionTeamName = teamName;}
  637. };
  638. //-------------------------------------------------------------------------------------------------
  639. // ******************************** class Parameter ***********************************************
  640. //-------------------------------------------------------------------------------------------------
  641. /** This is a parameter, in either a condition or an action. */
  642. class Parameter : public MemoryPoolObject
  643. {
  644. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Parameter, "Parameter")
  645. // friend bad for MPOs. (srj)
  646. //friend class EditParameter;
  647. //friend class EditCoordParameter;
  648. //friend class EditObjectParameter;
  649. //friend class ScriptEngine;
  650. //friend class ScriptConditions;
  651. public:
  652. enum ParameterType
  653. {
  654. INT=0, // Int.
  655. REAL, // Real.
  656. SCRIPT, // String. Any script.
  657. TEAM, // String.
  658. COUNTER, // String, int index into counters array at runtime.
  659. FLAG, // String, int index into flags array at runtime.
  660. COMPARISON, // Int, see comparison types below.
  661. WAYPOINT, // String.
  662. BOOLEAN, // Int 0 or 1 for flags.
  663. TRIGGER_AREA, // String.
  664. TEXT_STRING, // String.
  665. SIDE, // String.
  666. SOUND, // String.
  667. SCRIPT_SUBROUTINE, // String. Script that is a subroutine.
  668. UNIT, // String. Name of a unit.
  669. OBJECT_TYPE, // String. Name of a thing template.
  670. COORD3D, // String. (x,y,z), ie (2.0,7,5). Use getCoord()
  671. ANGLE, // Real. Radians.
  672. TEAM_STATE, // String. Name of a state that a team is in.
  673. RELATION, // Int. Specifies the relation towards a team
  674. AI_MOOD, // Int. Specifies the aggressiveness towards a team.
  675. DIALOG, // String, specifies string usable with getSpeech(...)
  676. MUSIC, // String, specifies string usable with getTrack(...)
  677. MOVIE, // String, specifies string usable with open(...) or load(...)
  678. WAYPOINT_PATH, // String, waypoint path label.
  679. LOCALIZED_TEXT, // String, must be looked up from the localized text file.
  680. BRIDGE, // String, Named bridge.
  681. KIND_OF_PARAM, // Integer, KindOfType enum.
  682. ATTACK_PRIORITY_SET,// String, name of an attack priority set.
  683. RADAR_EVENT_TYPE, // Int. Specifies the radar Event type
  684. SPECIAL_POWER, // String, specifies superweapon types
  685. SCIENCE, // String, specifies a science/general/faction/buzzword-of-the-week
  686. UPGRADE, // String, specifies a type of upgrade
  687. COMMANDBUTTON_ABILITY, // Int, refers to the appropriate 1-12 commandbutton that is used for an object.
  688. BOUNDARY, // Int, specifies a boundary index.
  689. BUILDABLE, // Int, specifies buildability of a specific object.
  690. SURFACES_ALLOWED, // Int, specifies whether the check should consider Air, Ground, or Air and Ground
  691. SHAKE_INTENSITY, // Int, specifies which Intensity to use (Intensity in 10 cities!)
  692. COMMAND_BUTTON, // String
  693. FONT_NAME, // String, the name of the desired font
  694. OBJECT_STATUS, // String, specifies ObjectStatusBits name. However, translated to an int on read.
  695. COMMANDBUTTON_ALL_ABILITIES, // String, refers to all command buttons
  696. SKIRMISH_WAYPOINT_PATH, // String, name of a predefined skirmish waypoint path.
  697. COLOR, // color (as int) in ARGB format.
  698. EMOTICON, // List of all possible emoticons.
  699. OBJECT_PANEL_FLAG, // String, specifies a flag name available on the options panel.
  700. FACTION_NAME, // The name of the faction (GLA, America, Munkee, China, etc)
  701. OBJECT_TYPE_LIST, // String, Special case of Object Type.
  702. REVEALNAME, // String, the name of the look taking place.
  703. SCIENCE_AVAILABILITY, // String, the name of the different science availabilities.
  704. NUM_ITEMS
  705. };
  706. enum { // Comparison types. Stored in Int value.
  707. LESS_THAN = 0,
  708. LESS_EQUAL,
  709. EQUAL,
  710. GREATER_EQUAL,
  711. GREATER,
  712. NOT_EQUAL
  713. };
  714. enum { // Relation types. Stored in Int value. (Values from GameCommon.h)
  715. REL_ENEMY = ENEMIES,
  716. REL_NEUTRAL = NEUTRAL,
  717. REL_FRIEND = ALLIES
  718. };
  719. Parameter(ParameterType type, int val = 0) :
  720. m_initialized(false),
  721. m_paramType(type),
  722. m_int(val),
  723. m_real(0)
  724. {
  725. m_coord.x=0;m_coord.y=0;m_coord.z=0;
  726. }
  727. private:
  728. ParameterType m_paramType;
  729. Bool m_initialized;
  730. Int m_int;
  731. Real m_real;
  732. AsciiString m_string;
  733. Coord3D m_coord;
  734. protected:
  735. void setInt(Int i) {m_int = i;}
  736. void setReal(Real r) {m_real = r;}
  737. void setCoord3D(const Coord3D *pLoc);
  738. void setString(AsciiString s) {m_string = s;}
  739. public:
  740. Int getInt(void) const {return m_int;}
  741. Real getReal(void) const {return m_real;}
  742. void getCoord3D(Coord3D *pLoc) const;
  743. ParameterType getParameterType(void) const {return m_paramType;}
  744. void friend_setInt(Int i) {m_int = i;}
  745. void friend_setReal(Real r) {m_real = r;}
  746. void friend_setCoord3D(const Coord3D *pLoc) { setCoord3D(pLoc); }
  747. void friend_setString(AsciiString s) {m_string = s;}
  748. void qualify(const AsciiString& qualifier,const AsciiString& playerTemplateName,const AsciiString& newPlayerName);
  749. const AsciiString& getString(void) const {return m_string;}
  750. AsciiString getUiText(void) const;
  751. void WriteParameter(DataChunkOutput &chunkWriter);
  752. static Parameter *ReadParameter(DataChunkInput &file);
  753. };
  754. EMPTY_DTOR(Parameter)
  755. extern const char* TheObjectFlagsNames[];
  756. //-------------------------------------------------------------------------------------------------
  757. // ******************************** class Condition ***********************************************
  758. //-------------------------------------------------------------------------------------------------
  759. /** This is a condition. The parameters for a ConditionType are set up in
  760. ConditionTemplates created in ScriptEngine::init.
  761. // SPECIAL NOTE ABOUT Skirmish Scripts: Please note that ALL Skirmish conditions should first pass a pSkirmishPlayerParm to
  762. // prevet the necessity of having to write additional scripts for other players / skirmish types later.
  763. */
  764. class Condition : public MemoryPoolObject // This is the conditional class.
  765. {
  766. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Condition, "Condition")
  767. // friend bad for MPOs. (srj)
  768. //friend class EditCondition;
  769. public:
  770. enum ConditionType
  771. {
  772. CONDITION_FALSE=0, // Always evaluates to false.
  773. COUNTER, // COUNTER, COMPARISON, INT
  774. FLAG, // FLAG BOOLEAN compares flag to value.
  775. CONDITION_TRUE, // Always evaluates to true.
  776. TIMER_EXPIRED, // If a timer expired.
  777. PLAYER_ALL_DESTROYED, // If a side (player) is totally destroyed.
  778. PLAYER_ALL_BUILDFACILITIES_DESTROYED, // If a side (player) has all build facilities destroyed.
  779. TEAM_INSIDE_AREA_PARTIALLY, // If a player has units from a team entering an area.
  780. TEAM_DESTROYED, // If a team has been destroyed.
  781. CAMERA_MOVEMENT_FINISHED, // If the camera has completed it's current movement.
  782. TEAM_HAS_UNITS, // If a team has units.
  783. TEAM_STATE_IS, // If a team is in a particular state.
  784. TEAM_STATE_IS_NOT, // If a team is not in a particular state.
  785. NAMED_INSIDE_AREA, // If a player has units inside an area.
  786. NAMED_OUTSIDE_AREA, // If a player has units outside an area.
  787. NAMED_DESTROYED, // If a unit is destroyed
  788. NAMED_NOT_DESTROYED, // If a unit is destroyed
  789. TEAM_INSIDE_AREA_ENTIRELY, // If a team is entirely inside an area.
  790. TEAM_OUTSIDE_AREA_ENTIRELY, // If a team is entirely outside an area.
  791. NAMED_ATTACKED_BY_OBJECTTYPE, // If a unit has been attacked by an object of type objecttype
  792. TEAM_ATTACKED_BY_OBJECTTYPE, // If a team has been attacked by an object of type objecttype
  793. NAMED_ATTACKED_BY_PLAYER, // If a unit has been attacked by a unit controlled by player
  794. TEAM_ATTACKED_BY_PLAYER, // If a team has been attacked by a unit controlled by player
  795. BUILT_BY_PLAYER, // If a unit of type objecttype has been built by player
  796. NAMED_CREATED, // If a unit is currently in existence
  797. TEAM_CREATED, // If a team is currently in existence
  798. PLAYER_HAS_CREDITS, // If X [Less Than | Equal | More than] Players credits
  799. NAMED_DISCOVERED, // If a named unit is currently "seen" by a player.
  800. TEAM_DISCOVERED, // If a unit in a team is currently "seen" by a player.
  801. MISSION_ATTEMPTS, // Impl JKMCD
  802. NAMED_OWNED_BY_PLAYER, // If a unit is currently owned by a player
  803. TEAM_OWNED_BY_PLAYER, // If a team is currently owned by a player
  804. PLAYER_HAS_N_OR_FEWER_BUILDINGS, // If a player has count or fewer buildings
  805. PLAYER_HAS_POWER, // If a player currently has power to his facilities
  806. NAMED_REACHED_WAYPOINTS_END, // If a unit has reached the end of the path that contains Waypoint
  807. TEAM_REACHED_WAYPOINTS_END, // If a team has reached the end of the path that contains Waypoint
  808. NAMED_SELECTED, // If a unit is selected
  809. NAMED_ENTERED_AREA, // If a unit enters an area
  810. NAMED_EXITED_AREA, // If a unit exits an area
  811. TEAM_ENTERED_AREA_ENTIRELY, // If a team has entirely entered an area
  812. TEAM_ENTERED_AREA_PARTIALLY, // If a team has exactly one unit entering an area
  813. TEAM_EXITED_AREA_ENTIRELY, // If a team has entirely exited an area
  814. TEAM_EXITED_AREA_PARTIALLY, // If a team has exactly one unit exiting an area
  815. MULTIPLAYER_ALLIED_VICTORY, // If a single group of allies has vanquished everyone else
  816. MULTIPLAYER_ALLIED_DEFEAT, // If a single group of allies has been vanquished
  817. MULTIPLAYER_PLAYER_DEFEAT, // If a player (but not necessarily his allies) has been defeated
  818. PLAYER_HAS_NO_POWER, // If a player doesn't have power
  819. HAS_FINISHED_VIDEO, // If a video has completed playing
  820. HAS_FINISHED_SPEECH, // If a speech has completed playing
  821. HAS_FINISHED_AUDIO, // If an audio piece has completed playing
  822. BUILDING_ENTERED_BY_PLAYER, // If a player has garrisoned a building.
  823. ENEMY_SIGHTED, // If a unit sees any type of unit/building belonging to a player.
  824. UNIT_HEALTH, // Compares the unit health
  825. BRIDGE_REPAIRED, // If a bridge has been repaired.
  826. BRIDGE_BROKEN, // If a bridge has been broken.
  827. NAMED_DYING, // A unit has been killed, but is in the process of dying (using slow death state)
  828. NAMED_TOTALLY_DEAD, // A unit is done dying.
  829. PLAYER_HAS_OBJECT_COMPARISON, // Does a player have more/less than X number of units of type object
  830. OBSOLETE_SCRIPT_1, // Obsolete!
  831. OBSOLETE_SCRIPT_2, // Obsolete!
  832. PLAYER_TRIGGERED_SPECIAL_POWER, // has a player triggered a specific special power type
  833. PLAYER_COMPLETED_SPECIAL_POWER, // has a player's special power completed?
  834. PLAYER_MIDWAY_SPECIAL_POWER, // If the special power is midway through activation
  835. PLAYER_TRIGGERED_SPECIAL_POWER_FROM_NAMED, // has a player triggered a specific special power type
  836. PLAYER_COMPLETED_SPECIAL_POWER_FROM_NAMED, // has a player's special power completed?
  837. PLAYER_MIDWAY_SPECIAL_POWER_FROM_NAMED, // If the special power is midway through activation
  838. DEFUNCT_PLAYER_SELECTED_GENERAL, // no longer in use!
  839. DEFUNCT_PLAYER_SELECTED_GENERAL_FROM_NAMED, // no longer in use!
  840. PLAYER_BUILT_UPGRADE, // If a player built a specific upgrade
  841. PLAYER_BUILT_UPGRADE_FROM_NAMED, // If a player built a specific upgrade from a specific building
  842. PLAYER_DESTROYED_N_BUILDINGS_PLAYER, // If a player has destroyed N or more buildings of a specific player
  843. UNIT_COMPLETED_SEQUENTIAL_EXECUTION, // If a unit has completed sequential execution
  844. TEAM_COMPLETED_SEQUENTIAL_EXECUTION, // If a team has completed sequential execution
  845. PLAYER_HAS_COMPARISON_UNIT_TYPE_IN_TRIGGER_AREA, // If player has a specific unit or building type...
  846. PLAYER_HAS_COMPARISON_UNIT_KIND_IN_TRIGGER_AREA, // If player has a kindof in a trigger area.
  847. UNIT_EMPTIED, // True if a unit has just emptied its cargo
  848. TYPE_SIGHTED, // True if a specific unit has just seen a type of unit belonging to a specific player
  849. NAMED_BUILDING_IS_EMPTY, // True if a specific building is empty
  850. PLAYER_HAS_N_OR_FEWER_FACTION_BUILDINGS, // If a player has count or fewer faction buildings
  851. UNIT_HAS_OBJECT_STATUS, // True if an object has that object status bit set to true
  852. TEAM_ALL_HAS_OBJECT_STATUS, // True if all objects on a team have that object status bit set to true
  853. TEAM_SOME_HAVE_OBJECT_STATUS, // True if an object on the team has that object status bit set to true
  854. PLAYER_POWER_COMPARE_PERCENT, // True if a player's power ratio compares to a percentage.
  855. PLAYER_EXCESS_POWER_COMPARE_VALUE, // True if a player has comparison power in kilowatts.
  856. SKIRMISH_SPECIAL_POWER_READY, // True if the special power is ready to fire.
  857. SKIRMISH_VALUE_IN_AREA, // True if the units in an area are worth comparison to a value
  858. SKIRMISH_PLAYER_FACTION, // True if player is a specific faction
  859. SKIRMISH_SUPPLIES_VALUE_WITHIN_DISTANCE,// True if there are supplies within distance of the perimeter
  860. SKIRMISH_TECH_BUILDING_WITHIN_DISTANCE, // True if there is a tech building within distance of the perimeter
  861. SKIRMISH_COMMAND_BUTTON_READY_ALL, // True when ???
  862. SKIRMISH_COMMAND_BUTTON_READY_PARTIAL, // True when ???
  863. SKIRMISH_UNOWNED_FACTION_UNIT_EXISTS, // True if there are comparison to unowned faction unit on the map.
  864. SKIRMISH_PLAYER_HAS_PREREQUISITE_TO_BUILD, // True if we can build this thing (we have prerequisites)
  865. SKIRMISH_PLAYER_HAS_COMPARISON_GARRISONED, // True if there are comparison to garrisoned buildings (by player) on the map
  866. SKIRMISH_PLAYER_HAS_COMPARISON_CAPTURED_UNITS, // True if there are comparison to captured units
  867. SKIRMISH_NAMED_AREA_EXIST, // True if a named area exists
  868. SKIRMISH_PLAYER_HAS_UNITS_IN_AREA, // True if a player has units in an area
  869. SKIRMISH_PLAYER_HAS_BEEN_ATTACKED_BY_PLAYER, // True if the player has been attacked by a player
  870. SKIRMISH_PLAYER_IS_OUTSIDE_AREA, // True if player doesn't have any units in an area
  871. SKIRMISH_PLAYER_HAS_DISCOVERED_PLAYER, // True if a player has discovered another player
  872. PLAYER_ACQUIRED_SCIENCE, // True if the player has acquired the specified Science.
  873. PLAYER_HAS_SCIENCEPURCHASEPOINTS, // True if the player has at least N SciencePurchasePoints.
  874. PLAYER_CAN_PURCHASE_SCIENCE, // True is player can purchase the given science (has all prereqs & points needed)
  875. MUSIC_TRACK_HAS_COMPLETED, // True if the specified track has completed at least N times
  876. PLAYER_LOST_OBJECT_TYPE, // True if a player has lost a specific unit type
  877. SUPPLY_SOURCE_SAFE, // True if the nearest available supply source is not under enemy influence.
  878. SUPPLY_SOURCE_ATTACKED, // True if our supply depot or dozer near depot was attacked.
  879. START_POSITION_IS, // True if our start position matches.
  880. NUM_ITEMS // Always the last condition.
  881. };
  882. Condition(enum ConditionType type);
  883. //~Condition();
  884. Condition *duplicate(void) const;
  885. Condition *duplicateAndQualify(const AsciiString& qualifier,
  886. const AsciiString& playerTemplateName, const AsciiString& newPlayerName) const;
  887. protected:
  888. Condition(); ///< Protected constructor for read.
  889. protected:
  890. enum ConditionType m_conditionType;
  891. Int m_numParms;
  892. Parameter *m_parms[MAX_PARMS];
  893. Condition *m_nextAndCondition;
  894. Int m_hasWarnings; ///< Runtime flag used by the editor only.
  895. Int m_customData;
  896. public:
  897. void setConditionType(enum ConditionType type);
  898. public:
  899. void setNextCondition(Condition *pScr) {m_nextAndCondition = pScr;}
  900. void setWarnings(Bool warnings) { m_hasWarnings = warnings;}
  901. enum ConditionType getConditionType(void) {return m_conditionType;}
  902. Condition * getNext(void) {return m_nextAndCondition;}
  903. AsciiString getUiText(void);
  904. Parameter *getParameter(Int ndx)
  905. {
  906. if (ndx>=0 && ndx<m_numParms)
  907. return m_parms[ndx];
  908. return NULL;
  909. }
  910. Int getNumParameters(void) {return m_numParms;}
  911. Int getUiStrings(AsciiString strings[MAX_PARMS]);
  912. Bool hasWarnings(void) const { return m_hasWarnings;}
  913. Int getCustomData(void) const {return m_customData;}
  914. void setCustomData(Int val) { m_customData = val;}
  915. static void WriteConditionDataChunk(DataChunkOutput &chunkWriter, Condition *pCond);
  916. static Bool ParseConditionDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  917. };
  918. //-------------------------------------------------------------------------------------------------
  919. // ******************************** class Template ***********************************************
  920. //-------------------------------------------------------------------------------------------------
  921. /** The template defines the parameters and ui strings used to display a
  922. condition or action. */
  923. class Template : public MemoryPoolObject
  924. {
  925. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Template, "Template")
  926. // friend bad for MPOs. (srj)
  927. //friend class ScriptEngine;
  928. public:
  929. AsciiString m_name;
  930. Int m_numUiStrings;
  931. AsciiString m_uiStrings[MAX_PARMS];
  932. Int m_numParameters;
  933. enum Parameter::ParameterType m_parameters[MAX_PARMS];
  934. public:
  935. Template();
  936. public:
  937. AsciiString getName(void) const {return m_name;}
  938. Int getUiStrings(AsciiString strings[MAX_PARMS]) const;
  939. Int getNumParameters(void) const {return m_numParameters;}
  940. enum Parameter::ParameterType getParameterType(Int ndx) const;
  941. };
  942. EMPTY_DTOR(Template)
  943. //-------------------------------------------------------------------------------------------------
  944. // ******************************** class ConditionTemplate ***********************************************
  945. //-------------------------------------------------------------------------------------------------
  946. /// Template for condition.
  947. class ConditionTemplate : public Template{};
  948. //-------------------------------------------------------------------------------------------------
  949. // ******************************** class ActionTemplate ***********************************************
  950. //-------------------------------------------------------------------------------------------------
  951. /// Template for action.
  952. class ActionTemplate : public Template{};
  953. //-------------------------------------------------------------------------------------------------
  954. // ******************************** class ScriptList ***********************************************
  955. //-------------------------------------------------------------------------------------------------
  956. /// List of scripts. May have one level of hierarchy in the ScriptGroup list.
  957. class ScriptList : public MemoryPoolObject, public Snapshot
  958. // A script list belongs to a Player. It contains the heads of the
  959. // the top level scripts, and the script groups.
  960. {
  961. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ScriptList, "ScriptList")
  962. protected:
  963. // snapshot methods
  964. virtual void crc( Xfer *xfer );
  965. virtual void xfer( Xfer *xfer );
  966. virtual void loadPostProcess( void );
  967. ScriptGroup *m_firstGroup;
  968. Script *m_firstScript;
  969. static Int m_curId;
  970. static ScriptList *s_readLists[MAX_PLAYER_COUNT];
  971. static Int s_numInReadList;
  972. public:
  973. ScriptList();
  974. //~ScriptList();
  975. public:
  976. static void updateDefaults(void);
  977. static void reset(void);
  978. static Int getNextID(void) {m_curId++; return m_curId;};
  979. public:
  980. ScriptGroup *getScriptGroup(void) {return m_firstGroup;};
  981. Script *getScript(void) {return m_firstScript;};
  982. void WriteScriptListDataChunk(DataChunkOutput &chunkWriter);
  983. static Bool ParseScriptListDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  984. void addGroup(ScriptGroup *pGrp, Int ndx);
  985. void addScript(Script *pScr, Int ndx);
  986. void deleteScript(Script *pScr);
  987. void deleteGroup(ScriptGroup *pGrp);
  988. void discard(void);
  989. ScriptList *duplicate(void) const;
  990. ScriptList *duplicateAndQualify(const AsciiString& qualifier,
  991. const AsciiString& playerTemplateName, const AsciiString& newPlayerName ) const;
  992. /// Reads a set of scripts into m_readScripts. Use getReadScripts to access.
  993. static Bool ParseScriptsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData);
  994. /// Writes sides (including build list info.)
  995. static void WriteScriptsDataChunk(DataChunkOutput &chunkWriter, ScriptList *scriptLists[], Int numLists);
  996. /// Returns array of script list pointers. This can only be called once after scripts
  997. /// are read, and the caller is responsible for deleting the scripts.
  998. static Int getReadScripts(ScriptList *scriptLists[MAX_PLAYER_COUNT]);
  999. };
  1000. #endif