mount.8: Fix typo.
[dragonfly.git] / games / battlestar / command2.c
1 /*      @(#)com2.c      8.2 (Berkeley) 4/28/95                  */
2 /*      $NetBSD: command2.c,v 1.4 2019/02/03 03:19:25 mrg Exp $ */
3
4 /*
5  * Copyright (c) 1983, 1993
6  *      The Regents of the University of California.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32
33 #include "extern.h"
34
35 int
36 wearit(void)
37 {                               /* synonyms = {sheathe, sheath} */
38         int     firstnumber, value;
39
40         firstnumber = wordnumber;
41         wordnumber++;
42         while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
43             wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
44                 value = wordvalue[wordnumber];
45                 if (value >= 0 && objsht[value] == NULL)
46                         break;
47                 switch (value) {
48
49                 case -1:
50                         puts("Wear what?");
51                         return (firstnumber);
52
53                 default:
54                         printf("You can't wear %s%s!\n",
55                             A_OR_AN_OR_BLANK(value), objsht[value]);
56                         return (firstnumber);
57
58                 case KNIFE:
59                         /* case SHIRT:   */
60                 case ROBE:
61                 case LEVIS:     /* wearable things */
62                 case SWORD:
63                 case MAIL:
64                 case HELM:
65                 case SHOES:
66                 case PAJAMAS:
67                 case COMPASS:
68                 case LASER:
69                 case AMULET:
70                 case TALISMAN:
71                 case MEDALION:
72                 case ROPE:
73                 case RING:
74                 case BRACELET:
75                 case GRENADE:
76
77                         if (testbit(inven, value)) {
78                                 clearbit(inven, value);
79                                 setbit(wear, value);
80                                 carrying -= objwt[value];
81                                 encumber -= objcumber[value];
82                                 ourtime++;
83                                 printf("You are now wearing %s%s.\n",
84                                     A_OR_AN_OR_THE(value), objsht[value]);
85                         } else
86                                 if (testbit(wear, value)) {
87                                         printf("You are already wearing the %s",
88                                             objsht[value]);
89                                         printf(".\n");
90                                 } else
91                                         printf("You aren't holding the %s.\n",
92                                             objsht[value]);
93                         if (wordnumber < wordcount - 1 &&
94                             wordvalue[++wordnumber] == AND)
95                                 wordnumber++;
96                         else
97                                 return (firstnumber);
98                 }               /* end switch */
99         }                       /* end while */
100         puts("Don't be ridiculous.");
101         return (firstnumber);
102 }
103
104 int
105 put(void)
106 {                               /* synonyms = {buckle, strap, tie} */
107         if (wordvalue[wordnumber + 1] == ON) {
108                 wordvalue[++wordnumber] = PUTON;
109                 wordtype[wordnumber] = VERB;
110                 return (cypher());
111         }
112         if (wordvalue[wordnumber + 1] == DOWN) {
113                 wordvalue[++wordnumber] = DROP;
114                 wordtype[wordnumber] = VERB;
115                 return (cypher());
116         }
117         puts("I don't understand what you want to put.");
118         return (-1);
119
120 }
121
122 int
123 draw(void)
124 {                               /* synonyms = {pull, carry} */
125         return (take(wear));
126 }
127
128 int
129 use(void)
130 {
131         wordnumber++;
132         if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
133             position != FINAL) {
134                 puts("The amulet begins to glow.");
135                 if (testbit(inven, MEDALION)) {
136                         puts("The medallion comes to life too.");
137                         if (position == 114) {
138                                 location[position].down = 160;
139                                 whichway(location[position]);
140                                 printf("The waves subside and it is possible ");
141                                 puts("to descend to the sea cave now.");
142                                 ourtime++;
143                                 return (-1);
144                         }
145                 }
146                 printf("A light mist falls over your eyes and the sound of ");
147                 puts("purling water trickles in");
148                 printf("your ears.   When the mist lifts you are standing ");
149                 puts("beside a cool stream.");
150                 if (position == 229)
151                         position = 224;
152                 else
153                         position = 229;
154                 ourtime++;
155                 notes[CANTSEE] = 0;
156                 return (0);
157         } else if (position == FINAL)
158                 puts("The amulet won't work in here.");
159         else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
160                 printf("Your compass points %s.\n", truedirec(NORTH, '-'));
161         else if (wordvalue[wordnumber] == COMPASS)
162                 puts("You aren't holding the compass.");
163         else if (wordvalue[wordnumber] == AMULET)
164                 puts("You aren't holding the amulet.");
165         else
166                 puts("There is no apparent use.");
167         return (-1);
168 }
169
170 void
171 murder(void)
172 {
173         int     n;
174
175         for (n = 0; 
176             !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || 
177                 n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || 
178                 n == HALBERD) && testbit(inven, n)) && n < NUMOFOBJECTS; 
179             n++);
180         if (n == NUMOFOBJECTS) {
181                 if (testbit(inven, LASER)) {
182                         printf("Your laser should do the trick.\n");
183                         wordnumber++;
184                         switch(wordvalue[wordnumber]) {
185                         case NORMGOD:
186                         case TIMER:
187                         case NATIVE:
188                         case MAN:
189                                 wordvalue[--wordnumber] = SHOOT;
190                                 cypher();
191                                 break;
192                         case -1:
193                                 puts("Kill what?");
194                                 break;
195                         default:
196                                 if (wordtype[wordnumber] != OBJECT ||
197                                     wordvalue[wordnumber] == EVERYTHING)
198                                         puts("You can't kill that!");
199                                 else
200                                         printf("You can't kill %s%s!\n",
201                                             A_OR_AN_OR_BLANK(wordvalue[wordnumber]),
202                                             objsht[wordvalue[wordnumber]]);
203                                 break;
204                         }
205                 } else
206                         puts("You don't have suitable weapons to kill.");
207         } else {
208                 printf("Your %s should do the trick.\n", objsht[n]);
209                 wordnumber++;
210                 switch (wordvalue[wordnumber]) {
211
212                 case NORMGOD:
213                         if (testbit(location[position].objects, BATHGOD)) {
214                                 printf("The goddess's head slices off.  Her ");
215                                 puts("corpse floats in the water.");
216                                 clearbit(location[position].objects, BATHGOD);
217                                 setbit(location[position].objects, DEADGOD);
218                                 power += 5;
219                                 notes[JINXED]++;
220                         } else
221                                 if (testbit(location[position].objects, 
222                                     NORMGOD)) {
223                                         printf("The goddess pleads but you ");
224                                         printf("strike her mercilessly.  Her ");
225                                         printf("broken body lies in a\n");
226                                         puts("pool of blood.");
227                                         clearbit(location[position].objects, 
228                                             NORMGOD);
229                                         setbit(location[position].objects, 
230                                             DEADGOD);
231                                         power += 5;
232                                         notes[JINXED]++;
233                                         if (wintime)
234                                                 live();
235                                 } else
236                                         puts("I don't see her anywhere.");
237                         break;
238                 case TIMER:
239                         if (testbit(location[position].objects, TIMER)) {
240                                 puts("The old man offers no resistance.");
241                                 clearbit(location[position].objects, TIMER);
242                                 setbit(location[position].objects, DEADTIME);
243                                 power++;
244                                 notes[JINXED]++;
245                         } else
246                                 puts("Who?");
247                         break;
248                 case NATIVE:
249                         if (testbit(location[position].objects, NATIVE)) {
250                                 printf("The girl screams as you cut her ");
251                                 puts("body to shreds.  She is dead.");
252                                 clearbit(location[position].objects, NATIVE);
253                                 setbit(location[position].objects, DEADNATIVE);
254                                 power += 5;
255                                 notes[JINXED]++;
256                         } else
257                                 puts("What girl?");
258                         break;
259                 case MAN:
260                         if (testbit(location[position].objects, MAN)) {
261                                 printf("You strike him to the ground, and ");
262                                 puts("he coughs up blood.");
263                                 puts("Your fantasy is over.");
264                                 die();
265                         }
266                         /* FALLTHROUGH */
267                 case -1:
268                         puts("Kill what?");
269                         break;
270
271                 default:
272                         if (wordtype[wordnumber] != OBJECT ||
273                             wordvalue[wordnumber] == EVERYTHING)
274                                 puts("You can't kill that!");
275                         else
276                                 printf("You can't kill the %s!\n",
277                                     objsht[wordvalue[wordnumber]]);
278                 }
279         }
280 }
281
282 void
283 ravage(void)
284 {
285         while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
286                 continue;
287         if (wordtype[wordnumber] == NOUNS && 
288             (testbit(location[position].objects, wordvalue[wordnumber])
289             || (wordvalue[wordnumber] == NORMGOD && 
290                 testbit(location[position].objects, BATHGOD)))) {
291                 ourtime++;
292                 switch (wordvalue[wordnumber]) {
293                 case NORMGOD:
294                         printf("You attack the goddess, and she screams as ");
295                         puts("you beat her.  She falls down");
296                         if (testbit(location[position].objects, BATHGOD)) {
297                                 printf("crying and tries to cover her ");
298                                 puts("nakedness.");
299                         } else {
300                                 printf("crying and tries to hold her torn ");
301                                 puts("and bloodied dress around her.");
302                         }
303                         power += 5;
304                         pleasure += 8;
305                         ego -= 10;
306                         wordnumber--;
307                         godready = -30000;
308                         murder();
309                         win = -30000;
310                         break;
311                 case NATIVE:
312                         printf("The girl tries to run, but you catch her and ");
313                         puts("throw her down.  Her face is");
314                         printf("bleeding, and she screams as you tear off ");
315                         puts("her clothes.");
316                         power += 3;
317                         pleasure += 5;
318                         ego -= 10;
319                         wordnumber--;
320                         murder();
321                         if (rnd(100) < 50) {
322                                 printf("Her screams have attracted ");
323                                 puts("attention.  I think we are surrounded.");
324                                 setbit(location[ahead].objects, WOODSMAN);
325                                 setbit(location[ahead].objects, DEADWOOD);
326                                 setbit(location[ahead].objects, MALLET);
327                                 setbit(location[back].objects, WOODSMAN);
328                                 setbit(location[back].objects, DEADWOOD);
329                                 setbit(location[back].objects, MALLET);
330                                 setbit(location[left].objects, WOODSMAN);
331                                 setbit(location[left].objects, DEADWOOD);
332                                 setbit(location[left].objects, MALLET);
333                                 setbit(location[right].objects, WOODSMAN);
334                                 setbit(location[right].objects, DEADWOOD);
335                                 setbit(location[right].objects, MALLET);
336                         }
337                         break;
338                 default:
339                         puts("You are perverted.");
340                 }
341         } else
342                 puts("Who?");
343 }
344
345 int
346 follow(void)
347 {
348         if (followfight == ourtime) {
349                 printf("The Dark Lord leaps away and runs down secret ");
350                 puts("tunnels and corridors.");
351                 printf("You chase him through the darkness and splash in ");
352                 puts("pools of water.");
353                 printf("You have cornered him.  His laser sword extends ");
354                 puts("as he steps forward.");
355                 position = FINAL;
356                 fight(DARK, 75);
357                 setbit(location[position].objects, TALISMAN);
358                 setbit(location[position].objects, AMULET);
359                 return (0);
360         } else
361                 if (followgod == ourtime) {
362                         printf("The goddess leads you down a steamy tunnel ");
363                         puts("and into a high, wide chamber.");
364                         puts("She sits down on a throne.");
365                         position = 268;
366                         setbit(location[position].objects, NORMGOD);
367                         notes[CANTSEE] = 1;
368                         return (0);
369                 } else
370                         puts("There is no one to follow.");
371         return (-1);
372 }