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