|
|
1.1 root 1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)com4.c 5.2 (Berkeley) 6/19/88";
20: #endif /* not lint */
21:
22: #include "externs.h"
23:
24: take(from)
25: unsigned int from[];
26: {
27: int firstnumber, heavy, bulky, value;
28: register int n;
29:
30: firstnumber = wordnumber;
31: if (wordnumber < wordcount && wordvalue[wordnumber+1] == OFF){
32: wordnumber++;
33: wordvalue[wordnumber] = TAKEOFF;
34: return(cypher());
35: }
36: else {
37: while(wordtype[++wordnumber] == ADJS);
38: while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
39: value = wordvalue[wordnumber];
40: printf("%s:\n", objsht[value]);
41: for (n=0; objsht[value][n]; n++);
42: heavy = (carrying + objwt[value]) <= WEIGHT;
43: bulky = (encumber + objcumber[value]) <= CUMBER;
44: if ((testbit(from,value) || wiz || tempwiz) && heavy && bulky && !testbit(inven,value)){
45: setbit(inven,value);
46: carrying += objwt[value];
47: encumber += objcumber[value];
48: time++;
49: if (testbit(from,value))
50: printf("Taken.\n");
51: else
52: printf("Zap! Taken from thin air.\n");
53: clearbit(from,value);
54: if (value == MEDALION)
55: win--;
56: }
57: else if (testbit(inven,value))
58: printf("You're already holding%s%s.\n", (objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
59: else if (!heavy)
60: printf("The %s %s too heavy.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
61: else if (!bulky)
62: printf("The %s %s too cumbersome to hold.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
63: else
64: printf("I dont see any %s around here.\n", objsht[value]);
65: if (wordnumber < wordcount -1 && wordvalue[++wordnumber] == AND)
66: wordnumber++;
67: else
68: return(firstnumber);
69: }
70: }
71: /* special cases with their own return()'s */
72:
73: if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS)
74: switch(wordvalue[wordnumber]){
75:
76: case SWORD:
77: if (testbit(from, SWORD)){
78: wordtype[wordnumber--] = OBJECT;
79: return(take(from));
80: }
81: if (testbit(from, TWO_HANDED)){
82: wordvalue[wordnumber] = TWO_HANDED;
83: wordtype[wordnumber--] = OBJECT;
84: return(take(from));
85: }
86: wordvalue[wordnumber] = BROAD;
87: wordtype[wordnumber--] = OBJECT;
88: return(take(from));
89:
90: case BODY:
91: if (testbit(from,MAID)){
92: wordvalue[wordnumber] = MAID;
93: wordtype[wordnumber--] = OBJECT;
94: return(take(from));
95: }
96: else if (testbit(from,DEADWOOD)){
97: wordvalue[wordnumber] = DEADWOOD;
98: wordtype[wordnumber--] = OBJECT;
99: return(take(from));
100: }
101: else if (testbit(from,DEADNATIVE)){
102: wordvalue[wordnumber] = DEADNATIVE;
103: wordtype[wordnumber--] = OBJECT;
104: return(take(from));
105: }
106: else if (testbit(from,DEADGOD)){
107: wordvalue[wordnumber] = DEADGOD;
108: wordtype[wordnumber--] = OBJECT;
109: return(take(from));
110: }
111: else {
112: wordvalue[wordnumber] = DEADTIME;
113: wordtype[wordnumber--] = OBJECT;
114: return(take(from));
115: }
116: break;
117:
118: case AMULET:
119: if (testbit(location[position].objects,AMULET)){
120: puts("The amulet is warm to the touch, and its beauty catches your breath.");
121: puts("A mist falls over your eyes, but then it is gone. Sounds seem clearer");
122: puts("and sharper but far away as if in a dream. The sound of purling water reaches");
123: puts("you from afar. The mist falls again, and your heart leaps in horror. The gold");
124: puts("freezes your hands and fathomless darkness engulfs your soul.");
125: }
126: wordtype[wordnumber--] = OBJECT;
127: return(take(from));
128:
129: case MEDALION:
130: if (testbit(location[position].objects, MEDALION)){
131: puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
132: puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
133: }
134: wordtype[wordnumber--] = OBJECT;
135: return(take(from));
136:
137: case TALISMAN:
138: if (testbit(location[position].objects,TALISMAN)){
139: puts("The talisman is cold to the touch, and it sends a chill down your spine.");
140: }
141: wordtype[wordnumber--] = OBJECT;
142: return(take(from));
143:
144: case NORMGOD:
145: if (testbit(location[position].objects,BATHGOD) && (testbit(wear,AMULET) || testbit(inven,AMULET))){
146: puts("She offers a delicate hand, and you help her out of the sparkling springs.");
147: puts("Water droplets like liquid silver bedew her golden skin, but when they part");
148: puts("from her, they fall as teardrops. She wraps a single cloth around her and");
149: puts("ties it at the waist. Around her neck hangs a golden amulet.");
150: puts("She bids you to follow her.");
151: pleasure++;
152: followgod = time;
153: clearbit(location[position].objects,BATHGOD);
154: } else if (!testbit(location[position].objects,BATHGOD))
155: puts("You're in no position to take her.");
156: else
157: puts("She moves away from you.");
158: break;
159:
160: default:
161: puts("It doesn't seem to work.");
162: }
163: else
164: puts("You've got to be kidding.");
165: return(firstnumber);
166: }
167:
168: throw(name)
169: char *name;
170: {
171: int n;
172: int deposit = 0;
173: int first, value;
174:
175: first = wordnumber;
176: if (drop(name) != -1){
177: switch(wordvalue[wordnumber]){
178:
179: case AHEAD:
180: deposit = ahead;
181: break;
182:
183: case BACK:
184: deposit = back;
185: break;
186:
187: case LEFT:
188: deposit = left;
189: break;
190:
191: case RIGHT:
192: deposit = right;
193: break;
194:
195: case UP:
196: deposit = location[position].up * (location[position].access || position == FINAL);
197: break;
198:
199: case DOWN:
200: deposit = location[position].down;
201: break;
202: }
203: wordnumber = first;
204: while (wordtype[++wordnumber] == ADJS);
205: while (wordnumber <= wordcount){
206: value = wordvalue[wordnumber];
207: if (deposit && testbit(location[position].objects,value)){
208: clearbit(location[position].objects,value);
209: if (value != GRENADE)
210: setbit(location[deposit].objects,value);
211: else{
212: puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
213: for (n = 0; n < NUMOFWORDS; n ++)
214: location[deposit].objects[n] = 0;
215: setbit(location[deposit].objects,CHAR);
216: }
217: if (value == ROPE && position == FINAL)
218: location[position].access = 1;
219: switch(deposit){
220: case 189:
221: case 231:
222: puts("The stone door is unhinged.");
223: location[189].north = 231;
224: location[231].south = 189;
225: break;
226: case 30:
227: puts("The wooden door is blown open.");
228: location[30].west = 25;
229: break;
230: case 31:
231: puts("The door is not damaged.");
232: }
233: }
234: else if (value == GRENADE && testbit(location[position].objects,value)){
235: puts("You are blown into shreds when your grenade explodes.");
236: die();
237: }
238: if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
239: wordnumber++;
240: else
241: return(first);
242: }
243: return(first);
244: }
245: return(first);
246: }
247:
248: drop(name)
249: char *name;
250: {
251:
252: int firstnumber, value;
253:
254: firstnumber = wordnumber;
255: while (wordtype[++wordnumber] == ADJS)
256: ;
257: while (wordnumber<=wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
258: value = wordvalue[wordnumber];
259: printf("%s:\n", objsht[value]);
260: if (testbit(inven,value)){
261: clearbit(inven,value);
262: carrying -= objwt[value];
263: encumber -= objcumber[value];
264: if (value == BOMB){
265: puts("The bomb explodes. A blinding white light and immense concussion obliterate us.");
266: die();
267: }
268: if (value != AMULET && value != MEDALION && value != TALISMAN)
269: setbit(location[position].objects,value);
270: else
271: tempwiz = 0;
272: time++;
273: if (*name == 'K')
274: puts("Drop kicked.");
275: else
276: printf("%s.\n", name);
277: }
278: else {
279: if (*name != 'K') {
280: printf("You aren't holding the %s.\n", objsht[value]);
281: if (testbit(location[position].objects,value)) {
282: if (*name == 'T')
283: puts("Kicked instead.");
284: else if (*name == 'G')
285: puts("Given anyway.");
286: }
287: } else
288: puts("Kicked.");
289: }
290: if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
291: wordnumber++;
292: else
293: return(firstnumber);
294: }
295: puts("Do what?");
296: return(-1);
297: }
298:
299: takeoff()
300: {
301: wordnumber = take(wear);
302: return(drop("Dropped"));
303: }
304:
305: puton()
306: {
307: wordnumber = take(location[position].objects);
308: return(wearit());
309: }
310:
311: eat()
312: {
313: register int n;
314: int firstnumber, value;
315:
316: firstnumber = wordnumber;
317: while(wordtype[++wordnumber] == ADJS);
318: while(wordnumber <= wordcount){
319: value = wordvalue[wordnumber];
320: for (n=0; objsht[value][n]; n++);
321: switch(value){
322:
323: case -1:
324: puts("Eat what?");
325: return(firstnumber);
326:
327: default:
328: printf("You can't eat%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
329: return(firstnumber);
330:
331: case PAPAYAS:
332: case PINEAPPLE:
333: case KIWI:
334: case COCONUTS: /* eatable things */
335: case MANGO:
336:
337: printf("%s:\n",objsht[value]);
338: if (testbit(inven,value) && time > ate - CYCLE && testbit(inven,KNIFE)){
339: clearbit(inven,value);
340: carrying -= objwt[value];
341: encumber -= objcumber[value];
342: ate = max(time,ate) + CYCLE/3;
343: snooze += CYCLE/10;
344: time++;
345: puts("Eaten. You can explore a little longer now.");
346: }
347: else if (time < ate - CYCLE)
348: puts("You're stuffed.");
349: else if (!testbit(inven,KNIFE))
350: puts("You need a knife.");
351: else
352: printf("You aren't holding the %s.\n", objsht[value]);
353: if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
354: wordnumber++;
355: else
356: return(firstnumber);
357: } /* end switch */
358: } /* end while */
359: return(firstnumber);
360: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.