command5.c revision 1.3 1 1.3 jmc /* $NetBSD: command5.c,v 1.3 2005/07/01 06:04:54 jmc 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[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95";
36 1.1 tv #else
37 1.3 jmc __RCSID("$NetBSD: command5.c,v 1.3 2005/07/01 06:04:54 jmc 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 void
44 1.1 tv kiss()
45 1.1 tv {
46 1.1 tv while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
47 1.1 tv continue;
48 1.1 tv /* The goddess must be "taken" first if bathing. */
49 1.1 tv if (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == NORMGOD
50 1.1 tv && testbit(location[position].objects, BATHGOD)) {
51 1.1 tv wordvalue[--wordnumber] = TAKE;
52 1.1 tv cypher();
53 1.1 tv return;
54 1.1 tv }
55 1.1 tv if (wordtype[wordnumber] == NOUNS) {
56 1.3 jmc if (testbit(location[position].objects,
57 1.3 jmc wordvalue[wordnumber])) {
58 1.1 tv pleasure++;
59 1.1 tv printf("Kissed.\n");
60 1.1 tv switch (wordvalue[wordnumber]) {
61 1.1 tv case NORMGOD:
62 1.1 tv switch (godready++) {
63 1.1 tv case 0:
64 1.3 jmc printf("She squirms and avoids your ");
65 1.3 jmc puts("advances.");
66 1.1 tv break;
67 1.1 tv case 1:
68 1.3 jmc puts("She is coming around; she ");
69 1.3 jmc puts("didn't fight it as much.");
70 1.1 tv break;
71 1.1 tv case 2:
72 1.1 tv puts("She's beginning to like it.");
73 1.1 tv break;
74 1.1 tv default:
75 1.1 tv puts("She's gone limp.");
76 1.1 tv
77 1.1 tv }
78 1.1 tv break;
79 1.1 tv case NATIVE:
80 1.3 jmc printf("Her lips are warm and her body ");
81 1.3 jmc printf("robust. She pulls you down to ");
82 1.3 jmc puts("the ground.");
83 1.1 tv break;
84 1.1 tv case TIMER:
85 1.1 tv puts("The old man blushes.");
86 1.1 tv break;
87 1.1 tv case MAN:
88 1.1 tv puts("The dwarf punches you in the kneecap.");
89 1.1 tv break;
90 1.1 tv default:
91 1.1 tv pleasure--;
92 1.1 tv }
93 1.1 tv } else
94 1.1 tv puts("I see nothing like that here.");
95 1.1 tv } else
96 1.1 tv puts("I'd prefer not to.");
97 1.1 tv }
98 1.1 tv
99 1.1 tv void
100 1.3 jmc love(void)
101 1.1 tv {
102 1.1 tv int n;
103 1.1 tv
104 1.1 tv while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
105 1.1 tv continue;
106 1.1 tv if (wordtype[wordnumber] == NOUNS) {
107 1.1 tv if ((testbit(location[position].objects, BATHGOD) ||
108 1.1 tv testbit(location[position].objects, NORMGOD)) &&
109 1.1 tv wordvalue[wordnumber] == NORMGOD) {
110 1.1 tv if (loved) {
111 1.1 tv printf("Loved.\n");
112 1.1 tv return;
113 1.1 tv }
114 1.1 tv if (godready >= 2) {
115 1.3 jmc printf("She cuddles up to you, and her mouth ");
116 1.3 jmc printf("starts to work:\n'That was my ");
117 1.3 jmc printf("sister's amulet. The lovely ");
118 1.3 jmc printf("goddess, Purl, was she. The Empire\n");
119 1.3 jmc printf("captured her just after the Darkness ");
120 1.3 jmc printf("came. My other sister, Vert, was ");
121 1.3 jmc printf("killed\nby the Dark Lord himself. ");
122 1.3 jmc printf("He took her amulet and warped its ");
123 1.3 jmc printf("power.\nYour quest was foretold by ");
124 1.3 jmc printf("my father before he died, but to get ");
125 1.3 jmc printf("the Dark Lord's\namulet you must use ");
126 1.3 jmc printf("cunning and skill. I will leave you ");
127 1.3 jmc puts("my amulet,");
128 1.3 jmc printf("which you may use as you wish. As ");
129 1.3 jmc printf("for me, I am the last goddess of ");
130 1.3 jmc printf("the\nwaters. My father was the ");
131 1.3 jmc printf("Island King, and the rule is ");
132 1.3 jmc printf("rightfully mine.'\n\nShe pulls the ");
133 1.3 jmc puts("throne out into a large bed.");
134 1.1 tv power++;
135 1.1 tv pleasure += 15;
136 1.1 tv ego++;
137 1.1 tv if (card(injuries, NUMOFINJURIES)) {
138 1.3 jmc printf("Her kisses revive you; your ");
139 1.3 jmc printf("wounds are healed.\n");
140 1.1 tv for (n = 0; n < NUMOFINJURIES; n++)
141 1.1 tv injuries[n] = 0;
142 1.1 tv WEIGHT = MAXWEIGHT;
143 1.1 tv CUMBER = MAXCUMBER;
144 1.1 tv }
145 1.1 tv printf("Goddess:\n");
146 1.1 tv if (!loved)
147 1.3 jmc setbit(location[position].objects,
148 1.3 jmc MEDALION);
149 1.1 tv loved = 1;
150 1.1 tv ourtime += 10;
151 1.1 tv printf("Loved.\n");
152 1.1 tv zzz();
153 1.1 tv return;
154 1.1 tv } else {
155 1.1 tv puts("You wish!");
156 1.1 tv return;
157 1.1 tv }
158 1.1 tv }
159 1.3 jmc if (testbit(location[position].objects,
160 1.3 jmc wordvalue[wordnumber])) {
161 1.1 tv if (wordvalue[wordnumber] == NATIVE) {
162 1.3 jmc printf("The girl is easy prey. She peels ");
163 1.3 jmc puts("off her sarong and indulges you.");
164 1.1 tv power++;
165 1.1 tv pleasure += 5;
166 1.1 tv printf("Girl:\n");
167 1.1 tv ourtime += 10;
168 1.1 tv printf("Loved.\n");
169 1.1 tv zzz();
170 1.1 tv }
171 1.1 tv if (wordvalue[wordnumber] == MAN ||
172 1.1 tv wordvalue[wordnumber] == BODY ||
173 1.1 tv wordvalue[wordnumber] == ELF ||
174 1.1 tv wordvalue[wordnumber] == TIMER)
175 1.1 tv puts("Kinky!");
176 1.1 tv else
177 1.1 tv puts("It doesn't seem to work.");
178 1.1 tv } else
179 1.1 tv puts("Where's your lover?");
180 1.1 tv } else
181 1.1 tv puts("It doesn't seem to work.");
182 1.1 tv }
183 1.1 tv
184 1.1 tv int
185 1.3 jmc zzz(void)
186 1.1 tv {
187 1.1 tv int oldtime;
188 1.1 tv int n;
189 1.1 tv
190 1.1 tv oldtime = ourtime;
191 1.1 tv if ((snooze - ourtime) < (0.75 * CYCLE)) {
192 1.1 tv ourtime += 0.75 * CYCLE - (snooze - ourtime);
193 1.1 tv printf("<zzz>");
194 1.1 tv for (n = 0; n < ourtime - oldtime; n++)
195 1.1 tv printf(".");
196 1.1 tv printf("\n");
197 1.1 tv snooze += 3 * (ourtime - oldtime);
198 1.1 tv if (notes[LAUNCHED]) {
199 1.1 tv fuel -= (ourtime - oldtime);
200 1.1 tv if (location[position].down) {
201 1.1 tv position = location[position].down;
202 1.1 tv crash();
203 1.1 tv } else
204 1.1 tv notes[LAUNCHED] = 0;
205 1.1 tv }
206 1.1 tv if (OUTSIDE && rnd(100) < 50) {
207 1.3 jmc printf("You are awakened abruptly by the sound ");
208 1.3 jmc puts("of someone nearby.");
209 1.1 tv switch (rnd(4)) {
210 1.1 tv case 0:
211 1.1 tv if (ucard(inven)) {
212 1.1 tv n = rnd(NUMOFOBJECTS);
213 1.1 tv while (!testbit(inven, n))
214 1.1 tv n = rnd(NUMOFOBJECTS);
215 1.1 tv clearbit(inven, n);
216 1.3 jmc if (n != AMULET && n != MEDALION &&
217 1.3 jmc n != TALISMAN)
218 1.3 jmc setbit(
219 1.3 jmc location[position].objects,
220 1.3 jmc n);
221 1.1 tv carrying -= objwt[n];
222 1.1 tv encumber -= objcumber[n];
223 1.1 tv }
224 1.3 jmc printf("A fiendish little Elf is stealing ");
225 1.3 jmc puts("your treasures!");
226 1.1 tv fight(ELF, 10);
227 1.1 tv break;
228 1.1 tv case 1:
229 1.1 tv setbit(location[position].objects, DEADWOOD);
230 1.1 tv break;
231 1.1 tv case 2:
232 1.1 tv setbit(location[position].objects, HALBERD);
233 1.1 tv break;
234 1.1 tv default:
235 1.1 tv break;
236 1.1 tv }
237 1.1 tv }
238 1.1 tv } else
239 1.1 tv return (0);
240 1.1 tv return (1);
241 1.1 tv }
242 1.1 tv
243 1.1 tv void
244 1.3 jmc chime(void)
245 1.1 tv {
246 1.1 tv if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
247 1.1 tv switch ((ourtime % CYCLE) / (CYCLE / 7)) {
248 1.1 tv case 0:
249 1.1 tv puts("It is just after sunrise.");
250 1.1 tv break;
251 1.1 tv case 1:
252 1.1 tv puts("It is early morning.");
253 1.1 tv break;
254 1.1 tv case 2:
255 1.1 tv puts("It is late morning.");
256 1.1 tv break;
257 1.1 tv case 3:
258 1.1 tv puts("It is near noon.");
259 1.1 tv break;
260 1.1 tv case 4:
261 1.1 tv puts("It is early afternoon.");
262 1.1 tv break;
263 1.1 tv case 5:
264 1.1 tv puts("It is late afternoon.");
265 1.1 tv break;
266 1.1 tv case 6:
267 1.1 tv puts("It is near sunset.");
268 1.1 tv break;
269 1.1 tv }
270 1.1 tv else if (OUTSIDE)
271 1.1 tv switch ((ourtime % CYCLE) / (CYCLE / 7)) {
272 1.1 tv case 0:
273 1.1 tv puts("It is just after sunset.");
274 1.1 tv break;
275 1.1 tv case 1:
276 1.1 tv puts("It is early evening.");
277 1.1 tv break;
278 1.1 tv case 2:
279 1.1 tv puts("The evening is getting old.");
280 1.1 tv break;
281 1.1 tv case 3:
282 1.1 tv puts("It is near midnight.");
283 1.1 tv break;
284 1.1 tv case 4:
285 1.1 tv puts("These are the wee hours of the morning.");
286 1.1 tv break;
287 1.1 tv case 5:
288 1.1 tv puts("The night is waning.");
289 1.1 tv break;
290 1.1 tv case 6:
291 1.1 tv puts("It is almost morning.");
292 1.1 tv break;
293 1.1 tv }
294 1.1 tv else
295 1.1 tv puts("I can't tell the time in here.");
296 1.1 tv }
297 1.1 tv
298 1.1 tv int
299 1.3 jmc give(void)
300 1.1 tv {
301 1.1 tv int obj = -1, result = -1, person = 0, firstnumber, last1, last2;
302 1.1 tv
303 1.1 tv last1 = last2 = 0;
304 1.1 tv firstnumber = wordnumber;
305 1.3 jmc while (wordtype[++wordnumber] != OBJECT &&
306 1.3 jmc wordvalue[wordnumber] != AMULET &&
307 1.3 jmc wordvalue[wordnumber] != MEDALION &&
308 1.3 jmc wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount)
309 1.1 tv continue;
310 1.1 tv if (wordnumber <= wordcount) {
311 1.1 tv obj = wordvalue[wordnumber];
312 1.1 tv if (obj == EVERYTHING)
313 1.1 tv wordtype[wordnumber] = -1;
314 1.1 tv last1 = wordnumber;
315 1.1 tv }
316 1.1 tv wordnumber = firstnumber;
317 1.3 jmc while ((wordtype[++wordnumber] != NOUNS ||
318 1.3 jmc wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
319 1.1 tv if (wordtype[wordnumber] == NOUNS) {
320 1.1 tv person = wordvalue[wordnumber];
321 1.1 tv last2 = wordnumber;
322 1.1 tv }
323 1.1 tv /* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
324 1.1 tv * plain `give'. However, detecting this case is liable to detect
325 1.1 tv * `give foo' as well, which would give a confusing error. We
326 1.1 tv * need to make sure the -1 value can cause no problems if it arises.
327 1.1 tv * If in the below we get to the drop("Given") then drop will look
328 1.1 tv * at word 0 for an object to give, and fail, which is OK; then
329 1.1 tv * result will be -1 and we get to the end, where wordnumber gets
330 1.1 tv * set to something more sensible. If we get to "I don't think
331 1.1 tv * that is possible" then again wordnumber is set to something
332 1.1 tv * sensible. The wordnumber we leave with still isn't right if
333 1.1 tv * you include words the game doesn't know in your command, but
334 1.1 tv * that's no worse than what other commands than give do in
335 1.1 tv * the same place. */
336 1.1 tv wordnumber = last1 - 1;
337 1.1 tv if (person && testbit(location[position].objects, person)) {
338 1.3 jmc if (person == NORMGOD && godready < 2 &&
339 1.3 jmc !(obj == RING || obj == BRACELET))
340 1.1 tv puts("The goddess won't look at you.");
341 1.1 tv else
342 1.1 tv result = drop("Given");
343 1.1 tv } else {
344 1.1 tv puts("I don't think that is possible.");
345 1.1 tv wordnumber = max(last1, last2) + 1;
346 1.1 tv return (0);
347 1.1 tv }
348 1.3 jmc if (result != -1 && (testbit(location[position].objects, obj) ||
349 1.3 jmc obj == AMULET || obj == MEDALION || obj == TALISMAN)) {
350 1.1 tv clearbit(location[position].objects, obj);
351 1.1 tv ourtime++;
352 1.1 tv ego++;
353 1.1 tv switch (person) {
354 1.1 tv case NATIVE:
355 1.1 tv puts("She accepts it shyly.");
356 1.1 tv ego += 2;
357 1.1 tv break;
358 1.1 tv case NORMGOD:
359 1.1 tv if (obj == RING || obj == BRACELET) {
360 1.3 jmc printf("She takes the charm and puts it on.");
361 1.3 jmc puts(" A little kiss on the cheek is");
362 1.1 tv puts("your reward.");
363 1.1 tv ego += 5;
364 1.1 tv godready += 3;
365 1.1 tv }
366 1.3 jmc if (obj == AMULET || obj == MEDALION ||
367 1.3 jmc obj == TALISMAN) {
368 1.1 tv win++;
369 1.1 tv ego += 5;
370 1.1 tv power -= 5;
371 1.1 tv if (win >= 3) {
372 1.3 jmc printf("The powers of the earth are ");
373 1.3 jmc printf("now legitimate. You have ");
374 1.3 jmc puts("destroyed the Darkness");
375 1.3 jmc printf("and restored the goddess to ");
376 1.3 jmc printf("her throne. The entire ");
377 1.3 jmc puts("island celebrates with");
378 1.3 jmc printf("dancing and spring feasts. ");
379 1.3 jmc printf("As a measure of her ");
380 1.3 jmc puts("gratitude, the goddess weds you");
381 1.3 jmc printf("in the late summer and ");
382 1.3 jmc printf("crowns you Prince Liverwort, ");
383 1.3 jmc puts("Lord of Fungus.");
384 1.3 jmc printf("\nBut, as the year wears on ");
385 1.3 jmc printf("and autumn comes along, you ");
386 1.3 jmc puts("become restless and");
387 1.3 jmc printf("yearn for adventure. The ");
388 1.3 jmc printf("goddess, too, realizes that ");
389 1.3 jmc puts("the marriage can't last.");
390 1.3 jmc printf("She becomes bored and takes ");
391 1.3 jmc printf("several more natives as ");
392 1.3 jmc puts("husbands. One evening,");
393 1.3 jmc printf("after having been out ");
394 1.3 jmc printf("drinking with the girls, she ");
395 1.3 jmc puts("kicks the throne particularly");
396 1.3 jmc printf("hard and wakes you up. (If ");
397 1.3 jmc printf("you want to win this game, ");
398 1.3 jmc printf("you're going to have to\n");
399 1.3 jmc puts("shoot her!)");
400 1.3 jmc clearbit(location[position].objects,
401 1.3 jmc MEDALION);
402 1.1 tv wintime = ourtime;
403 1.1 tv }
404 1.1 tv }
405 1.1 tv break;
406 1.1 tv case TIMER:
407 1.1 tv if (obj == COINS) {
408 1.3 jmc printf("He fingers the coins for a moment ");
409 1.3 jmc printf("and then looks up agape. `Kind you ");
410 1.3 jmc puts("are and");
411 1.3 jmc printf("I mean to repay you as best I can.' ");
412 1.3 jmc printf("Grabbing a pencil and cocktail ");
413 1.3 jmc puts("napkin...\n");
414 1.3 jmc printf("+-----------------------------------");
415 1.3 jmc printf("------------------------------------");
416 1.3 jmc printf("------+\n");
417 1.1 tv printf("| xxxxxxxx\\ |\n");
418 1.1 tv printf("| xxxxx\\ CLIFFS |\n");
419 1.1 tv printf("| FOREST xxx\\ |\n");
420 1.1 tv printf("| \\\\ x\\ OCEAN |\n");
421 1.1 tv printf("| || x\\ |\n");
422 1.1 tv printf("| || ROAD x\\ |\n");
423 1.1 tv printf("| || x\\ |\n");
424 1.1 tv printf("| SECRET || ......... |\n");
425 1.1 tv printf("| - + - || ........ |\n");
426 1.1 tv printf("| ENTRANCE || ... BEACH |\n");
427 1.1 tv printf("| || ... E |\n");
428 1.1 tv printf("| || ... | |\n");
429 1.1 tv printf("| // ... N <-- + --- S |\n");
430 1.1 tv printf("| PALM GROVE // ... | |\n");
431 1.1 tv printf("| // ... W |\n");
432 1.3 jmc printf("+");
433 1.3 jmc printf("---------------------------------");
434 1.3 jmc printf("---------------------------------");
435 1.3 jmc printf("-----------+\n");
436 1.3 jmc printf("\n`This map shows a secret entrance ");
437 1.3 jmc puts("to the catacombs.");
438 1.3 jmc printf("You will know when you arrive ");
439 1.3 jmc printf("because I left an old pair of shoes ");
440 1.3 jmc puts("there.'");
441 1.1 tv }
442 1.1 tv break;
443 1.1 tv }
444 1.1 tv }
445 1.1 tv wordnumber = max(last1, last2) + 1;
446 1.1 tv return (firstnumber);
447 1.1 tv }
448