Initial import from FreeBSD RELENG_4:
[games.git] / games / battlestar / com2.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[] = "@(#)com2.c      8.1 (Berkeley) 5/31/93";
37 #endif
38 static const char rcsid[] =
39  "$FreeBSD: src/games/battlestar/com2.c,v 1.8.2.2 2002/05/01 09:17:16 roam Exp $";
40 #endif /* not lint */
41
42 #include "externs.h"
43
44 int
45 wearit()                /* synonyms = {sheathe, sheath} */
46 {
47         int n;
48         int firstnumber, value;
49
50         firstnumber = wordnumber;
51         while(wordtype[++wordnumber] == ADJS);
52         while(wordnumber <= wordcount){
53                 value = wordvalue[wordnumber];
54                 if (value == -1) {
55                         puts("Wear what?");
56                         return (firstnumber);
57                 }
58                 for (n=0; objsht[value][n]; n++);
59                 switch(value){
60                         default:
61                                 printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
62                                 return(firstnumber);
63
64                         case KNIFE:
65                 /*      case SHIRT:     */
66                         case ROBE:
67                         case LEVIS:     /* wearable things */
68                         case SWORD:
69                         case MAIL:
70                         case HELM:
71                         case SHOES:
72                         case PAJAMAS:
73                         case COMPASS:
74                         case LASER:
75                         case AMULET:
76                         case TALISMAN:
77                         case MEDALION:
78                         case ROPE:
79                         case RING:
80                         case BRACELET:
81                         case GRENADE:
82
83                                 if (testbit(inven,value)){
84                                         clearbit(inven,value);
85                                         setbit(wear,value);
86                                         carrying -= objwt[value];
87                                         encumber -= objcumber[value];
88                                         gtime++;
89                                         printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
90                                 }
91                                 else if (testbit(wear,value))
92                                         printf("You are already wearing the %s.\n", objsht[value]);
93                                 else
94                                         printf("You aren't holding the %s.\n", objsht[value]);
95                                 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
96                                         wordnumber++;
97                                 else
98                                         return(firstnumber);
99                 } /* end switch */
100         } /* end while */
101         puts("Don't be ridiculous.");
102         return(firstnumber);
103 }
104
105 int
106 put()           /* synonyms = {buckle, strap, tie} */
107 {
108         if (wordvalue[wordnumber + 1] == ON){
109                 wordvalue[++wordnumber] = PUTON;
110                 return(cypher());
111         }
112         if (wordvalue[wordnumber + 1] == DOWN){
113                 wordvalue[++wordnumber] = DROP;
114                 return(cypher());
115         }
116         puts("I don't understand what you want to put.");
117         return(-1);
118
119 }
120
121 int
122 draw()                  /* synonyms = {pull, carry} */
123 {
124         return(take(wear));
125 }
126
127 int
128 use()
129 {
130         while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
131         if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
132                 puts("The amulet begins to glow.");
133                 if (testbit(inven,MEDALION)){
134                         puts("The medallion comes to life too.");
135                         if (position == 114){
136                                 location[position].down = 160;
137                                 whichway(location[position]);
138                                 puts("The waves subside and it is possible to descend to the sea cave now.");
139                                 gtime++;
140                                 return(-1);
141                         }
142                 }
143                 puts("A light mist falls over your eyes and the sound of purling water trickles in");
144                 puts("your ears.   When the mist lifts you are standing beside a cool stream.");
145                 if (position == 229)
146                         position = 224;
147                 else
148                         position = 229;
149                 gtime++;
150                 notes[CANTSEE] = 0;
151                 return(0);
152         }
153         else if (position == FINAL)
154                 puts("The amulet won't work in here.");
155         else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
156                 printf("Your compass points %s.\n",truedirec(NORTH,'-'));
157         else if (wordvalue[wordnumber] == COMPASS)
158                 puts("You aren't holding the compass.");
159         else if (wordvalue[wordnumber] == AMULET)
160                 puts("You aren't holding the amulet.");
161         else
162                 puts("There is no apparent use.");
163         return(-1);
164 }
165
166 void
167 murder()
168 {
169         int n;
170
171         for (n=0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven,n)) && n < NUMOFOBJECTS; n++);
172         if (n == NUMOFOBJECTS)
173                 puts("You don't have suitable weapons to kill.");
174         else {
175                 printf("Your %s should do the trick.\n",objsht[n]);
176                 while (wordtype[++wordnumber] == ADJS);
177                 switch(wordvalue[wordnumber]){
178
179                         case NORMGOD:
180                                 if (testbit(location[position].objects,BATHGOD)){
181                                         puts("The goddess's head slices off.  Her corpse floats in the water.");
182                                         clearbit(location[position].objects,BATHGOD);
183                                         setbit(location[position].objects,DEADGOD);
184                                         power += 5;
185                                         notes[JINXED]++;
186                                 } else if (testbit(location[position].objects,NORMGOD)){
187                                         puts("The goddess pleads but you strike her mercilessly.  Her broken body lies in a\npool of blood.");
188                                         clearbit(location[position].objects,NORMGOD);
189                                         setbit(location[position].objects,DEADGOD);
190                                         power += 5;
191                                         notes[JINXED]++;
192                                         if (wintime)
193                                                 live();
194                                 } else puts("I dont see her anywhere.");
195                                 break;
196                         case TIMER:
197                                 if (testbit(location[position].objects,TIMER)){
198                                         puts("The old man offers no resistance.");
199                                         clearbit(location[position].objects,TIMER);
200                                         setbit(location[position].objects,DEADTIME);
201                                         power++;
202                                         notes[JINXED]++;
203                                 } else puts("Who?");
204                                 break;
205                         case NATIVE:
206                                 if (testbit(location[position].objects,NATIVE)){
207                                         puts("The girl screams as you cut her body to shreds.  She is dead.");
208                                         clearbit(location[position].objects,NATIVE);
209                                         setbit(location[position].objects,DEADNATIVE);
210                                         power += 5;
211                                         notes[JINXED]++;
212                                 } else puts("What girl?");
213                                 break;
214                         case MAN:
215                                 if (testbit(location[position].objects,MAN)){
216                                         puts("You strike him to the ground, and he coughs up blood.");
217                                         puts("Your fantasy is over.");
218                                         die(0);
219                                 }
220                         case -1:
221                                 puts("Kill what?");
222                                 break;
223
224                         default:
225                                 if (wordtype[wordnumber] != NOUNS)
226                                         puts("Kill what?");
227                                 else
228                                         printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
229                 }
230         }
231 }
232
233 void
234 ravage()
235 {
236         while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
237         if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
238                 gtime++;
239                 switch(wordvalue[wordnumber]){
240                         case NORMGOD:
241                                 puts("You attack the goddess, and she screams as you beat her.  She falls down");
242                                 puts("crying and tries to hold her torn and bloodied dress around her.");
243                                 power += 5;
244                                 pleasure += 8;
245                                 ego -= 10;
246                                 wordnumber--;
247                                 godready = -30000;
248                                 murder();
249                                 bs_win = -30000;
250                                 break;
251                         case NATIVE:
252                                 puts("The girl tries to run, but you catch her and throw her down.  Her face is");
253                                 puts("bleeding, and she screams as you tear off her clothes.");
254                                 power += 3;
255                                 pleasure += 5;
256                                 ego -= 10;
257                                 wordnumber--;
258                                 murder();
259                                 if (rnd(100) < 50){
260                                         puts("Her screams have attracted attention.  I think we are surrounded.");
261                                         setbit(location[ahead].objects,WOODSMAN);
262                                         setbit(location[ahead].objects,DEADWOOD);
263                                         setbit(location[ahead].objects,MALLET);
264                                         setbit(location[back].objects,WOODSMAN);
265                                         setbit(location[back].objects,DEADWOOD);
266                                         setbit(location[back].objects,MALLET);
267                                         setbit(location[left].objects,WOODSMAN);
268                                         setbit(location[left].objects,DEADWOOD);
269                                         setbit(location[left].objects,MALLET);
270                                         setbit(location[right].objects,WOODSMAN);
271                                         setbit(location[right].objects,DEADWOOD);
272                                         setbit(location[right].objects,MALLET);
273                                 }
274                                 break;
275                         default:
276                                 puts("You are perverted.");
277                 }
278         }
279         else
280                 puts("Who?");
281 }
282
283 int
284 follow()
285 {
286         if (followfight == gtime){
287                 puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
288                 puts("You chase him through the darkness and splash in pools of water.");
289                 puts("You have cornered him.  His laser sword extends as he steps forward.");
290                 position = FINAL;
291                 fight(DARK,75);
292                 setbit(location[position].objects,TALISMAN);
293                 setbit(location[position].objects,AMULET);
294                 return(0);
295         }
296         else if (followgod == gtime){
297                 puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
298                 puts("She sits down on a throne.");
299                 position = 268;
300                 setbit(location[position].objects,NORMGOD);
301                 notes[CANTSEE] = 1;
302                 return(0);
303         }
304         else
305                 puts("There is no one to follow.");
306         return(-1);
307 }