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