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