QuestEvent.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * QuestEvent.c
  6. *
  7. * Copyright (C) 2000-2002 Pieter Spronck, All Rights Reserved
  8. *
  9. * Additional coding by Sam Anderson (rulez2@home.com)
  10. * Additional coding by Samuel Goldstein (palm@fogbound.net)
  11. *
  12. * Some code of Matt Lee's Dope Wars program has been used.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27. *
  28. * You can contact the author at space_trader@hotmail.com
  29. *
  30. * For those who are familiar with the classic game Elite: many of the
  31. * ideas in Space Trader are heavily inspired by Elite.
  32. *
  33. **********************************************************************/
  34. // *************************************************************************
  35. //
  36. // Quests Screen Event Handler
  37. //
  38. // *************************************************************************
  39. #include "external.h"
  40. // Returns number of open quests.
  41. int OpenQuests( void )
  42. {
  43. int r = 0;
  44. if (MonsterStatus == 1)
  45. ++r;
  46. if (DragonflyStatus >= 1 && DragonflyStatus <= 4)
  47. ++r;
  48. else if (SolarSystem[ZALKONSYSTEM].Special == INSTALLLIGHTNINGSHIELD)
  49. ++r;
  50. if (JaporiDiseaseStatus == 1)
  51. ++r;
  52. if (ArtifactOnBoard)
  53. ++r;
  54. if (WildStatus == 1)
  55. ++r;
  56. if (JarekStatus == 1)
  57. ++r;
  58. if (InvasionStatus >= 1 && InvasionStatus < 7)
  59. ++r;
  60. else if (SolarSystem[GEMULONSYSTEM].Special == GETFUELCOMPACTOR)
  61. ++r;
  62. if (ExperimentStatus >= 1 && ExperimentStatus < 11)
  63. ++r;
  64. if (ReactorStatus >= 1 && ReactorStatus < 21)
  65. ++r;
  66. if (SolarSystem[NIXSYSTEM].Special == GETSPECIALLASER)
  67. ++r;
  68. if (ScarabStatus == 1)
  69. ++r;
  70. if (Ship.Tribbles > 0)
  71. ++r;
  72. if (MoonBought)
  73. ++r;
  74. return r;
  75. }
  76. static void DrawQuestsForm()
  77. {
  78. FormPtr frmP;
  79. int Line;
  80. frmP = FrmGetActiveForm();
  81. RectangularShortcuts( frmP, QuestsBButton );
  82. FrmDrawForm( frmP );
  83. FntSetFont( stdFont );
  84. Line = 18;
  85. if (MonsterStatus == 1)
  86. {
  87. DrawChars( "Kill the space monster at Acamar.", 0, Line );
  88. Line += 16;
  89. }
  90. if (DragonflyStatus >= 1 && DragonflyStatus <= 4)
  91. {
  92. StrCopy( SBuf, "Follow the Dragonfly to " );
  93. if (DragonflyStatus == 1)
  94. StrCat( SBuf, "Baratas." );
  95. else if (DragonflyStatus == 2)
  96. StrCat( SBuf, "Melina." );
  97. else if (DragonflyStatus == 3)
  98. StrCat( SBuf, "Regulas." );
  99. else if (DragonflyStatus == 4)
  100. StrCat( SBuf, "Zalkon." );
  101. DrawChars( SBuf, 0, Line );
  102. Line += 16;
  103. }
  104. else if (SolarSystem[ZALKONSYSTEM].Special == INSTALLLIGHTNINGSHIELD)
  105. {
  106. DrawChars( "Get your lightning shield at Zalkon.", 0, Line );
  107. Line += 16;
  108. }
  109. if (JaporiDiseaseStatus == 1)
  110. {
  111. DrawChars( "Deliver antidote to Japori.", 0, Line );
  112. Line += 16;
  113. }
  114. if (ArtifactOnBoard)
  115. {
  116. DrawChars( "Deliver the alien artifact to professor", 0, Line );
  117. Line += 12;
  118. DrawChars( "Berger at some hi-tech system.", 0, Line );
  119. Line += 16;
  120. }
  121. if (WildStatus == 1)
  122. {
  123. DrawChars( "Smuggle Jonathan Wild to Kravat.", 0, Line );
  124. Line += 16;
  125. }
  126. if (JarekStatus == 1)
  127. {
  128. DrawChars( "Bring ambassador Jarek to Devidia.", 0, Line );
  129. Line += 16;
  130. }
  131. // I changed this, and the reused the code in the Experiment quest.
  132. // I think it makes more sense to display the time remaining in
  133. // this fashion. SjG 10 July 2002
  134. if (InvasionStatus >= 1 && InvasionStatus < 7)
  135. {
  136. DrawChars( "Inform Gemulon about alien invasion", 0, Line );
  137. Line += 12;
  138. if (InvasionStatus == 6)
  139. StrCopy( SBuf, "by tomorrow" );
  140. else
  141. {
  142. StrCopy( SBuf, "within " );
  143. SBufMultiples( 7 - InvasionStatus, "day" );
  144. }
  145. StrCat( SBuf, "." );
  146. DrawChars( SBuf, 0, Line );
  147. Line += 16;
  148. }
  149. else if (SolarSystem[GEMULONSYSTEM].Special == GETFUELCOMPACTOR)
  150. {
  151. DrawChars( "Get your fuel compactor at Gemulon.", 0, Line );
  152. Line += 16;
  153. }
  154. if (ExperimentStatus >= 1 && ExperimentStatus < 11)
  155. {
  156. DrawChars( "Stop Dr. Fehler's experiment at Daled", 0, Line );
  157. Line += 12;
  158. if (ExperimentStatus == 10)
  159. StrCopy( SBuf, "by tomorrow" );
  160. else
  161. {
  162. StrCopy( SBuf, "within " );
  163. SBufMultiples( 11 - ExperimentStatus, "day" );
  164. }
  165. StrCat( SBuf, "." );
  166. DrawChars( SBuf, 0, Line );
  167. Line += 16;
  168. }
  169. if (ReactorStatus >= 1 && ReactorStatus < 21)
  170. {
  171. DrawChars( "Deliver the unstable reactor to Nix", 0, Line );
  172. Line += 12;
  173. if (ReactorStatus < 2)
  174. {
  175. DrawChars( "for Henry Morgan.", 0, Line );
  176. }
  177. else
  178. {
  179. DrawChars( "before it consumes all its fuel.", 0, Line );
  180. }
  181. Line += 16;
  182. }
  183. if (SolarSystem[NIXSYSTEM].Special == GETSPECIALLASER)
  184. {
  185. DrawChars( "Get your special laser at Nix.", 0, Line );
  186. Line += 16;
  187. }
  188. if (ScarabStatus == 1)
  189. {
  190. DrawChars( "Find and destroy the Scarab (which", 0, Line );
  191. Line += 12;
  192. DrawChars( "is hiding at the exit to a wormhole).", 0, Line );
  193. Line += 16;
  194. }
  195. if (Ship.Tribbles > 0)
  196. {
  197. DrawChars( "Get rid of those pesky tribbles.", 0, Line );
  198. Line += 16;
  199. }
  200. if (MoonBought)
  201. {
  202. DrawChars( "Claim your moon at Utopia.", 0, Line );
  203. Line += 16;
  204. }
  205. if (Line <= 18)
  206. DrawChars( "There are no open quests.", 0, Line );
  207. }
  208. Boolean QuestsFormHandleEvent( EventPtr eventP )
  209. {
  210. Boolean handled = false;
  211. switch (eventP->eType)
  212. {
  213. case frmOpenEvent:
  214. case frmUpdateEvent:
  215. DrawQuestsForm();
  216. handled = true;
  217. break;
  218. case ctlSelectEvent:
  219. if (eventP->data.ctlSelect.controlID == QuestsStatusButton)
  220. {
  221. CurForm = CommanderStatusForm;
  222. }
  223. else if (eventP->data.ctlSelect.controlID == QuestsShipButton)
  224. {
  225. CurForm = CurrentShipForm;
  226. }
  227. else if (eventP->data.ctlSelect.controlID == QuestsSpecialButton)
  228. {
  229. CurForm = SpecialCargoForm;
  230. }
  231. FrmGotoForm( CurForm );
  232. handled = true;
  233. break;
  234. default:
  235. break;
  236. }
  237. return handled;
  238. }