command2.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. /* $NetBSD: command2.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[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
  34. #else
  35. __RCSID("$NetBSD: command2.c,v 1.2 2003/08/07 09:37:00 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include "extern.h"
  39. int
  40. wearit()
  41. { /* synonyms = {sheathe, sheath} */
  42. int firstnumber, value;
  43. firstnumber = wordnumber;
  44. wordnumber++;
  45. while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
  46. wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
  47. value = wordvalue[wordnumber];
  48. if (value >= 0 && objsht[value] == NULL)
  49. break;
  50. switch (value) {
  51. case -1:
  52. puts("Wear what?");
  53. return (firstnumber);
  54. default:
  55. printf("You can't wear %s%s!\n",
  56. A_OR_AN_OR_BLANK(value), objsht[value]);
  57. return (firstnumber);
  58. case KNIFE:
  59. /* case SHIRT: */
  60. case ROBE:
  61. case LEVIS: /* wearable things */
  62. case SWORD:
  63. case MAIL:
  64. case HELM:
  65. case SHOES:
  66. case PAJAMAS:
  67. case COMPASS:
  68. case LASER:
  69. case AMULET:
  70. case TALISMAN:
  71. case MEDALION:
  72. case ROPE:
  73. case RING:
  74. case BRACELET:
  75. case GRENADE:
  76. if (testbit(inven, value)) {
  77. clearbit(inven, value);
  78. setbit(wear, value);
  79. carrying -= objwt[value];
  80. encumber -= objcumber[value];
  81. ourtime++;
  82. printf("You are now wearing %s%s.\n",
  83. A_OR_AN_OR_THE(value), objsht[value]);
  84. } else
  85. if (testbit(wear, value))
  86. printf("You are already wearing the %s.\n",
  87. objsht[value]);
  88. else
  89. printf("You aren't holding the %s.\n",
  90. objsht[value]);
  91. if (wordnumber < wordcount - 1 &&
  92. wordvalue[++wordnumber] == AND)
  93. wordnumber++;
  94. else
  95. return (firstnumber);
  96. } /* end switch */
  97. } /* end while */
  98. puts("Don't be ridiculous.");
  99. return (firstnumber);
  100. }
  101. int
  102. put()
  103. { /* synonyms = {buckle, strap, tie} */
  104. if (wordvalue[wordnumber + 1] == ON) {
  105. wordvalue[++wordnumber] = PUTON;
  106. wordtype[wordnumber] = VERB;
  107. return (cypher());
  108. }
  109. if (wordvalue[wordnumber + 1] == DOWN) {
  110. wordvalue[++wordnumber] = DROP;
  111. wordtype[wordnumber] = VERB;
  112. return (cypher());
  113. }
  114. puts("I don't understand what you want to put.");
  115. return (-1);
  116. }
  117. int
  118. draw()
  119. { /* synonyms = {pull, carry} */
  120. return (take(wear));
  121. }
  122. int
  123. use()
  124. {
  125. wordnumber++;
  126. if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
  127. position != FINAL) {
  128. puts("The amulet begins to glow.");
  129. if (testbit(inven, MEDALION)) {
  130. puts("The medallion comes to life too.");
  131. if (position == 114) {
  132. location[position].down = 160;
  133. whichway(location[position]);
  134. puts("The waves subside and it is possible to descend to the sea cave now.");
  135. ourtime++;
  136. return (-1);
  137. }
  138. }
  139. puts("A light mist falls over your eyes and the sound of purling water trickles in");
  140. puts("your ears. When the mist lifts you are standing beside a cool stream.");
  141. if (position == 229)
  142. position = 224;
  143. else
  144. position = 229;
  145. ourtime++;
  146. notes[CANTSEE] = 0;
  147. return (0);
  148. } else if (position == FINAL)
  149. puts("The amulet won't work in here.");
  150. else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
  151. printf("Your compass points %s.\n", truedirec(NORTH, '-'));
  152. else if (wordvalue[wordnumber] == COMPASS)
  153. puts("You aren't holding the compass.");
  154. else if (wordvalue[wordnumber] == AMULET)
  155. puts("You aren't holding the amulet.");
  156. else
  157. puts("There is no apparent use.");
  158. return (-1);
  159. }
  160. void
  161. murder()
  162. {
  163. int n;
  164. for (n = 0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven, n)) && n < NUMOFOBJECTS; n++);
  165. if (n == NUMOFOBJECTS) {
  166. if (testbit(inven, LASER)) {
  167. printf("Your laser should do the trick.\n");
  168. wordnumber++;
  169. switch(wordvalue[wordnumber]) {
  170. case NORMGOD:
  171. case TIMER:
  172. case NATIVE:
  173. case MAN:
  174. wordvalue[--wordnumber] = SHOOT;
  175. cypher();
  176. break;
  177. case -1:
  178. puts("Kill what?");
  179. break;
  180. default:
  181. if (wordtype[wordnumber] != OBJECT ||
  182. wordvalue[wordnumber] == EVERYTHING)
  183. puts("You can't kill that!");
  184. else
  185. printf("You can't kill %s%s!\n",
  186. A_OR_AN_OR_BLANK(wordvalue[wordnumber]),
  187. objsht[wordvalue[wordnumber]]);
  188. break;
  189. }
  190. } else
  191. puts("You don't have suitable weapons to kill.");
  192. } else {
  193. printf("Your %s should do the trick.\n", objsht[n]);
  194. wordnumber++;
  195. switch (wordvalue[wordnumber]) {
  196. case NORMGOD:
  197. if (testbit(location[position].objects, BATHGOD)) {
  198. puts("The goddess's head slices off. Her corpse floats in the water.");
  199. clearbit(location[position].objects, BATHGOD);
  200. setbit(location[position].objects, DEADGOD);
  201. power += 5;
  202. notes[JINXED]++;
  203. } else
  204. if (testbit(location[position].objects, NORMGOD)) {
  205. puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
  206. clearbit(location[position].objects, NORMGOD);
  207. setbit(location[position].objects, DEADGOD);
  208. power += 5;
  209. notes[JINXED]++;
  210. if (wintime)
  211. live();
  212. } else
  213. puts("I don't see her anywhere.");
  214. break;
  215. case TIMER:
  216. if (testbit(location[position].objects, TIMER)) {
  217. puts("The old man offers no resistance.");
  218. clearbit(location[position].objects, TIMER);
  219. setbit(location[position].objects, DEADTIME);
  220. power++;
  221. notes[JINXED]++;
  222. } else
  223. puts("Who?");
  224. break;
  225. case NATIVE:
  226. if (testbit(location[position].objects, NATIVE)) {
  227. puts("The girl screams as you cut her body to shreds. She is dead.");
  228. clearbit(location[position].objects, NATIVE);
  229. setbit(location[position].objects, DEADNATIVE);
  230. power += 5;
  231. notes[JINXED]++;
  232. } else
  233. puts("What girl?");
  234. break;
  235. case MAN:
  236. if (testbit(location[position].objects, MAN)) {
  237. puts("You strike him to the ground, and he coughs up blood.");
  238. puts("Your fantasy is over.");
  239. die();
  240. }
  241. case -1:
  242. puts("Kill what?");
  243. break;
  244. default:
  245. if (wordtype[wordnumber] != OBJECT ||
  246. wordvalue[wordnumber] == EVERYTHING)
  247. puts("You can't kill that!");
  248. else
  249. printf("You can't kill the %s!\n",
  250. objsht[wordvalue[wordnumber]]);
  251. }
  252. }
  253. }
  254. void
  255. ravage()
  256. {
  257. while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
  258. continue;
  259. if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, wordvalue[wordnumber])
  260. || (wordvalue[wordnumber] == NORMGOD && testbit(location[position].objects, BATHGOD)))) {
  261. ourtime++;
  262. switch (wordvalue[wordnumber]) {
  263. case NORMGOD:
  264. puts("You attack the goddess, and she screams as you beat her. She falls down");
  265. if (testbit(location[position].objects, BATHGOD))
  266. puts("crying and tries to cover her nakedness.");
  267. else
  268. puts("crying and tries to hold her torn and bloodied dress around her.");
  269. power += 5;
  270. pleasure += 8;
  271. ego -= 10;
  272. wordnumber--;
  273. godready = -30000;
  274. murder();
  275. win = -30000;
  276. break;
  277. case NATIVE:
  278. puts("The girl tries to run, but you catch her and throw her down. Her face is");
  279. puts("bleeding, and she screams as you tear off her clothes.");
  280. power += 3;
  281. pleasure += 5;
  282. ego -= 10;
  283. wordnumber--;
  284. murder();
  285. if (rnd(100) < 50) {
  286. puts("Her screams have attracted attention. I think we are surrounded.");
  287. setbit(location[ahead].objects, WOODSMAN);
  288. setbit(location[ahead].objects, DEADWOOD);
  289. setbit(location[ahead].objects, MALLET);
  290. setbit(location[back].objects, WOODSMAN);
  291. setbit(location[back].objects, DEADWOOD);
  292. setbit(location[back].objects, MALLET);
  293. setbit(location[left].objects, WOODSMAN);
  294. setbit(location[left].objects, DEADWOOD);
  295. setbit(location[left].objects, MALLET);
  296. setbit(location[right].objects, WOODSMAN);
  297. setbit(location[right].objects, DEADWOOD);
  298. setbit(location[right].objects, MALLET);
  299. }
  300. break;
  301. default:
  302. puts("You are perverted.");
  303. }
  304. } else
  305. puts("Who?");
  306. }
  307. int
  308. follow()
  309. {
  310. if (followfight == ourtime) {
  311. puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
  312. puts("You chase him through the darkness and splash in pools of water.");
  313. puts("You have cornered him. His laser sword extends as he steps forward.");
  314. position = FINAL;
  315. fight(DARK, 75);
  316. setbit(location[position].objects, TALISMAN);
  317. setbit(location[position].objects, AMULET);
  318. return (0);
  319. } else
  320. if (followgod == ourtime) {
  321. puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
  322. puts("She sits down on a throne.");
  323. position = 268;
  324. setbit(location[position].objects, NORMGOD);
  325. notes[CANTSEE] = 1;
  326. return (0);
  327. } else
  328. puts("There is no one to follow.");
  329. return (-1);
  330. }