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