]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com5.c
Add explicit no-ops to empty loops following the NetBSD style guide.
[bsdgames-darwin.git] / battlestar / com5.c
1 /* $NetBSD: com5.c,v 1.16 2000/09/24 14:20:23 jsm 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: com5.c,v 1.16 2000/09/24 14:20:23 jsm 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 && !loved) {
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 } else {
130 puts("You wish!");
131 return;
132 }
133 }
134 if (testbit(location[position].objects, wordvalue[wordnumber])) {
135 if (wordvalue[wordnumber] == NATIVE) {
136 puts("The girl is easy prey. She peels off her sarong and indulges you.");
137 power++;
138 pleasure += 5;
139 printf("Girl:\n");
140 ourtime += 10;
141 printf("Loved.\n");
142 zzz();
143 }
144 if (wordvalue[wordnumber] == MAN ||
145 wordvalue[wordnumber] == BODY ||
146 wordvalue[wordnumber] == ELF ||
147 wordvalue[wordnumber] == TIMER)
148 puts("Kinky!");
149 } else
150 puts("Where's your lover?");
151 } else
152 puts("It doesn't seem to work.");
153 }
154
155 int
156 zzz()
157 {
158 int oldtime;
159 int n;
160
161 oldtime = ourtime;
162 if ((snooze - ourtime) < (0.75 * CYCLE)) {
163 ourtime += 0.75 * CYCLE - (snooze - ourtime);
164 printf("<zzz>");
165 for (n = 0; n < ourtime - oldtime; n++)
166 printf(".");
167 printf("\n");
168 snooze += 3 * (ourtime - oldtime);
169 if (notes[LAUNCHED]) {
170 fuel -= (ourtime - oldtime);
171 if (location[position].down) {
172 position = location[position].down;
173 crash();
174 } else
175 notes[LAUNCHED] = 0;
176 }
177 if (OUTSIDE && rnd(100) < 50) {
178 puts("You are awakened abruptly by the sound of someone nearby.");
179 switch (rnd(4)) {
180 case 0:
181 if (ucard(inven)) {
182 n = rnd(NUMOFOBJECTS);
183 while (!testbit(inven, n))
184 n = rnd(NUMOFOBJECTS);
185 clearbit(inven, n);
186 if (n != AMULET && n != MEDALION && n != TALISMAN)
187 setbit(location[position].objects, n);
188 carrying -= objwt[n];
189 encumber -= objcumber[n];
190 }
191 puts("A fiendish little Elf is stealing your treasures!");
192 fight(ELF, 10);
193 break;
194 case 1:
195 setbit(location[position].objects, DEADWOOD);
196 break;
197 case 2:
198 setbit(location[position].objects, HALBERD);
199 break;
200 default:
201 break;
202 }
203 }
204 } else
205 return (0);
206 return (1);
207 }
208
209 void
210 chime()
211 {
212 if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
213 switch ((ourtime % CYCLE) / (CYCLE / 7)) {
214 case 0:
215 puts("It is just after sunrise.");
216 break;
217 case 1:
218 puts("It is early morning.");
219 break;
220 case 2:
221 puts("It is late morning.");
222 break;
223 case 3:
224 puts("It is near noon.");
225 break;
226 case 4:
227 puts("It is early afternoon.");
228 break;
229 case 5:
230 puts("It is late afternoon.");
231 break;
232 case 6:
233 puts("It is near sunset.");
234 break;
235 }
236 else if (OUTSIDE)
237 switch ((ourtime % CYCLE) / (CYCLE / 7)) {
238 case 0:
239 puts("It is just after sunset.");
240 break;
241 case 1:
242 puts("It is early evening.");
243 break;
244 case 2:
245 puts("The evening is getting old.");
246 break;
247 case 3:
248 puts("It is near midnight.");
249 break;
250 case 4:
251 puts("These are the wee hours of the morning.");
252 break;
253 case 5:
254 puts("The night is waning.");
255 break;
256 case 6:
257 puts("It is almost morning.");
258 break;
259 }
260 else
261 puts("I can't tell the time in here.");
262 }
263
264 int
265 give()
266 {
267 int obj = -1, result = -1, person = 0, firstnumber, last1, last2;
268
269 last1 = last2 = 0;
270 firstnumber = wordnumber;
271 while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount)
272 continue;
273 if (wordnumber <= wordcount) {
274 obj = wordvalue[wordnumber];
275 if (obj == EVERYTHING)
276 wordtype[wordnumber] = -1;
277 last1 = wordnumber;
278 }
279 wordnumber = firstnumber;
280 while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
281 if (wordtype[wordnumber] == NOUNS) {
282 person = wordvalue[wordnumber];
283 last2 = wordnumber;
284 }
285 /* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
286 * plain `give'. However, detecting this case is liable to detect
287 * `give foo' as well, which would give a confusing error. We
288 * need to make sure the -1 value can cause no problems if it arises.
289 * If in the below we get to the drop("Given") then drop will look
290 * at word 0 for an object to give, and fail, which is OK; then
291 * result will be -1 and we get to the end, where wordnumber gets
292 * set to something more sensible. If we get to "I don't think
293 * that is possible" then again wordnumber is set to something
294 * sensible. The wordnumber we leave with still isn't right if
295 * you include words the game doesn't know in your command, but
296 * that's no worse than what other commands than give do in
297 * the same place. */
298 wordnumber = last1 - 1;
299 if (person && testbit(location[position].objects, person)) {
300 if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
301 puts("The goddess won't look at you.");
302 else
303 result = drop("Given");
304 } else {
305 puts("I don't think that is possible.");
306 wordnumber = max(last1, last2) + 1;
307 return (0);
308 }
309 if (result != -1 && (testbit(location[position].objects, obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)) {
310 clearbit(location[position].objects, obj);
311 ourtime++;
312 ego++;
313 switch (person) {
314 case NATIVE:
315 puts("She accepts it shyly.");
316 ego += 2;
317 break;
318 case NORMGOD:
319 if (obj == RING || obj == BRACELET) {
320 puts("She takes the charm and puts it on. A little kiss on the cheek is");
321 puts("your reward.");
322 ego += 5;
323 godready += 3;
324 }
325 if (obj == AMULET || obj == MEDALION || obj == TALISMAN) {
326 win++;
327 ego += 5;
328 power -= 5;
329 if (win >= 3) {
330 puts("The powers of the earth are now legitimate. You have destroyed the Darkness");
331 puts("and restored the goddess to her throne. The entire island celebrates with");
332 puts("dancing and spring feasts. As a measure of her gratitude, the goddess weds you");
333 puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus.");
334 puts("\nBut, as the year wears on and autumn comes along, you become restless and");
335 puts("yearn for adventure. The goddess, too, realizes that the marriage can't last.");
336 puts("She becomes bored and takes several more natives as husbands. One evening,");
337 puts("after having been out drinking with the girls, she kicks the throne particularly");
338 puts("hard and wakes you up. (If you want to win this game, you're going to have to\nshoot her!)");
339 clearbit(location[position].objects, MEDALION);
340 wintime = ourtime;
341 }
342 }
343 break;
344 case TIMER:
345 if (obj == COINS) {
346 puts("He fingers the coins for a moment and then looks up agape. `Kind you are and");
347 puts("I mean to repay you as best I can.' Grabbing a pencil and cocktail napkin...\n");
348 printf("+-----------------------------------------------------------------------------+\n");
349 printf("| xxxxxxxx\\ |\n");
350 printf("| xxxxx\\ CLIFFS |\n");
351 printf("| FOREST xxx\\ |\n");
352 printf("| \\\\ x\\ OCEAN |\n");
353 printf("| || x\\ |\n");
354 printf("| || ROAD x\\ |\n");
355 printf("| || x\\ |\n");
356 printf("| SECRET || ......... |\n");
357 printf("| - + - || ........ |\n");
358 printf("| ENTRANCE || ... BEACH |\n");
359 printf("| || ... E |\n");
360 printf("| || ... | |\n");
361 printf("| // ... N <-- + --- S |\n");
362 printf("| PALM GROVE // ... | |\n");
363 printf("| // ... W |\n");
364 printf("+-----------------------------------------------------------------------------+\n");
365 puts("\n`This map shows a secret entrance to the catacombs.");
366 puts("You will know when you arrive because I left an old pair of shoes there.'");
367 }
368 break;
369 }
370 }
371 wordnumber = max(last1, last2) + 1;
372 return (firstnumber);
373 }