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