mission2.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. /*
  2. ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: Mission2.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the very first training mission
  10. **
  11. ** History:
  12. */
  13. #include "pch.h"
  14. #include "Mission2.h"
  15. #include "Training.h"
  16. #include "GoalList.h"
  17. #include "Predicate.h"
  18. #include "TrueCondition.h"
  19. #include "FalseCondition.h"
  20. #include "AndCondition.h"
  21. #include "OrCondition.h"
  22. #include "NotCondition.h"
  23. #include "PeriodicCondition.h"
  24. #include "ElapsedTimeCondition.h"
  25. #include "ObjectMovingTowardsCondition.h"
  26. #include "ObjectWithinRadiusCondition.h"
  27. #include "ObjectPointingAtCondition.h"
  28. #include "ConditionalAction.h"
  29. #include "ConditionList.h"
  30. #include "ActionList.h"
  31. #include "MessageAction.h"
  32. #include "PlaySoundAction.h"
  33. #include "SetCommandAction.h"
  34. #include "NoAction.h"
  35. #include "NTimesCondition.h"
  36. #include "EndMissionAction.h"
  37. #include "ResetAction.h"
  38. #include "ResetShipAction.h"
  39. #include "SoundFinishedCondition.h"
  40. #include "SetDisplayModeAction.h"
  41. #include "TurnShipAboutCondition.h"
  42. #include "GetRadarLODCondition.h"
  43. #include "SetRadarLODAction.h"
  44. #include "GetControlActiveCondition.h"
  45. #include "GetStateBitsCondition.h"
  46. #include "GetShipIsStoppedCondition.h"
  47. #include "GetShipIsDestroyedCondition.h"
  48. #include "SetControlConstraintsAction.h"
  49. #include "SetControlsAction.h"
  50. #include "GetAutopilotCondition.h"
  51. #include "SetAutopilotAction.h"
  52. #include "SetSignatureAction.h"
  53. #include "GetTargetCondition.h"
  54. #include "CommandAcknowledgedCondition.h"
  55. #include "GetCommandCondition.h"
  56. #include "ReleaseConsumerAction.h"
  57. #include "CreateProbeAction.h"
  58. #include "CreateDroneAction.h"
  59. #include "CreateWaypointAction.h"
  60. #include "SetHUDOverlayAction.h"
  61. #include "GetKeyCondition.h"
  62. #include "TurnToAction.h"
  63. #include "ProxyCondition.h"
  64. #include "missionIGC.h"
  65. namespace Training
  66. {
  67. //------------------------------------------------------------------------------
  68. // class methods
  69. //------------------------------------------------------------------------------
  70. /* void */ Mission2::~Mission2 (void)
  71. {
  72. }
  73. //------------------------------------------------------------------------------
  74. int Mission2::GetMissionID (void)
  75. {
  76. return c_TM_2_Basic_Flight;
  77. }
  78. //------------------------------------------------------------------------------
  79. SectorID Mission2::GetStartSectorID (void)
  80. {
  81. return 1010;
  82. }
  83. //------------------------------------------------------------------------------
  84. bool Mission2::ShipLanded (void)
  85. {
  86. Terminate ();
  87. return false;
  88. }
  89. //------------------------------------------------------------------------------
  90. void Mission2::CreateUniverse (void)
  91. {
  92. LoadUniverse ("training_1", 412, 1010); // an interceptor
  93. // make the universe bigger so people don't die going out of bounds
  94. trekClient.GetCore ()->SetFloatConstant (c_fcidRadiusUniverse, 20000.0f);
  95. trekClient.GetCore ()->SetFloatConstant (c_fcidOutOfBounds, 100.0f);
  96. // stuff for setup
  97. ImissionIGC* pCore = trekClient.GetCore();
  98. // put the commander ship in the scene
  99. IshipIGC* pCommander = pCore->GetShip (m_commanderID);
  100. assert (pCommander);
  101. Vector position (500.0f, 0.0f, 0.0f);
  102. pCommander->SetPosition (position);
  103. pCommander->SetOrientation (Orientation (pCommander->GetOrientation ().GetForward () * -1.0f, position * -1.0f));
  104. pCommander->SetCluster (pCore->GetCluster(1010));
  105. }
  106. //------------------------------------------------------------------------------
  107. Condition* Mission2::CreateMission (void)
  108. {
  109. // create the goal and the goal list
  110. GoalList* pGoalList = new GoalList;
  111. Goal* pGoal = new Goal (pGoalList);
  112. // put a constraint that will point the back in if it's more than 7500m from the base
  113. ImodelIGC* pShip = static_cast<ImodelIGC*> (trekClient.GetShip ());
  114. TurnToAction* pTurnToAction = new TurnToAction (pShip, OT_station, 1010);
  115. ObjectWithinRadiusCondition* pObjectWithinRadiusCondition = new ObjectWithinRadiusCondition (pShip, OT_station, 1010, 7500.0f);
  116. ObjectWithinRadiusCondition* pObjectWithinRadiusCondition2 = new ObjectWithinRadiusCondition (pShip, OT_station, 1010, 7000.0f);
  117. ConditionalAction* pConditionalAction = new ConditionalAction (new NotCondition (pObjectWithinRadiusCondition), pTurnToAction);
  118. ConditionalAction* pConditionalAction2 = new ConditionalAction (new AndCondition (new NotCondition (pObjectWithinRadiusCondition2), new ProxyCondition (pObjectWithinRadiusCondition)), new SetControlsAction);
  119. pGoal->AddConstraintCondition (pConditionalAction);
  120. pGoal->AddConstraintCondition (pConditionalAction2);
  121. // add the subgoals
  122. pGoalList->AddGoal (CreateGoal01 ());
  123. pGoalList->AddGoal (CreateGoal02 ());
  124. pGoalList->AddGoal (CreateGoal03 ());
  125. pGoalList->AddGoal (CreateGoal04 ());
  126. pGoalList->AddGoal (CreateGoal05 ());
  127. pGoalList->AddGoal (CreateGoal06 ());
  128. pGoalList->AddGoal (CreateGoal07 ());
  129. pGoalList->AddGoal (CreateGoal08 ());
  130. pGoalList->AddGoal (CreateGoal09 ());
  131. // return the goal
  132. return pGoal;
  133. }
  134. //------------------------------------------------------------------------------
  135. Goal* Mission2::CreateGoal01 (void)
  136. {
  137. GoalList* pGoalList = new GoalList;
  138. // play the introductory audio
  139. {
  140. Goal* pGoal = CreatePlaySoundGoal (salCommenceScanSound);
  141. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  142. pSetControlConstraintsAction->DisableInputAction (0xffffffff);
  143. pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 0.0f);
  144. pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 0.0f);
  145. pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 0.0f);
  146. pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 0.0f);
  147. pGoal->AddStartAction (pSetControlConstraintsAction);
  148. pGoalList->AddGoal (pGoal);
  149. }
  150. // wait two seconds
  151. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (2.0f)));
  152. // tm_2_01
  153. // In this mission, you will receive a basic introduction to
  154. // your controls and heads-up display and do a little bit of
  155. // flying.
  156. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_01Sound));
  157. // wait one second, zoom into ship
  158. {
  159. Goal* pGoal = new Goal (new ElapsedTimeCondition (1.0f));
  160. pGoal->AddStartAction (new SetDisplayModeAction (TrekWindow::cmCockpit));
  161. pGoalList->AddGoal (pGoal);
  162. }
  163. // tm_2_02
  164. // For now, your flight controls are disabled; so don't do
  165. // anything until I tell you to.
  166. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_02Sound));
  167. // wait half second
  168. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  169. // tm_2_03
  170. // First, I?ll explain the peripheral radar system. This
  171. // system highlights objects of interest in space by placing
  172. // icons to represent them on your screen. When an object is
  173. // in your field of view, its icon is located appropriately on
  174. // your screen. When the object is out of your field of view,
  175. // its icon rides in a gutter at the edge of your screen.
  176. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_03Sound));
  177. // wait half second
  178. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  179. return new Goal (pGoalList);
  180. }
  181. //------------------------------------------------------------------------------
  182. Goal* Mission2::CreateGoal02 (void)
  183. {
  184. ImissionIGC* pMission = trekClient.GetCore ();
  185. IshipIGC* pCommander = pMission->GetShip (m_commanderID);
  186. GoalList* pGoalList = new GoalList;
  187. BuoyID buoyID = pMission->GenerateNewBuoyID();
  188. // tm_2_04
  189. // Look out in front of your ship right now. You should see a
  190. // small craft with a purple icon near it. That's me. This
  191. // icon indicates my ship?s class. Beside it is the name of
  192. // the pilot, me. The number just under the icon is my
  193. // distance from you, measured in meters.
  194. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_04Sound));
  195. // wait half second
  196. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  197. // tm_2_05
  198. // Watch how the icon moves as I approach you. I am going to
  199. // fly over your head. Pay attention to how the icon travels
  200. // as my ship approaches the edge of your screen and then
  201. // moves out of your field of view.
  202. {
  203. Goal* pGoal = CreatePlaySoundGoal (tm_2_05Sound);
  204. pGoal->AddStartAction (new CreateWaypointAction (buoyID, Vector (-200.0f, -200.0f, 400.0f), 1010));
  205. pGoal->AddStartAction (new SetCommandAction (pCommander, c_cmdCurrent, OT_buoy, buoyID, c_cidGoto));
  206. pGoal->AddStartAction (new SetCommandAction (pCommander, c_cmdAccepted, OT_buoy, buoyID, c_cidGoto));
  207. pGoalList->AddGoal (pGoal);
  208. }
  209. // wait 'til ship is close to waypoint
  210. pGoalList->AddGoal (new Goal (new ObjectWithinRadiusCondition (pCommander, OT_buoy, buoyID, 100.0f)));
  211. // tm_2_06
  212. // Notice that the icon remains on the screen, in a gutter.
  213. // You can find me again by turning your ship toward my icon
  214. // on the edge of the screen. I am above you and to your
  215. // right. Now your craft will turn to show you how it works.
  216. {
  217. Goal* pGoal = CreatePlaySoundGoal (tm_2_06Sound);
  218. pGoal->AddStartAction (new SetCommandAction (pCommander, c_cmdCurrent, NA, NA, c_cidDoNothing));
  219. pGoal->AddStartAction (new SetCommandAction (pCommander, c_cmdAccepted, NA, NA, c_cidDoNothing));
  220. pGoalList->AddGoal (pGoal);
  221. }
  222. // turn the craft until it lines up
  223. {
  224. ObjectPointingAtCondition* pObjectPointingAtCondition = new ObjectPointingAtCondition (static_cast<ImodelIGC*> (trekClient.GetShip ()), static_cast<ImodelIGC*> (pCommander));
  225. Goal* pGoal = new Goal (pObjectPointingAtCondition);
  226. pObjectPointingAtCondition->SetMinimumAngle (1.0f);
  227. TurnToAction* pTurnToAction = new TurnToAction (trekClient.GetShip (), pCommander);
  228. ConditionalAction* pConditionalAction = new ConditionalAction (new TrueCondition, pTurnToAction);
  229. pGoal->AddConstraintCondition (pConditionalAction);
  230. pGoalList->AddGoal (pGoal);
  231. }
  232. // wait half second, and reset the controls
  233. {
  234. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  235. SetControlsAction* pSetControlsAction = new SetControlsAction;
  236. pGoal->AddStartAction (pSetControlsAction);
  237. pGoalList->AddGoal (pGoal);
  238. }
  239. // tm_2_07
  240. // You'll get the chance to use the radar later.
  241. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_07Sound));
  242. // wait half second
  243. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  244. return new Goal (pGoalList);
  245. }
  246. //------------------------------------------------------------------------------
  247. Goal* Mission2::CreateGoal03 (void)
  248. {
  249. GoalList* pGoalList = new GoalList;
  250. // tm_2_08
  251. // Now I'm going to tell you about your ship controls. You can
  252. // change the orientation of your craft using your joystick or
  253. // keyboard. I'm going to release the controls now, so you can
  254. // try them out while I explain them.
  255. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_08Sound));
  256. // wait half second, and release the controls
  257. {
  258. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  259. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  260. pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 1.0f);
  261. pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 1.0f);
  262. pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 1.0f);
  263. // XXX the keys for rolling don't seem to be active
  264. pGoal->AddStartAction (pSetControlConstraintsAction);
  265. pGoalList->AddGoal (pGoal);
  266. }
  267. if (GetWindow ()->GetInputEngine ()->GetJoystickCount () > 0)
  268. {
  269. // tm_2_09
  270. // With your joystick, pushing the stick forward will tip your
  271. // ship?s nose down, and pulling the stick back will tip its
  272. // nose up. Pushing the stick to the right or left will turn
  273. // the nose to the right or left, respectively. If your
  274. // joystick has rudder controls, you can use these to roll
  275. // your craft as well. Otherwise, you can hold down the SHIFT
  276. // key while pressing the RIGHT and LEFT ARROW keys to roll
  277. // your craft.
  278. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_09Sound));
  279. }
  280. else
  281. {
  282. // tm_2_10
  283. // On the keyboard, the UP ARROW key will tip your ship?s nose
  284. // down, and the DOWN ARROW key will tip its nose up. The
  285. // RIGHT and LEFT ARROW keys work as you might expect, facing
  286. // the ship nose to the right and left, respectively. You can
  287. // hold down the SHIFT key while pressing the RIGHT and LEFT
  288. // ARROW keys to roll your craft.
  289. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_10Sound));
  290. }
  291. // wait half second
  292. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  293. // tm_2_11
  294. // Now I want you to practice turning the ship about.
  295. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_11Sound));
  296. // wait half second
  297. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  298. // tm_2_11r
  299. // When you are comfortable with the operation of your craft,
  300. // press the SPACEBAR to proceed.
  301. {
  302. Goal* pGoal = new Goal (new GetKeyCondition (TK_FireWeapon));
  303. pGoal->AddStartAction (new MessageAction ("Press the SPACEBAR when you are ready to proceed."));
  304. pGoal->AddStartAction (new PlaySoundAction (tm_2_11rSound));
  305. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_11rSound));
  306. pGoalList->AddGoal (pGoal);
  307. }
  308. // wait half second
  309. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  310. // tm_2_12
  311. // Good. Now you know how to turn the craft.
  312. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_12Sound));
  313. // wait half second
  314. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  315. return new Goal (pGoalList);
  316. }
  317. //------------------------------------------------------------------------------
  318. Goal* Mission2::CreateGoal04 (void)
  319. {
  320. GoalList* pGoalList = new GoalList;
  321. // tm_2_13
  322. // Next, you're going to move this interceptor around a bit
  323. // and get used to the throttle. I'm going to disable turning
  324. // for a moment, but the throttle will be active so you can
  325. // experiment with it while I talk.
  326. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_13Sound));
  327. // wait half second
  328. {
  329. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  330. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  331. pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 0.0f);
  332. pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 0.0f);
  333. pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 0.0f);
  334. pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 1.0f);
  335. pGoal->AddStartAction (pSetControlConstraintsAction);
  336. pGoalList->AddGoal (pGoal);;
  337. }
  338. // XXX hope ship faces empty space
  339. if (GetWindow ()->GetInputEngine ()->GetJoystickCount () > 0)
  340. {
  341. // tm_2_14
  342. // If your joystick has a throttle control, you can use that
  343. // to finely adjust your throttle.
  344. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_14Sound));
  345. }
  346. else
  347. {
  348. // tm_2_15
  349. // You can use the keyboard to set the throttle. The BACKSLASH
  350. // key is full throttle, and BACKSPACE is stop. You can use
  351. // the RIGHT BRACKET key for 66% throttle and the LEFT BRACKET
  352. // key for 33% throttle.
  353. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_15Sound));
  354. }
  355. // wait half second
  356. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  357. // tm_2_16
  358. // Now I want you to fly forward at full throttle.
  359. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_16Sound));
  360. // wait half second
  361. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  362. // tm_2_16r
  363. // Adjust the throttle control full forward on your joystick,
  364. // or press the BACKSLASH key.
  365. {
  366. TRef<ImodelIGC> pShip = static_cast<ImodelIGC*> (trekClient.GetShip());
  367. Goal* pGoal = new Goal (new GetControlActiveCondition (trekClient.GetShip(), c_axisThrottle, 1.0f));
  368. pGoal->AddStartAction (new MessageAction ("Press BACKSLASH (\\) or set your joystick throttle to maximum for full thrust."));
  369. pGoal->AddStartAction (new PlaySoundAction (tm_2_16rSound));
  370. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_16rSound));
  371. pGoalList->AddGoal (pGoal);
  372. }
  373. // wait half second
  374. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  375. // tm_2_17
  376. // Good.
  377. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_17Sound));
  378. // wait half second
  379. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  380. return new Goal (pGoalList);
  381. }
  382. //------------------------------------------------------------------------------
  383. Goal* Mission2::CreateGoal05 (void)
  384. {
  385. GoalList* pGoalList = new GoalList;
  386. // tm_2_18
  387. // You can see the precise setting of your throttle by looking
  388. // at this gauge.
  389. {
  390. Goal* pGoal = CreatePlaySoundGoal (tm_2_18Sound);
  391. pGoal->AddStartAction (new SetHUDOverlayAction (ThrottleTrainingOverlay));
  392. pGoalList->AddGoal (pGoal);
  393. }
  394. // wait half second
  395. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  396. // tm_2_18r
  397. // Try adjusting the throttle to see how this gauge changes.
  398. {
  399. TRef<ImodelIGC> pShip = static_cast<ImodelIGC*> (trekClient.GetShip());
  400. Goal* pGoal = new Goal (new NotCondition (new GetControlActiveCondition (trekClient.GetShip(), c_axisThrottle, 1.0f)));
  401. pGoal->AddStartAction (new MessageAction ("Press [, ], or use your joystick throttle to adjust thrust."));
  402. pGoal->AddStartAction (new PlaySoundAction (tm_2_18rSound));
  403. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_18rSound));
  404. pGoalList->AddGoal (pGoal);
  405. }
  406. // wait half second
  407. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  408. // tm_2_19
  409. // Now you know how to adjust the throttle and read a gauge on
  410. // your heads-up display. Now I'm going to go over some of the
  411. // other items on your display. Your controls will be disabled
  412. // while I talk about these things, so just pay attention.
  413. {
  414. Goal* pGoal = CreatePlaySoundGoal (tm_2_19Sound);
  415. pGoal->AddStartAction (new SetHUDOverlayAction (NoTrainingOverlay));
  416. pGoalList->AddGoal (pGoal);
  417. }
  418. // wait half second
  419. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  420. return new Goal (pGoalList);
  421. }
  422. //------------------------------------------------------------------------------
  423. Goal* Mission2::CreateGoal06 (void)
  424. {
  425. GoalList* pGoalList = new GoalList;
  426. // tm_2_20
  427. // When you are moving, the velocity indicator will tell you
  428. // how fast you are moving. The indicator reads in meters per
  429. // second, or M.P.S.
  430. {
  431. Goal* pGoal = CreatePlaySoundGoal (tm_2_20Sound);
  432. pGoal->AddStartAction (new SetHUDOverlayAction (SpeedTrainingOverlay));
  433. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  434. pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 0.0f);
  435. pGoal->AddStartAction (pSetControlConstraintsAction);
  436. SetControlsAction* pSetControlsAction = new SetControlsAction;
  437. pSetControlsAction->SetInputControl (c_axisThrottle, 0.33f);
  438. pGoal->AddStartAction (pSetControlsAction);
  439. pGoalList->AddGoal (pGoal);
  440. }
  441. // wait half second
  442. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  443. // tm_2_21
  444. // Notice the motion indicator in the center of your screen.
  445. // This indicator tells you which way you are moving. In
  446. // space, there is nothing to stop your ship from sliding
  447. // sideways. When you turn, it takes a moment for the ship's
  448. // engines to compensate for your velocity. As a result, you
  449. // won't always be facing the same direction you are moving.
  450. // This indicator will show you the direction that your craft
  451. // is traveling. Now your ship will turn a bit to demonstrate.
  452. {
  453. Goal* pGoal = CreatePlaySoundGoal (tm_2_21Sound);
  454. pGoal->AddStartAction (new SetHUDOverlayAction (MotionIndicatorTrainingOverlay));
  455. pGoalList->AddGoal (pGoal);
  456. }
  457. // wait half second, while turning right
  458. {
  459. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  460. SetControlsAction* pSetControlsAction = new SetControlsAction;
  461. pGoal->AddStartAction (new SetHUDOverlayAction (NoTrainingOverlay));
  462. pSetControlsAction->SetInputControl (c_axisYaw, -0.5f);
  463. pSetControlsAction->SetInputControl (c_axisThrottle, 0.33f);
  464. pGoal->AddStartAction (pSetControlsAction);
  465. pGoalList->AddGoal (pGoal);
  466. }
  467. // wait half second, and reset the controls
  468. {
  469. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  470. SetControlsAction* pSetControlsAction = new SetControlsAction;
  471. pSetControlsAction->SetInputControl (c_axisThrottle, 0.33f);
  472. pGoal->AddStartAction (pSetControlsAction);
  473. pGoalList->AddGoal (pGoal);
  474. }
  475. // wait half second, while pitching up
  476. {
  477. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  478. SetControlsAction* pSetControlsAction = new SetControlsAction;
  479. pSetControlsAction->SetInputControl (c_axisPitch, -0.5f);
  480. pSetControlsAction->SetInputControl (c_axisThrottle, 0.33f);
  481. pGoal->AddStartAction (pSetControlsAction);
  482. pGoalList->AddGoal (pGoal);
  483. }
  484. // wait half second, and reset the controls
  485. {
  486. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  487. SetControlsAction* pSetControlsAction = new SetControlsAction;
  488. pSetControlsAction->SetInputControl (c_axisThrottle, 0.33f);
  489. pGoal->AddStartAction (pSetControlsAction);
  490. pGoalList->AddGoal (pGoal);
  491. }
  492. // wait half second
  493. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  494. // wait half second, and reset the controls
  495. {
  496. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  497. SetControlsAction* pSetControlsAction = new SetControlsAction;
  498. pGoal->AddStartAction (pSetControlsAction);
  499. pGoalList->AddGoal (pGoal);
  500. }
  501. // tm_2_22
  502. // Got it? ? Good.
  503. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_22Sound));
  504. // wait half second
  505. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  506. // tm_2_23
  507. // I'm going to activate your controls again, and I want you
  508. // to practice turning and adjusting your throttle.
  509. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_23Sound));
  510. // wait half second
  511. {
  512. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.5f));
  513. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  514. pSetControlConstraintsAction->ScaleInputControl (c_axisYaw, 1.0f);
  515. pSetControlConstraintsAction->ScaleInputControl (c_axisPitch, 1.0f);
  516. pSetControlConstraintsAction->ScaleInputControl (c_axisRoll, 1.0f);
  517. pSetControlConstraintsAction->ScaleInputControl (c_axisThrottle, 1.0f);
  518. pGoal->AddStartAction (pSetControlConstraintsAction);
  519. pGoalList->AddGoal (pGoal);
  520. }
  521. // tm_2_24
  522. // Notice how the motion indicator floats around the screen as
  523. // you turn and that you don't stop immediately when you
  524. // throttle down.
  525. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_24Sound));
  526. // wait half second
  527. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  528. // tm_2_24r
  529. // When you are comfortable with the operation of your ship,
  530. // press the SPACEBAR to proceed.
  531. {
  532. Goal* pGoal = new Goal (new GetKeyCondition (TK_FireWeapon));
  533. pGoal->AddStartAction (new MessageAction ("Press the SPACEBAR when you are ready to proceed."));
  534. pGoal->AddStartAction (new PlaySoundAction (tm_2_24rSound));
  535. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_24rSound));
  536. pGoalList->AddGoal (pGoal);
  537. }
  538. // wait half second
  539. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  540. // tm_2_25
  541. // Okay. That wasn?t so bad was it? You?re doing good ? You?ve
  542. // learned the basics of space flight.
  543. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_25Sound));
  544. // wait half second
  545. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  546. return new Goal (pGoalList);
  547. }
  548. //------------------------------------------------------------------------------
  549. Goal* Mission2::CreateGoal07 (void)
  550. {
  551. GoalList* pGoalList = new GoalList;
  552. // tm_2_26
  553. // I'm going to introduce you to the booster now.
  554. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_26Sound));
  555. // wait quarter second, and set the controls
  556. {
  557. Goal* pGoal = new Goal (new ElapsedTimeCondition (0.25f));
  558. SetControlsAction* pSetControlsAction = new SetControlsAction;
  559. pSetControlsAction->SetInputAction (afterburnerButtonIGC);
  560. pGoal->AddStartAction (pSetControlsAction);
  561. pGoalList->AddGoal (pGoal);
  562. }
  563. // tm_2_27
  564. // This shaking and rumbling is your booster firing.
  565. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_27Sound));
  566. // wait quarter second
  567. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.25f)));
  568. // tm_2_28
  569. // Notice your speed.
  570. {
  571. Goal* pGoal = CreatePlaySoundGoal (tm_2_28Sound);
  572. pGoal->AddStartAction (new SetHUDOverlayAction (SpeedTrainingOverlay));
  573. pGoalList->AddGoal (pGoal);
  574. }
  575. // wait half second
  576. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  577. // tm_2_29
  578. // Notice how the fuel gauge drops when using the boosters.
  579. {
  580. Goal* pGoal = CreatePlaySoundGoal (tm_2_29Sound);
  581. pGoal->AddStartAction (new SetHUDOverlayAction (FuelTrainingOverlay));
  582. pGoalList->AddGoal (pGoal);
  583. }
  584. // wait a couple of seconds, turn off the boosters
  585. {
  586. Goal* pGoal = new Goal (new ElapsedTimeCondition (1.75f));
  587. SetControlsAction* pSetControlsAction = new SetControlsAction;
  588. pGoal->AddStartAction (pSetControlsAction);
  589. pGoalList->AddGoal (pGoal);
  590. }
  591. // tm_2_30
  592. // You carry a limited supply of fuel on the ship, and it
  593. // doesn't regenerate, so make sure you watch your fuel gauge
  594. // when firing the boosters.
  595. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_30Sound));
  596. // wait half second
  597. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  598. // tm_2_31
  599. // Now I want you to give it a try.
  600. {
  601. Goal* pGoal = CreatePlaySoundGoal (tm_2_31Sound);
  602. pGoal->AddStartAction (new SetHUDOverlayAction (NoTrainingOverlay));
  603. pGoalList->AddGoal (pGoal);
  604. }
  605. // wait half second
  606. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  607. // explain and wait for burners to take effect
  608. {
  609. TRef<ImodelIGC> ship = static_cast<ImodelIGC*> (trekClient.GetShip());
  610. Condition* pGetStateBitsCondition = new GetStateBitsCondition (trekClient.GetShip(), afterburnerButtonIGC);
  611. Goal* pGoal = new Goal (pGetStateBitsCondition);
  612. if (GetWindow ()->GetInputEngine ()->GetJoystickCount () > 0)
  613. {
  614. // tm_2_32
  615. // Activate the booster with your joystick by pressing and
  616. // holding button 3.
  617. pGoal->AddStartAction (new PlaySoundAction (tm_2_32Sound));
  618. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_32Sound));
  619. pGoal->AddStartAction (new MessageAction ("Press and hold button #3 on your joystick to fire the booster."));
  620. }
  621. else
  622. {
  623. // tm_2_33
  624. // On the keyboard, press and hold the TAB key to fire your
  625. // boosters.
  626. pGoal->AddStartAction (new PlaySoundAction (tm_2_33Sound));
  627. pGoal->AddConstraintCondition (CreateTooLongCondition (30.0f, tm_2_33Sound));
  628. pGoal->AddStartAction (new MessageAction ("Press and hold the TAB key to fire the booster."));
  629. }
  630. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  631. pSetControlConstraintsAction->EnableInputAction (afterburnerButtonIGC);
  632. pGoal->AddStartAction (pSetControlConstraintsAction);
  633. pGoalList->AddGoal (pGoal);
  634. }
  635. // wait five seconds
  636. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (5.0f)));
  637. // tm_2_34
  638. // Good!
  639. {
  640. Goal* pGoal = CreatePlaySoundGoal (tm_2_34Sound);
  641. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  642. pSetControlConstraintsAction->DisableInputAction (afterburnerButtonIGC);
  643. pGoal->AddStartAction (pSetControlConstraintsAction);
  644. pGoalList->AddGoal (pGoal);
  645. }
  646. // wait half second
  647. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  648. return new Goal (pGoalList);
  649. }
  650. //------------------------------------------------------------------------------
  651. Goal* Mission2::CreateGoal08 (void)
  652. {
  653. GoalList* pGoalList = new GoalList;
  654. // tm_2_35
  655. // I cut the boosters there because I didn't want to get too
  656. // far away from home. The boosters can get you up to speed
  657. // very fast and can even take you over the top handling speed
  658. // for your craft. You have to be careful where you point the
  659. // ship when you use the boosters, because you might not be
  660. // able turn or stop fast enough to avoid obstacles.
  661. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_35Sound));
  662. // wait half second
  663. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  664. // tm_2_36
  665. // All right, Cadet, you've made it through your introductory
  666. // flight! Excellent.
  667. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_36Sound));
  668. // wait half second
  669. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  670. // tm_2_37
  671. // Let's go home now. I'm switching you over to autopilot, so
  672. // you can look over the gauges and such in the heads-up
  673. // display. Enjoy the ride.
  674. pGoalList->AddGoal (CreatePlaySoundGoal (tm_2_37Sound));
  675. // wait to get close to the station
  676. {
  677. ImodelIGC* pStation = trekClient.GetCore ()->GetModel (OT_station, 1010);
  678. Goal* pGoal = new Goal (new AndCondition (new ObjectWithinRadiusCondition (trekClient.GetShip (), pStation, 500.0f), new ElapsedTimeCondition (0.5f)));
  679. pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdCurrent, pStation, c_cidGoto));
  680. pGoal->AddStartAction (new SetCommandAction (trekClient.GetShip (), c_cmdAccepted, pStation, c_cidGoto));
  681. pGoal->AddStartAction (new SetAutopilotAction (trekClient.GetShip ()));
  682. SetControlConstraintsAction* pSetControlConstraintsAction = new SetControlConstraintsAction;
  683. pSetControlConstraintsAction->DisableInputAction (afterburnerButtonIGC);
  684. pGoal->AddStartAction (pSetControlConstraintsAction);
  685. pGoal->AddConstraintCondition (new PeriodicCondition (new ConditionalAction (new NotCondition (new GetAutopilotCondition (trekClient.GetShip ())), new SetAutopilotAction (trekClient.GetShip ())), 2.0f));
  686. pGoalList->AddGoal (pGoal);
  687. }
  688. return new Goal (pGoalList);
  689. }
  690. //------------------------------------------------------------------------------
  691. Goal* Mission2::CreateGoal09 (void)
  692. {
  693. GoalList* pGoalList = new GoalList;
  694. // XXX I could stop the ship here if there is a problem
  695. // tm_2_38
  696. // I'm going to go back to the outpost and land in a green
  697. // hangar bay. The red bays are the launching points. Make
  698. // sure you never try to land in a red hangar, or you'll be a
  699. // trophy on somebody's canopy.
  700. {
  701. Goal* pGoal = CreatePlaySoundGoal (tm_2_38Sound);
  702. pGoal->AddConstraintCondition (new PeriodicCondition (new ConditionalAction (new NotCondition (new GetAutopilotCondition (trekClient.GetShip ())), new SetAutopilotAction (trekClient.GetShip ())), 2.0f));
  703. pGoalList->AddGoal (pGoal);
  704. }
  705. // wait for ship to land
  706. {
  707. Goal* pGoal = new Goal (new FalseCondition);
  708. pGoal->AddStartAction (new SetDisplayModeAction (TrekWindow::cmExternalStation));
  709. pGoal->AddConstraintCondition (new PeriodicCondition (new ConditionalAction (new NotCondition (new GetAutopilotCondition (trekClient.GetShip ())), new SetAutopilotAction (trekClient.GetShip ())), 2.0f));
  710. pGoalList->AddGoal (pGoal);
  711. }
  712. return new Goal (pGoalList);
  713. }
  714. //------------------------------------------------------------------------------
  715. }