1*166ddc28Sdaniel /* $OpenBSD: command3.c,v 1.1 2020/12/15 00:38:18 daniel Exp $ */
2*166ddc28Sdaniel /* $NetBSD: com3.c,v 1.3 1995/03/21 15:07:00 cgd Exp $ */
3*166ddc28Sdaniel
4*166ddc28Sdaniel /*
5*166ddc28Sdaniel * Copyright (c) 1983, 1993
6*166ddc28Sdaniel * The Regents of the University of California. All rights reserved.
7*166ddc28Sdaniel *
8*166ddc28Sdaniel * Redistribution and use in source and binary forms, with or without
9*166ddc28Sdaniel * modification, are permitted provided that the following conditions
10*166ddc28Sdaniel * are met:
11*166ddc28Sdaniel * 1. Redistributions of source code must retain the above copyright
12*166ddc28Sdaniel * notice, this list of conditions and the following disclaimer.
13*166ddc28Sdaniel * 2. Redistributions in binary form must reproduce the above copyright
14*166ddc28Sdaniel * notice, this list of conditions and the following disclaimer in the
15*166ddc28Sdaniel * documentation and/or other materials provided with the distribution.
16*166ddc28Sdaniel * 3. Neither the name of the University nor the names of its contributors
17*166ddc28Sdaniel * may be used to endorse or promote products derived from this software
18*166ddc28Sdaniel * without specific prior written permission.
19*166ddc28Sdaniel *
20*166ddc28Sdaniel * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*166ddc28Sdaniel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*166ddc28Sdaniel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*166ddc28Sdaniel * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*166ddc28Sdaniel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*166ddc28Sdaniel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*166ddc28Sdaniel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*166ddc28Sdaniel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*166ddc28Sdaniel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*166ddc28Sdaniel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*166ddc28Sdaniel * SUCH DAMAGE.
31*166ddc28Sdaniel */
32*166ddc28Sdaniel
33*166ddc28Sdaniel #include <stdio.h>
34*166ddc28Sdaniel
35*166ddc28Sdaniel #include "extern.h"
36*166ddc28Sdaniel
37*166ddc28Sdaniel void
dig(void)38*166ddc28Sdaniel dig(void)
39*166ddc28Sdaniel {
40*166ddc28Sdaniel if (TestBit(inven, SHOVEL)) {
41*166ddc28Sdaniel puts("OK");
42*166ddc28Sdaniel ourtime++;
43*166ddc28Sdaniel switch (position) {
44*166ddc28Sdaniel case 144: /* copse near beach */
45*166ddc28Sdaniel if (!notes[DUG]) {
46*166ddc28Sdaniel SetBit(location[position].objects, DEADWOOD);
47*166ddc28Sdaniel SetBit(location[position].objects, COMPASS);
48*166ddc28Sdaniel SetBit(location[position].objects, KNIFE);
49*166ddc28Sdaniel SetBit(location[position].objects, MACE);
50*166ddc28Sdaniel notes[DUG] = 1;
51*166ddc28Sdaniel }
52*166ddc28Sdaniel break;
53*166ddc28Sdaniel
54*166ddc28Sdaniel default:
55*166ddc28Sdaniel puts("Nothing happens.");
56*166ddc28Sdaniel }
57*166ddc28Sdaniel } else
58*166ddc28Sdaniel puts("You don't have a shovel.");
59*166ddc28Sdaniel }
60*166ddc28Sdaniel
61*166ddc28Sdaniel int
jump(void)62*166ddc28Sdaniel jump(void)
63*166ddc28Sdaniel {
64*166ddc28Sdaniel int n;
65*166ddc28Sdaniel
66*166ddc28Sdaniel switch (position) {
67*166ddc28Sdaniel default:
68*166ddc28Sdaniel puts("Nothing happens.");
69*166ddc28Sdaniel return (-1);
70*166ddc28Sdaniel
71*166ddc28Sdaniel case 242:
72*166ddc28Sdaniel position = 133;
73*166ddc28Sdaniel break;
74*166ddc28Sdaniel case 214:
75*166ddc28Sdaniel case 215:
76*166ddc28Sdaniel case 162:
77*166ddc28Sdaniel case 159:
78*166ddc28Sdaniel position = 145;
79*166ddc28Sdaniel break;
80*166ddc28Sdaniel case 232:
81*166ddc28Sdaniel position = FINAL;
82*166ddc28Sdaniel break;
83*166ddc28Sdaniel case 3:
84*166ddc28Sdaniel position = 1;
85*166ddc28Sdaniel break;
86*166ddc28Sdaniel case 172:
87*166ddc28Sdaniel position = 201;
88*166ddc28Sdaniel }
89*166ddc28Sdaniel puts("Ahhhhhhh...");
90*166ddc28Sdaniel injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
91*166ddc28Sdaniel for (n = 0; n < NUMOFOBJECTS; n++)
92*166ddc28Sdaniel if (TestBit(inven, n)) {
93*166ddc28Sdaniel ClearBit(inven, n);
94*166ddc28Sdaniel SetBit(location[position].objects, n);
95*166ddc28Sdaniel }
96*166ddc28Sdaniel carrying = 0;
97*166ddc28Sdaniel encumber = 0;
98*166ddc28Sdaniel return (0);
99*166ddc28Sdaniel }
100*166ddc28Sdaniel
101*166ddc28Sdaniel void
bury(void)102*166ddc28Sdaniel bury(void)
103*166ddc28Sdaniel {
104*166ddc28Sdaniel int value;
105*166ddc28Sdaniel
106*166ddc28Sdaniel if (TestBit(inven, SHOVEL)) {
107*166ddc28Sdaniel while (wordtype[++wordnumber] != OBJECT &&
108*166ddc28Sdaniel wordtype[wordnumber] != NOUNS && wordnumber <= wordcount)
109*166ddc28Sdaniel continue;
110*166ddc28Sdaniel value = wordvalue[wordnumber];
111*166ddc28Sdaniel if (wordtype[wordnumber] == NOUNS && (TestBit(location[position].objects, value) || value == BODY)) {
112*166ddc28Sdaniel switch (value) {
113*166ddc28Sdaniel case BODY:
114*166ddc28Sdaniel wordtype[wordnumber] = OBJECT;
115*166ddc28Sdaniel if (TestBit(inven, MAID) || TestBit(location[position].objects, MAID))
116*166ddc28Sdaniel value = MAID;
117*166ddc28Sdaniel if (TestBit(inven, DEADWOOD) || TestBit(location[position].objects, DEADWOOD))
118*166ddc28Sdaniel value = DEADWOOD;
119*166ddc28Sdaniel if (TestBit(inven, DEADGOD) || TestBit(location[position].objects, DEADGOD))
120*166ddc28Sdaniel value = DEADGOD;
121*166ddc28Sdaniel if (TestBit(inven, DEADTIME) || TestBit(location[position].objects, DEADTIME))
122*166ddc28Sdaniel value = DEADTIME;
123*166ddc28Sdaniel if (TestBit(inven, DEADNATIVE) || TestBit(location[position].objects, DEADNATIVE))
124*166ddc28Sdaniel value = DEADNATIVE;
125*166ddc28Sdaniel break;
126*166ddc28Sdaniel
127*166ddc28Sdaniel case NATIVE:
128*166ddc28Sdaniel case NORMGOD:
129*166ddc28Sdaniel puts("She screams as you wrestle her into the hole.");
130*166ddc28Sdaniel case TIMER:
131*166ddc28Sdaniel power += 7;
132*166ddc28Sdaniel ego -= 10;
133*166ddc28Sdaniel case AMULET:
134*166ddc28Sdaniel case MEDALION:
135*166ddc28Sdaniel case TALISMAN:
136*166ddc28Sdaniel wordtype[wordnumber] = OBJECT;
137*166ddc28Sdaniel break;
138*166ddc28Sdaniel
139*166ddc28Sdaniel default:
140*166ddc28Sdaniel puts("Wha..?");
141*166ddc28Sdaniel }
142*166ddc28Sdaniel }
143*166ddc28Sdaniel if (wordtype[wordnumber] == OBJECT && position > 88 && (TestBit(inven, value) || TestBit(location[position].objects, value))) {
144*166ddc28Sdaniel puts("Buried.");
145*166ddc28Sdaniel if (TestBit(inven, value)) {
146*166ddc28Sdaniel ClearBit(inven, value);
147*166ddc28Sdaniel carrying -= objwt[value];
148*166ddc28Sdaniel encumber -= objcumber[value];
149*166ddc28Sdaniel }
150*166ddc28Sdaniel ClearBit(location[position].objects, value);
151*166ddc28Sdaniel switch (value) {
152*166ddc28Sdaniel case MAID:
153*166ddc28Sdaniel case DEADWOOD:
154*166ddc28Sdaniel case DEADNATIVE:
155*166ddc28Sdaniel case DEADTIME:
156*166ddc28Sdaniel case DEADGOD:
157*166ddc28Sdaniel ego += 2;
158*166ddc28Sdaniel printf("The %s should rest easier now.\n", objsht[value]);
159*166ddc28Sdaniel }
160*166ddc28Sdaniel } else
161*166ddc28Sdaniel puts("It doesn't seem to work.");
162*166ddc28Sdaniel } else
163*166ddc28Sdaniel puts("You aren't holding a shovel.");
164*166ddc28Sdaniel }
165*166ddc28Sdaniel
166*166ddc28Sdaniel void
drink(void)167*166ddc28Sdaniel drink(void)
168*166ddc28Sdaniel {
169*166ddc28Sdaniel int n;
170*166ddc28Sdaniel
171*166ddc28Sdaniel if (TestBit(inven, POTION)) {
172*166ddc28Sdaniel puts("The cool liquid runs down your throat but turns to fire and you choke.");
173*166ddc28Sdaniel puts("The heat reaches your limbs and tingles your spirit. You feel like falling");
174*166ddc28Sdaniel puts("asleep.");
175*166ddc28Sdaniel ClearBit(inven, POTION);
176*166ddc28Sdaniel WEIGHT = MAXWEIGHT;
177*166ddc28Sdaniel CUMBER = MAXCUMBER;
178*166ddc28Sdaniel for (n = 0; n < NUMOFINJURIES; n++)
179*166ddc28Sdaniel injuries[n] = 0;
180*166ddc28Sdaniel ourtime++;
181*166ddc28Sdaniel zzz();
182*166ddc28Sdaniel } else
183*166ddc28Sdaniel puts("I'm not thirsty.");
184*166ddc28Sdaniel }
185*166ddc28Sdaniel
186*166ddc28Sdaniel int
shoot(void)187*166ddc28Sdaniel shoot(void)
188*166ddc28Sdaniel {
189*166ddc28Sdaniel int firstnumber, value;
190*166ddc28Sdaniel
191*166ddc28Sdaniel firstnumber = wordnumber;
192*166ddc28Sdaniel if (!TestBit(inven, LASER))
193*166ddc28Sdaniel puts("You aren't holding a blaster.");
194*166ddc28Sdaniel else {
195*166ddc28Sdaniel wordnumber++;
196*166ddc28Sdaniel while(wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
197*166ddc28Sdaniel value = wordvalue[wordnumber];
198*166ddc28Sdaniel printf("%s:\n", objsht[value]);
199*166ddc28Sdaniel if (TestBit(location[position].objects, value)) {
200*166ddc28Sdaniel ClearBit(location[position].objects, value);
201*166ddc28Sdaniel ourtime++;
202*166ddc28Sdaniel printf("The %s explode%s\n", objsht[value],
203*166ddc28Sdaniel (IS_PLURAL(value) ? "." : "s."));
204*166ddc28Sdaniel if (value == BOMB)
205*166ddc28Sdaniel die(0);
206*166ddc28Sdaniel } else
207*166ddc28Sdaniel printf("I don't see any %s around here.\n", objsht[value]);
208*166ddc28Sdaniel if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
209*166ddc28Sdaniel wordnumber++;
210*166ddc28Sdaniel else
211*166ddc28Sdaniel return (firstnumber);
212*166ddc28Sdaniel }
213*166ddc28Sdaniel /* special cases with their own return()'s */
214*166ddc28Sdaniel
215*166ddc28Sdaniel if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
216*166ddc28Sdaniel ourtime++;
217*166ddc28Sdaniel switch (wordvalue[wordnumber]) {
218*166ddc28Sdaniel
219*166ddc28Sdaniel case DOOR:
220*166ddc28Sdaniel switch(position) {
221*166ddc28Sdaniel case 189:
222*166ddc28Sdaniel case 231:
223*166ddc28Sdaniel puts("The door is unhinged.");
224*166ddc28Sdaniel location[189].north = 231;
225*166ddc28Sdaniel location[231].south = 189;
226*166ddc28Sdaniel whichway(location[position]);
227*166ddc28Sdaniel break;
228*166ddc28Sdaniel case 30:
229*166ddc28Sdaniel puts("The wooden door splinters.");
230*166ddc28Sdaniel location[30].west = 25;
231*166ddc28Sdaniel whichway(location[position]);
232*166ddc28Sdaniel break;
233*166ddc28Sdaniel case 31:
234*166ddc28Sdaniel puts("The laser blast has no effect on the door.");
235*166ddc28Sdaniel break;
236*166ddc28Sdaniel case 20:
237*166ddc28Sdaniel puts("The blast hits the door and it explodes into flame. The magnesium burns");
238*166ddc28Sdaniel puts("so rapidly that we have no chance to escape.");
239*166ddc28Sdaniel die(0);
240*166ddc28Sdaniel default:
241*166ddc28Sdaniel puts("Nothing happens.");
242*166ddc28Sdaniel }
243*166ddc28Sdaniel break;
244*166ddc28Sdaniel
245*166ddc28Sdaniel case NORMGOD:
246*166ddc28Sdaniel case BATHGOD:
247*166ddc28Sdaniel if (TestBit(location[position].objects, BATHGOD)) {
248*166ddc28Sdaniel puts("The goddess is hit in the chest and splashes back against the rocks.");
249*166ddc28Sdaniel puts("Dark blood oozes from the charred blast hole. Her naked body floats in the");
250*166ddc28Sdaniel puts("pools and then off downstream.");
251*166ddc28Sdaniel ClearBit(location[position].objects, BATHGOD);
252*166ddc28Sdaniel SetBit(location[180].objects, DEADGOD);
253*166ddc28Sdaniel power += 5;
254*166ddc28Sdaniel ego -= 10;
255*166ddc28Sdaniel notes[JINXED]++;
256*166ddc28Sdaniel } else
257*166ddc28Sdaniel if (TestBit(location[position].objects, NORMGOD)) {
258*166ddc28Sdaniel puts("The blast catches the goddess in the stomach, knocking her to the ground.");
259*166ddc28Sdaniel puts("She writhes in the dirt as the agony of death taunts her.");
260*166ddc28Sdaniel puts("She has stopped moving.");
261*166ddc28Sdaniel ClearBit(location[position].objects, NORMGOD);
262*166ddc28Sdaniel SetBit(location[position].objects, DEADGOD);
263*166ddc28Sdaniel power += 5;
264*166ddc28Sdaniel ego -= 10;
265*166ddc28Sdaniel notes[JINXED]++;
266*166ddc28Sdaniel if (wintime)
267*166ddc28Sdaniel live();
268*166ddc28Sdaniel break;
269*166ddc28Sdaniel } else
270*166ddc28Sdaniel puts("I don't see any goddess around here.");
271*166ddc28Sdaniel break;
272*166ddc28Sdaniel
273*166ddc28Sdaniel case TIMER:
274*166ddc28Sdaniel if (TestBit(location[position].objects, TIMER)) {
275*166ddc28Sdaniel puts("The old man slumps over the bar.");
276*166ddc28Sdaniel power++;
277*166ddc28Sdaniel ego -= 2;
278*166ddc28Sdaniel notes[JINXED]++;
279*166ddc28Sdaniel ClearBit(location[position].objects, TIMER);
280*166ddc28Sdaniel SetBit(location[position].objects, DEADTIME);
281*166ddc28Sdaniel } else
282*166ddc28Sdaniel puts("What old-timer?");
283*166ddc28Sdaniel break;
284*166ddc28Sdaniel case MAN:
285*166ddc28Sdaniel if (TestBit(location[position].objects, MAN)) {
286*166ddc28Sdaniel puts("The man falls to the ground with blood pouring all over his white suit.");
287*166ddc28Sdaniel puts("Your fantasy is over.");
288*166ddc28Sdaniel die(0);
289*166ddc28Sdaniel } else
290*166ddc28Sdaniel puts("What man?");
291*166ddc28Sdaniel break;
292*166ddc28Sdaniel case NATIVE:
293*166ddc28Sdaniel if (TestBit(location[position].objects, NATIVE)) {
294*166ddc28Sdaniel puts("The girl is blown backwards several feet and lies in a pool of blood.");
295*166ddc28Sdaniel ClearBit(location[position].objects, NATIVE);
296*166ddc28Sdaniel SetBit(location[position].objects, DEADNATIVE);
297*166ddc28Sdaniel power += 5;
298*166ddc28Sdaniel ego -= 2;
299*166ddc28Sdaniel notes[JINXED]++;
300*166ddc28Sdaniel } else
301*166ddc28Sdaniel puts("There is no girl here.");
302*166ddc28Sdaniel break;
303*166ddc28Sdaniel case -1:
304*166ddc28Sdaniel puts("Shoot what?");
305*166ddc28Sdaniel break;
306*166ddc28Sdaniel
307*166ddc28Sdaniel default:
308*166ddc28Sdaniel printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]);
309*166ddc28Sdaniel }
310*166ddc28Sdaniel } else
311*166ddc28Sdaniel puts("You must be a looney.");
312*166ddc28Sdaniel }
313*166ddc28Sdaniel return (firstnumber);
314*166ddc28Sdaniel }
315