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