Scripts.h 62 KB

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