command5.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. /* $NetBSD: command5.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */
  2. /*
  3. * Copyright (c) 1983, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95";
  34. #else
  35. __RCSID("$NetBSD: command5.c,v 1.2 2003/08/07 09:37:00 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include "extern.h"
  39. void
  40. kiss()
  41. {
  42. while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
  43. continue;
  44. /* The goddess must be "taken" first if bathing. */
  45. if (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == NORMGOD
  46. && testbit(location[position].objects, BATHGOD)) {
  47. wordvalue[--wordnumber] = TAKE;
  48. cypher();
  49. return;
  50. }
  51. if (wordtype[wordnumber] == NOUNS) {
  52. if (testbit(location[position].objects, wordvalue[wordnumber])) {
  53. pleasure++;
  54. printf("Kissed.\n");
  55. switch (wordvalue[wordnumber]) {
  56. case NORMGOD:
  57. switch (godready++) {
  58. case 0:
  59. puts("She squirms and avoids your advances.");
  60. break;
  61. case 1:
  62. puts("She is coming around; she didn't fight it as much.");
  63. break;
  64. case 2:
  65. puts("She's beginning to like it.");
  66. break;
  67. default:
  68. puts("She's gone limp.");
  69. }
  70. break;
  71. case NATIVE:
  72. puts("Her lips are warm and her body robust. She pulls you down to the ground.");
  73. break;
  74. case TIMER:
  75. puts("The old man blushes.");
  76. break;
  77. case MAN:
  78. puts("The dwarf punches you in the kneecap.");
  79. break;
  80. default:
  81. pleasure--;
  82. }
  83. } else
  84. puts("I see nothing like that here.");
  85. } else
  86. puts("I'd prefer not to.");
  87. }
  88. void
  89. love()
  90. {
  91. int n;
  92. while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
  93. continue;
  94. if (wordtype[wordnumber] == NOUNS) {
  95. if ((testbit(location[position].objects, BATHGOD) ||
  96. testbit(location[position].objects, NORMGOD)) &&
  97. wordvalue[wordnumber] == NORMGOD) {
  98. if (loved) {
  99. printf("Loved.\n");
  100. return;
  101. }
  102. if (godready >= 2) {
  103. puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet. The lovely goddess, Purl, was she. The Empire\ncaptured her just after the Darkness came. My other sister, Vert, was killed\nby the Dark Lord himself. He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill. I will leave you my amulet,");
  104. puts("which you may use as you wish. As for me, I am the last goddess of the\nwaters. My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed.");
  105. power++;
  106. pleasure += 15;
  107. ego++;
  108. if (card(injuries, NUMOFINJURIES)) {
  109. puts("Her kisses revive you; your wounds are healed.\n");
  110. for (n = 0; n < NUMOFINJURIES; n++)
  111. injuries[n] = 0;
  112. WEIGHT = MAXWEIGHT;
  113. CUMBER = MAXCUMBER;
  114. }
  115. printf("Goddess:\n");
  116. if (!loved)
  117. setbit(location[position].objects, MEDALION);
  118. loved = 1;
  119. ourtime += 10;
  120. printf("Loved.\n");
  121. zzz();
  122. return;
  123. } else {
  124. puts("You wish!");
  125. return;
  126. }
  127. }
  128. if (testbit(location[position].objects, wordvalue[wordnumber])) {
  129. if (wordvalue[wordnumber] == NATIVE) {
  130. puts("The girl is easy prey. She peels off her sarong and indulges you.");
  131. power++;
  132. pleasure += 5;
  133. printf("Girl:\n");
  134. ourtime += 10;
  135. printf("Loved.\n");
  136. zzz();
  137. }
  138. if (wordvalue[wordnumber] == MAN ||
  139. wordvalue[wordnumber] == BODY ||
  140. wordvalue[wordnumber] == ELF ||
  141. wordvalue[wordnumber] == TIMER)
  142. puts("Kinky!");
  143. else
  144. puts("It doesn't seem to work.");
  145. } else
  146. puts("Where's your lover?");
  147. } else
  148. puts("It doesn't seem to work.");
  149. }
  150. int
  151. zzz()
  152. {
  153. int oldtime;
  154. int n;
  155. oldtime = ourtime;
  156. if ((snooze - ourtime) < (0.75 * CYCLE)) {
  157. ourtime += 0.75 * CYCLE - (snooze - ourtime);
  158. printf("<zzz>");
  159. for (n = 0; n < ourtime - oldtime; n++)
  160. printf(".");
  161. printf("\n");
  162. snooze += 3 * (ourtime - oldtime);
  163. if (notes[LAUNCHED]) {
  164. fuel -= (ourtime - oldtime);
  165. if (location[position].down) {
  166. position = location[position].down;
  167. crash();
  168. } else
  169. notes[LAUNCHED] = 0;
  170. }
  171. if (OUTSIDE && rnd(100) < 50) {
  172. puts("You are awakened abruptly by the sound of someone nearby.");
  173. switch (rnd(4)) {
  174. case 0:
  175. if (ucard(inven)) {
  176. n = rnd(NUMOFOBJECTS);
  177. while (!testbit(inven, n))
  178. n = rnd(NUMOFOBJECTS);
  179. clearbit(inven, n);
  180. if (n != AMULET && n != MEDALION && n != TALISMAN)
  181. setbit(location[position].objects, n);
  182. carrying -= objwt[n];
  183. encumber -= objcumber[n];
  184. }
  185. puts("A fiendish little Elf is stealing your treasures!");
  186. fight(ELF, 10);
  187. break;
  188. case 1:
  189. setbit(location[position].objects, DEADWOOD);
  190. break;
  191. case 2:
  192. setbit(location[position].objects, HALBERD);
  193. break;
  194. default:
  195. break;
  196. }
  197. }
  198. } else
  199. return (0);
  200. return (1);
  201. }
  202. void
  203. chime()
  204. {
  205. if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
  206. switch ((ourtime % CYCLE) / (CYCLE / 7)) {
  207. case 0:
  208. puts("It is just after sunrise.");
  209. break;
  210. case 1:
  211. puts("It is early morning.");
  212. break;
  213. case 2:
  214. puts("It is late morning.");
  215. break;
  216. case 3:
  217. puts("It is near noon.");
  218. break;
  219. case 4:
  220. puts("It is early afternoon.");
  221. break;
  222. case 5:
  223. puts("It is late afternoon.");
  224. break;
  225. case 6:
  226. puts("It is near sunset.");
  227. break;
  228. }
  229. else if (OUTSIDE)
  230. switch ((ourtime % CYCLE) / (CYCLE / 7)) {
  231. case 0:
  232. puts("It is just after sunset.");
  233. break;
  234. case 1:
  235. puts("It is early evening.");
  236. break;
  237. case 2:
  238. puts("The evening is getting old.");
  239. break;
  240. case 3:
  241. puts("It is near midnight.");
  242. break;
  243. case 4:
  244. puts("These are the wee hours of the morning.");
  245. break;
  246. case 5:
  247. puts("The night is waning.");
  248. break;
  249. case 6:
  250. puts("It is almost morning.");
  251. break;
  252. }
  253. else
  254. puts("I can't tell the time in here.");
  255. }
  256. int
  257. give()
  258. {
  259. int obj = -1, result = -1, person = 0, firstnumber, last1, last2;
  260. last1 = last2 = 0;
  261. firstnumber = wordnumber;
  262. while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount)
  263. continue;
  264. if (wordnumber <= wordcount) {
  265. obj = wordvalue[wordnumber];
  266. if (obj == EVERYTHING)
  267. wordtype[wordnumber] = -1;
  268. last1 = wordnumber;
  269. }
  270. wordnumber = firstnumber;
  271. while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
  272. if (wordtype[wordnumber] == NOUNS) {
  273. person = wordvalue[wordnumber];
  274. last2 = wordnumber;
  275. }
  276. /* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
  277. * plain `give'. However, detecting this case is liable to detect
  278. * `give foo' as well, which would give a confusing error. We
  279. * need to make sure the -1 value can cause no problems if it arises.
  280. * If in the below we get to the drop("Given") then drop will look
  281. * at word 0 for an object to give, and fail, which is OK; then
  282. * result will be -1 and we get to the end, where wordnumber gets
  283. * set to something more sensible. If we get to "I don't think
  284. * that is possible" then again wordnumber is set to something
  285. * sensible. The wordnumber we leave with still isn't right if
  286. * you include words the game doesn't know in your command, but
  287. * that's no worse than what other commands than give do in
  288. * the same place. */
  289. wordnumber = last1 - 1;
  290. if (person && testbit(location[position].objects, person)) {
  291. if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
  292. puts("The goddess won't look at you.");
  293. else
  294. result = drop("Given");
  295. } else {
  296. puts("I don't think that is possible.");
  297. wordnumber = max(last1, last2) + 1;
  298. return (0);
  299. }
  300. if (result != -1 && (testbit(location[position].objects, obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)) {
  301. clearbit(location[position].objects, obj);
  302. ourtime++;
  303. ego++;
  304. switch (person) {
  305. case NATIVE:
  306. puts("She accepts it shyly.");
  307. ego += 2;
  308. break;
  309. case NORMGOD:
  310. if (obj == RING || obj == BRACELET) {
  311. puts("She takes the charm and puts it on. A little kiss on the cheek is");
  312. puts("your reward.");
  313. ego += 5;
  314. godready += 3;
  315. }
  316. if (obj == AMULET || obj == MEDALION || obj == TALISMAN) {
  317. win++;
  318. ego += 5;
  319. power -= 5;
  320. if (win >= 3) {
  321. puts("The powers of the earth are now legitimate. You have destroyed the Darkness");
  322. puts("and restored the goddess to her throne. The entire island celebrates with");
  323. puts("dancing and spring feasts. As a measure of her gratitude, the goddess weds you");
  324. puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus.");
  325. puts("\nBut, as the year wears on and autumn comes along, you become restless and");
  326. puts("yearn for adventure. The goddess, too, realizes that the marriage can't last.");
  327. puts("She becomes bored and takes several more natives as husbands. One evening,");
  328. puts("after having been out drinking with the girls, she kicks the throne particularly");
  329. puts("hard and wakes you up. (If you want to win this game, you're going to have to\nshoot her!)");
  330. clearbit(location[position].objects, MEDALION);
  331. wintime = ourtime;
  332. }
  333. }
  334. break;
  335. case TIMER:
  336. if (obj == COINS) {
  337. puts("He fingers the coins for a moment and then looks up agape. `Kind you are and");
  338. puts("I mean to repay you as best I can.' Grabbing a pencil and cocktail napkin...\n");
  339. printf("+-----------------------------------------------------------------------------+\n");
  340. printf("| xxxxxxxx\\ |\n");
  341. printf("| xxxxx\\ CLIFFS |\n");
  342. printf("| FOREST xxx\\ |\n");
  343. printf("| \\\\ x\\ OCEAN |\n");
  344. printf("| || x\\ |\n");
  345. printf("| || ROAD x\\ |\n");
  346. printf("| || x\\ |\n");
  347. printf("| SECRET || ......... |\n");
  348. printf("| - + - || ........ |\n");
  349. printf("| ENTRANCE || ... BEACH |\n");
  350. printf("| || ... E |\n");
  351. printf("| || ... | |\n");
  352. printf("| // ... N <-- + --- S |\n");
  353. printf("| PALM GROVE // ... | |\n");
  354. printf("| // ... W |\n");
  355. printf("+-----------------------------------------------------------------------------+\n");
  356. puts("\n`This map shows a secret entrance to the catacombs.");
  357. puts("You will know when you arrive because I left an old pair of shoes there.'");
  358. }
  359. break;
  360. }
  361. }
  362. wordnumber = max(last1, last2) + 1;
  363. return (firstnumber);
  364. }