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