mission6.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: Mission6.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the fifth training mission
  10. **
  11. ** History:
  12. */
  13. #include "pch.h"
  14. #include "Mission6.h"
  15. #include "Training.h"
  16. #include "GoalList.h"
  17. #include "ConditionalAction.h"
  18. #include "GetShipIsDestroyedCondition.h"
  19. #include "FalseCondition.h"
  20. #include "ElapsedTimeCondition.h"
  21. #include "SetDisplayModeAction.h"
  22. #include "CreateDroneAction.h"
  23. #include "MessageAction.h"
  24. namespace Training
  25. {
  26. //------------------------------------------------------------------------------
  27. // class methods
  28. //------------------------------------------------------------------------------
  29. /* void */ Mission6::~Mission6 (void)
  30. {
  31. }
  32. //------------------------------------------------------------------------------
  33. int Mission6::GetMissionID (void)
  34. {
  35. return c_TM_6_Practice_Arena;
  36. }
  37. //------------------------------------------------------------------------------
  38. SectorID Mission6::GetStartSectorID (void)
  39. {
  40. return 1030;
  41. }
  42. //------------------------------------------------------------------------------
  43. bool Mission6::RestoreShip (void)
  44. {
  45. // end the mission
  46. Terminate ();
  47. // and return false so the engine stays in the override camera mode
  48. return false;
  49. }
  50. //------------------------------------------------------------------------------
  51. void Mission6::CreateUniverse (void)
  52. {
  53. LoadUniverse ("training_3", 488, 1030); // a fighter 3
  54. // activate all the starting weapons
  55. trekClient.fGroupFire = true;
  56. // put the commander ship in the station
  57. ImissionIGC* pCore = trekClient.GetCore();
  58. ImodelIGC* pStation = pCore->GetModel (OT_station, 1030);
  59. IshipIGC* pCommander = pCore->GetShip (m_commanderID);
  60. pCommander->SetStation (static_cast<IstationIGC*> (pStation));
  61. pCommander->SetCommand (c_cmdAccepted, NULL, c_cidDoNothing);
  62. pCommander->SetCommand (c_cmdCurrent, NULL, c_cidDoNothing);
  63. pCommander->SetAutopilot (false);
  64. }
  65. //------------------------------------------------------------------------------
  66. Condition* Mission6::CreateMission (void)
  67. {
  68. GoalList* pGoalList = new GoalList;
  69. // play the introductory audio
  70. pGoalList->AddGoal (CreatePlaySoundGoal (salCommenceScanSound));
  71. // wait half second
  72. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  73. // tm_6_01
  74. // Okay, Cadet, here's your Advanced Fighter. There's a base
  75. // outpost here in case you need to replenish yourself.
  76. pGoalList->AddGoal (CreatePlaySoundGoal (tm_6_01Sound));
  77. // wait two more seconds
  78. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (2.0f)));
  79. // tm_6_02
  80. // Iron Coalition Intelligence reports inbound enemy craft.
  81. // They're using an old code for their comms, so we can hear
  82. // them. Watch your message stream to see what they're up to.
  83. {
  84. Goal* pGoal = CreatePlaySoundGoal (tm_6_02Sound);
  85. pGoal->AddStartAction (new SetDisplayModeAction (TrekWindow::cmCockpit));
  86. pGoal->AddStartAction (new MessageAction ("Watch the chat to see what the enemy craft are after."));
  87. pGoalList->AddGoal (pGoal);
  88. }
  89. // wait half second
  90. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (0.5f)));
  91. // tm_6_03
  92. // DEFEND THE MINERS! This simulation is over when you die.
  93. pGoalList->AddGoal (CreatePlaySoundGoal (tm_6_03Sound));
  94. // wait two more seconds
  95. pGoalList->AddGoal (new Goal (new ElapsedTimeCondition (2.0f)));
  96. // need this
  97. ImissionIGC* pMission = trekClient.GetCore();
  98. ImodelIGC* pStation = pMission->GetModel (OT_station, 1030);
  99. // wait for player to be dead
  100. {
  101. Goal* pGoal = new Goal (new FalseCondition);
  102. // create enemy ships
  103. ShipID enemyShipID = pMission->GenerateNewShipID ();
  104. CreateDroneAction* pCreateDroneAction = new CreateDroneAction ("Enemy Support", enemyShipID, 310, 1, c_ptWingman);
  105. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), Vector (3800.0f, 4275.0f, 855.0f));
  106. Condition* pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (enemyShipID));
  107. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  108. enemyShipID = pMission->GenerateNewShipID ();
  109. pCreateDroneAction = new CreateDroneAction ("Enemy Fighter", enemyShipID, 315, 1, c_ptWingman);
  110. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), Vector (3800.0f, 4175.0f, 855.0f));
  111. pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (enemyShipID));
  112. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  113. pGoalList->AddGoal (pGoal);
  114. }
  115. // build the goal that we'll return
  116. {
  117. Goal* pGoal = new Goal (pGoalList);
  118. // create friendly miners
  119. Vector pos = pStation->GetPosition ();
  120. pos.x += random(-1000.0f, 1000.0f);
  121. pos.y += random(-1000.0f, 1000.0f);
  122. pos.z += random(-1000.0f, 1000.0f);
  123. ShipID minerShipID = pMission->GenerateNewShipID ();
  124. CreateDroneAction* pCreateDroneAction = new CreateDroneAction ("Miner 01", minerShipID, 436, 0, c_ptMiner);
  125. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
  126. Condition* pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (minerShipID));
  127. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  128. pos = pStation->GetPosition ();
  129. pos.x += random(-1000.0f, 1000.0f);
  130. pos.y += random(-1000.0f, 1000.0f);
  131. pos.z += random(-1000.0f, 1000.0f);
  132. minerShipID = pMission->GenerateNewShipID ();
  133. pCreateDroneAction = new CreateDroneAction ("Miner 02", minerShipID, 436, 0, c_ptMiner);
  134. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
  135. pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (minerShipID));
  136. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  137. pos = pStation->GetPosition ();
  138. pos.x += random(-1000.0f, 1000.0f);
  139. pos.y += random(-1000.0f, 1000.0f);
  140. pos.z += random(-1000.0f, 1000.0f);
  141. minerShipID = pMission->GenerateNewShipID ();
  142. pCreateDroneAction = new CreateDroneAction ("Miner 03", minerShipID, 436, 0, c_ptMiner);
  143. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
  144. pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (minerShipID));
  145. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  146. pos = pStation->GetPosition ();
  147. pos.x += random(-1000.0f, 1000.0f);
  148. pos.y += random(-1000.0f, 1000.0f);
  149. pos.z += random(-1000.0f, 1000.0f);
  150. minerShipID = pMission->GenerateNewShipID ();
  151. pCreateDroneAction = new CreateDroneAction ("Miner 04", minerShipID, 436, 0, c_ptMiner);
  152. pCreateDroneAction->SetCreatedLocation (GetStartSectorID (), pos);
  153. pShipIsDestroyedcondition = new GetShipIsDestroyedCondition2 (OT_ship, static_cast<ObjectID> (minerShipID));
  154. pGoal->AddConstraintCondition (new ConditionalAction (pShipIsDestroyedcondition, pCreateDroneAction));
  155. return pGoal;
  156. }
  157. }
  158. //------------------------------------------------------------------------------
  159. }