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