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