command3.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /* $NetBSD: command3.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[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95";
  34. #else
  35. __RCSID("$NetBSD: command3.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. dig()
  41. {
  42. if (testbit(inven, SHOVEL)) {
  43. puts("OK");
  44. ourtime++;
  45. switch (position) {
  46. case 144: /* copse near beach */
  47. if (!notes[DUG]) {
  48. setbit(location[position].objects, DEADWOOD);
  49. setbit(location[position].objects, COMPASS);
  50. setbit(location[position].objects, KNIFE);
  51. setbit(location[position].objects, MACE);
  52. notes[DUG] = 1;
  53. }
  54. break;
  55. default:
  56. puts("Nothing happens.");
  57. }
  58. } else
  59. puts("You don't have a shovel.");
  60. }
  61. int
  62. jump()
  63. {
  64. int n;
  65. switch (position) {
  66. default:
  67. puts("Nothing happens.");
  68. return (-1);
  69. case 242:
  70. position = 133;
  71. break;
  72. case 214:
  73. case 215:
  74. case 162:
  75. case 159:
  76. position = 145;
  77. break;
  78. case 232:
  79. position = FINAL;
  80. break;
  81. case 3:
  82. position = 1;
  83. break;
  84. case 172:
  85. position = 201;
  86. }
  87. puts("Ahhhhhhh...");
  88. injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
  89. for (n = 0; n < NUMOFOBJECTS; n++)
  90. if (testbit(inven, n)) {
  91. clearbit(inven, n);
  92. setbit(location[position].objects, n);
  93. }
  94. carrying = 0;
  95. encumber = 0;
  96. return (0);
  97. }
  98. void
  99. bury()
  100. {
  101. int value;
  102. if (testbit(inven, SHOVEL)) {
  103. while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
  104. continue;
  105. value = wordvalue[wordnumber];
  106. if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, value) || value == BODY))
  107. switch (value) {
  108. case BODY:
  109. wordtype[wordnumber] = OBJECT;
  110. if (testbit(inven, MAID) || testbit(location[position].objects, MAID))
  111. value = MAID;
  112. if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD))
  113. value = DEADWOOD;
  114. if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD))
  115. value = DEADGOD;
  116. if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME))
  117. value = DEADTIME;
  118. if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE))
  119. value = DEADNATIVE;
  120. break;
  121. case NATIVE:
  122. case NORMGOD:
  123. puts("She screams as you wrestle her into the hole.");
  124. case TIMER:
  125. power += 7;
  126. ego -= 10;
  127. case AMULET:
  128. case MEDALION:
  129. case TALISMAN:
  130. wordtype[wordnumber] = OBJECT;
  131. break;
  132. default:
  133. puts("Wha..?");
  134. }
  135. if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven, value) || testbit(location[position].objects, value))) {
  136. puts("Buried.");
  137. if (testbit(inven, value)) {
  138. clearbit(inven, value);
  139. carrying -= objwt[value];
  140. encumber -= objcumber[value];
  141. }
  142. clearbit(location[position].objects, value);
  143. switch (value) {
  144. case MAID:
  145. case DEADWOOD:
  146. case DEADNATIVE:
  147. case DEADTIME:
  148. case DEADGOD:
  149. ego += 2;
  150. printf("The %s should rest easier now.\n", objsht[value]);
  151. }
  152. } else
  153. puts("It doesn't seem to work.");
  154. } else
  155. puts("You aren't holding a shovel.");
  156. }
  157. void
  158. drink()
  159. {
  160. int n;
  161. if (testbit(inven, POTION)) {
  162. puts("The cool liquid runs down your throat but turns to fire and you choke.");
  163. puts("The heat reaches your limbs and tingles your spirit. You feel like falling");
  164. puts("asleep.");
  165. clearbit(inven, POTION);
  166. WEIGHT = MAXWEIGHT;
  167. CUMBER = MAXCUMBER;
  168. for (n = 0; n < NUMOFINJURIES; n++)
  169. injuries[n] = 0;
  170. ourtime++;
  171. zzz();
  172. } else
  173. puts("I'm not thirsty.");
  174. }
  175. int
  176. shoot()
  177. {
  178. int firstnumber, value;
  179. firstnumber = wordnumber;
  180. if (!testbit(inven, LASER))
  181. puts("You aren't holding a blaster.");
  182. else {
  183. wordnumber++;
  184. while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
  185. value = wordvalue[wordnumber];
  186. printf("%s:\n", objsht[value]);
  187. if (testbit(location[position].objects, value)) {
  188. clearbit(location[position].objects, value);
  189. ourtime++;
  190. printf("The %s explode%s\n", objsht[value],
  191. (is_plural_object(value) ? "." : "s."));
  192. if (value == BOMB)
  193. die();
  194. } else
  195. printf("I don't see any %s around here.\n", objsht[value]);
  196. if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
  197. wordnumber++;
  198. else
  199. return (firstnumber);
  200. }
  201. /* special cases with their own return()'s */
  202. if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
  203. ourtime++;
  204. switch (wordvalue[wordnumber]) {
  205. case DOOR:
  206. switch (position) {
  207. case 189:
  208. case 231:
  209. puts("The door is unhinged.");
  210. location[189].north = 231;
  211. location[231].south = 189;
  212. whichway(location[position]);
  213. break;
  214. case 30:
  215. puts("The wooden door splinters.");
  216. location[30].west = 25;
  217. whichway(location[position]);
  218. break;
  219. case 31:
  220. puts("The laser blast has no effect on the door.");
  221. break;
  222. case 20:
  223. puts("The blast hits the door and it explodes into flame. The magnesium burns");
  224. puts("so rapidly that we have no chance to escape.");
  225. die();
  226. default:
  227. puts("Nothing happens.");
  228. }
  229. break;
  230. case NORMGOD:
  231. if (testbit(location[position].objects, BATHGOD)) {
  232. puts("The goddess is hit in the chest and splashes back against the rocks.");
  233. puts("Dark blood oozes from the charred blast hole. Her naked body floats in the");
  234. puts("pools and then off downstream.");
  235. clearbit(location[position].objects, BATHGOD);
  236. setbit(location[180].objects, DEADGOD);
  237. power += 5;
  238. ego -= 10;
  239. notes[JINXED]++;
  240. } else
  241. if (testbit(location[position].objects, NORMGOD)) {
  242. puts("The blast catches the goddess in the stomach, knocking her to the ground.");
  243. puts("She writhes in the dirt as the agony of death taunts her.");
  244. puts("She has stopped moving.");
  245. clearbit(location[position].objects, NORMGOD);
  246. setbit(location[position].objects, DEADGOD);
  247. power += 5;
  248. ego -= 10;
  249. notes[JINXED]++;
  250. if (wintime)
  251. live();
  252. break;
  253. } else
  254. puts("I don't see any goddess around here.");
  255. break;
  256. case TIMER:
  257. if (testbit(location[position].objects, TIMER)) {
  258. puts("The old man slumps over the bar.");
  259. power++;
  260. ego -= 2;
  261. notes[JINXED]++;
  262. clearbit(location[position].objects, TIMER);
  263. setbit(location[position].objects, DEADTIME);
  264. } else
  265. puts("What old-timer?");
  266. break;
  267. case MAN:
  268. if (testbit(location[position].objects, MAN)) {
  269. puts("The man falls to the ground with blood pouring all over his white suit.");
  270. puts("Your fantasy is over.");
  271. die();
  272. } else
  273. puts("What man?");
  274. break;
  275. case NATIVE:
  276. if (testbit(location[position].objects, NATIVE)) {
  277. puts("The girl is blown backwards several feet and lies in a pool of blood.");
  278. clearbit(location[position].objects, NATIVE);
  279. setbit(location[position].objects, DEADNATIVE);
  280. power += 5;
  281. ego -= 2;
  282. notes[JINXED]++;
  283. } else
  284. puts("There is no girl here.");
  285. break;
  286. case -1:
  287. puts("Shoot what?");
  288. break;
  289. default:
  290. printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]);
  291. }
  292. } else
  293. puts("You must be a looney.");
  294. }
  295. return (firstnumber);
  296. }