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