store.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. /* =============================================================================
  2. * PROGRAM: ularn
  3. * FILENAME: store.c
  4. *
  5. * DESCRIPTION:
  6. * This module contaions functions to handle the locations found on the home
  7. * level and in the dungeon.
  8. *
  9. * =============================================================================
  10. * EXPORTED VARIABLES
  11. *
  12. * None
  13. *
  14. * =============================================================================
  15. * EXPORTED FUNCTIONS
  16. *
  17. * dndstore : Handles entering the DND store
  18. * oschool : Handles entering the college of larn
  19. * obank : Handles entering the bank of larn
  20. * obank2 : Handles entering the 8th branch of the bank of larn
  21. * ointerest : Calculates interest on bank accounts
  22. * item_value : Calculates the value of an item as per the trading post
  23. * otradepost : Handles entering the trading post.
  24. * olrs : Handles entering the Larn Revenue Service
  25. * opad : Handles enetering dealer McDope's pad.
  26. * ohome : Handes the player returning home.
  27. * write_store : Writes all shop data to the save file
  28. * read_store : Reads all shop data from the save file
  29. *
  30. * =============================================================================
  31. */
  32. #include "ularn_game.h"
  33. #include "ularn_win.h"
  34. #include "ularn_ask.h"
  35. #include "saveutils.h"
  36. #include "store.h"
  37. #include "header.h"
  38. #include "player.h"
  39. #include "potion.h"
  40. #include "scroll.h"
  41. #include "dungeon.h"
  42. #include "scores.h"
  43. #include "show.h"
  44. #include "itm.h"
  45. /* =============================================================================
  46. *
  47. * ###### ###### #####
  48. * # # # # # # # # ##### #### ##### ######
  49. * # # ## # # # # # # # # # #
  50. * # # # # # # # ##### # # # # # #####
  51. * # # # # # # # # # # # ##### #
  52. * # # # ## # # # # # # # # # #
  53. * ###### # # ###### ##### # #### # # ######
  54. *
  55. */
  56. /* =============================================================================
  57. * Local variables
  58. */
  59. /* max # items in the dnd store */
  60. #define DNDSIZE 93
  61. static int dnditm = 0;
  62. struct _itm {
  63. long price;
  64. int *mem;
  65. char obj;
  66. char arg;
  67. char qty;
  68. };
  69. /*
  70. * Store inventory and prices
  71. */
  72. static struct _itm itm[DNDSIZE] = {
  73. /*cost memory iven name iven arg how
  74. gp pointer iven[] ivenarg[] many */
  75. { 2, 0, OLEATHER, 0, 3 },
  76. { 10, 0, OSTUDLEATHER, 0, 2 },
  77. { 40, 0, ORING, 0, 2 },
  78. { 85, 0, OCHAIN, 0, 2 },
  79. { 220, 0, OSPLINT, 0, 1 },
  80. { 400, 0, OPLATE, 0, 1 },
  81. { 900, 0, OPLATEARMOR, 0, 1 },
  82. { 2600, 0, OSSPLATE, 0, 1 },
  83. { 150, 0, OSHIELD, 0, 1 },
  84. { 5000, 0, OELVENCHAIN, 0, 0 },
  85. { 1000, 0, OORB, 0, 0 }, /* 10 */
  86. { 10000, 0, OSLAYER, 0, 0 },
  87. /*cost memory iven name iven arg how
  88. gp pointer iven[] ivenarg[] many */
  89. { 2, 0, ODAGGER, 0, 3 },
  90. { 20, 0, OSPEAR, 0, 3 },
  91. { 80, 0, OFLAIL, 0, 2 },
  92. { 150, 0, OBATTLEAXE, 0, 2 },
  93. { 450, 0, OLONGSWORD, 0, 2 },
  94. { 1000, 0, O2SWORD, 0, 2 },
  95. { 5000, 0, OSWORD, 0, 1 },
  96. { 20000, 0, OLANCE, 0, 1 },
  97. { 2000, 0, OSWORDofSLASHING, 0, 0 }, /* 20 */
  98. { 7500, 0, OHAMMER, 0, 0 },
  99. /*cost memory iven name iven arg how
  100. gp pointer iven[] ivenarg[] many */
  101. { 150, 0, OPROTRING, 1, 1 },
  102. { 85, 0, OSTRRING, 1, 1 },
  103. { 120, 0, ODEXRING, 1, 1 },
  104. { 120, 0, OCLEVERRING, 1, 1 },
  105. { 180, 0, OENERGYRING, 0, 1 },
  106. { 125, 0, ODAMRING, 0, 1 },
  107. { 220, 0, OREGENRING, 0, 1 },
  108. { 1000, 0, ORINGOFEXTRA, 0, 1 },
  109. { 280, 0, OBELT, 0, 1 }, /* 30 */
  110. { 400, 0, OAMULET, 5, 1 },
  111. { 500, 0, OCUBEofUNDEAD, 0, 0 },
  112. { 600, 0, ONOTHEFT, 0, 0 },
  113. { 590, 0, OCHEST, 3, 1 },
  114. { 200, 0, OBOOK, 2, 1 },
  115. { 10, 0, OCOOKIE, 0, 3 },
  116. { 666, 0, OHANDofFEAR, 0, 0 },
  117. /*cost memory iven name iven arg how
  118. gp pointer iven[] ivenarg[] many */
  119. { 20, potionknown, OPOTION, PSLEEP, 6 },
  120. { 90, potionknown, OPOTION, PHEALING, 5 },
  121. { 520, potionknown, OPOTION, PRAISELEVEL, 1 }, /* 40 */
  122. { 100, potionknown, OPOTION, PINCABILITY, 2 },
  123. { 50, potionknown, OPOTION, PWISDOM, 2 },
  124. { 150, potionknown, OPOTION, PSTRENGTH, 2 },
  125. { 70, potionknown, OPOTION, PCHARISMA, 1 },
  126. { 30, potionknown, OPOTION, PDIZZINESS, 7 },
  127. { 200, potionknown, OPOTION, PLEARNING, 1 },
  128. { 50, potionknown, OPOTION, PGOLDDET, 1 },
  129. { 80, potionknown, OPOTION, PMONSTDET, 1 },
  130. /*cost memory iven name iven arg how
  131. gp pointer iven[] ivenarg[] many */
  132. { 30, potionknown, OPOTION, PFORGETFUL, 3 },
  133. { 20, potionknown, OPOTION, PWATER, 5 }, /* 50 */
  134. { 40, potionknown, OPOTION, PBLINDNESS, 3 },
  135. { 35, potionknown, OPOTION, PCONFUSION, 2 },
  136. { 520, potionknown, OPOTION, PHEROISM, 1 },
  137. { 90, potionknown, OPOTION, PSTURDINESS, 2 },
  138. { 200, potionknown, OPOTION, PGIANTSTR, 2 },
  139. { 220, potionknown, OPOTION, PFIRERESIST, 4 },
  140. { 80, potionknown, OPOTION, PTREASURE, 6 },
  141. { 370, potionknown, OPOTION, PINSTHEAL, 3 },
  142. { 50, potionknown, OPOTION, PPOISON, 1 },
  143. { 150, potionknown, OPOTION, PSEEINVIS, 3 }, /* 60 */
  144. /*cost memory iven name iven arg how
  145. gp pointer iven[] ivenarg[] many */
  146. { 850, 0, OORBOFDRAGON, 0, 0 },
  147. { 750, 0, OSPIRITSCARAB, 0, 0 },
  148. { 8000, 0, OVORPAL, 0, 0, },
  149. { 100, scrollknown, OSCROLL, SENCHANTARM, 2 },
  150. { 125, scrollknown, OSCROLL, SENCHANTWEAP, 2 },
  151. { 60, scrollknown, OSCROLL, SENLIGHTEN, 4 },
  152. { 10, scrollknown, OSCROLL, SBLANK, 4 },
  153. { 100, scrollknown, OSCROLL, SCREATEMONST, 3 },
  154. { 200, scrollknown, OSCROLL, SCREATEITEM, 2 },
  155. { 110, scrollknown, OSCROLL, SAGGMONST, 1 }, /* 70 */
  156. { 500, scrollknown, OSCROLL, STIMEWARP, 2 },
  157. { 200, scrollknown, OSCROLL, STELEPORT, 2 },
  158. { 250, scrollknown, OSCROLL, SAWARENESS, 4 },
  159. { 20, scrollknown, OSCROLL, SHASTEMONST, 5 },
  160. { 30, scrollknown, OSCROLL, SMONSTHEAL, 3 },
  161. /*cost memory iven name iven arg how
  162. gp pointer iven[] ivenarg[] many */
  163. { 340, scrollknown, OSCROLL, SSPIRITPROT, 1 },
  164. { 340, scrollknown, OSCROLL, SUNDEADPROT, 1 },
  165. { 300, scrollknown, OSCROLL, SSTEALTH, 2 },
  166. { 400, scrollknown, OSCROLL, SMAGICMAP, 2 },
  167. { 500, scrollknown, OSCROLL, SHOLDMONST, 2 }, /* 80 */
  168. { 1000, scrollknown, OSCROLL, SGEMPERFECT, 1 },
  169. { 500, scrollknown, OSCROLL, SSPELLEXT, 1 },
  170. { 340, scrollknown, OSCROLL, SIDENTIFY, 2 },
  171. { 220, scrollknown, OSCROLL, SREMCURSE, 3 },
  172. { 3900, scrollknown, OSCROLL, SANNIHILATE, 0 },
  173. { 610, scrollknown, OSCROLL, SPULVERIZE, 1 },
  174. { 3000, scrollknown, OSCROLL, SLIFEPROT, 0 },
  175. { 300, 0, OSPHTALISMAN, 0, 0 },
  176. { 150, 0, OWWAND, 0, 0 },
  177. { 50, 0, OBRASSLAMP, 0, 0 }, /* 90 */
  178. { 9500, 0, OPSTAFF, 0, 0 },
  179. { 10000, 0, OLIFEPRESERVER, 0, 0 }
  180. };
  181. /* =============================================================================
  182. * Local functions
  183. */
  184. /* =============================================================================
  185. * FUNCTION: write_dnd_store
  186. *
  187. * DESCRIPTION:
  188. * Writes the DnD store inventory data to the save file.
  189. *
  190. * PARAMETERS:
  191. *
  192. * fp : A pointer to the save file being written.
  193. *
  194. * RETURN VALUE:
  195. *
  196. * None.
  197. */
  198. static void write_dnd_store(FILE *fp)
  199. {
  200. int i;
  201. /* write the number of each item remaining */
  202. for (i = 0; i < DNDSIZE; i++)
  203. bwrite(fp, &(itm[i].qty), sizeof(char));
  204. }
  205. /* =============================================================================
  206. * FUNCTION: read_dnd_store
  207. *
  208. * DESCRIPTION:
  209. * Reads the DnD Store inventory from the save file.
  210. *
  211. * PARAMETERS:
  212. *
  213. * fp : A pointer to the save file being read.
  214. *
  215. * RETURN VALUE:
  216. *
  217. * None.
  218. */
  219. static void read_dnd_store(FILE *fp)
  220. {
  221. int i;
  222. /* read the number of each item remaining */
  223. for (i = 0; i < DNDSIZE; i++)
  224. bread(fp, &(itm[i].qty), sizeof(char));
  225. }
  226. /* =============================================================================
  227. * FUNCTION: handsfull
  228. *
  229. * DESCRIPTION:
  230. * Prints the hands full message.
  231. *
  232. * PARAMETERS:
  233. *
  234. * None.
  235. *
  236. * RETURN VALUE:
  237. *
  238. * None.
  239. */
  240. static void handsfull(void)
  241. {
  242. Print("\nYou can't carry anything more!");
  243. nap(2200);
  244. }
  245. /* =============================================================================
  246. * FUNCTION: outofstock
  247. *
  248. * DESCRIPTION:
  249. * Printd the out of stock message.
  250. *
  251. * PARAMETERS:
  252. *
  253. * None.
  254. *
  255. * RETURN VALUE:
  256. *
  257. * None.
  258. */
  259. static void outofstock(void)
  260. {
  261. Print("\nSorry, but we are out of that item.");
  262. nap(2200);
  263. }
  264. /* =============================================================================
  265. * FUNCTION: nogold
  266. *
  267. * DESCRIPTION:
  268. * Prints the insufficient funds message.
  269. *
  270. * PARAMETERS:
  271. *
  272. * None.
  273. *
  274. * RETURN VALUE:
  275. *
  276. * None.
  277. */
  278. static void nogold(void)
  279. {
  280. Print("\nYou don't have enough gold to pay for that!");
  281. nap(2200);
  282. }
  283. /* =============================================================================
  284. * FUNCTION: dnditem
  285. *
  286. * DESCRIPTION:
  287. * Function to print an item from the DnD store inventory at the appropriate
  288. * screen location for a 2 column output.
  289. * It is assumed that items will be displayed in pages of IVENSIZE items.
  290. *
  291. * PARAMETERS:
  292. *
  293. * i : The index of the item in the DnD Store inventory.
  294. *
  295. * RETURN VALUE:
  296. *
  297. * None.
  298. */
  299. static void dnditem(int i)
  300. {
  301. int x, y;
  302. if (i >= DNDSIZE) return;
  303. x = (i & 1) * 40 + 1;
  304. y = ((i % IVENSIZE) >> 1) + 5;
  305. MoveCursor(x, y);
  306. if (itm[i].qty == 0) {
  307. Printf("%39s", "");
  308. return;
  309. }
  310. Printf("%c) ", (i % IVENSIZE) + 'a');
  311. if (itm[i].obj == OPOTION) {
  312. Print("potion of ");
  313. Printf("%s", &potionname[(int)itm[i].arg][1]);
  314. }else if (itm[i].obj == OSCROLL) {
  315. Print("scroll of ");
  316. Printf("%s", &scrollname[(int)itm[i].arg][1]);
  317. }else
  318. Printf("%s", objectname[(int)itm[i].obj]);
  319. MoveCursor(x + 31, y);
  320. Printf("%6ld", ((long)(itm[i].price * 10L)));
  321. }
  322. /* =============================================================================
  323. * FUNCTION: dnd_2hed
  324. *
  325. * DESCRIPTION:
  326. * Function to print the DnD Store heading text.
  327. *
  328. * PARAMETERS:
  329. *
  330. * None.
  331. *
  332. * RETURN VALUE:
  333. *
  334. * None.
  335. */
  336. static void dnd_2hed(void)
  337. {
  338. Print("Welcome to the VLarn Thrift Shoppe. We stock many items explorers find useful\n");
  339. Print("in their adventures. Feel free to browse to your heart's content.\n");
  340. Print("Also be advised that if you break 'em, you pay for 'em.");
  341. }
  342. /* =============================================================================
  343. * FUNCTION: dnd_hed
  344. *
  345. * DESCRIPTION:
  346. * Function to display a page of the DnD Store items.
  347. * The list of items displayed starts at dnditem.
  348. *
  349. * PARAMETERS:
  350. *
  351. * None.
  352. *
  353. * RETURN VALUE:
  354. *
  355. * None.
  356. */
  357. static void dnd_hed(void)
  358. {
  359. int i;
  360. for (i = dnditm; i < IVENSIZE + dnditm; i++) dnditem(i);
  361. MoveCursor(50, 18);
  362. Print("You have ");
  363. }
  364. /* =============================================================================
  365. * Exported functions
  366. */
  367. /* =============================================================================
  368. * FUNCTION: dndstore
  369. */
  370. void dndstore(void)
  371. {
  372. int i;
  373. dnditm = 0;
  374. nosignal = 1; /* disable signals */
  375. set_display(DISPLAY_TEXT);
  376. ClearText();
  377. dnd_2hed();
  378. if (outstanding_taxes > 0) {
  379. Print("\n\nThe VLarn Revenue Service has ordered us to not do business with tax evaders.\n");
  380. UlarnBeep();
  381. Printf("They have also told us that you owe %d gp in back taxes and, as we must\n", (long)outstanding_taxes);
  382. Print("comply with the law, we cannot serve you at this time. So Sorry.\n");
  383. Print("\nPress ");
  384. Standout("escape");
  385. Print(" to leave: ");
  386. get_prompt_input("", "\033", 0);
  387. set_display(DISPLAY_MAP);
  388. nosignal = 0; /* enable signals */
  389. return;
  390. }
  391. dnd_hed();
  392. while (1) {
  393. MoveCursor(59, 18);
  394. Printf("%ld gold piece%s", (long)c[GOLD], plural(c[GOLD]));
  395. ClearToEOL();
  396. ClearToEOPage(1, 20); /* erase to eod */
  397. Print("\nEnter your transaction [");
  398. Standout("space");
  399. Print(" for more, ");
  400. Standout("escape");
  401. Print(" to leave]? ");
  402. i = get_prompt_input("", "abcdefghijklmnopqrstuvwxyz \033", 1);
  403. if (i == 12) {
  404. ClearText();
  405. dnd_2hed();
  406. dnd_hed();
  407. }else if (i == ESC) {
  408. set_display(DISPLAY_MAP);
  409. nosignal = 0; /* enable signals */
  410. return;
  411. }else if (i == ' ') {
  412. ClearToEOPage(1, 4);
  413. if ((dnditm += IVENSIZE) >= DNDSIZE)
  414. dnditm = 0;
  415. dnd_hed();
  416. }else {/* buy something */
  417. Printc((char)i); /* echo the byte */
  418. i += dnditm - 'a';
  419. if (i >= DNDSIZE)
  420. outofstock();
  421. else if (itm[i].qty <= 0)
  422. outofstock();
  423. else if (pocketfull())
  424. handsfull();
  425. else if (c[GOLD] < itm[i].price * 10L)
  426. nogold();
  427. else{
  428. /* Player learns this item */
  429. if (itm[i].mem != 0)
  430. itm[i].mem[(int)itm[i].arg] = 1;
  431. c[GOLD] -= itm[i].price * 10L;
  432. itm[i].qty--;
  433. take(itm[i].obj, itm[i].arg);
  434. if (itm[i].qty == 0)
  435. dnditem(i);
  436. nap(1001);
  437. }
  438. }
  439. }
  440. }
  441. /* =============================================================================
  442. *
  443. * #####
  444. * # # #### # # ###### #### ######
  445. * # # # # # # # # #
  446. * # # # # # ##### # #####
  447. * # # # # # # # ### #
  448. * # # # # # # # # # #
  449. * ##### #### ###### ###### ###### #### ######
  450. *
  451. */
  452. /* =============================================================================
  453. * Local variables
  454. */
  455. /* the list of courses taken and the time required */
  456. #define MAX_COURSES 8
  457. char course[MAX_COURSES] = { 0, 0, 0, 0, 0, 0, 0, 0 };
  458. char coursetime[MAX_COURSES] = { 10, 15, 10, 20, 10, 10, 10, 5 };
  459. /* =============================================================================
  460. * Local functions
  461. */
  462. /* =============================================================================
  463. * FUNCTION: write_college
  464. *
  465. * DESCRIPTION:
  466. * Write the college data to the save file.
  467. *
  468. * PARAMETERS:
  469. *
  470. * fp : A pointer to the save file being written.
  471. *
  472. * RETURN VALUE:
  473. *
  474. * None.
  475. */
  476. static void write_college(FILE *fp)
  477. {
  478. bwrite(fp, course, MAX_COURSES * sizeof(char));
  479. }
  480. /* =============================================================================
  481. * FUNCTION: read_college
  482. *
  483. * DESCRIPTION:
  484. * Function to read the college data from the save file.
  485. *
  486. * PARAMETERS:
  487. *
  488. * fp : A pointer to the save file being read.
  489. *
  490. * RETURN VALUE:
  491. *
  492. * None.
  493. */
  494. static void read_college(FILE *fp)
  495. {
  496. bread(fp, course, MAX_COURSES * sizeof(char));
  497. }
  498. /* =============================================================================
  499. * FUNCTION: sch_hed
  500. *
  501. * DESCRIPTION:
  502. * Function to display the header info for the school.
  503. *
  504. * PARAMETERS:
  505. *
  506. * None.
  507. *
  508. * RETURN VALUE:
  509. *
  510. * None.
  511. */
  512. static void sch_hed(void)
  513. {
  514. ClearText();
  515. Print("The College of VLarn offers the exciting opportunity of higher education to\n");
  516. Print("all inhabitants of the caves. Here is the class schedule:\n\n\n");
  517. Print("\t\t Course Name \t Time Needed\n\n");
  518. /*line 7 of crt*/
  519. if (course[0] == 0)
  520. Print("\t\ta) Fighter's Training I 10 mobuls");
  521. Printc('\n');
  522. if (course[1] == 0)
  523. Print("\t\tb) Fighter's Training II 15 mobuls");
  524. Printc('\n');
  525. if (course[2] == 0)
  526. Print("\t\tc) Introduction to Wizardry 10 mobuls");
  527. Printc('\n');
  528. if (course[3] == 0)
  529. Print("\t\td) Applied Wizardry 20 mobuls");
  530. Printc('\n');
  531. if (course[4] == 0)
  532. Print("\t\te) Behavioral Psychology 10 mobuls");
  533. Printc('\n');
  534. if (course[5] == 0)
  535. Print("\t\tf) Faith for Today 10 mobuls");
  536. Printc('\n');
  537. if (course[6] == 0)
  538. Print("\t\tg) Contemporary Dance 10 mobuls");
  539. Printc('\n');
  540. if (course[7] == 0)
  541. Print("\t\th) History of VLarn 5 mobuls");
  542. Print("\n\n\t\tAll courses cost 250 gold pieces.");
  543. MoveCursor(30, 18);
  544. Print("You are presently carrying ");
  545. }
  546. /* =============================================================================
  547. * Exported functions
  548. */
  549. /* =============================================================================
  550. * FUNCTION: oschool
  551. */
  552. void oschool(void)
  553. {
  554. int i;
  555. long time_used;
  556. nosignal = 1; /* disable signals */
  557. set_display(DISPLAY_TEXT);
  558. sch_hed();
  559. while (1) {
  560. MoveCursor(57, 18);
  561. Printf("%d gold piece%s. ", (long)c[GOLD], plural(c[GOLD]));
  562. Print("\nWhat is your choice [");
  563. Standout("escape");
  564. Print(" to leave] ? ");
  565. yrepcount = 0;
  566. i = get_prompt_input("", "abcdefgh\033", 1);
  567. if (i == 12) {
  568. /* Pressed ^R, so redraw */
  569. sch_hed();
  570. continue;
  571. }else if (i == ESC) {
  572. /* exit */
  573. nosignal = 0;
  574. set_display(DISPLAY_MAP);
  575. return;
  576. }
  577. Printc((char)i);
  578. if (c[GOLD] < 250)
  579. nogold();
  580. else{
  581. if (course[i - 'a']) {
  582. Print("\nSorry but that class is filled.");
  583. nap(1000);
  584. }else if (i <= 'h') {
  585. c[GOLD] -= 250;
  586. time_used = 0;
  587. switch (i) {
  588. case 'a':
  589. c[STRENGTH] += 2;
  590. c[CONSTITUTION]++;
  591. Print("\nYou feel stronger!");
  592. ClearToEOL();
  593. MoveCursor(16, 7);
  594. ClearToEOL();
  595. break;
  596. case 'b':
  597. if (course[0] == 0) {
  598. Print("\nSorry but this class has a prerequisite of Fighter's Training I");
  599. ClearToEOL();
  600. c[GOLD] += 250;
  601. time_used = -10000;
  602. }else {
  603. Print("\nYou feel much stronger!");
  604. ClearToEOL();
  605. MoveCursor(16, 8);
  606. ClearToEOL();
  607. c[STRENGTH] += 2;
  608. c[CONSTITUTION] += 2;
  609. }
  610. break;
  611. case 'c':
  612. c[INTELLIGENCE] += 2;
  613. Print("\nThe task before you now seems more attainable!");
  614. ClearToEOL();
  615. MoveCursor(16, 9);
  616. ClearToEOL();
  617. break;
  618. case 'd':
  619. if (course[2] == 0) {
  620. Print("\nSorry but this class has a prerequisite of Introduction to Wizardry");
  621. ClearToEOL();
  622. c[GOLD] += 250;
  623. time_used = -10000;
  624. }else {
  625. Print("\nThe task before you now seems very attainable!");
  626. ClearToEOL();
  627. MoveCursor(16, 10);
  628. ClearToEOL();
  629. c[INTELLIGENCE] += 2;
  630. }
  631. break;
  632. case 'e':
  633. c[CHARISMA] += 3;
  634. Print("\nYou now feel like a born leader!");
  635. ClearToEOL();
  636. MoveCursor(16, 11);
  637. ClearToEOL();
  638. break;
  639. case 'f':
  640. c[WISDOM] += 2;
  641. Print("\nYou now feel more confident that you can find the potion in time!");
  642. ClearToEOL();
  643. MoveCursor(16, 12);
  644. ClearToEOL();
  645. break;
  646. case 'g':
  647. c[DEXTERITY] += 3;
  648. Print("\nYou feel like dancing!");
  649. ClearToEOL();
  650. MoveCursor(16, 13);
  651. ClearToEOL();
  652. break;
  653. case 'h':
  654. c[INTELLIGENCE]++;
  655. Print("\nWow! e = mc^2!");
  656. ClearToEOL();
  657. MoveCursor(16, 14);
  658. ClearToEOL();
  659. break;
  660. }
  661. time_used += coursetime[i - 'a'] * 100;
  662. if (time_used > 0) {
  663. gtime += time_used;
  664. /* remember that he has taken that course */
  665. course[i - 'a']++;
  666. /* he regenerated */
  667. c[HP] = c[HPMAX];
  668. c[SPELLS] = c[SPELLMAX];
  669. /* cure blindness too! */
  670. if (c[BLINDCOUNT])
  671. c[BLINDCOUNT] = 1;
  672. /* end confusion */
  673. if (c[CONFUSE])
  674. c[CONFUSE] = 1;
  675. /* adjust parameters for time change */
  676. adjusttime((long)time_used);
  677. }
  678. nap(1000);
  679. }
  680. }
  681. }
  682. }
  683. /* =============================================================================
  684. *
  685. * ###### #
  686. * # # ## # # # # # ## ##### # #
  687. * # # # # ## # # # # # # # # ## #
  688. * ###### # # # # # #### # # # # # # # #
  689. * # # ###### # # # # # # ###### ##### # # #
  690. * # # # # # ## # # # # # # # # ##
  691. * ###### # # # # # # Of ####### # # # # # #
  692. *
  693. */
  694. /* =============================================================================
  695. * Local variables
  696. */
  697. /*
  698. * limit of 1 million gold pieces in bank
  699. */
  700. #define BANKLIMIT 1000000
  701. /* last time he was in bank */
  702. static long lasttime = 0;
  703. /* the reference to screen location for each gem */
  704. static short gemorder[IVENSIZE] = { 0 };
  705. /* the appraisal of the gems */
  706. static long gemvalue[IVENSIZE] = { 0 };
  707. /* =============================================================================
  708. * Local functions
  709. */
  710. /* =============================================================================
  711. * FUNCTION: write_bank
  712. *
  713. * DESCRIPTION:
  714. * Function to write the bank data to the save file.
  715. *
  716. * PARAMETERS:
  717. *
  718. * fp : A pointer to the save file being written.
  719. *
  720. * RETURN VALUE:
  721. *
  722. * None.
  723. */
  724. static void write_bank(FILE *fp)
  725. {
  726. bwrite(fp, (char *)&lasttime, sizeof(long));
  727. }
  728. /* =============================================================================
  729. * FUNCTION: read_bank
  730. *
  731. * DESCRIPTION:
  732. * Function to read the bank data from the save file.
  733. *
  734. * PARAMETERS:
  735. *
  736. * fp : A pointer to the save file being read.
  737. *
  738. * RETURN VALUE:
  739. *
  740. * None.
  741. */
  742. static void read_bank(FILE *fp)
  743. {
  744. bread(fp, (char *)&lasttime, sizeof(long));
  745. }
  746. /* =============================================================================
  747. * FUNCTION: appraise
  748. *
  749. * DESCRIPTION:
  750. * Function to appraise the eye of larn and offer to buy it.
  751. *
  752. * PARAMETERS:
  753. *
  754. * eye : The index of the inventory slot holding the eye of larn
  755. *
  756. * order : The order of the eye oflarn in the gem appraisal display
  757. *
  758. * RETURN VALUE:
  759. *
  760. * None.
  761. */
  762. static void appraise(int eye, int order)
  763. {
  764. long amt;
  765. MoveCursor(1, 20);
  766. Printf("I see you have %s", objectname[OLARNEYE]);
  767. Print(" I must commend you. I didn't think\nyou could get it.");
  768. Print(" Shall I appraise it for you? ");
  769. yrepcount = 0;
  770. if (getyn() == 'y') {
  771. Print("yes.\n Just one moment please...");
  772. nap(1000);
  773. amt = (long)250000L - ((gtime * 7) / 100) * 100;
  774. if (amt < 50000L) amt = 50000L;
  775. ClearToEOPage(1, 20);
  776. MoveCursor(1, 20);
  777. Printf("\nThis is an excellent stone.\n");
  778. Printf("It is worth %d gold pieces to us\n", (long)amt);
  779. Print("Would you like to sell it? ");
  780. yrepcount = 0;
  781. if (getyn() == 'y') {
  782. Print("yes");
  783. c[GOLD] += amt;
  784. iven[eye] = ONOTHING;
  785. c[EYEOFLARN] = 0;
  786. MoveCursor( (order % 2) * 40 + 1, (order >> 1) + 4 );
  787. Printf("%39s", "");
  788. MoveCursor(40, 17);
  789. Printf("%8d", (long)c[BANKACCOUNT]);
  790. MoveCursor(49, 18);
  791. Printf("%8d", (long)c[GOLD]);
  792. }else {
  793. Print("no");
  794. Print("\nIt is, of course, your privilege to keep the stone.");
  795. nap(500);
  796. }
  797. }else {
  798. Print("no.");
  799. nap(500);
  800. }
  801. ClearToEOPage(1, 20);
  802. MoveCursor(1, 20);
  803. }
  804. /* =============================================================================
  805. * FUNCTION: obanksub
  806. *
  807. * DESCRIPTION:
  808. * Function to handle the main processing for the bank.
  809. *
  810. * PARAMETERS:
  811. *
  812. * None.
  813. *
  814. * RETURN VALUE:
  815. *
  816. * None.
  817. */
  818. static void obanksub(void)
  819. {
  820. long amt;
  821. int i, k, eye = 0;
  822. ointerest(); /* credit any needed interest */
  823. if (level == 8) c[TELEFLAG] = 0;
  824. k = 0;
  825. for (i = 0; i < IVENSIZE; i++) {
  826. switch (iven[i]) {
  827. case OLARNEYE:
  828. case ODIAMOND:
  829. case OEMERALD:
  830. case ORUBY:
  831. case OSAPPHIRE:
  832. if (iven[i] == OLARNEYE) {
  833. eye = i;
  834. gemvalue[i] = (long)250000L - ((gtime * 7) / 100) * 100;
  835. if (gemvalue[i] < 50000L)
  836. gemvalue[i] = 50000L;
  837. }else
  838. gemvalue[i] = ivenarg[i] * 100;
  839. gemorder[i] = (short)k;
  840. MoveCursor((k % 2) * 40 + 1, (k >> 1) + 4 );
  841. Printf("%c) %s", i + 'a', objectname[(int)iven[i]]);
  842. MoveCursor((k % 2) * 40 + 33, (k >> 1) + 4 );
  843. Printf("%5d", (long)gemvalue[i]);
  844. k++;
  845. break;
  846. default:
  847. gemvalue[i] = 0;
  848. }
  849. }
  850. MoveCursor(31, 17);
  851. Printf("You have %8d gold piece%s in the bank.",
  852. (long)c[BANKACCOUNT],
  853. plural(c[BANKACCOUNT]));
  854. MoveCursor(40, 18);
  855. Printf("You have %8d gold piece%s", (long)c[GOLD], plural(c[GOLD]));
  856. if (c[BANKACCOUNT] + c[GOLD] >= 500000L)
  857. Print("\nNote: Only deposits under 1,000,000gp can earn interest.");
  858. if (eye)
  859. appraise(eye, gemorder[eye]);
  860. while (1) {
  861. ClearToEOPage(1, 20);
  862. MoveCursor(1, 20);
  863. Print("\nYour wish? [(");
  864. Standout("d");
  865. Print(") deposit, (");
  866. Standout("w");
  867. Print(") withdraw, (");
  868. Standout("s");
  869. Print(") sell a stone, or ");
  870. Standout("escape");
  871. Print("] ");
  872. yrepcount = 0;
  873. i = get_prompt_input("", "dws\033", 1);
  874. switch (i) {
  875. case 'd':
  876. Print("deposit\nHow much? ");
  877. amt = get_num_input((long)c[GOLD]);
  878. if (amt < 0)
  879. amt = 0;
  880. else if (amt > c[GOLD]) {
  881. Print("\n You don't have that much.");
  882. amt = 0;
  883. nap(2000);
  884. }
  885. /* Deposit the money */
  886. c[GOLD] -= amt;
  887. c[BANKACCOUNT] += amt;
  888. break;
  889. case 'w':
  890. Print("withdraw\nHow much? ");
  891. amt = get_num_input((long)c[BANKACCOUNT]);
  892. if (amt < 0)
  893. amt = 0;
  894. else if (amt > c[BANKACCOUNT]) {
  895. Print("\n You don't have that much in the bank!");
  896. amt = 0;
  897. nap(2000);
  898. }
  899. /* Withdraw the money */
  900. c[GOLD] += amt;
  901. c[BANKACCOUNT] -= amt;
  902. break;
  903. case 's':
  904. i = get_prompt_input("sell\nWhich stone would you like to sell? ",
  905. "abcdefghijklmnopqrstuvwxys*", 1);
  906. if (i == '*') {
  907. /* sell all gems */
  908. for (i = 0; i < IVENSIZE; i++) {
  909. if (gemvalue[i]) {
  910. if (iven[i] == OLARNEYE)
  911. c[EYEOFLARN] = 0;
  912. c[GOLD] += gemvalue[i];
  913. iven[i] = ONOTHING;
  914. gemvalue[i] = 0;
  915. k = gemorder[i];
  916. MoveCursor( (k % 2) * 40 + 1, (k >> 1) + 4 );
  917. Printf("%39s", "");
  918. }
  919. }
  920. }else {
  921. if (gemvalue[i = i - 'a'] == 0) {
  922. Printf("\nItem %c is not a gemstone!", i + 'a');
  923. nap(2000);
  924. }else {
  925. if (iven[i] == OLARNEYE)
  926. c[EYEOFLARN] = 0;
  927. c[GOLD] += gemvalue[i];
  928. iven[i] = ONOTHING;
  929. gemvalue[i] = 0;
  930. k = gemorder[i];
  931. MoveCursor( (k % 2) * 40 + 1, (k >> 1) + 4 );
  932. Printf("%39s", "");
  933. }
  934. }
  935. break;
  936. case ESC:
  937. return;
  938. }
  939. MoveCursor(40, 17);
  940. Printf("%8d", (long)c[BANKACCOUNT]);
  941. MoveCursor(49, 18);
  942. Printf("%8d", (long)c[GOLD]);
  943. }
  944. }
  945. /* =============================================================================
  946. * FUNCTION: banktitle
  947. *
  948. * DESCRIPTION:
  949. * Function to display the title for this branck of the bank and then
  950. * perform the bank processing.
  951. *
  952. * PARAMETERS:
  953. *
  954. * str : The title string for the branch
  955. *
  956. * RETURN VALUE:
  957. *
  958. * None.
  959. */
  960. static void banktitle(char *str)
  961. {
  962. nosignal = 1; /* disable signals */
  963. set_display(DISPLAY_TEXT);
  964. ClearText();
  965. Print(str);
  966. if (outstanding_taxes > 0) {
  967. Print("\n\nThe VLarn Revenue Service has ordered that your account be frozen until all\n");
  968. UlarnBeep();
  969. Printf("levied taxes have been paid. They have also told us that you owe %d gp in\n", (long)outstanding_taxes);
  970. Print("taxes and we must comply with them. We cannot serve you at this time. Sorry.\n");
  971. Print("We suggest you go to the LRS office and pay your taxes.\n");
  972. Print("\nPress ");
  973. Standout("escape");
  974. Print(" to leave: ");
  975. get_prompt_input("", "\033", 0);
  976. set_display(DISPLAY_MAP);
  977. nosignal = 0; /* enable signals */
  978. return;
  979. }
  980. Print("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
  981. obanksub();
  982. nosignal = 0; /* enable signals */
  983. set_display(DISPLAY_MAP);
  984. }
  985. /* =============================================================================
  986. * Exported functions
  987. */
  988. /* =============================================================================
  989. * FUNCTION: obank
  990. */
  991. void obank(void)
  992. {
  993. banktitle(" Welcome to the First National Bank of VLarn.");
  994. }
  995. /* =============================================================================
  996. * FUNCTION: obank2
  997. */
  998. void obank2(void)
  999. {
  1000. banktitle("Welcome to the 8th-level branch office of the First National Bank of VLarn.");
  1001. }
  1002. /* =============================================================================
  1003. * FUNCTION: ointerest
  1004. */
  1005. void ointerest(void)
  1006. {
  1007. int i;
  1008. if (c[BANKACCOUNT] < 0)
  1009. c[BANKACCOUNT] = 0;
  1010. else if ((c[BANKACCOUNT] > 0) && (c[BANKACCOUNT] < BANKLIMIT)) {
  1011. i = (gtime - lasttime) / 100; /*# mobuls elapsed since last here*/
  1012. while ((i-- > 0) && (c[BANKACCOUNT] < BANKLIMIT))
  1013. /*
  1014. ** at 1 mobul ~=~ 1 hour, is 10 % a year
  1015. */
  1016. c[BANKACCOUNT] += (long)(c[BANKACCOUNT] / 877);
  1017. }
  1018. lasttime = (gtime / 100) * 100;
  1019. }
  1020. /* =============================================================================
  1021. *
  1022. * #######
  1023. * # ##### ## ##### # # # ####
  1024. * # # # # # # # # ## # # #
  1025. * # # # # # # # # # # # #
  1026. * # ##### ###### # # # # # # # ###
  1027. * # # # # # # # # # ## # #
  1028. * # # # # # ##### # # # ####
  1029. */
  1030. /* =============================================================================
  1031. * Local functions
  1032. */
  1033. /* =============================================================================
  1034. * FUNCTION: otradhead
  1035. *
  1036. * DESCRIPTION:
  1037. * Function to print the trading post heading text.
  1038. *
  1039. * PARAMETERS:
  1040. *
  1041. * None.
  1042. *
  1043. * RETURN VALUE:
  1044. *
  1045. * None.
  1046. */
  1047. static void otradhead(void)
  1048. {
  1049. ClearText();
  1050. Print("Welcome to the VLarn Trading Post. We buy items that explorers no longer find\n");
  1051. Print("useful. Since the condition of the items you bring in is not certain,\n");
  1052. Print("and we incur great expense in reconditioning the items, we usually pay\n");
  1053. Print("only 20% of their value were they to be new. If the items are badly\n");
  1054. Print("damaged, we will pay only 10% of their new value.\n\n");
  1055. }
  1056. /* =============================================================================
  1057. * FUNCTION: cnsitm
  1058. *
  1059. * DESCRIPTION:
  1060. * Prints the 'can't sell unidentified items' message.
  1061. *
  1062. * PARAMETERS:
  1063. *
  1064. * None.
  1065. *
  1066. * RETURN VALUE:
  1067. *
  1068. * None.
  1069. */
  1070. static void cnsitm(void)
  1071. {
  1072. Print("\nSorry, we can't accept unidentified objects.");
  1073. }
  1074. /* =============================================================================
  1075. * Exported functions
  1076. */
  1077. /* =============================================================================
  1078. * FUNCTION: item_value
  1079. */
  1080. int item_value(int it, int itarg)
  1081. {
  1082. int arg;
  1083. int value;
  1084. int found_item;
  1085. int j;
  1086. value = -1;
  1087. if ((it == ODIAMOND) ||
  1088. (it == ORUBY) ||
  1089. (it == OEMERALD) ||
  1090. (it == OSAPPHIRE))
  1091. value = (long)20 * itarg;
  1092. else{
  1093. found_item = 0;
  1094. j = 0;
  1095. while ((j < DNDSIZE) && (!found_item)) {
  1096. if (itm[j].obj == it) {
  1097. if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION))
  1098. value = (long)2 * itm[j + itarg].price;
  1099. else{
  1100. value = (long)itm[j].price;
  1101. arg = itarg;
  1102. if (arg >= 0) value *= 2;
  1103. while ((arg != 0) && (value < 500000L)) {
  1104. if (arg > 0) {
  1105. /* appreciate if a +n object */
  1106. value = (14 * (value + 67)) / 10;
  1107. arg--;
  1108. }else {
  1109. /* depreciate -n object */
  1110. value = (value * 10) / 14;
  1111. arg++;
  1112. }
  1113. }
  1114. }
  1115. /* always offer at least 1 gp */
  1116. if (value == 0) value = 1;
  1117. found_item = 1;
  1118. }
  1119. j++;
  1120. }
  1121. }
  1122. return value;
  1123. }
  1124. /* =============================================================================
  1125. * FUNCTION: otradepost
  1126. */
  1127. void otradepost(void)
  1128. {
  1129. int ans;
  1130. int no_sell_flag; /* set to true if the selected item can't be sold */
  1131. int idx; /* inventory index of the item to sell */
  1132. int it, itarg; /* item number and argument of the item to sell */
  1133. long value; /* value of the item in gold */
  1134. set_display(DISPLAY_TEXT);
  1135. ClearText();
  1136. yrepcount = 0;
  1137. dnditm = 0;
  1138. otradhead();
  1139. while (1) {
  1140. Print("\nWhat item do you want to sell to us [");
  1141. Standout("*");
  1142. Print(" for list, or ");
  1143. Standout("escape");
  1144. Print("] ? ");
  1145. ans = get_prompt_input("", "abcdefghijklmnopqrstuvwxyz.*\033", 1);
  1146. if (ans == ESC) {
  1147. recalc();
  1148. set_display(DISPLAY_MAP);
  1149. return;
  1150. }else if (ans == '*') {
  1151. ClearText();
  1152. qshowstr();
  1153. otradhead();
  1154. }else if ((ans >= 'a') && (ans <= 'z')) {
  1155. no_sell_flag = 0;
  1156. idx = ans - 'a';
  1157. it = iven[idx];
  1158. itarg = ivenarg[idx];
  1159. if (it == OSCROLL) {
  1160. if (!scrollknown[itarg]) {
  1161. /* can't sell unidentified item */
  1162. no_sell_flag = 1;
  1163. cnsitm();
  1164. }
  1165. }else if (it == OPOTION) {
  1166. if (!potionknown[itarg]) {
  1167. /* can't sell unidentified item */
  1168. no_sell_flag = 1;
  1169. cnsitm();
  1170. }
  1171. }else if ((it == OLANCE) && ramboflag) {
  1172. no_sell_flag = 1;
  1173. Print("\nYou don't *really* want to sell that, now do you?");
  1174. }
  1175. if (!no_sell_flag) {
  1176. if (it == ONOTHING)
  1177. Printf("\nYou don't have item %c!", ans);
  1178. else{
  1179. value = item_value(it, itarg);
  1180. if (value >= 0) {
  1181. /* show what the item was */
  1182. show3(idx);
  1183. Printf("\nItem (%c) is worth %d gold piece%s to us. Do you want to sell it? ", ans, (long)value, plural(value));
  1184. if (getyn() == 'y') {
  1185. Print("yes.\n");
  1186. c[GOLD] += value;
  1187. if (c[WEAR] == idx) c[WEAR] = -1;
  1188. if (c[WIELD] == idx) c[WIELD] = -1;
  1189. if (c[SHIELD] == idx) c[SHIELD] = -1;
  1190. adjustcvalues(it, itarg);
  1191. iven[idx] = ONOTHING;
  1192. }else
  1193. Print("no thanks.\n");
  1194. }else
  1195. /*
  1196. * negative value indicates that the item is not in the price list
  1197. */
  1198. Print("\nSo sorry but we are not authorized to accept that item.");
  1199. }
  1200. } /* if not no_sell_flag */
  1201. } /* if item selected */
  1202. }
  1203. }
  1204. /* =============================================================================
  1205. *
  1206. * # ###### #####
  1207. * # # # # #
  1208. * # # # #
  1209. * # ###### #####
  1210. * # # # #
  1211. * # # # # #
  1212. * ####### # # #####
  1213. *
  1214. */
  1215. /* =============================================================================
  1216. * Exported functions
  1217. */
  1218. /* =============================================================================
  1219. * FUNCTION: olrs
  1220. */
  1221. void olrs(void)
  1222. {
  1223. int i;
  1224. long amt;
  1225. nosignal = 1; /* disable signals */
  1226. set_display(DISPLAY_TEXT);
  1227. ClearText();
  1228. MoveCursor(1, 4);
  1229. if (outstanding_taxes) {
  1230. if (cheat) {
  1231. Print("Sorry but it seems you are trying to pay off your taxes by cheating!");
  1232. Print("\n\n\tpress [escape] to exit the office.");
  1233. get_prompt_input("", "\033", 0);
  1234. nosignal = 0; /* enable signals */
  1235. set_display(DISPLAY_MAP);
  1236. return;
  1237. }
  1238. }
  1239. Print("Welcome to the VLarn Revenue Service district office. How can we help you?");
  1240. while (1) {
  1241. MoveCursor(1, 6);
  1242. if (outstanding_taxes > 0)
  1243. Printf("You presently owe %d gp in taxes. ", (long)outstanding_taxes);
  1244. else
  1245. Print("You do not owe us any taxes. ");
  1246. MoveCursor(1, 8);
  1247. if (c[GOLD] > 0)
  1248. Printf("You have %6d gp. ", (long)c[GOLD]);
  1249. else
  1250. Print("You have no gold pieces. ");
  1251. MoveCursor(1, 20);
  1252. Print("\n\nYour wish? [(");
  1253. Standout("p");
  1254. Print(") pay taxes, or ");
  1255. Standout("escape");
  1256. Print("] ");
  1257. ClearToEOPage(40, 22);
  1258. yrepcount = 0;
  1259. i = get_prompt_input("", "p\033", 1);
  1260. switch (i) {
  1261. case 'p':
  1262. Print("pay taxes.\nHow much? ");
  1263. amt = (long)get_num_input((long)c[GOLD]);
  1264. if (amt < 0)
  1265. amt = 0;
  1266. else if (amt > c[GOLD]) {
  1267. Print(" You don't have that much.");
  1268. amt = 0;
  1269. }
  1270. c[GOLD] -= paytaxes((long)amt);
  1271. nap(500);
  1272. break;
  1273. case ESC:
  1274. nosignal = 0; /* enable signals */
  1275. set_display(DISPLAY_MAP);
  1276. return;
  1277. }
  1278. }
  1279. }
  1280. /* =============================================================================
  1281. *
  1282. * # # ###### ###
  1283. * ## ## #### # # #### ##### ###### ### ####
  1284. * # # # # # # # # # # # # # # #
  1285. * # # # # # # # # # # ##### # ####
  1286. * # # # # # # # ##### # #
  1287. * # # # # # # # # # # # #
  1288. * # # #### ###### #### # ###### ####
  1289. *
  1290. */
  1291. /* =============================================================================
  1292. * Local variables
  1293. */
  1294. typedef enum DrugType {
  1295. DOPE_SPEED,
  1296. DOPE_ACID,
  1297. DOPE_HASH,
  1298. DOPE_MUSHROOMS,
  1299. DOPE_COKE,
  1300. DOPE_COUNT
  1301. } DrugType;
  1302. struct DopeDataType {
  1303. char *Name; /* The name of this dope */
  1304. int Price; /* The selling price */
  1305. int Line; /* The display line for showing in MacDope's inventory*/
  1306. ObjectIdType Item; /* The item id for the drug */
  1307. };
  1308. /*
  1309. * Flags for what dope has been sold
  1310. * 0 = Dealer has in stock
  1311. * 1 = Sold out
  1312. */
  1313. char drug[DOPE_COUNT] =
  1314. { 0, 0, 0, 0, 0 };
  1315. static struct DopeDataType DopeData[DOPE_COUNT] =
  1316. {
  1317. { "Killer Speed", 100, 8, OSPEED },
  1318. { "Groovy Acid", 250, 9, OACID },
  1319. { "Moster Hash", 500, 10, OHASH },
  1320. { "Trippy Shrooms", 1000, 11, OSHROOMS },
  1321. { "Cool Coke", 5000, 12, OCOKE }
  1322. };
  1323. /* =============================================================================
  1324. * Local functions
  1325. */
  1326. /* =============================================================================
  1327. * FUNCTION: write_pad
  1328. *
  1329. * DESCRIPTION:
  1330. * Function to write the data for McDope's pad to the save file.
  1331. *
  1332. * PARAMETERS:
  1333. *
  1334. * fp : A pointer to the save file being written.
  1335. *
  1336. * RETURN VALUE:
  1337. *
  1338. * None.
  1339. */
  1340. static void write_pad(FILE *fp)
  1341. {
  1342. bwrite(fp, drug, DOPE_COUNT * sizeof(char));
  1343. }
  1344. /* =============================================================================
  1345. * FUNCTION: read_pad
  1346. *
  1347. * DESCRIPTION:
  1348. * Function to read the data for McDope's pad from the save file.
  1349. *
  1350. * PARAMETERS:
  1351. *
  1352. * fp : a pointer to the save file being read.
  1353. *
  1354. * RETURN VALUE:
  1355. *
  1356. * None.
  1357. */
  1358. static void read_pad(FILE *fp)
  1359. {
  1360. bread(fp, drug, DOPE_COUNT * sizeof(char));
  1361. }
  1362. /* =============================================================================
  1363. * FUNCTION: nomore
  1364. *
  1365. * DESCRIPTION:
  1366. * Function to print the out of stock message for McDope's.
  1367. *
  1368. * PARAMETERS:
  1369. *
  1370. * None.
  1371. *
  1372. * RETURN VALUE:
  1373. *
  1374. * None.
  1375. */
  1376. static void nomore(void)
  1377. {
  1378. Print("\nSorry man, I ain't got no more of that stuff.");
  1379. nap(2200);
  1380. }
  1381. /* =============================================================================
  1382. * FUNCTION: nocash
  1383. *
  1384. * DESCRIPTION:
  1385. * Function to print the insufficient funds message for McDope's.
  1386. *
  1387. * PARAMETERS:
  1388. *
  1389. * None.
  1390. *
  1391. * RETURN VALUE:
  1392. *
  1393. * None.
  1394. */
  1395. static void nocash(void)
  1396. {
  1397. Print("\nWhattaya trying to pull on me? You aint got the cash!");
  1398. nap(1200);
  1399. }
  1400. /* =============================================================================
  1401. * FUNCTION: pad_hd
  1402. *
  1403. * DESCRIPTION:
  1404. * Function to display the header info for Dealer McDope's pad
  1405. *
  1406. * PARAMETERS:
  1407. *
  1408. * None.
  1409. *
  1410. * RETURN VALUE:
  1411. *
  1412. * None.
  1413. */
  1414. static void pad_hd(void)
  1415. {
  1416. int Dope;
  1417. ClearText();
  1418. Print("Hey man, welcome to Dealer McDope's Pad! I gots the some of the finest dope\n");
  1419. Print("you'll find anywhere in VLarn -- check it out...\n\n\n");
  1420. Print("\t\t The Stash\t\t\tThe Cash\n\n");
  1421. for (Dope = 0; Dope < DOPE_COUNT; Dope++) {
  1422. if (drug[Dope] == 0) {
  1423. MoveCursor(1, DopeData[Dope].Line);
  1424. Printf("\t\t%c) %s", 'a' + Dope, DopeData[Dope].Name);
  1425. MoveCursor(49, DopeData[Dope].Line);
  1426. Printf("%d bucks", DopeData[Dope].Price);
  1427. }
  1428. }
  1429. MoveCursor(30, 18);
  1430. Print("Looks like you got about ");
  1431. }
  1432. /* =============================================================================
  1433. * FUNCTION: snag
  1434. *
  1435. * DESCRIPTION:
  1436. * Function to get something from McDope's.
  1437. * Checks the inventory size to make sure the player can carry the item.
  1438. *
  1439. * PARAMETERS:
  1440. *
  1441. * itm : The item being bought.
  1442. *
  1443. * RETURN VALUE:
  1444. *
  1445. * 0 => no free inventory slot for the item
  1446. * 1 => the player could take the item
  1447. */
  1448. static int snag(int itm)
  1449. {
  1450. ClearToEOPage(1, 20);
  1451. if (pocketfull()) {
  1452. Print("\nHey, you can't carry any more.");
  1453. return 0;
  1454. }else {
  1455. Print("\nOk, here ya go.");
  1456. take(itm, 0);
  1457. return 1;
  1458. }
  1459. }
  1460. /* =============================================================================
  1461. * Exported functions
  1462. */
  1463. /* =============================================================================
  1464. * FUNCTION: opad
  1465. */
  1466. void opad(void)
  1467. {
  1468. int i;
  1469. int Dope;
  1470. nosignal = 1; /* disable signals */
  1471. set_display(DISPLAY_TEXT);
  1472. pad_hd();
  1473. while (1) {
  1474. MoveCursor(57, 18);
  1475. Printf("%d buck%s on you. ", (long)c[GOLD],
  1476. plural(c[GOLD]));
  1477. Print("\nSo, whaddya want [");
  1478. Standout("escape");
  1479. Print(" to split] ? ");
  1480. yrepcount = 0;
  1481. i = get_prompt_input("", "abcde\033", 1);
  1482. if (i == 12) {
  1483. /* Redraw */
  1484. pad_hd();
  1485. continue;
  1486. }else if (i == ESC) {
  1487. nosignal = 0;
  1488. set_display(DISPLAY_MAP);
  1489. return;
  1490. }
  1491. Printc((char)i);
  1492. if ((i >= 'a') && (i < ('a' + DOPE_COUNT))) {
  1493. Dope = i - 'a';
  1494. if (drug[Dope])
  1495. /* None of that dope left */
  1496. nomore();
  1497. else{
  1498. if (c[GOLD] < DopeData[Dope].Price)
  1499. /* Player can't afford this */
  1500. nocash();
  1501. else if (snag(DopeData[Dope].Item)) {
  1502. /* Player can afford and has taken, so pay for it. */
  1503. c[GOLD] -= DopeData[Dope].Price;
  1504. /* Remove line from the screen for this dope */
  1505. MoveCursor(16, DopeData[Dope].Line);
  1506. ClearToEOL();
  1507. /* Note tht this drug has been bought */
  1508. drug[Dope]++;
  1509. nap(1000);
  1510. }
  1511. }
  1512. }
  1513. } /*end while(1) */
  1514. } /* end pad() */
  1515. /* =============================================================================
  1516. *
  1517. * # #
  1518. * # # #### # # ######
  1519. * # # # # ## ## #
  1520. * ####### # # # ## # #####
  1521. * # # # # # # #
  1522. * # # # # # # #
  1523. * # # #### # # ######
  1524. *
  1525. */
  1526. /* =============================================================================
  1527. * Exported functions
  1528. */
  1529. /* =============================================================================
  1530. * FUNCTION: ohome
  1531. */
  1532. void ohome(void)
  1533. {
  1534. int i;
  1535. set_display(DISPLAY_TEXT);
  1536. nosignal = 1; /* disable signals */
  1537. for (i = 0; i < IVENSIZE; i++)
  1538. /* remove the potion of cure dianthroritis from inventory */
  1539. if (iven[i] == OPOTION)
  1540. if (ivenarg[i] == PCUREDIANTH) {
  1541. iven[i] = ONOTHING;
  1542. ClearText();
  1543. Print("Congratulations. You found the potion of cure "
  1544. "dianthroritis!\n");
  1545. Print("\nFrankly, No one thought you could do it.");
  1546. Print(" Boy! Did you surprise them!\n");
  1547. nap(1000);
  1548. if (gtime > TIMELIMIT) {
  1549. Print("\nHowever... the doctor has the sad duty to "
  1550. "inform you that your daughter has\n");
  1551. Print("died! You didn't make it in time. In your agony, "
  1552. "you kill the doctor,\nyour ");
  1553. if (sex == 1)
  1554. Print("wife");
  1555. else
  1556. Print("husband");
  1557. Print(" and yourself! Too bad...\n");
  1558. nap(5000);
  1559. died(DIED_KILLED_FAMILY, 0);
  1560. }else {
  1561. Print("\nThe doctor is now administering the potion and, "
  1562. "in a few moments,\n");
  1563. Print("your daughter should be well on her way to "
  1564. "recovery.\n");
  1565. nap(6000);
  1566. Print("\nThe potion is.");
  1567. nap(1000);
  1568. Print(".");
  1569. nap(1000);
  1570. Print(".");
  1571. nap(1000);
  1572. Print(" working! The doctor thinks that\n");
  1573. Print("your daughter will recover in a few days. "
  1574. "Congratulations!");
  1575. UlarnBeep();
  1576. nap(5000);
  1577. died(DIED_WINNER, 0);
  1578. }
  1579. }
  1580. while (1) {
  1581. ClearText();
  1582. Printf("Welcome home %s.", logname);
  1583. Print(" Latest word from the doctor is not good.\n");
  1584. if (gtime > TIMELIMIT) {
  1585. Print("\nThe doctor has the sad duty to inform you that your "
  1586. "daughter has died!\n");
  1587. Print("You didn't make it in time.");
  1588. Print("In your agony, you kill the doctor,\nyour ");
  1589. if (sex == 1)
  1590. Print("wife");
  1591. else
  1592. Print("husband");
  1593. Print(" and yourself! Too bad...");
  1594. nap(5000);
  1595. died(DIED_KILLED_FAMILY, 0);
  1596. }
  1597. Print("\nThe diagnosis is confirmed as dianthroritis. "
  1598. "He guesses that\n");
  1599. Printf("your daughter has only %d mobuls left in this world. "
  1600. "It's up to you,\n", (long)((TIMELIMIT - gtime + 99) / 100));
  1601. Printf("%s, to find the only hope for your daughter, the very rare\n",
  1602. logname);
  1603. Print("potion of cure dianthroritis. It is rumored that only deep "
  1604. "in the\n");
  1605. Print("depths of the caves can this potion be found.\n\n\n");
  1606. Print("\n ----- press ");
  1607. Standout("return");
  1608. Print(" to continue, ");
  1609. Standout("escape");
  1610. Print(" to leave ----- ");
  1611. i = get_prompt_input("", "\033\015", 0);
  1612. if (i == ESC) {
  1613. set_display(DISPLAY_MAP);
  1614. nosignal = 0; /* enable signals */
  1615. return;
  1616. }
  1617. }
  1618. }
  1619. /* =============================================================================
  1620. * FUNCTION: write_store
  1621. */
  1622. void write_store(FILE *fp)
  1623. {
  1624. write_dnd_store(fp);
  1625. write_college(fp);
  1626. write_bank(fp);
  1627. write_pad(fp);
  1628. }
  1629. /* =============================================================================
  1630. * FUNCTION: read_store
  1631. */
  1632. void read_store(FILE *fp)
  1633. {
  1634. read_dnd_store(fp);
  1635. read_college(fp);
  1636. read_bank(fp);
  1637. read_pad(fp);
  1638. }