SystemInfoEvent.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. /***********************************************************************
  2. *
  3. * SPACE TRADER 1.2.0
  4. *
  5. * SystemInfoEvent.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. #include "external.h"
  35. static int NewsEvents[MAXSPECIALNEWSEVENTS];
  36. // *************************************************************************
  37. // Draw one mercenary
  38. // *************************************************************************
  39. static void DrawMercenary( int Index, int y )
  40. {
  41. int j, d;
  42. DrawChars( MercenaryName[Mercenary[Index].NameIndex], 30, y );
  43. StrIToA( SBuf, MERCENARYHIREPRICE( Index ) );
  44. StrCat( SBuf, " cr." );
  45. j = MAXDIGITS - StrLen( SBuf );
  46. d = 101+j*5;
  47. StrCat( SBuf, " daily" );
  48. DrawChars( SBuf, d, y );
  49. StrCopy( SBuf, "Pilot: " );
  50. StrIToA( SBuf2, Mercenary[Index].Pilot );
  51. StrCat( SBuf, SBuf2 );
  52. DrawChars( SBuf, 30, y + 13 );
  53. StrCopy( SBuf, "Trader: " );
  54. StrIToA( SBuf2, Mercenary[Index].Trader );
  55. StrCat( SBuf, SBuf2 );
  56. DrawChars( SBuf, 30, y + 26 );
  57. StrCopy( SBuf, "Fighter: " );
  58. StrIToA( SBuf2, Mercenary[Index].Fighter );
  59. StrCat( SBuf, SBuf2 );
  60. DrawChars( SBuf, 80, y + 13 );
  61. StrCopy( SBuf, "Engineer: " );
  62. StrIToA( SBuf2, Mercenary[Index].Engineer );
  63. StrCat( SBuf, SBuf2 );
  64. DrawChars( SBuf, 80, y + 26 );
  65. }
  66. // *************************************************************************
  67. // Return available crew quarters
  68. // *************************************************************************
  69. static char AvailableQuarters( void )
  70. {
  71. return Shiptype[Ship.Type].CrewQuarters - (JarekStatus == 1 ? 1 : 0) -
  72. (WildStatus == 1 ? 1 : 0);
  73. }
  74. // *************************************************************************
  75. // Determine which mercenary is for hire in the current system
  76. // *************************************************************************
  77. static int GetForHire( void )
  78. {
  79. int ForHire = -1;
  80. int i;
  81. for (i=1; i<MAXCREWMEMBER; ++i)
  82. {
  83. if (i == Ship.Crew[1] || i == Ship.Crew[2])
  84. continue;
  85. if (Mercenary[i].CurSystem == Mercenary[0].CurSystem)
  86. {
  87. ForHire = i;
  88. break;
  89. }
  90. }
  91. return ForHire;
  92. }
  93. // *************************************************************************
  94. // Drawing the Personnel Roster screen
  95. // *************************************************************************
  96. static void DrawPersonnelRoster( void )
  97. {
  98. FormPtr frmP;
  99. RectangleType a;
  100. int i, ForHire;
  101. frmP = FrmGetActiveForm();
  102. RectangularShortcuts( frmP, PersonnelRosterBButton );
  103. for (i=0; i<3; ++i)
  104. RectangularButton( frmP, PersonnelRosterFire0Button + i );
  105. FrmDrawForm( frmP );
  106. EraseRectangle( 30, 18, 130, 142 );
  107. a.topLeft.x = 0;
  108. a.topLeft.y = BOUNDSY + 38;
  109. a.extent.x = 160;
  110. a.extent.y = 2;
  111. WinDrawRectangle( &a, 0 );
  112. a.topLeft.y = BOUNDSY + 83;
  113. WinDrawRectangle( &a, 0 );
  114. FntSetFont( stdFont );
  115. for (i=0; i<2; ++i)
  116. {
  117. if (i == Shiptype[Ship.Type].CrewQuarters-2 && (JarekStatus == 1 || WildStatus == 1))
  118. {
  119. if (JarekStatus == 1)
  120. DrawChars( "Jarek's quarters", 30, 30 + i*45 );
  121. else
  122. DrawChars( "Wild's quarters", 30, 30 + i*45 );
  123. FrmHideObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterFire0Button + i ) );
  124. continue;
  125. }
  126. if (Shiptype[Ship.Type].CrewQuarters <= i+1)
  127. {
  128. DrawChars( "No quarters available", 30, 30 + i*45 );
  129. FrmHideObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterFire0Button + i ) );
  130. continue;
  131. }
  132. if (Ship.Crew[i+1] < 0)
  133. {
  134. DrawChars( "Vacancy", 30, 30 + i*45 );
  135. FrmHideObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterFire0Button + i ) );
  136. continue;
  137. }
  138. FrmShowObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterFire0Button + i ) );
  139. DrawMercenary( Ship.Crew[i+1], 17+i*45 );
  140. }
  141. ForHire = GetForHire();
  142. if (ForHire < 0)
  143. {
  144. DrawChars( "No one for hire", 30, 120 );
  145. FrmHideObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterHire0Button ) );
  146. }
  147. else
  148. {
  149. FrmShowObject( frmP, FrmGetObjectIndex( frmP, PersonnelRosterHire0Button ) );
  150. DrawMercenary( ForHire, 107 );
  151. }
  152. DisplayTradeCredits();
  153. }
  154. // *************************************************************************
  155. // Add a news event flag
  156. // *************************************************************************
  157. void addNewsEvent(int eventFlag)
  158. {
  159. if (NewsSpecialEventCount < MAXSPECIALNEWSEVENTS - 1)
  160. NewsEvents[NewsSpecialEventCount++] = eventFlag;
  161. }
  162. // *************************************************************************
  163. // replace a news event flag with another
  164. // *************************************************************************
  165. void replaceNewsEvent(int originalEventFlag, int replacementEventFlag)
  166. {
  167. int i;
  168. if (originalEventFlag == -1)
  169. {
  170. addNewsEvent(replacementEventFlag);
  171. }
  172. else
  173. {
  174. for (i=0;i<NewsSpecialEventCount; i++)
  175. {
  176. if (NewsEvents[i] == originalEventFlag)
  177. NewsEvents[i] = replacementEventFlag;
  178. }
  179. }
  180. }
  181. // *************************************************************************
  182. // Reset news event flags
  183. // *************************************************************************
  184. void resetNewsEvents(void)
  185. {
  186. NewsSpecialEventCount = 0;
  187. }
  188. // *************************************************************************
  189. // get most recently addded news event flag
  190. // *************************************************************************
  191. int latestNewsEvent(void)
  192. {
  193. if (NewsSpecialEventCount == 0)
  194. return -1;
  195. else
  196. return NewsEvents[NewsSpecialEventCount - 1];
  197. }
  198. // *************************************************************************
  199. // Query news event flags
  200. // *************************************************************************
  201. Boolean isNewsEvent(int eventFlag)
  202. {
  203. int i;
  204. for (i=0;i<NewsSpecialEventCount; i++)
  205. {
  206. if (NewsEvents[i] == eventFlag)
  207. return true;
  208. }
  209. return false;
  210. }
  211. static void DrawSystemInformationForm()
  212. {
  213. FormPtr frmP;
  214. int OpenQ = OpenQuests();
  215. frmP = FrmGetActiveForm();
  216. setLabelText( frmP, SystemInformationSystemNameLabel,
  217. SolarSystemName[CURSYSTEM.NameIndex] );
  218. setLabelText( frmP, SystemInformationTechLevelLabel,
  219. TechLevel[CURSYSTEM.TechLevel] );
  220. setLabelText( frmP, SystemInformationGovernmentLabel,
  221. Politics[CURSYSTEM.Politics].Name );
  222. setLabelText( frmP, SystemInformationResourcesLabel,
  223. SpecialResources[CURSYSTEM.SpecialResources] );
  224. setLabelText( frmP, SystemInformationStatusLabel,
  225. Status[CURSYSTEM.Status] );
  226. setLabelText( frmP, SystemInformationSizeLabel,
  227. SystemSize[CURSYSTEM.Size] );
  228. setLabelText( frmP, SystemInformationPoliceLabel,
  229. Activity[Politics[CURSYSTEM.Politics].StrengthPolice] );
  230. setLabelText( frmP, SystemInformationPiratesLabel,
  231. Activity[Politics[CURSYSTEM.Politics].StrengthPirates] );
  232. if ((CURSYSTEM.Special < 0) ||
  233. (CURSYSTEM.Special == BUYTRIBBLE && Ship.Tribbles <= 0) ||
  234. (CURSYSTEM.Special == ERASERECORD && PoliceRecordScore >= DUBIOUSSCORE) ||
  235. (CURSYSTEM.Special == CARGOFORSALE && (FilledCargoBays() > TotalCargoBays() - 3)) ||
  236. ((CURSYSTEM.Special == DRAGONFLY || CURSYSTEM.Special == JAPORIDISEASE ||
  237. CURSYSTEM.Special == ALIENARTIFACT || CURSYSTEM.Special == AMBASSADORJAREK ||
  238. CURSYSTEM.Special == EXPERIMENT) && (PoliceRecordScore < DUBIOUSSCORE)) ||
  239. (CURSYSTEM.Special == TRANSPORTWILD && (PoliceRecordScore >= DUBIOUSSCORE)) ||
  240. (CURSYSTEM.Special == GETREACTOR && (PoliceRecordScore >= DUBIOUSSCORE || ReputationScore < AVERAGESCORE || ReactorStatus != 0)) ||
  241. (CURSYSTEM.Special == REACTORDELIVERED && !(ReactorStatus > 0 && ReactorStatus < 21)) ||
  242. (CURSYSTEM.Special == MONSTERKILLED && MonsterStatus < 2) ||
  243. (CURSYSTEM.Special == EXPERIMENTSTOPPED && !(ExperimentStatus >= 1 && ExperimentStatus < 12)) ||
  244. (CURSYSTEM.Special == FLYBARATAS && DragonflyStatus < 1) ||
  245. (CURSYSTEM.Special == FLYMELINA && DragonflyStatus < 2) ||
  246. (CURSYSTEM.Special == FLYREGULAS && DragonflyStatus < 3) ||
  247. (CURSYSTEM.Special == DRAGONFLYDESTROYED && DragonflyStatus < 5) ||
  248. (CURSYSTEM.Special == SCARAB && (ReputationScore < AVERAGESCORE || ScarabStatus != 0)) ||
  249. (CURSYSTEM.Special == SCARABDESTROYED && ScarabStatus != 2) ||
  250. (CURSYSTEM.Special == GETHULLUPGRADED && ScarabStatus != 2) ||
  251. (CURSYSTEM.Special == MEDICINEDELIVERY && JaporiDiseaseStatus != 1) ||
  252. (CURSYSTEM.Special == JAPORIDISEASE && (JaporiDiseaseStatus != 0)) ||
  253. (CURSYSTEM.Special == ARTIFACTDELIVERY && !ArtifactOnBoard) ||
  254. (CURSYSTEM.Special == JAREKGETSOUT && JarekStatus != 1) ||
  255. (CURSYSTEM.Special == WILDGETSOUT && WildStatus != 1) ||
  256. (CURSYSTEM.Special == GEMULONRESCUED && !(InvasionStatus >= 1 && InvasionStatus <= 7)) ||
  257. (CURSYSTEM.Special == MOONFORSALE && (MoonBought || CurrentWorth() < (COSTMOON * 4) / 5)) ||
  258. (CURSYSTEM.Special == MOONBOUGHT && MoonBought != true))
  259. FrmHideObject( frmP, FrmGetObjectIndex( frmP, SystemInformationSpecialButton ) );
  260. else if (OpenQ > 3 &&
  261. (CURSYSTEM.Special == TRIBBLE ||
  262. CURSYSTEM.Special == SPACEMONSTER ||
  263. CURSYSTEM.Special == DRAGONFLY ||
  264. CURSYSTEM.Special == JAPORIDISEASE ||
  265. CURSYSTEM.Special == ALIENARTIFACT ||
  266. CURSYSTEM.Special == AMBASSADORJAREK ||
  267. CURSYSTEM.Special == ALIENINVASION ||
  268. CURSYSTEM.Special == EXPERIMENT ||
  269. CURSYSTEM.Special == TRANSPORTWILD ||
  270. CURSYSTEM.Special == GETREACTOR ||
  271. CURSYSTEM.Special == SCARAB))
  272. FrmHideObject( frmP, FrmGetObjectIndex( frmP, SystemInformationSpecialButton ) );
  273. else
  274. FrmShowObject( frmP, FrmGetObjectIndex( frmP, SystemInformationSpecialButton ) );
  275. if (GetForHire() < 0)
  276. FrmHideObject( frmP, FrmGetObjectIndex( frmP, SystemInformationMercenaryForHireButton ) );
  277. else
  278. FrmShowObject( frmP, FrmGetObjectIndex( frmP, SystemInformationMercenaryForHireButton ) );
  279. RectangularShortcuts( frmP, SystemInformationBButton );
  280. FrmDrawForm( frmP );
  281. }
  282. // *************************************************************************
  283. // Handling of events on the System Information screen
  284. // *************************************************************************
  285. Boolean SystemInformationFormHandleEvent(EventPtr eventP)
  286. {
  287. Boolean handled = false;
  288. int OpenQ = OpenQuests();
  289. switch (eventP->eType)
  290. {
  291. // Show information on current system
  292. case frmOpenEvent:
  293. // also, we decide if we want to set the News Flags here...
  294. if (CURSYSTEM.Special > -1)
  295. {
  296. if (CURSYSTEM.Special == MONSTERKILLED && MonsterStatus == 2)
  297. addNewsEvent(MONSTERKILLED);
  298. else if (CURSYSTEM.Special == DRAGONFLY)
  299. addNewsEvent(DRAGONFLY);
  300. else if (CURSYSTEM.Special == SCARAB)
  301. addNewsEvent(SCARAB);
  302. else if (CURSYSTEM.Special == SCARABDESTROYED && ScarabStatus == 2)
  303. addNewsEvent(SCARABDESTROYED);
  304. else if (CURSYSTEM.Special == FLYBARATAS && DragonflyStatus == 1)
  305. addNewsEvent(FLYBARATAS);
  306. else if (CURSYSTEM.Special == FLYMELINA && DragonflyStatus == 2)
  307. addNewsEvent(FLYMELINA);
  308. else if (CURSYSTEM.Special == FLYREGULAS && DragonflyStatus == 3)
  309. addNewsEvent(FLYREGULAS);
  310. else if (CURSYSTEM.Special == DRAGONFLYDESTROYED && DragonflyStatus == 5)
  311. addNewsEvent(DRAGONFLYDESTROYED);
  312. else if (CURSYSTEM.Special == MEDICINEDELIVERY && JaporiDiseaseStatus == 1)
  313. addNewsEvent(MEDICINEDELIVERY);
  314. else if (CURSYSTEM.Special == ARTIFACTDELIVERY && ArtifactOnBoard)
  315. addNewsEvent(ARTIFACTDELIVERY);
  316. else if (CURSYSTEM.Special == JAPORIDISEASE && JaporiDiseaseStatus == 0)
  317. addNewsEvent(JAPORIDISEASE);
  318. else if (CURSYSTEM.Special == JAREKGETSOUT && JarekStatus == 1)
  319. addNewsEvent(JAREKGETSOUT);
  320. else if (CURSYSTEM.Special == WILDGETSOUT && WildStatus == 1)
  321. addNewsEvent(WILDGETSOUT);
  322. else if (CURSYSTEM.Special == GEMULONRESCUED && InvasionStatus > 0 && InvasionStatus < 8)
  323. addNewsEvent(GEMULONRESCUED);
  324. else if (CURSYSTEM.Special == ALIENINVASION)
  325. addNewsEvent(ALIENINVASION);
  326. else if (CURSYSTEM.Special == EXPERIMENTSTOPPED && ExperimentStatus > 0 && ExperimentStatus < 12)
  327. addNewsEvent(EXPERIMENTSTOPPED);
  328. else if (CURSYSTEM.Special == EXPERIMENTNOTSTOPPED)
  329. addNewsEvent(EXPERIMENTNOTSTOPPED);
  330. }
  331. DrawSystemInformationForm();
  332. CURSYSTEM.Visited = true;
  333. handled = true;
  334. break;
  335. case frmUpdateEvent:
  336. DrawSystemInformationForm();
  337. handled = true;
  338. break;
  339. // Special event
  340. case ctlSelectEvent:
  341. if (eventP->data.ctlSelect.controlID == SystemInformationSpecialButton)
  342. {
  343. CurForm = SpecialEventForm;
  344. }
  345. else if (eventP->data.ctlSelect.controlID == SystemInformationMercenaryForHireButton)
  346. {
  347. CurForm = PersonnelRosterForm;
  348. }
  349. else if (eventP->data.ctlSelect.controlID == SystemInformationNewsButton)
  350. {
  351. StrIToA( SBuf, Difficulty + 1 );
  352. if (!AlreadyPaidForNewspaper && ToSpend() < (long)(Difficulty + 1.0) )
  353. {
  354. FrmCustomAlert(CantAffordPaperAlert, SBuf, NULL, NULL);
  355. return true;
  356. }
  357. else
  358. {
  359. if (!NewsAutoPay && !AlreadyPaidForNewspaper)
  360. if (FrmCustomAlert( BuyNewspaperAlert, SBuf, NULL, NULL ) == BuyNewspaperCancel)
  361. return true;
  362. if (!AlreadyPaidForNewspaper)
  363. {
  364. Credits -= (Difficulty + 1);
  365. AlreadyPaidForNewspaper = true;
  366. }
  367. CurForm = NewspaperForm;
  368. }
  369. }
  370. FrmGotoForm( CurForm );
  371. handled = true;
  372. break;
  373. default:
  374. break;
  375. }
  376. return handled;
  377. }
  378. static void DrawNewspaperForm()
  379. {
  380. FormPtr frmP;
  381. int line = 18, i, j;
  382. Boolean shown[MAXSTORIES];
  383. Boolean realNews = false;
  384. frmP = FrmGetActiveForm();
  385. FrmDrawForm( frmP );
  386. i = WarpSystem % MAXMASTHEADS;
  387. SysStringByIndex(AnarchyMastheadsStringList + CURSYSTEM.Politics * 100,i,SBuf2,50);
  388. if (StrNCompare(SBuf2,"*",1) == 0)
  389. {
  390. StrCopy(SBuf,"The ");
  391. StrCat(SBuf, SolarSystemName[CURSYSTEM.NameIndex]);
  392. StrCat(SBuf, SBuf2 + 1);
  393. //DrawCharsCentered(SBuf, line, true);
  394. setCurrentWinTitle(SBuf);
  395. }
  396. else if (StrNCompare(SBuf2,"+",1) == 0)
  397. {
  398. StrCopy(SBuf, SolarSystemName[CURSYSTEM.NameIndex]);
  399. StrCat(SBuf, SBuf2 + 1);
  400. //DrawCharsCentered(SBuf, line, true);
  401. setCurrentWinTitle(SBuf);
  402. }
  403. else
  404. {
  405. //DrawCharsCentered(SBuf2, line, true);
  406. setCurrentWinTitle(SBuf2);
  407. }
  408. RandSeed( WarpSystem, Days );
  409. // Special Events get to go first, crowding out other news
  410. if (isNewsEvent(CAPTAINHUIEATTACKED))
  411. {
  412. DisplayHeadline("Famed Captain Huie Attacked by Brigand!", &line);
  413. }
  414. if (isNewsEvent(EXPERIMENTPERFORMED))
  415. {
  416. DisplayHeadline("Travelers Report Timespace Damage, Warp Problems!", &line);
  417. }
  418. if (isNewsEvent(CAPTAINHUIEDESTROYED))
  419. {
  420. DisplayHeadline("Citizens Mourn Destruction of Captain Huie's Ship!", &line);
  421. }
  422. if (isNewsEvent(CAPTAINAHABATTACKED))
  423. {
  424. DisplayHeadline("Thug Assaults Captain Ahab!", &line);
  425. }
  426. if (isNewsEvent(CAPTAINAHABDESTROYED))
  427. {
  428. DisplayHeadline("Destruction of Captain Ahab's Ship Causes Anger!", &line);
  429. }
  430. if (isNewsEvent(CAPTAINCONRADATTACKED))
  431. {
  432. DisplayHeadline("Captain Conrad Comes Under Attack By Criminal!", &line);
  433. }
  434. if (isNewsEvent(CAPTAINCONRADDESTROYED))
  435. {
  436. DisplayHeadline("Captain Conrad's Ship Destroyed by Villain!", &line);
  437. }
  438. if (isNewsEvent(MONSTERKILLED))
  439. {
  440. DisplayHeadline("Hero Slays Space Monster! Parade, Honors Planned for Today.", &line);
  441. }
  442. if (isNewsEvent(WILDARRESTED))
  443. {
  444. DisplayHeadline("Notorious Criminal Jonathan Wild Arrested!", &line);
  445. }
  446. if (CURSYSTEM.Special == MONSTERKILLED && MonsterStatus == 1)
  447. {
  448. DisplayHeadline("Space Monster Threatens Homeworld!", &line);
  449. }
  450. if (CURSYSTEM.Special == SCARABDESTROYED && ScarabStatus == 1)
  451. {
  452. DisplayHeadline("Wormhole Travelers Harassed by Unusual Ship!", &line);
  453. }
  454. if (isNewsEvent(EXPERIMENTSTOPPED))
  455. {
  456. DisplayHeadline("Scientists Cancel High-profile Test! Committee to Investigate Design.", &line);
  457. }
  458. if (isNewsEvent(EXPERIMENTNOTSTOPPED))
  459. {
  460. DisplayHeadline("Huge Explosion Reported at Research Facility.", &line);
  461. }
  462. if (isNewsEvent(DRAGONFLY))
  463. {
  464. DisplayHeadline("Experimental Craft Stolen! Critics Demand Security Review.", &line);
  465. }
  466. if (isNewsEvent(SCARAB))
  467. {
  468. DisplayHeadline("Security Scandal: Test Craft Confirmed Stolen.", &line);
  469. }
  470. if (isNewsEvent(FLYBARATAS))
  471. {
  472. DisplayHeadline("Investigators Report Strange Craft.", &line);
  473. }
  474. if (isNewsEvent(FLYMELINA))
  475. {
  476. DisplayHeadline("Rumors Continue: Melina Orbitted by Odd Starcraft.", &line);
  477. }
  478. if (isNewsEvent(FLYREGULAS))
  479. {
  480. DisplayHeadline("Strange Ship Observed in Regulas Orbit.", &line);
  481. }
  482. if (CURSYSTEM.Special == DRAGONFLYDESTROYED && DragonflyStatus == 4 &&
  483. !isNewsEvent(DRAGONFLYDESTROYED))
  484. {
  485. DisplayHeadline("Unidentified Ship: A Threat to Zalkon?", &line);
  486. }
  487. if (isNewsEvent(DRAGONFLYDESTROYED))
  488. {
  489. DisplayHeadline("Spectacular Display as Stolen Ship Destroyed in Fierce Space Battle.", &line);
  490. }
  491. if (isNewsEvent(SCARABDESTROYED))
  492. {
  493. DisplayHeadline("Wormhole Traffic Delayed as Stolen Craft Destroyed.", &line);
  494. }
  495. if (isNewsEvent(MEDICINEDELIVERY))
  496. {
  497. DisplayHeadline("Disease Antidotes Arrive! Health Officials Optimistic.", &line);
  498. }
  499. if (isNewsEvent(JAPORIDISEASE))
  500. {
  501. DisplayHeadline("Editorial: We Must Help Japori!",&line);
  502. }
  503. if (isNewsEvent(ARTIFACTDELIVERY))
  504. {
  505. DisplayHeadline("Scientist Adds Alien Artifact to Museum Collection.", &line);
  506. }
  507. if (isNewsEvent(JAREKGETSOUT))
  508. {
  509. DisplayHeadline("Ambassador Jarek Returns from Crisis.", &line);
  510. }
  511. if (isNewsEvent(WILDGETSOUT))
  512. {
  513. DisplayHeadline("Rumors Suggest Known Criminal J. Wild May Come to Kravat!", &line);
  514. }
  515. if (isNewsEvent(GEMULONRESCUED))
  516. {
  517. DisplayHeadline("Invasion Imminent! Plans in Place to Repel Hostile Invaders.", &line);
  518. }
  519. if (CURSYSTEM.Special == GEMULONRESCUED && !isNewsEvent(GEMULONRESCUED))
  520. {
  521. DisplayHeadline("Alien Invasion Devastates Planet!", &line);
  522. }
  523. if (isNewsEvent(ALIENINVASION))
  524. {
  525. DisplayHeadline("Editorial: Who Will Warn Gemulon?", &line);
  526. }
  527. if (isNewsEvent(ARRIVALVIASINGULARITY))
  528. {
  529. DisplayHeadline("Travelers Claim Sighting of Ship Materializing in Orbit!", &line);
  530. }
  531. // local system status information
  532. if (CURSYSTEM.Status > 0)
  533. {
  534. switch (CURSYSTEM.Status)
  535. {
  536. case WAR:
  537. DisplayHeadline("War News: Offensives Continue!", &line);
  538. break;
  539. case PLAGUE:
  540. DisplayHeadline("Plague Spreads! Outlook Grim.", &line);
  541. break;
  542. case DROUGHT:
  543. DisplayHeadline("No Rain in Sight!",&line);
  544. break;
  545. case BOREDOM:
  546. DisplayHeadline("Editors: Won't Someone Entertain Us?",&line);
  547. break;
  548. case COLD:
  549. DisplayHeadline("Cold Snap Continues!", &line);
  550. break;
  551. case CROPFAILURE:
  552. DisplayHeadline("Serious Crop Failure! Must We Ration?", &line);
  553. break;
  554. case LACKOFWORKERS:
  555. DisplayHeadline("Jobless Rate at All-Time Low!", &line);
  556. break;
  557. }
  558. }
  559. // character-specific news.
  560. if (PoliceRecordScore <= VILLAINSCORE)
  561. {
  562. j = GetRandom2(4);
  563. switch (j)
  564. {
  565. case 0:
  566. StrCopy( SBuf, "Police Warning: ");
  567. StrCat( SBuf, NameCommander);
  568. StrCat( SBuf, " Will Dock At ");
  569. StrCat( SBuf, SolarSystemName[CURSYSTEM.NameIndex]);
  570. StrCat( SBuf, "!");
  571. break;
  572. case 1:
  573. StrCopy(SBuf,"Notorious Criminal ");
  574. StrCat(SBuf, NameCommander);
  575. StrCat(SBuf, " Sighted in ");
  576. StrCat( SBuf, SolarSystemName[CURSYSTEM.NameIndex]);
  577. StrCat( SBuf, "!");
  578. break;
  579. case 2:
  580. StrCopy(SBuf,"Locals Rally to Deny Spaceport Access to ");
  581. StrCat(SBuf, NameCommander);
  582. StrCat(SBuf, "!");
  583. break;
  584. case 3:
  585. StrCopy(SBuf,"Terror Strikes Locals on Arrival of ");
  586. StrCat(SBuf, NameCommander);
  587. StrCat(SBuf, "!");
  588. break;
  589. }
  590. DisplayHeadline(SBuf, &line);
  591. }
  592. if (PoliceRecordScore == HEROSCORE)
  593. {
  594. j = GetRandom2(3);
  595. switch (j)
  596. {
  597. case 0:
  598. StrCopy(SBuf,"Locals Welcome Visiting Hero ");
  599. StrCat(SBuf, NameCommander);
  600. StrCat(SBuf, "!");
  601. break;
  602. case 1:
  603. StrCopy(SBuf,"Famed Hero ");
  604. StrCat(SBuf, NameCommander);
  605. StrCat(SBuf, " to Visit System!");
  606. break;
  607. case 2:
  608. StrCopy(SBuf,"Large Turnout At Spaceport to Welcome ");
  609. StrCat(SBuf, NameCommander);
  610. StrCat(SBuf, "!");
  611. break;
  612. }
  613. DisplayHeadline(SBuf, &line);
  614. }
  615. // caught littering?
  616. if (isNewsEvent(CAUGHTLITTERING))
  617. {
  618. StrCopy( SBuf, "Police Trace Orbiting Space Litter to ");
  619. StrCat( SBuf, NameCommander );
  620. StrCat( SBuf, ".");
  621. DisplayHeadline(SBuf, &line);
  622. }
  623. // and now, finally, useful news (if any)
  624. // base probability of a story showing up is (50 / MAXTECHLEVEL) * Current Tech Level
  625. // This is then modified by adding 10% for every level of play less than Impossible
  626. for (i=0; i < MAXSOLARSYSTEM; i++)
  627. {
  628. if (i != COMMANDER.CurSystem &&
  629. ((RealDistance(CURSYSTEM, SolarSystem[i]) <= Shiptype[Ship.Type].FuelTanks)
  630. ||
  631. (WormholeExists( COMMANDER.CurSystem, i )))
  632. &&
  633. SolarSystem[i].Status > 0)
  634. {
  635. // Special stories that always get shown: moon, millionaire
  636. if (SolarSystem[i].Special == MOONFORSALE)
  637. {
  638. StrCopy(SBuf, "Seller in ");
  639. StrCat(SBuf,SolarSystemName[i]);
  640. StrCat(SBuf, " System has Utopian Moon available.");
  641. DisplayHeadline(SBuf, &line);
  642. }
  643. if (SolarSystem[i].Special == BUYTRIBBLE)
  644. {
  645. StrCopy(SBuf, "Collector in ");
  646. StrCat(SBuf,SolarSystemName[i]);
  647. StrCat(SBuf, " System seeks to purchase Tribbles.");
  648. DisplayHeadline(SBuf, &line);
  649. }
  650. // And not-always-shown stories
  651. if (GetRandom2(100) <= STORYPROBABILITY * CURSYSTEM.TechLevel + 10 * (5 - Difficulty))
  652. {
  653. j = GetRandom2(6);
  654. switch (j)
  655. {
  656. case 0:
  657. StrCopy(SBuf, "Reports of");
  658. break;
  659. case 1:
  660. StrCopy(SBuf, "News of");
  661. break;
  662. case 2:
  663. StrCopy(SBuf, "New Rumors of");
  664. break;
  665. case 3:
  666. StrCopy(SBuf, "Sources say");
  667. break;
  668. case 4:
  669. StrCopy(SBuf, "Notice:");
  670. break;
  671. case 5:
  672. StrCopy(SBuf, "Evidence Suggests");
  673. break;
  674. }
  675. StrCat(SBuf, " ");
  676. switch (SolarSystem[i].Status)
  677. {
  678. case WAR:
  679. StrCat(SBuf,"Strife and War");
  680. break;
  681. case PLAGUE:
  682. StrCat(SBuf, "Plague Outbreaks");
  683. break;
  684. case DROUGHT:
  685. StrCat(SBuf, "Severe Drought");
  686. break;
  687. case BOREDOM:
  688. StrCat(SBuf, "Terrible Boredom");
  689. break;
  690. case COLD:
  691. StrCat(SBuf, "Cold Weather");
  692. break;
  693. case CROPFAILURE:
  694. StrCat(SBuf, "Crop Failures");
  695. break;
  696. case LACKOFWORKERS:
  697. StrCat(SBuf, "Labor Shortages");
  698. break;
  699. }
  700. StrCat(SBuf, " in the ");
  701. StrCat(SBuf,SolarSystemName[i]);
  702. StrCat(SBuf, " System.");
  703. DisplayHeadline(SBuf, &line);
  704. realNews = true;
  705. }
  706. }
  707. }
  708. // if there's no useful news, we throw up at least one
  709. // headline from our canned news list.
  710. if (! realNews)
  711. {
  712. for (i=0; i< MAXSTORIES; i++)
  713. {
  714. shown[i]= false;
  715. }
  716. for (i=0; i <=GetRandom2(MAXSTORIES); i++)
  717. {
  718. j = GetRandom2(MAXSTORIES);
  719. if (!shown[j] && line <= 150)
  720. {
  721. SysStringByIndex(AnarchyHeadlinesStringList + CURSYSTEM.Politics * 100,j,SBuf,63);
  722. DisplayHeadline(SBuf, &line);
  723. shown[j] = true;
  724. }
  725. }
  726. }
  727. }
  728. // Show the newspaper screen
  729. Boolean NewspaperFormHandleEvent(EventPtr eventP)
  730. {
  731. Boolean handled = false;
  732. switch (eventP->eType)
  733. {
  734. // Show information on current system
  735. case frmOpenEvent:
  736. case frmUpdateEvent:
  737. DrawNewspaperForm();
  738. handled = true;
  739. break;
  740. // Special event
  741. case ctlSelectEvent:
  742. if (eventP->data.ctlSelect.controlID == NewspaperDoneButton)
  743. {
  744. CurForm = SystemInformationForm;
  745. }
  746. FrmGotoForm( CurForm );
  747. handled = true;
  748. break;
  749. default:
  750. break;
  751. }
  752. return handled;
  753. }
  754. // *****************************************************************
  755. // Handling of the events of the Personnel Roster form
  756. // *****************************************************************
  757. Boolean PersonnelRosterFormHandleEvent( EventPtr eventP )
  758. {
  759. Boolean handled = false;
  760. Boolean Sale;
  761. int FirstFree, ForHire, oldtraderskill;
  762. switch (eventP->eType)
  763. {
  764. case frmOpenEvent:
  765. DrawPersonnelRoster();
  766. handled = true;
  767. break;
  768. case frmUpdateEvent:
  769. DrawPersonnelRoster();
  770. handled = true;
  771. break;
  772. case ctlSelectEvent:
  773. Sale = true;
  774. oldtraderskill = TraderSkill( &Ship );
  775. if (eventP->data.ctlSelect.controlID == PersonnelRosterFire0Button)
  776. {
  777. if (FrmAlert( FireMercenaryAlert ) == 0)
  778. {
  779. Ship.Crew[1] = Ship.Crew[2];
  780. Ship.Crew[2] = -1;
  781. }
  782. }
  783. else if (eventP->data.ctlSelect.controlID == PersonnelRosterFire1Button)
  784. {
  785. if (FrmAlert( FireMercenaryAlert ) == 0)
  786. {
  787. Ship.Crew[2] = -1;
  788. }
  789. }
  790. else if (eventP->data.ctlSelect.controlID == PersonnelRosterHire0Button)
  791. {
  792. /*
  793. ForHire = -1;
  794. for (i=1; i<MAXCREWMEMBER; ++i)
  795. {
  796. if (i == Ship.Crew[1] || i == Ship.Crew[2])
  797. continue;
  798. if (Mercenary[i].CurSystem == Mercenary[0].CurSystem)
  799. {
  800. ForHire = i;
  801. break;
  802. }
  803. }
  804. */
  805. ForHire = GetForHire();
  806. FirstFree = -1;
  807. if (Ship.Crew[1] == -1)
  808. FirstFree = 1;
  809. else if (Ship.Crew[2] == -1)
  810. FirstFree = 2;
  811. if ((FirstFree < 0) ||
  812. (AvailableQuarters() <= FirstFree))
  813. {
  814. FrmAlert( NoFreeQuartersAlert );
  815. Sale = false;
  816. }
  817. else
  818. Ship.Crew[FirstFree] = ForHire;
  819. }
  820. if (Sale)
  821. {
  822. DrawPersonnelRoster();
  823. if (oldtraderskill != TraderSkill( &Ship ))
  824. RecalculateBuyPrices(COMMANDER.CurSystem);
  825. }
  826. handled = true;
  827. break;
  828. default:
  829. break;
  830. }
  831. return handled;
  832. }