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