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