command2.c revision 1.2 1 1.2 agc /* $NetBSD: command2.c,v 1.2 2003/08/07 09:37:00 agc Exp $ */
2 1.1 tv
3 1.1 tv /*
4 1.1 tv * Copyright (c) 1983, 1993
5 1.1 tv * The Regents of the University of California. All rights reserved.
6 1.1 tv *
7 1.1 tv * Redistribution and use in source and binary forms, with or without
8 1.1 tv * modification, are permitted provided that the following conditions
9 1.1 tv * are met:
10 1.1 tv * 1. Redistributions of source code must retain the above copyright
11 1.1 tv * notice, this list of conditions and the following disclaimer.
12 1.1 tv * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 tv * notice, this list of conditions and the following disclaimer in the
14 1.1 tv * documentation and/or other materials provided with the distribution.
15 1.2 agc * 3. Neither the name of the University nor the names of its contributors
16 1.1 tv * may be used to endorse or promote products derived from this software
17 1.1 tv * without specific prior written permission.
18 1.1 tv *
19 1.1 tv * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.1 tv * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 tv * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 tv * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.1 tv * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 tv * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 tv * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 tv * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 tv * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 tv * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 tv * SUCH DAMAGE.
30 1.1 tv */
31 1.1 tv
32 1.1 tv #include <sys/cdefs.h>
33 1.1 tv #ifndef lint
34 1.1 tv #if 0
35 1.1 tv static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
36 1.1 tv #else
37 1.2 agc __RCSID("$NetBSD: command2.c,v 1.2 2003/08/07 09:37:00 agc Exp $");
38 1.1 tv #endif
39 1.1 tv #endif /* not lint */
40 1.1 tv
41 1.1 tv #include "extern.h"
42 1.1 tv
43 1.1 tv int
44 1.1 tv wearit()
45 1.1 tv { /* synonyms = {sheathe, sheath} */
46 1.1 tv int firstnumber, value;
47 1.1 tv
48 1.1 tv firstnumber = wordnumber;
49 1.1 tv wordnumber++;
50 1.1 tv while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
51 1.1 tv wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
52 1.1 tv value = wordvalue[wordnumber];
53 1.1 tv if (value >= 0 && objsht[value] == NULL)
54 1.1 tv break;
55 1.1 tv switch (value) {
56 1.1 tv
57 1.1 tv case -1:
58 1.1 tv puts("Wear what?");
59 1.1 tv return (firstnumber);
60 1.1 tv
61 1.1 tv default:
62 1.1 tv printf("You can't wear %s%s!\n",
63 1.1 tv A_OR_AN_OR_BLANK(value), objsht[value]);
64 1.1 tv return (firstnumber);
65 1.1 tv
66 1.1 tv case KNIFE:
67 1.1 tv /* case SHIRT: */
68 1.1 tv case ROBE:
69 1.1 tv case LEVIS: /* wearable things */
70 1.1 tv case SWORD:
71 1.1 tv case MAIL:
72 1.1 tv case HELM:
73 1.1 tv case SHOES:
74 1.1 tv case PAJAMAS:
75 1.1 tv case COMPASS:
76 1.1 tv case LASER:
77 1.1 tv case AMULET:
78 1.1 tv case TALISMAN:
79 1.1 tv case MEDALION:
80 1.1 tv case ROPE:
81 1.1 tv case RING:
82 1.1 tv case BRACELET:
83 1.1 tv case GRENADE:
84 1.1 tv
85 1.1 tv if (testbit(inven, value)) {
86 1.1 tv clearbit(inven, value);
87 1.1 tv setbit(wear, value);
88 1.1 tv carrying -= objwt[value];
89 1.1 tv encumber -= objcumber[value];
90 1.1 tv ourtime++;
91 1.1 tv printf("You are now wearing %s%s.\n",
92 1.1 tv A_OR_AN_OR_THE(value), objsht[value]);
93 1.1 tv } else
94 1.1 tv if (testbit(wear, value))
95 1.1 tv printf("You are already wearing the %s.\n",
96 1.1 tv objsht[value]);
97 1.1 tv else
98 1.1 tv printf("You aren't holding the %s.\n",
99 1.1 tv objsht[value]);
100 1.1 tv if (wordnumber < wordcount - 1 &&
101 1.1 tv wordvalue[++wordnumber] == AND)
102 1.1 tv wordnumber++;
103 1.1 tv else
104 1.1 tv return (firstnumber);
105 1.1 tv } /* end switch */
106 1.1 tv } /* end while */
107 1.1 tv puts("Don't be ridiculous.");
108 1.1 tv return (firstnumber);
109 1.1 tv }
110 1.1 tv
111 1.1 tv int
112 1.1 tv put()
113 1.1 tv { /* synonyms = {buckle, strap, tie} */
114 1.1 tv if (wordvalue[wordnumber + 1] == ON) {
115 1.1 tv wordvalue[++wordnumber] = PUTON;
116 1.1 tv wordtype[wordnumber] = VERB;
117 1.1 tv return (cypher());
118 1.1 tv }
119 1.1 tv if (wordvalue[wordnumber + 1] == DOWN) {
120 1.1 tv wordvalue[++wordnumber] = DROP;
121 1.1 tv wordtype[wordnumber] = VERB;
122 1.1 tv return (cypher());
123 1.1 tv }
124 1.1 tv puts("I don't understand what you want to put.");
125 1.1 tv return (-1);
126 1.1 tv
127 1.1 tv }
128 1.1 tv
129 1.1 tv int
130 1.1 tv draw()
131 1.1 tv { /* synonyms = {pull, carry} */
132 1.1 tv return (take(wear));
133 1.1 tv }
134 1.1 tv
135 1.1 tv int
136 1.1 tv use()
137 1.1 tv {
138 1.1 tv wordnumber++;
139 1.1 tv if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
140 1.1 tv position != FINAL) {
141 1.1 tv puts("The amulet begins to glow.");
142 1.1 tv if (testbit(inven, MEDALION)) {
143 1.1 tv puts("The medallion comes to life too.");
144 1.1 tv if (position == 114) {
145 1.1 tv location[position].down = 160;
146 1.1 tv whichway(location[position]);
147 1.1 tv puts("The waves subside and it is possible to descend to the sea cave now.");
148 1.1 tv ourtime++;
149 1.1 tv return (-1);
150 1.1 tv }
151 1.1 tv }
152 1.1 tv puts("A light mist falls over your eyes and the sound of purling water trickles in");
153 1.1 tv puts("your ears. When the mist lifts you are standing beside a cool stream.");
154 1.1 tv if (position == 229)
155 1.1 tv position = 224;
156 1.1 tv else
157 1.1 tv position = 229;
158 1.1 tv ourtime++;
159 1.1 tv notes[CANTSEE] = 0;
160 1.1 tv return (0);
161 1.1 tv } else if (position == FINAL)
162 1.1 tv puts("The amulet won't work in here.");
163 1.1 tv else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
164 1.1 tv printf("Your compass points %s.\n", truedirec(NORTH, '-'));
165 1.1 tv else if (wordvalue[wordnumber] == COMPASS)
166 1.1 tv puts("You aren't holding the compass.");
167 1.1 tv else if (wordvalue[wordnumber] == AMULET)
168 1.1 tv puts("You aren't holding the amulet.");
169 1.1 tv else
170 1.1 tv puts("There is no apparent use.");
171 1.1 tv return (-1);
172 1.1 tv }
173 1.1 tv
174 1.1 tv void
175 1.1 tv murder()
176 1.1 tv {
177 1.1 tv int n;
178 1.1 tv
179 1.1 tv 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++);
180 1.1 tv if (n == NUMOFOBJECTS) {
181 1.1 tv if (testbit(inven, LASER)) {
182 1.1 tv printf("Your laser should do the trick.\n");
183 1.1 tv wordnumber++;
184 1.1 tv switch(wordvalue[wordnumber]) {
185 1.1 tv case NORMGOD:
186 1.1 tv case TIMER:
187 1.1 tv case NATIVE:
188 1.1 tv case MAN:
189 1.1 tv wordvalue[--wordnumber] = SHOOT;
190 1.1 tv cypher();
191 1.1 tv break;
192 1.1 tv case -1:
193 1.1 tv puts("Kill what?");
194 1.1 tv break;
195 1.1 tv default:
196 1.1 tv if (wordtype[wordnumber] != OBJECT ||
197 1.1 tv wordvalue[wordnumber] == EVERYTHING)
198 1.1 tv puts("You can't kill that!");
199 1.1 tv else
200 1.1 tv printf("You can't kill %s%s!\n",
201 1.1 tv A_OR_AN_OR_BLANK(wordvalue[wordnumber]),
202 1.1 tv objsht[wordvalue[wordnumber]]);
203 1.1 tv break;
204 1.1 tv }
205 1.1 tv } else
206 1.1 tv puts("You don't have suitable weapons to kill.");
207 1.1 tv } else {
208 1.1 tv printf("Your %s should do the trick.\n", objsht[n]);
209 1.1 tv wordnumber++;
210 1.1 tv switch (wordvalue[wordnumber]) {
211 1.1 tv
212 1.1 tv case NORMGOD:
213 1.1 tv if (testbit(location[position].objects, BATHGOD)) {
214 1.1 tv puts("The goddess's head slices off. Her corpse floats in the water.");
215 1.1 tv clearbit(location[position].objects, BATHGOD);
216 1.1 tv setbit(location[position].objects, DEADGOD);
217 1.1 tv power += 5;
218 1.1 tv notes[JINXED]++;
219 1.1 tv } else
220 1.1 tv if (testbit(location[position].objects, NORMGOD)) {
221 1.1 tv puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
222 1.1 tv clearbit(location[position].objects, NORMGOD);
223 1.1 tv setbit(location[position].objects, DEADGOD);
224 1.1 tv power += 5;
225 1.1 tv notes[JINXED]++;
226 1.1 tv if (wintime)
227 1.1 tv live();
228 1.1 tv } else
229 1.1 tv puts("I don't see her anywhere.");
230 1.1 tv break;
231 1.1 tv case TIMER:
232 1.1 tv if (testbit(location[position].objects, TIMER)) {
233 1.1 tv puts("The old man offers no resistance.");
234 1.1 tv clearbit(location[position].objects, TIMER);
235 1.1 tv setbit(location[position].objects, DEADTIME);
236 1.1 tv power++;
237 1.1 tv notes[JINXED]++;
238 1.1 tv } else
239 1.1 tv puts("Who?");
240 1.1 tv break;
241 1.1 tv case NATIVE:
242 1.1 tv if (testbit(location[position].objects, NATIVE)) {
243 1.1 tv puts("The girl screams as you cut her body to shreds. She is dead.");
244 1.1 tv clearbit(location[position].objects, NATIVE);
245 1.1 tv setbit(location[position].objects, DEADNATIVE);
246 1.1 tv power += 5;
247 1.1 tv notes[JINXED]++;
248 1.1 tv } else
249 1.1 tv puts("What girl?");
250 1.1 tv break;
251 1.1 tv case MAN:
252 1.1 tv if (testbit(location[position].objects, MAN)) {
253 1.1 tv puts("You strike him to the ground, and he coughs up blood.");
254 1.1 tv puts("Your fantasy is over.");
255 1.1 tv die();
256 1.1 tv }
257 1.1 tv case -1:
258 1.1 tv puts("Kill what?");
259 1.1 tv break;
260 1.1 tv
261 1.1 tv default:
262 1.1 tv if (wordtype[wordnumber] != OBJECT ||
263 1.1 tv wordvalue[wordnumber] == EVERYTHING)
264 1.1 tv puts("You can't kill that!");
265 1.1 tv else
266 1.1 tv printf("You can't kill the %s!\n",
267 1.1 tv objsht[wordvalue[wordnumber]]);
268 1.1 tv }
269 1.1 tv }
270 1.1 tv }
271 1.1 tv
272 1.1 tv void
273 1.1 tv ravage()
274 1.1 tv {
275 1.1 tv while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
276 1.1 tv continue;
277 1.1 tv if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, wordvalue[wordnumber])
278 1.1 tv || (wordvalue[wordnumber] == NORMGOD && testbit(location[position].objects, BATHGOD)))) {
279 1.1 tv ourtime++;
280 1.1 tv switch (wordvalue[wordnumber]) {
281 1.1 tv case NORMGOD:
282 1.1 tv puts("You attack the goddess, and she screams as you beat her. She falls down");
283 1.1 tv if (testbit(location[position].objects, BATHGOD))
284 1.1 tv puts("crying and tries to cover her nakedness.");
285 1.1 tv else
286 1.1 tv puts("crying and tries to hold her torn and bloodied dress around her.");
287 1.1 tv power += 5;
288 1.1 tv pleasure += 8;
289 1.1 tv ego -= 10;
290 1.1 tv wordnumber--;
291 1.1 tv godready = -30000;
292 1.1 tv murder();
293 1.1 tv win = -30000;
294 1.1 tv break;
295 1.1 tv case NATIVE:
296 1.1 tv puts("The girl tries to run, but you catch her and throw her down. Her face is");
297 1.1 tv puts("bleeding, and she screams as you tear off her clothes.");
298 1.1 tv power += 3;
299 1.1 tv pleasure += 5;
300 1.1 tv ego -= 10;
301 1.1 tv wordnumber--;
302 1.1 tv murder();
303 1.1 tv if (rnd(100) < 50) {
304 1.1 tv puts("Her screams have attracted attention. I think we are surrounded.");
305 1.1 tv setbit(location[ahead].objects, WOODSMAN);
306 1.1 tv setbit(location[ahead].objects, DEADWOOD);
307 1.1 tv setbit(location[ahead].objects, MALLET);
308 1.1 tv setbit(location[back].objects, WOODSMAN);
309 1.1 tv setbit(location[back].objects, DEADWOOD);
310 1.1 tv setbit(location[back].objects, MALLET);
311 1.1 tv setbit(location[left].objects, WOODSMAN);
312 1.1 tv setbit(location[left].objects, DEADWOOD);
313 1.1 tv setbit(location[left].objects, MALLET);
314 1.1 tv setbit(location[right].objects, WOODSMAN);
315 1.1 tv setbit(location[right].objects, DEADWOOD);
316 1.1 tv setbit(location[right].objects, MALLET);
317 1.1 tv }
318 1.1 tv break;
319 1.1 tv default:
320 1.1 tv puts("You are perverted.");
321 1.1 tv }
322 1.1 tv } else
323 1.1 tv puts("Who?");
324 1.1 tv }
325 1.1 tv
326 1.1 tv int
327 1.1 tv follow()
328 1.1 tv {
329 1.1 tv if (followfight == ourtime) {
330 1.1 tv puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
331 1.1 tv puts("You chase him through the darkness and splash in pools of water.");
332 1.1 tv puts("You have cornered him. His laser sword extends as he steps forward.");
333 1.1 tv position = FINAL;
334 1.1 tv fight(DARK, 75);
335 1.1 tv setbit(location[position].objects, TALISMAN);
336 1.1 tv setbit(location[position].objects, AMULET);
337 1.1 tv return (0);
338 1.1 tv } else
339 1.1 tv if (followgod == ourtime) {
340 1.1 tv puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
341 1.1 tv puts("She sits down on a throne.");
342 1.1 tv position = 268;
343 1.1 tv setbit(location[position].objects, NORMGOD);
344 1.1 tv notes[CANTSEE] = 1;
345 1.1 tv return (0);
346 1.1 tv } else
347 1.1 tv puts("There is no one to follow.");
348 1.1 tv return (-1);
349 1.1 tv }
350